restores wounds logic

pull/63/head
macniel 2025-10-30 11:03:58 +01:00
parent d62bbe9886
commit eb6f13f78e
6 changed files with 59 additions and 38 deletions

View File

@ -125,14 +125,16 @@ export class Character extends Actor {
// half KO is the maximum a character can sustain wounds before collapsing // half KO is the maximum a character can sustain wounds before collapsing
systemData.wunden.max = ko / 2; systemData.wunden.max = ko / 2;
if (game.settings.get("DSA_4-1", "optional_trefferzonen")) { if (game.settings.get("DSA_4-1", "optional_trefferzonen")) {
systemData.wunden.kopf = 0; systemData.wunden.kopf = 0
systemData.wunden.brust = 0; systemData.wunden.brust = 0
systemData.wunden.bauch = 0; systemData.wunden.bauch = 0
systemData.wunden.ruecken = 0; systemData.wunden.ruecken = 0
systemData.wunden.armlinks = 0; systemData.wunden.armlinks = 0
systemData.wunden.armrechts = 0; systemData.wunden.armrechts = 0
systemData.wunden.beinlinks = 0; systemData.wunden.beinlinks = 0
systemData.wunden.beinrechts = 0; systemData.wunden.beinrechts = 0
} else {
systemData.wunden.gesamt = 0
} }
systemData.ws = ko / 2; systemData.ws = ko / 2;

View File

@ -12,13 +12,12 @@ export default {
context.isGM = game.user.isGM context.isGM = game.user.isGM
context.effects = [] context.effects = []
Object.values(actorData.items).forEach((item, index) => {
if (item.type === "ActiveEffect") { for (let i = 0; i < actorData.appliedEffects.length; i++) {
const effect = item.effects[0]; const item = actorData.appliedEffects[i]
const conditions = [] const conditions = []
if (effect) { item.changes.forEach(change => {
effect.changes.forEach(change => {
if (change.key.indexOf("wunden") === -1) { if (change.key.indexOf("wunden") === -1) {
const key = change.key const key = change.key
.replace(/system\./g, "") .replace(/system\./g, "")
@ -32,16 +31,15 @@ export default {
) )
} }
}) })
}
context.effects.push({ context.effects.push({
name: item.name, name: item.parent.name,
conditions: conditions.join(" "), conditions: conditions.join(" "),
id: item._id, id: item.parent._id,
actor: actorData._id actor: actorData._id
}); });
} }
})
return context return context
}, },

View File

@ -46,6 +46,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
cancelCooldown: CharacterSheet.#cancelCooldown, cancelCooldown: CharacterSheet.#cancelCooldown,
activateCooldown: CharacterSheet.#activateCooldown, activateCooldown: CharacterSheet.#activateCooldown,
rest: CharacterSheet.#startResting, rest: CharacterSheet.#startResting,
removeEffect: CharacterSheet.#removeEffect,
} }
} }
@ -235,6 +236,22 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
dialog.render(true) dialog.render(true)
} }
static async #removeEffect(event, target) {
const {actorId, effectId} = target.dataset
if (actorId === this.document._id) {
const item = this.document.items.get(effectId)
if (item.type === "ActiveEffect") {
this.document.deleteEmbeddedDocuments("Item", [effectId])
}
}
}
/** /**
* Handle form submission * Handle form submission
* @this {AdvantageSheet} * @this {AdvantageSheet}
@ -317,7 +334,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
context.effects = actorData.effects ?? [] context.effects = actorData.effects ?? []
context.maxWounds = actorData.system.wunden.max ?? 3 context.maxWounds = actorData.system.wunden.max ?? 3
context.wounds = actorData.system.wunden.aktuell ?? 0 context.wounds = actorData.system.wunden.gesamt ?? 0
context.woundsFilled = [] context.woundsFilled = []
for (let i = 1; i <= context.maxWounds; i++) { for (let i = 1; i <= context.maxWounds; i++) {
context.woundsFilled[i] = i <= context.wounds context.woundsFilled[i] = i <= context.wounds

View File

@ -5,7 +5,7 @@
"image": "icons/skills/wounds/bone-broken-knee-beam.webp", "image": "icons/skills/wounds/bone-broken-knee-beam.webp",
"effects": [ "effects": [
{ {
"key": "system.wunden", "key": "system.wunden.gesamt",
"mode": 2, "mode": 2,
"value": "1", "value": "1",
"priority": 10 "priority": 10

View File

@ -34,6 +34,10 @@
<label>BE:</label> <label>BE:</label>
{{derived.be}} {{derived.be}}
</div> </div>
<div class="speed">
<label>GS:</label>
{{derived.gs.aktuell}}
</div>
</div> </div>

View File

@ -18,7 +18,7 @@
</td> </td>
<td>{{this.conditions}}</td> <td>{{this.conditions}}</td>
<td>{{#if ../isGM}} <td>{{#if ../isGM}}
<button data-operation="removeEffect" data-actor-id="{{actor}}" data-effect-id="{{id}}"><i <button data-action="removeEffect" data-actor-id="{{actor}}" data-effect-id="{{id}}"><i
class="fa-solid fa-trash"></i></button>{{/if}}</td> class="fa-solid fa-trash"></i></button>{{/if}}</td>
</tr> </tr>
{{/each}} {{/each}}