Fix #28 : switch to manual BP management

This commit is contained in:
LeRatierBretonnien 2025-01-09 16:18:08 +01:00
parent 3adb34d721
commit 03a54d86e6
7 changed files with 32 additions and 11 deletions

View File

@ -326,6 +326,10 @@ i.fvtt-cthulhu-eternal {
cursor: pointer; cursor: pointer;
font-size: 0.9rem; font-size: 0.9rem;
} }
.fvtt-cthulhu-eternal .protagonist-main .protagonist-pc .protagonist-right .san .button {
min-width: 4rem;
max-width: 4rem;
}
.fvtt-cthulhu-eternal .protagonist-main .protagonist-pc .protagonist-right .san .san-checkbox { .fvtt-cthulhu-eternal .protagonist-main .protagonist-pc .protagonist-right .san .san-checkbox {
min-width: 1rem; min-width: 1rem;
max-width: 1rem; max-width: 1rem;

View File

@ -323,6 +323,7 @@
"veryHarsh": "Very Harsh" "veryHarsh": "Very Harsh"
}, },
"Label": { "Label": {
"setBP": "Set BP",
"Vehicle": "Vehicle", "Vehicle": "Vehicle",
"Speed": "Speed", "Speed": "Speed",
"Slow": "Slow", "Slow": "Slow",
@ -431,7 +432,8 @@
"roll": "Roll" "roll": "Roll"
}, },
"Tooltip": { "Tooltip": {
"sanBP": ">5 SAN lost in one roll, temporary insanity. If SAN less reaches BP = a Disorder unconscious Breaking and AND reset BP." "sanBP": ">5 SAN lost in one roll, temporary insanity. If SAN less reaches BP = a Disorder unconscious Breaking and AND reset BP.",
"setBP": "Set the current Breaking Point based on the current SAN value"
}, },
"Setting": { "Setting": {
}, },

View File

@ -12,6 +12,7 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
contentClasses: ["protagonist-content"], contentClasses: ["protagonist-content"],
}, },
actions: { actions: {
setBP: CthulhuEternalProtagonistSheet.#onSetBP,
createGear: CthulhuEternalProtagonistSheet.#onCreateGear, createGear: CthulhuEternalProtagonistSheet.#onCreateGear,
createArmor: CthulhuEternalProtagonistSheet.#onCreateArmor, createArmor: CthulhuEternalProtagonistSheet.#onCreateArmor,
createWeapon: CthulhuEternalProtagonistSheet.#onCreateWeapon, createWeapon: CthulhuEternalProtagonistSheet.#onCreateWeapon,
@ -125,6 +126,10 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
* @param {Event} event The initiating click event. * @param {Event} event The initiating click event.
* @param {HTMLElement} target The current target of the event listener. * @param {HTMLElement} target The current target of the event listener.
*/ */
static #onSetBP(event, target) {
this.document.system.setBP()
}
static #onCreateGear(event, target) { static #onCreateGear(event, target) {
this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("CTHULHUETERNAL.Label.newGear"), type: "gear" }]) this.document.createEmbeddedDocuments("Item", [{ name: game.i18n.localize("CTHULHUETERNAL.Label.newGear"), type: "gear" }])
} }

View File

@ -106,11 +106,6 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
updates[`system.san.max`] = maxSan updates[`system.san.max`] = maxSan
} }
let bp = Math.max(this.san.value - this.characteristics.pow.value, 0)
if ( this.san.breakingPoint !== bp) {
updates[`system.san.breakingPoint`] = bp
}
let recoverySan = this.characteristics.pow.value * 5 let recoverySan = this.characteristics.pow.value * 5
if (recoverySan > this.san.max) { if (recoverySan > this.san.max) {
recoverySan = this.san.max recoverySan = this.san.max
@ -183,6 +178,17 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
return this.wp.exhausted return this.wp.exhausted
} }
setBP() {
let updates = {}
let bp = Math.max(this.san.value - this.characteristics.pow.value, 0)
if ( this.san.breakingPoint !== bp) {
updates[`system.san.breakingPoint`] = bp
}
if (Object.keys(updates).length > 0) {
this.parent.update(updates)
}
}
/** */ /** */
/** /**
* Rolls a dice for a character. * Rolls a dice for a character.

View File

@ -20,7 +20,6 @@ export default class CthulhuEternalSkill extends foundry.abstract.TypeDataModel
/** @override */ /** @override */
static LOCALIZATION_PREFIXES = ["CTHULHUETERNAL.Skill"] static LOCALIZATION_PREFIXES = ["CTHULHUETERNAL.Skill"]
prepareDerivedData() { prepareDerivedData() {
super.prepareDerivedData(); super.prepareDerivedData();
this.skillTotal = this.computeScore(); this.skillTotal = this.computeScore();

View File

@ -83,6 +83,10 @@
cursor: pointer; cursor: pointer;
font-size: 0.9rem; font-size: 0.9rem;
} }
.button {
min-width: 4rem;
max-width: 4rem;
}
.san-checkbox { .san-checkbox {
min-width: 1rem; min-width: 1rem;
max-width: 1rem; max-width: 1rem;

View File

@ -42,8 +42,6 @@
<span class="label-bp" data-tooltip='{{localize "CTHULHUETERNAL.Tooltip.sanBPShort"}}'>{{localize <span class="label-bp" data-tooltip='{{localize "CTHULHUETERNAL.Tooltip.sanBPShort"}}'>{{localize
"CTHULHUETERNAL.Label.sanBPShort"}}</span> "CTHULHUETERNAL.Label.sanBPShort"}}</span>
{{formInput systemFields.san.fields.breakingPoint value=system.san.breakingPoint disabled=true}} {{formInput systemFields.san.fields.breakingPoint value=system.san.breakingPoint disabled=true}}
</div> </div>
@ -51,15 +49,18 @@
<div class="flexrow"> <div class="flexrow">
<span class="label-short-field">{{localize "CTHULHUETERNAL.Label.max"}}</span> <span class="label-short-field">{{localize "CTHULHUETERNAL.Label.max"}}</span>
{{formInput systemFields.san.fields.max value=system.san.max rootId=partId disabled=true}} {{formInput systemFields.san.fields.max value=system.san.max rootId=partId disabled=true}}
</div> </div>
<span class="label-insanity" > <span class="label-insanity" >
{{localize "CTHULHUETERNAL.Label.tempInsanity"}} {{localize "CTHULHUETERNAL.Label.tempInsanity"}}
</span> </span>
{{formInput systemFields.san.fields.insanity value=system.san.insanity localize=true}} {{formInput systemFields.san.fields.insanity value=system.san.insanity localize=true}}
{{#if (not isPlayMode)}}
<button data-action="setBP" class="button" data-tooltip="{{localize "CTHULHUETERNAL.Tooltip.setBP"}}">{{localize "CTHULHUETERNAL.Label.setBP"}}</button>
{{/if}}
</div> </div>
<div class="flexrow"> <div class="flexrow">