diff options
-rw-r--r-- | play.html | 1 | ||||
-rw-r--r-- | rules.js | 34 |
2 files changed, 22 insertions, 13 deletions
@@ -32,6 +32,7 @@ header.your_turn { background-color: orange; } #log > .i { padding-left: 20px; } #log > .ii { padding-left: 32px; } #log > div > .i { padding-left: 12px; } +#log .hex:hover { cursor: pointer; text-decoration: underline; } .action { cursor: pointer; @@ -1,7 +1,7 @@ "use strict" -// TODO: retreat withdraw co-exist with disrupted enemy - hexside control (wait for Craig) -// TODO: buildup steps in friendly battle hex +// TODO: retreat withdraw co-exist with disrupted enemy - no hexside limits or control + // TODO: rout during probe combat? // TODO: allow one-hex regroup moves? (failed forced march abuse) // TODO: rewrite regroup to group if only one hex moved (failed forced march abuse) @@ -778,20 +778,29 @@ function capture_fortress(fortress, capacity) { if (!is_fortress_friendly_controlled(fortress)) { if (has_undisrupted_friendly_unit(fortress) && !has_enemy_unit(fortress)) { invalidate_caches() - - log(`Captured #${fortress}!`) - let fresh = set_fortress_friendly_controlled(fortress) if (fresh) { + log(`Captured #${fortress}!`) if (is_axis_player()) { let award = capacity - log(`Awarded ${award} supply cards.`) + log(`Awarded ${award} bonus supply.`) game.axis_award += award } else { let award = Math.floor(capacity / 2) - log(`Awarded ${award} supply cards.`) + log(`Awarded ${award} bonus supply.`) game.allied_award += award } + } else { + log(`Recaptured #${fortress}!`) + if (is_allied_player()) { + let award = capacity + log(`Canceled ${award} bonus supply.`) + game.axis_award -= award + } else { + let award = Math.floor(capacity / 2) + log(`Canceled ${award} bonus supply.`) + game.allied_award -= award + } } } } @@ -822,12 +831,11 @@ function set_fortress_allied_controlled(fortress) { game.fortress |= fortress_bit(fortress) } -function set_fortress_captured(fortress) { +function toggle_fortress_captured(fortress) { let bit = fortress_bit(fortress) << 3 - if (game.fortress & bit) - return false - game.fortress |= bit - return true + let old = game.fortress & bit + game.fortress ^= bit + return old === 0 } function clear_fortresses_captured() { @@ -845,7 +853,7 @@ function set_fortress_friendly_controlled(fortress) { set_fortress_axis_controlled(fortress) else set_fortress_allied_controlled(fortress) - return set_fortress_captured(fortress) + return toggle_fortress_captured(fortress) } function is_port_besieged(port) { |