summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.html1
-rw-r--r--rules.js34
2 files changed, 22 insertions, 13 deletions
diff --git a/play.html b/play.html
index 0805cb4..a987bb8 100644
--- a/play.html
+++ b/play.html
@@ -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;
diff --git a/rules.js b/rules.js
index 972538e..8e67ee2 100644
--- a/rules.js
+++ b/rules.js
@@ -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) {