enables rolling of character flaws
parent
4395ada6f5
commit
9ce299a202
|
|
@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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}<br/>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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,15 @@
|
|||
data-tab="{{tabs.advsf.id}}"
|
||||
data-group="{{tabs.advsf.group}}">
|
||||
<div class="advantages-and-specialabilities">
|
||||
<div class="advantages">
|
||||
<div class="flaws">
|
||||
<h3>Schlechte Eigenschaften</h3>
|
||||
<ul>
|
||||
{{#each this.flaws}}
|
||||
<li>{{> "systems/DSA_4-1/templates/ui/partial-advantage-button.hbs" this}}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="advantages">
|
||||
<h3>Vor- und Nachteile</h3>
|
||||
<ul>
|
||||
{{#each this.advantages}}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,15 @@
|
|||
{{#if this.isBadAttribute}}
|
||||
<div class="flaw">
|
||||
<div class="die" data-action="rollFlaw" data-item-id="{{this.id}}">
|
||||
{{> 'systems/DSA_4-1/templates/ui/partial-die.hbs' }}
|
||||
</div>
|
||||
<span class="name" data-action="openEmbeddedDocument" data-item-id="{{this.id}}">{{this.name}} {{#if
|
||||
this.value}}
|
||||
: {{this.value}}{{/if}}</span>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="advantage {{#if isDisadvantage}}disadvantage{{/if}}">
|
||||
<span class="name" data-action="openEmbeddedDocument" data-item-id="{{this.id}}">{{this.name}} {{#if this.value}}
|
||||
: {{this.value}}{{/if}}</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue