index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-04-27 13:10:43 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-04-27 13:10:43 -0700 |
commit | 75a0c37ea5e5a9fa395690984c373536e8efccfa (patch) | |
tree | 808eeee44b89638b0583ba2375388c53be882c2f /src/modules/recordSheet.js | |
parent | b88945ced695e8478076c5f53a198fd405f7db96 (diff) |
Some cleanup
Diffstat (limited to 'src/modules/recordSheet.js')
-rw-r--r-- | src/modules/recordSheet.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/modules/recordSheet.js b/src/modules/recordSheet.js new file mode 100644 index 0000000..99af18f --- /dev/null +++ b/src/modules/recordSheet.js @@ -0,0 +1,32 @@ +export function unSelect() { + const selected = getSelected(); + + if (selected) { + selected.classList.remove('selected'); + } + + document.getElementById('toggle-prone-counter').checked = false; +} + +export function getSelected() { + return document.querySelector('.soldier-record.selected'); +} + +export function select(data) { + const selector = + `#record-sheet .soldier-record[data-number="${data.number}"][data-allegiance="${data.allegiance}"]` + + unSelect(); + document.querySelector(selector).classList.add('selected'); + document.getElementById('toggle-prone-counter').checked = data.prone; +} + +export function endMove() { + const selected = getSelected(); + + if (selected) { + selected.classList.toggle('movement-ended'); + } + + unSelect(); +} |