add dying value adjuster to conditions row

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
Matthew Huntington 1 month ago
parent cf77c914e0
commit 12fbdcb24d

@ -222,6 +222,9 @@
} }
.sim-cond-val.wounded-hi { color: #d0a030; } .sim-cond-val.wounded-hi { color: #d0a030; }
.sim-cond-val.doomed-hi { color: #d04040; } .sim-cond-val.doomed-hi { color: #d04040; }
.sim-cond-val.dying-hi-1 { color: var(--c-dying-1-hi); }
.sim-cond-val.dying-hi-2 { color: var(--c-dying-2-hi); }
.sim-cond-val.dying-hi-3 { color: var(--c-dying-3-hi); }
.sim-cond-btn { .sim-cond-btn {
background: var(--surface2); border: 1px solid var(--border); background: var(--surface2); border: 1px solid var(--border);
color: var(--text-muted); cursor: pointer; font-family: inherit; color: var(--text-muted); cursor: pointer; font-family: inherit;
@ -517,6 +520,12 @@ flowchart TD
<div class="sim-cond-row"> <div class="sim-cond-row">
<span class="sim-start-label">Conditions:</span> <span class="sim-start-label">Conditions:</span>
<div class="sim-cond-item">
<span class="sim-cond-label">Dying</span>
<button class="sim-cond-btn" onclick="adjustDying(-1)">&#x2212;</button>
<span class="sim-cond-val" id="sim-dying-val">0</span>
<button class="sim-cond-btn" onclick="adjustDying(1)">+</button>
</div>
<div class="sim-cond-item"> <div class="sim-cond-item">
<span class="sim-cond-label">Wounded</span> <span class="sim-cond-label">Wounded</span>
<button class="sim-cond-btn" onclick="adjustWounded(-1)">&#x2212;</button> <button class="sim-cond-btn" onclick="adjustWounded(-1)">&#x2212;</button>
@ -915,6 +924,24 @@ flowchart TD
// ── Condition Adjusters ─────────────────────────────────────── // ── Condition Adjusters ───────────────────────────────────────
function adjustDying(delta) {
var current = (simState === 'DYING') ? simDying : 0;
var newVal = current + delta;
if (newVal <= 0) {
if (simState === 'DYING') { simState = 'UNCONSCIOUS'; }
simDying = 0;
} else if (newVal >= deathThreshold()) {
simState = 'DEAD'; simDying = 0;
} else {
simState = 'DYING'; simDying = newVal;
}
renderCondVals();
simRenderStateBox();
simRenderActions();
document.getElementById('sim-outcomes-section').style.display = 'none';
document.getElementById('sim-result-container').innerHTML = '';
}
function adjustWounded(delta) { function adjustWounded(delta) {
simWounded = Math.max(0, simWounded + delta); simWounded = Math.max(0, simWounded + delta);
renderCondVals(); renderCondVals();
@ -934,8 +961,12 @@ flowchart TD
} }
function renderCondVals() { function renderCondVals() {
var wEl = document.getElementById('sim-wounded-val'); var dyEl = document.getElementById('sim-dying-val');
var dEl = document.getElementById('sim-doomed-val'); var wEl = document.getElementById('sim-wounded-val');
var dEl = document.getElementById('sim-doomed-val');
var dv = (simState === 'DYING') ? simDying : 0;
dyEl.textContent = dv;
dyEl.className = 'sim-cond-val' + (dv > 0 ? ' dying-hi-' + Math.min(3, dv) : '');
wEl.textContent = simWounded; wEl.textContent = simWounded;
wEl.className = 'sim-cond-val' + (simWounded > 0 ? ' wounded-hi' : ''); wEl.className = 'sim-cond-val' + (simWounded > 0 ? ' wounded-hi' : '');
dEl.textContent = simDoomed; dEl.textContent = simDoomed;
@ -952,6 +983,7 @@ flowchart TD
} }
simHistory = [{ state: simState, dying: simDying }]; simHistory = [{ state: simState, dying: simDying }];
simPending = null; simPending = null;
renderCondVals();
simRender(); simRender();
} }
@ -997,6 +1029,7 @@ flowchart TD
} }
function simRenderWithResult(msg) { function simRenderWithResult(msg) {
renderCondVals();
simRenderStateBox(); simRenderStateBox();
simRenderActions(); simRenderActions();
document.getElementById('sim-outcomes-section').style.display = 'none'; document.getElementById('sim-outcomes-section').style.display = 'none';

Loading…
Cancel
Save