summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--images/garrison_action.svg4
-rw-r--r--play.html4
-rw-r--r--play.js12
-rw-r--r--rules.js54
4 files changed, 53 insertions, 21 deletions
diff --git a/images/garrison_action.svg b/images/garrison_action.svg
new file mode 100644
index 0000000..f5af5b7
--- /dev/null
+++ b/images/garrison_action.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="333" height="80" viewBox="0 0 249.75 60" version="1.2">
+<path fill="white" fill-opacity="0.5" d="M11.342 1.5 4.3 10.622v36.487h14.09V10.62Zm227.058 0-7.049 9.122v36.487h14.098V10.62zM19.192 13.38v33.57h211.336V13.38Z"/>
+<path fill="none" stroke="white" stroke-width="2" d="M11.342 1.5 4.3 10.622v36.487h14.09V10.62Zm227.058 0-7.049 9.122v36.487h14.098V10.62zM19.192 46.95 h211.336M19.192 13.38 h211.336"/>
+</svg>
diff --git a/play.html b/play.html
index 82c9afb..1933de4 100644
--- a/play.html
+++ b/play.html
@@ -278,6 +278,10 @@ body.Teutons #plan_actions .russian { display: none }
margin: 0 auto;
}
+#garrison.action {
+ background-image: url(images/garrison_action.svg);
+}
+
#garrison.hide { display: none }
#garrison .unit { position: static }
diff --git a/play.js b/play.js
index ad5a7ba..c270365 100644
--- a/play.js
+++ b/play.js
@@ -321,6 +321,10 @@ function is_veche_action() {
return !!(view.actions && view.actions.veche === 1)
}
+function is_garrison_action() {
+ return !!(view.actions && view.actions.garrison === 1)
+}
+
function is_calendar_action(turn) {
return !!(view.actions && view.actions.calendar && set_has(view.actions.calendar, turn))
}
@@ -824,6 +828,11 @@ function on_click_array(evt) {
send_action('array', evt.target.my_id)
}
+function on_click_garrison(evt) {
+ if (evt.button === 0)
+ send_action('garrison')
+}
+
function on_blur(evt) {
document.getElementById("status").textContent = ""
}
@@ -1619,6 +1628,7 @@ function update_battle() {
}
ui.garrison.classList.toggle("hide", !view.battle.storm)
+ ui.garrison.classList.toggle("action", is_garrison_action())
ui.garrison.replaceChildren()
if (view.battle.garrison) {
@@ -2164,6 +2174,8 @@ function build_map() {
build_plan()
+ ui.garrison.addEventListener("mousedown", on_click_garrison)
+
for (let i = 0; i < 12; ++i) {
ui.battle_grid_array[i].my_id = i
ui.battle_grid_array[i].addEventListener("mousedown", on_click_array)
diff --git a/rules.js b/rules.js
index 5f1b48d..538126d 100644
--- a/rules.js
+++ b/rules.js
@@ -1,5 +1,7 @@
"use strict"
+// TODO: log end victory conditions at scenario start
+
// FIXME: lift_sieges / besieged needs checking! (automatic after disband_lord, manual after move/sail, extra careful manual after battle)
// FIXME: remove_legate_if_endangered needs checking! (automatic after disband_lord, manual after move/sail, manual after battle)
@@ -11,6 +13,7 @@
const data = require("./data.js")
const AUTOWALK = true
+const AUTOSTRIKE = false
const BOTH = "Both"
const TEUTONS = "Teutons"
@@ -8422,26 +8425,27 @@ states.assign_left_right = {
function goto_strike_group() {
game.state = "strike_group"
- // Auto-strike if only one group
- let first_striker = -1
- let first_target = -1
- let target
- for (let pos of current_strike_positions()) {
- if (has_strike(pos)) {
- if ((pos === SA1 || pos === SA2 || pos === SA3) && is_sa_without_rg())
- target = 100 // just a unique target id
- else
- target = find_strike_target(pos)
- if (first_target < 0) {
- first_striker = pos
- first_target = target
- } else if (first_target !== target) {
- return // more than one target!
+ if (AUTOSTRIKE) {
+ // Auto-strike if only one group
+ let first_striker = -1
+ let first_target = -1
+ let target
+ for (let pos of current_strike_positions()) {
+ if (has_strike(pos)) {
+ if ((pos === SA1 || pos === SA2 || pos === SA3) && is_sa_without_rg())
+ target = 100 // just a unique target id
+ else
+ target = find_strike_target(pos)
+ if (first_target < 0) {
+ first_striker = pos
+ first_target = target
+ } else if (first_target !== target) {
+ return // more than one target!
+ }
}
}
+ select_strike_group(first_striker)
}
-
- select_strike_group(first_striker)
}
function select_strike_group(pos) {
@@ -8462,14 +8466,22 @@ states.strike_group = {
return format_strike_step() + " \u2014 Strike"
},
prompt() {
- view.prompt = `${format_strike_step()}: Strike with a Lord.`
- for (let pos of current_strike_positions())
- if (has_strike(pos))
- gen_action_lord(game.battle.array[pos])
+ if (is_defender_step() && has_garrison() && !filled(D2)) {
+ view.prompt = `${format_strike_step()}: Strike with Garrison.`
+ view.actions.garrison = 1
+ } else {
+ view.prompt = `${format_strike_step()}: Strike with a Lord.`
+ for (let pos of current_strike_positions())
+ if (has_strike(pos))
+ gen_action_lord(game.battle.array[pos])
+ }
},
lord(lord) {
select_strike_group(get_lord_array_position(lord))
},
+ garrison() {
+ select_strike_group(-1)
+ },
}
// === BATTLE: TOTAL HITS (ROUND UP) ===