diff --git a/src/module/data/character.mjs b/src/module/data/character.mjs index 8297bd7d..c571c246 100644 --- a/src/module/data/character.mjs +++ b/src/module/data/character.mjs @@ -138,6 +138,10 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel { key: new StringField(), notiz: new StringField(), })), + erschoepfung: new SchemaField({ // only with DSA_4-1.optional_erschoepfung + max: new NumberField({required: true, integer: true}), + aktuell: new NumberField({required: true, integer: true}), + }), wunden: new SchemaField({ aktuell: new NumberField({required: true, integer: true}), // only with DSA_4-1.optional_trefferzonen = false max: new NumberField({required: true, integer: true}), // only with DSA_4-1.optional_trefferzonen = false diff --git a/src/module/documents/character.mjs b/src/module/documents/character.mjs index f158a631..bf116fee 100644 --- a/src/module/documents/character.mjs +++ b/src/module/documents/character.mjs @@ -105,6 +105,19 @@ export class Character extends Actor { systemData.ausweichen.basis = systemData.pa.basis systemData.ausweichen.aktuell = systemData.ausweichen.basis + systemData.ueberanstrengung = 0 + + if (game.settings.get("DSA_4-1", "optional_erschoepfung")) { + + systemData.erschoepfung = { + aktuell: systemData.erschoepfung.aktuell ?? 0, + max: ko + } + if (systemData.erschoepfung.aktuell > systemData.erschoepfung.max) { + systemData.ueberanstrengung = systemData.erschoepfung.aktuell - systemData.erschoepfung.max + } + } + if (game.settings.get("DSA_4-1", "optional_ruestungzonen")) { systemData.rs = { @@ -119,11 +132,11 @@ export class Character extends Actor { } else { systemData.rs = 0; // only with DSA_4-1.optional_trefferzonen = false } - systemData.be = 0; + systemData.be = 0 + systemData.ueberanstrengung; // half KO is the maximum a character can sustain wounds before collapsing - systemData.wunden.max = ko / 2; + systemData.wunden.max = Math.round(ko / 2); if (game.settings.get("DSA_4-1", "optional_trefferzonen")) { systemData.wunden.kopf = 0 systemData.wunden.brust = 0 diff --git a/src/module/settings/global-settings.mjs b/src/module/settings/global-settings.mjs index 50d919a8..65777bb8 100644 --- a/src/module/settings/global-settings.mjs +++ b/src/module/settings/global-settings.mjs @@ -36,6 +36,18 @@ function initGlobalSettings(settings) { requiresReload: true }) + settings.register('DSA_4-1', 'optional_erschoepfung', { + name: "Optional: Erschöpfung", + hint: "Aktiviert Regeln für das Spiel mit Erschöpfung und Überanstregung", + scope: "world", + config: true, + type: Boolean, + default: false, + onChange: value => { + }, + requiresReload: true + }) + settings.register('DSA_4-1', 'optional_distanzklassen', { name: "Optional: Distanzklassen", hint: "Aktiviert Regeln für das Spiel mit Distanzklassen", diff --git a/src/module/sheets/character/health.mjs b/src/module/sheets/character/health.mjs index 0e409976..9c3de352 100644 --- a/src/module/sheets/character/health.mjs +++ b/src/module/sheets/character/health.mjs @@ -27,6 +27,24 @@ export default { context.aspcurrent = actorData.system.asp.aktuell ?? 0 context.kapcurrent = actorData.system.kap.aktuell ?? 0 + context.maxWounds = actorData.system.wunden.max ?? 3 + context.wounds = actorData.system.wunden.aktuell ?? 0 + context.woundsFilled = [] + for (let i = 1; i <= context.maxWounds; i++) { + context.woundsFilled[i] = i <= context.wounds + } + + context.withErschoepfung = game.settings.get("DSA_4-1", "optional_erschoepfung") + context.ueberanstrengung = actorData.system.ueberanstrengung + context.erschoepfung = actorData.system.erschoepfung.aktuell + context.maxErschoepfung = actorData.system.erschoepfung.max + + context.erschoepfungFilled = [] + for (let i = 1; i <= context.maxErschoepfung; i++) { + context.erschoepfungFilled[i] = i <= context.erschoepfung + } + + context.effects = [] for (let i = 0; i < actorData.appliedEffects.length; i++) { const item = actorData.appliedEffects[i] diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index 59320a07..73e94338 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -67,6 +67,7 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { openBagpack: CharacterSheet.#openBagpack, openStandaloneSpells: CharacterSheet.#openStandaloneSpells, openStandaloneLiturgies: CharacterSheet.#openStandaloneLiturgies, + setWounds: CharacterSheet.#setWounds, } } @@ -320,6 +321,12 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { new StandaloneLiturgies(this.document) } + static async #setWounds(event, target) { + const {value} = target.dataset + this.document.update({"system.wunden.aktuell": value}) + this.render(true) + } + _configureRenderOptions(options) { super._configureRenderOptions(options) @@ -445,13 +452,6 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { context.img = actorData.img context.effects = actorData.effects ?? [] - context.maxWounds = actorData.system.wunden.max ?? 3 - context.wounds = actorData.system.wunden.gesamt ?? 0 - context.woundsFilled = [] - for (let i = 1; i <= context.maxWounds; i++) { - context.woundsFilled[i] = i <= context.wounds - } - context.zonenruestung = game.settings.get("DSA_4-1", "optional_ruestungzonen") context.trefferzonen = game.settings.get("DSA_4-1", "optional_trefferzonen") context.ausdauer = game.settings.get("DSA_4-1", "optional_ausdauer") diff --git a/src/style/organisms/character-tabs/_health.scss b/src/style/organisms/character-tabs/_health.scss index 1e3163b7..a8fb173d 100644 --- a/src/style/organisms/character-tabs/_health.scss +++ b/src/style/organisms/character-tabs/_health.scss @@ -3,8 +3,8 @@ display: grid; grid-template-columns: 1fr 320px; - grid-template-rows: 32px 32px 1fr; - grid-template-areas: "res res" "wounds wounds" "actions actions" "cooldowns cooldowns"; + grid-template-rows: 32px 32px 32px 1fr; + grid-template-areas: "res res" "wounds wounds" "fatigue fatigue" "effects effects" "effects effects"; padding: 8px; gap: 8px; @@ -31,7 +31,7 @@ } - .wounds { + .wounds, .fatigue { position: relative; height: 24px; display: flex; @@ -90,22 +90,46 @@ } - .actions { - grid-area: actions; - padding: 0; + .fatigue { + grid-area: fatigue; + flex-direction: row; - .grid-of-actions { - display: unset; + label { + span { + display: inline-block; + height: 26px; + line-height: 26px; + vertical-align: middle; + } + + input { + position: absolute; + right: 0; + height: 26px; + text-align: center; + padding: 0; + margin: 0; + width: 28px; + } } + + .filled-segment { + background-color: rgba(0, 128, 0, 0.8); + + &.danger { + background-color: rgba(255, 0, 0, 0.8); + } + } + } - .cooldowns { - grid-area: cooldowns; + .effects { + grid-area: effects; } &.zones { - grid-template-areas: "res res" "wounds wounds" "actions paperdoll" "cooldowns paperdoll"; + grid-template-areas: "res res" "wounds wounds" "fatigue fatigue" "effects paperdoll" "effects paperdoll"; .paperdoll { grid-area: paperdoll; diff --git a/src/templates/actor/character/tab-health.hbs b/src/templates/actor/character/tab-health.hbs index 2d49e510..dab36be2 100644 --- a/src/templates/actor/character/tab-health.hbs +++ b/src/templates/actor/character/tab-health.hbs @@ -42,31 +42,48 @@ {{#if (not trefferzonen)}}