From 96d471b2f8f07a03a6aa2c7fd85cf11e30c30fb0 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 1 Mar 2026 11:52:05 +0100 Subject: [PATCH] Add attacker selection from enemies list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow selecting an attacker from the bestiary/enemies list to automatically populate BS and WS values. This enables using player characters (added as enemies) as attackers in combat rolls. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/components/DeathwatchRoller.jsx | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/components/DeathwatchRoller.jsx b/src/components/DeathwatchRoller.jsx index 0a005c4..944d125 100755 --- a/src/components/DeathwatchRoller.jsx +++ b/src/components/DeathwatchRoller.jsx @@ -334,6 +334,7 @@ function DeathwatchRoller() { const [enemiesLoading,setEnemiesLoading] = useState(false) const [enemiesError,setEnemiesError] = useState(null) const [enemyName,setEnemyName] = useState('Custom/None') + const [attackerName,setAttackerName] = useState('Custom/None') // Load enemies from database API async function loadEnemiesFromAPI() { @@ -536,6 +537,29 @@ function DeathwatchRoller() { else setDefenderModifier(0) } + function onSelectAttacker(name) { + setAttackerName(name) + const e = enemies.find(x=>x.name===name) + if (!e || name === "Custom/None") return + // Extract WS/BS from enemy + function findNumeric(o, keys) { + if (!o || typeof o !== "object") return undefined + for (const k of keys) { + if (typeof o[k] === "number") return o[k] + const lower = k.toLowerCase() + for (const ok of Object.keys(o)) { + if (ok.toLowerCase() === lower && typeof o[ok] === "number") return o[ok] + } + } + return undefined + } + const char = e.characteristics || (e.tabInfo && e.tabInfo.characteristics) || {} + const wsVal = findNumeric(e, ["ws", "Ws", "WS"]) ?? findNumeric(char, ["ws"]) + const bsVal = findNumeric(e, ["bs", "Bs", "BS"]) ?? findNumeric(char, ["bs"]) + if (typeof wsVal === "number") setWS(wsVal) + if (typeof bsVal === "number") setBS(bsVal) + } + function importFromJSONText(txt) { try { const arr = JSON.parse(txt) @@ -1111,6 +1135,12 @@ function DeathwatchRoller() { TB / AR / W • {enemies.length} enemies loaded +
+ + +