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-attribute-button.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) {
|
||||
const actorAdvantages = {}
|
||||
context.advantages = [];
|
||||
const actorData = context.data;
|
||||
Object.values(actorData.items).forEach( (item) => {
|
||||
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) {
|
||||
|
|
@ -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 = [] } ) {
|
||||
let tap = taw;
|
||||
let meisterlichCounter = 0;
|
||||
|
|
@ -262,8 +245,7 @@ export class CharacterSheet extends ActorSheet {
|
|||
}
|
||||
}
|
||||
|
||||
_onOpenSkill(documentId) {
|
||||
console.log(this.object.items.get(documentId).sheet);
|
||||
openEmbeddedDocument(documentId) {
|
||||
this.object.items.get(documentId).sheet.render(true)
|
||||
}
|
||||
|
||||
|
|
@ -315,7 +297,12 @@ export class CharacterSheet extends ActorSheet {
|
|||
});
|
||||
|
||||
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();
|
||||
})
|
||||
|
||||
|
|
@ -342,7 +329,6 @@ export class CharacterSheet extends ActorSheet {
|
|||
}
|
||||
]);
|
||||
|
||||
|
||||
let handler = ev => this._onDragStart(ev);
|
||||
// Find all items on the character sheet.
|
||||
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) {
|
||||
const array = Array.from(collection);
|
||||
for (const element of array) {
|
||||
|
|
@ -383,6 +378,8 @@ export class CharacterSheet extends ActorSheet {
|
|||
switch (type) {
|
||||
case "Skill":
|
||||
return characterSheet.#handleDroppedSkill(actor, document); // on false cancel this whole operation
|
||||
case "Advantage":
|
||||
return characterSheet.#handleDroppedAdvantage(actor, document);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@
|
|||
</div>
|
||||
<div class="tab attributes" data-group="primary" data-tab="attributes">
|
||||
<ul>
|
||||
{{#each items}}
|
||||
<li>{{this.name}}</li>
|
||||
{{#each this.advantages}}
|
||||
<li>{{> "systems/DSA_4-1/templates/ui/partial-advantage-button.hbs" this}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
{{!-- Sheet Body --}}
|
||||
<section class="sheet-body" style="flex: 1">
|
||||
<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>
|
||||
</section>
|
||||
</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">
|
||||
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
|
||||
|
|
|
|||
Loading…
Reference in New Issue