Implements simple advantage template that is then placed on the character sheet.
also fixes rollable partial and skills can be rolled on again.pull/47/head
parent
21479ce082
commit
e47deaf938
|
|
@ -14,7 +14,8 @@ async function preloadHandlebarsTemplates() {
|
||||||
'systems/DSA_4-1/templates/ui/partial-rollable-button.hbs',
|
'systems/DSA_4-1/templates/ui/partial-rollable-button.hbs',
|
||||||
'systems/DSA_4-1/templates/ui/partial-attribute-button.hbs',
|
'systems/DSA_4-1/templates/ui/partial-attribute-button.hbs',
|
||||||
'systems/DSA_4-1/templates/ui/partial-talent-editable.hbs',
|
'systems/DSA_4-1/templates/ui/partial-talent-editable.hbs',
|
||||||
'systems/DSA_4-1/templates/ui/partial-die.hbs'
|
'systems/DSA_4-1/templates/ui/partial-die.hbs',
|
||||||
|
'systems/DSA_4-1/templates/ui/partial-advantage-button.hbs'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,25 +80,20 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
#addAdvantagesToContext(context) {
|
#addAdvantagesToContext(context) {
|
||||||
const actorAdvantages = {}
|
context.advantages = [];
|
||||||
const actorData = context.data;
|
const actorData = context.data;
|
||||||
Object.values(actorData.items).forEach( (item) => {
|
Object.values(actorData.items).forEach( (item) => {
|
||||||
if (item.type === "Advantage") {
|
if (item.type === "Advantage") {
|
||||||
actorAdvantages[item._id] = item;
|
context.advantages.push({
|
||||||
|
id: item._id,
|
||||||
|
name: item.name,
|
||||||
|
value: item.system.value,
|
||||||
|
options: item.system.auswahl,
|
||||||
|
description: item.system.description,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( context.system.vornachteile.length >= 0) {
|
|
||||||
context.system.vornachteile.forEach( ( { vornachteil }, index) => {
|
|
||||||
context.vornachteile.push(
|
|
||||||
{
|
|
||||||
name: vornachteil.name,
|
|
||||||
value: vornachteil.value,
|
|
||||||
auswahl: vornachteil.auswahl,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#addAttributesToContext(context) {
|
#addAttributesToContext(context) {
|
||||||
|
|
@ -193,18 +188,6 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDropDocument(event, item) {
|
|
||||||
console.log(item)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
_onDragStart(event) {
|
|
||||||
super._onDragStart(event);
|
|
||||||
const src = event.target
|
|
||||||
console.log(event)
|
|
||||||
event.dataTransfer.setData("plain/text", src.dataset.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
_evaluateRoll(rolledDice, { taw, lowerThreshold = 1, upperThreshold = 20, countToMeisterlich = 3, countToPatzer = 3, werte = [] } ) {
|
_evaluateRoll(rolledDice, { taw, lowerThreshold = 1, upperThreshold = 20, countToMeisterlich = 3, countToPatzer = 3, werte = [] } ) {
|
||||||
let tap = taw;
|
let tap = taw;
|
||||||
let meisterlichCounter = 0;
|
let meisterlichCounter = 0;
|
||||||
|
|
@ -262,8 +245,7 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_onOpenSkill(documentId) {
|
openEmbeddedDocument(documentId) {
|
||||||
console.log(this.object.items.get(documentId).sheet);
|
|
||||||
this.object.items.get(documentId).sheet.render(true)
|
this.object.items.get(documentId).sheet.render(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -315,7 +297,12 @@ export class CharacterSheet extends ActorSheet {
|
||||||
});
|
});
|
||||||
|
|
||||||
html.on('click', '.talent .name', (evt) => {
|
html.on('click', '.talent .name', (evt) => {
|
||||||
this._onOpenSkill(evt.target.dataset.id);
|
this.openEmbeddedDocument(evt.target.dataset.id);
|
||||||
|
evt.stopPropagation();
|
||||||
|
})
|
||||||
|
|
||||||
|
html.on('click', '.advantage .name', (evt) => {
|
||||||
|
this.openEmbeddedDocument(evt.target.dataset.id);
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -342,7 +329,6 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
let handler = ev => this._onDragStart(ev);
|
let handler = ev => this._onDragStart(ev);
|
||||||
// Find all items on the character sheet.
|
// Find all items on the character sheet.
|
||||||
html.find('.talent.rollable').each((i, li) => {
|
html.find('.talent.rollable').each((i, li) => {
|
||||||
|
|
@ -362,6 +348,15 @@ export class CharacterSheet extends ActorSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#handleDroppedAdvantage(actor, advantage) {
|
||||||
|
const array = Array.from(actor.items);
|
||||||
|
for ( let i = 0; i < array.length; i++ ) {
|
||||||
|
if (array[i].name === advantage.name) { // TODO: adjust for uniqueness
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static getElementByName(collection, id) {
|
static getElementByName(collection, id) {
|
||||||
const array = Array.from(collection);
|
const array = Array.from(collection);
|
||||||
for (const element of array) {
|
for (const element of array) {
|
||||||
|
|
@ -383,6 +378,8 @@ export class CharacterSheet extends ActorSheet {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "Skill":
|
case "Skill":
|
||||||
return characterSheet.#handleDroppedSkill(actor, document); // on false cancel this whole operation
|
return characterSheet.#handleDroppedSkill(actor, document); // on false cancel this whole operation
|
||||||
|
case "Advantage":
|
||||||
|
return characterSheet.#handleDroppedAdvantage(actor, document);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="tab attributes" data-group="primary" data-tab="attributes">
|
<div class="tab attributes" data-group="primary" data-tab="attributes">
|
||||||
<ul>
|
<ul>
|
||||||
{{#each items}}
|
{{#each this.advantages}}
|
||||||
<li>{{this.name}}</li>
|
<li>{{> "systems/DSA_4-1/templates/ui/partial-advantage-button.hbs" this}}</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -161,4 +161,4 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
{{!-- Sheet Body --}}
|
{{!-- Sheet Body --}}
|
||||||
<section class="sheet-body" style="flex: 1">
|
<section class="sheet-body" style="flex: 1">
|
||||||
<div class="tab json" data-group="primary" data-tab="json">
|
<div class="tab json" data-group="primary" data-tab="json">
|
||||||
<pre style="overflow: auto">{{json}}</pre>
|
<pre style="overflow: auto; white-space: normal; position: relative; top: 8px; bottom: 8px; left: 8px; right: 8px">{{json}}</pre>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div class="advantage">
|
||||||
|
<span class="name" data-id="{{this.id}}">{{this.name}}</span>
|
||||||
|
</div>
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="block rollable {{this.type}} {{this.gruppe}}" data-id="{{this.id}}" data-taw="{{this.taw}}'data-name="{{this.name}}" data-eigenschaft1="{{this.eigenschaft1}}" data-eigenschaft2="{{this.eigenschaft2}}" data-eigenschaft3="{{this.eigenschaft3}}" data-taw="{{this.taw}}" data-rollEigenschaft1="{{this.rollEigenschaft1}}" data-rollEigenschaft2="{{this.rollEigenschaft2}}" data-rollEigenschaft3="{{this.rollEigenschaft3}}">
|
<div class="block rollable {{this.type}} {{this.gruppe}}" data-id="{{this.id}}" data-taw="{{this.taw}}" data-name="{{this.name}}" data-eigenschaft1="{{this.eigenschaft1}}" data-eigenschaft2="{{this.eigenschaft2}}" data-eigenschaft3="{{this.eigenschaft3}}" data-taw="{{this.taw}}" data-rollEigenschaft1="{{this.rollEigenschaft1}}" data-rollEigenschaft2="{{this.rollEigenschaft2}}" data-rollEigenschaft3="{{this.rollEigenschaft3}}">
|
||||||
|
|
||||||
<div class="die">
|
<div class="die">
|
||||||
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
|
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue