summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-02-01 21:39:35 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 13:02:39 +0100
commit6fc4d02d7d171b90e880468fc5e51072e4e4a346 (patch)
tree06f5295429104b74e0b69270c5cbba9a6ab44242 /rules.js
parentee193334e466bb4b62bcec03e7cc5b0a7b264876 (diff)
downloadnevsky-6fc4d02d7d171b90e880468fc5e51072e4e4a346.tar.gz
Manual strikes.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js54
1 files changed, 33 insertions, 21 deletions
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) ===