summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-09-26 13:21:08 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-17 13:11:27 +0100
commit8f81eefde0abdd1dac0649ff53c1100b07cb3387 (patch)
treec422e06600582627be0741ef730470994904f2dd
parent60885bfbf9590c41d669b64fe64e7db5dade7d85 (diff)
downloadrommel-in-the-desert-8f81eefde0abdd1dac0649ff53c1100b07cb3387.tar.gz
Track fortress recapture and cancel bonus supply.
-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) {