diff --git a/src/module/sheets/character/advsf.mjs b/src/module/sheets/character/advsf.mjs index 878225e9..f0074d84 100644 --- a/src/module/sheets/character/advsf.mjs +++ b/src/module/sheets/character/advsf.mjs @@ -9,18 +9,32 @@ export default { context.name = context.derived.name ?? actorData.name context.effects = actorData.effects ?? [] context.advantages = [] + context.flaws = [] actorData.itemTypes.Advantage.forEach((item) => { - context.advantages.push({ - id: item._id, - name: item.name, - value: item.system.value, - options: item.system.auswahl, - description: item.system.description, - isAdvantage: !item.system.nachteil, - isDisadvantage: item.system.nachteil, - isBadAttribute: item.system.schlechteEigenschaft - }) + if (!item.system.schlechteEigenschaft) { + context.advantages.push({ + id: item._id, + name: item.name, + value: item.system.value, + options: item.system.auswahl, + description: item.system.description, + isAdvantage: !item.system.nachteil, + isDisadvantage: item.system.nachteil, + isBadAttribute: item.system.schlechteEigenschaft + }) + } else { + context.flaws.push({ + id: item._id, + name: item.name, + value: item.system.value, + options: item.system.auswahl, + description: item.system.description, + isAdvantage: !item.system.nachteil, + isDisadvantage: item.system.nachteil, + isBadAttribute: item.system.schlechteEigenschaft + }) + } } ) diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index da8df1df..e8159b67 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -35,6 +35,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { actions: { rollCombatSkill: CharacterSheet.#rollCombatSkill, rollSkill: CharacterSheet.#rollSkill, + rollFlaw: CharacterSheet.#rollFlaw, roll: CharacterSheet.#dieRoll, editImage: DocumentSheetV2.DEFAULT_OPTIONS.actions.editImage, openEmbeddedDocument: CharacterSheet.#openEmbeddedDocument, @@ -45,6 +46,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { cancelCooldown: CharacterSheet.#cancelCooldown, activateCooldown: CharacterSheet.#activateCooldown, rest: CharacterSheet.#startResting, + } } @@ -115,10 +117,10 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { } } - static #dieRoll(event) { + static #dieRoll(event, target) { event.preventDefault() - const dataset = event.currentTarget.dataset - if (dataset.roll) { + const {roll} = target.dataset + if (roll) { let label = dataset.label ? `[Attribut] ${dataset.label}` : '' let roll = new Roll(dataset.roll, this.actor.getRollData()) roll.toMessage({ @@ -130,6 +132,24 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { } } + static async #rollFlaw(event, target) { + event.preventDefault() + const {itemId} = target.dataset + if (itemId) { + const flaw = this.document.items.get(itemId) + if (flaw) { + const target = flaw.system.value + let roll = await new Roll(`1d20`).evaluate() + let diff = target - roll.terms[0].results[0].result + roll.toMessage({ + speaker: ChatMessage.getSpeaker({actor: this.actor}), + flavor: `Schlechte Eigenschaft: ${flaw.name}
Ergebnis: ${Math.abs(diff)}${diff > 0 ? " übrig" : " daneben"}`, + rollMode: game.settings.get('core', 'rollMode'), + }); + } + } + } + static async #progressCooldown(event, target) { const {cooldownId} = target.dataset const cooldowns = this.document.system.cooldowns diff --git a/src/style/organisms/character-tabs/_advsf.scss b/src/style/organisms/character-tabs/_advsf.scss index f03a8898..ecf0b2e8 100644 --- a/src/style/organisms/character-tabs/_advsf.scss +++ b/src/style/organisms/character-tabs/_advsf.scss @@ -6,7 +6,7 @@ gap: 8px; } - .advantages, .special-abilities { + .advantages, .special-abilities, .flaws { margin-bottom: 16px; ul { @@ -19,7 +19,7 @@ display: inline-block; } - .advantage, .special-ability { + .advantage, .special-ability, .flaw { position: relative; border: 1px solid gold; box-shadow: 2px 2px 4px #000; @@ -63,6 +63,29 @@ margin-left: 8px; } + &.flaw { + position: relative; + margin-left: 24px; + + .die { + + path { + fill: #6a24d8ff; + } + + position: absolute; + left: -24px; + + height: 24px; + width: 24px; + } + + &::after { + background: rgba(106, 36, 216, 0.5); + } + + } + &.disadvantage { font-style: italic; diff --git a/src/templates/actor/character/tab-advsf.hbs b/src/templates/actor/character/tab-advsf.hbs index 346a6ba4..63858a2d 100644 --- a/src/templates/actor/character/tab-advsf.hbs +++ b/src/templates/actor/character/tab-advsf.hbs @@ -2,7 +2,15 @@ data-tab="{{tabs.advsf.id}}" data-group="{{tabs.advsf.group}}">
-
+
+

Schlechte Eigenschaften

+
    + {{#each this.flaws}} +
  • {{> "systems/DSA_4-1/templates/ui/partial-advantage-button.hbs" this}}
  • + {{/each}} +
+
+

Vor- und Nachteile

    {{#each this.advantages}} diff --git a/src/templates/ui/partial-advantage-button.hbs b/src/templates/ui/partial-advantage-button.hbs index 044635cc..4dc86bff 100644 --- a/src/templates/ui/partial-advantage-button.hbs +++ b/src/templates/ui/partial-advantage-button.hbs @@ -1,4 +1,15 @@ +{{#if this.isBadAttribute}} +
    +
    + {{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }} +
    + {{this.name}} {{#if + this.value}} + : {{this.value}}{{/if}} +
    +{{else}}
    {{this.name}} {{#if this.value}} : {{this.value}}{{/if}}
    +{{/if}}