Automatically add compromised condition when strife goes beyond max and remove...

This commit is contained in:
Putty
2025-09-06 07:38:10 +00:00
committed by GitLab
parent 7c3ef81dec
commit 7fed2f0a98
6 changed files with 23 additions and 9 deletions

View File

@@ -125,6 +125,17 @@ export class ActorL5r5e extends Actor {
});
}
/** @inheritDoc */
async _preUpdate(changes, options, user) {
if (this.isCharacterType) {
// apply compromised condition if strife goes beyond max
const strife = changes.system?.strife?.value ?? this.system.strife.value;
const maxStrife = changes.system?.strife?.max ?? this.system.strife.max;
const isCompromised = strife > maxStrife;
await this.toggleStatusEffect('compromised', {active: isCompromised});
}
}
/** @override */
prepareData() {
super.prepareData();
@@ -137,13 +148,16 @@ export class ActorL5r5e extends Actor {
ActorL5r5e.computeDerivedAttributes(system);
}
const isAfflicted = this.statuses.has("afflicted");
const isCompromised = this.statuses.has("compromised");
// Attributes bars
system.fatigue.max = system.endurance;
system.strife.max = system.composure;
system.void_points.max = system.rings.void;
// if compromise, vigilance = 1
system.is_compromised = system.strife.value > system.strife.max;
// if compromised or afflicted, vigilance = 1
system.is_afflicted_or_compromised = isAfflicted || isCompromised;
// Make sure void points are never greater than max
if (system.void_points.value > system.void_points.max) {

View File

@@ -62,7 +62,7 @@ export class CombatL5r5e extends Combat {
// If the character was unprepared (such as when surprised), their base initiative value is their vigilance attribute.
// Minion NPCs can generate initiative value without a check, using their focus or vigilance attribute
let initiative =
isPrepared === "true" ? actorSystem.focus : actorSystem.is_compromised ? 1 : actorSystem.vigilance;
isPrepared === "true" ? actorSystem.focus : actorSystem.is_afflicted_or_compromised ? 1 : actorSystem.vigilance;
// Roll only for PC and Adversary
if (isPc || combatant.actor.isAdversary) {

View File

@@ -36,10 +36,10 @@
</label>
<p class="item-description"> {{localize 'l5r5e.attributes.focustip'}}</p>
</li>
<li class="vigilance-content {{#if data.system.is_compromised}}compromised{{/if}}">
<li class="vigilance-content {{#if data.system.is_afflicted_or_compromised}}compromised{{/if}}">
<label class="attribute-label">
<strong>{{localize 'l5r5e.attributes.vigilance'}}</strong>
{{#if data.system.is_compromised}}
{{#if data.system.is_afflicted_or_compromised}}
<input class="centered-input" type="number" value="1" disabled/>
{{else}}
<input class="centered-input" type="number" name="system.vigilance" value="{{data.system.vigilance}}" data-dtype="Number" disabled/>

View File

@@ -36,10 +36,10 @@
</label>
<p class="item-description"> {{localize 'l5r5e.attributes.focustip'}}</p>
</li>
<li class="vigilance-content {{#if data.system.is_compromised}}compromised{{/if}}">
<li class="vigilance-content {{#if data.system.is_afflicted_or_compromised}}compromised{{/if}}">
<label class="attribute-label">
<strong>{{localize 'l5r5e.attributes.vigilance'}}</strong>
{{#if data.system.is_compromised}}
{{#if data.system.is_afflicted_or_compromised}}
<input class="centered-input" type="number" value="1" disabled/>
{{else}}
<input class="centered-input" type="number" name="system.vigilance" value="{{data.system.vigilance}}" data-dtype="Number" min="0" placeholder="0" {{^if data.editable_not_soft_locked}}disabled{{/if}}/>

View File

@@ -69,7 +69,7 @@
</td>
<td>
{{actor.system.focus}}
/ {{#if actor.system.is_compromised}}<span class="badvalue">1</span>{{else}}{{actor.system.vigilance}}{{/if}}
/ {{#if actor.system.is_afflicted_or_compromised}}<span class="badvalue">1</span>{{else}}{{actor.system.vigilance}}{{/if}}
</td>
<td>
<a title="{{localize 'l5r5e.gm.monitor.mouse_control'}}" data-actor-uuid="{{actor.uuid}}" data-type="void_points" class="actor-modify-control">

View File

@@ -68,7 +68,7 @@
</td>
<td>
{{actor.system.focus}}
/ {{#if actor.system.is_compromised}}<span class="badvalue">1</span>{{else}}{{actor.system.vigilance}}{{/if}}
/ {{#if actor.system.is_afflicted_or_compromised}}<span class="badvalue">1</span>{{else}}{{actor.system.vigilance}}{{/if}}
</td>
<td>
<a title="{{localize 'l5r5e.gm.monitor.mouse_control'}}" data-actor-uuid="{{actor.uuid}}" data-action="modify_voidPoint" class="actor-modify-control">