summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-06-20 14:36:26 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-07 18:39:37 +0200
commit375a82682680786d8ff6c10df14a6efc3c41ee62 (patch)
tree8c1514de716112b57483d7bd6a050ae76f78c6f6
parentdb5183be29b35d777fed31753c8a14bb3c29ba06 (diff)
downloadtime-of-crisis-375a82682680786d8ff6c10df14a6efc3c41ee62.tar.gz
More battles.
-rw-r--r--rules.js58
1 files changed, 40 insertions, 18 deletions
diff --git a/rules.js b/rules.js
index 3120fdb..d3d7456 100644
--- a/rules.js
+++ b/rules.js
@@ -830,6 +830,11 @@ states.setup_hand = {
function goto_start_turn() {
log_h2(PLAYER_NAMES[game.current])
+
+ game.battled = 0
+ game.mbattled = 0
+ game.placed = 0
+
goto_upkeep()
}
@@ -1029,13 +1034,11 @@ function action_take_actions_card(c) {
}
function action_take_actions_governor(id) {
- push_undo()
game.who = id
game.state = "take_actions_governor"
}
function action_take_actions_general(id) {
- push_undo()
game.who = id
game.state = "take_actions_general"
}
@@ -1323,6 +1326,7 @@ function remove_governor(where) {
log("Removed Governor from S" + where)
remove_all_mobs(where)
+ remove_militia(where)
let old_governor = get_province_governor(where)
if (old_governor >= 0) {
@@ -1339,6 +1343,7 @@ function remove_governor(where) {
function place_governor(where, new_governor) {
remove_all_mobs(where)
+ remove_militia(where)
let old_governor = get_province_governor(where)
if (old_governor >= 0) {
@@ -1717,39 +1722,56 @@ function gen_hits_militia() {
return false
}
+function gen_hits_barbarians(tribe) {
+ let prov = is_province(game.misc.where)
+ for (let id = first_barbarian[tribe]; id <= last_barbarian[tribe]; ++id)
+ if (get_barbarian_location(id) === game.misc.where)
+ if (prov || is_barbarian_active(id))
+ gen_action_barbarian(id)
+}
+
function gen_hits_general(general) {
let army = ARMY + general
+ let done = true
// TODO: castra
- if (is_general_inside_capital(general) && has_militia(game.misc.where)) {
- gen_action_militia(game.misc.where)
- return false
+ if (!done) {
+ if (is_general_inside_capital(general) && has_militia(game.misc.where)) {
+ gen_action_militia(game.misc.where)
+ done = true
+ }
}
- for (let id = 0; id < game.barbarians.length; ++id) {
- if (get_barbarian_location(id) === army) {
- gen_action_barbarian(id)
- return false
+ if (!done) {
+ for (let id = 0; id < game.barbarians.length; ++id) {
+ if (get_barbarian_location(id) === army) {
+ gen_action_barbarian(id)
+ done = true
+ }
}
}
// NOTE: reduce all legions before eliminating any
- for (let id = 0; id < 33; ++id) {
- if (get_legion_location(id) === army && !is_legion_reduced(id)) {
- gen_action_legion(id)
- return false
+ if (!done) {
+ for (let id = 0; id < 33; ++id) {
+ if (get_legion_location(id) === army && !is_legion_reduced(id)) {
+ gen_action_legion(id)
+ done = true
+ }
}
}
- for (let id = 0; id < 33; ++id) {
- if (get_legion_location(id) === army && is_legion_reduced(id)) {
- gen_action_legion(id)
- return false
+ if (!done) {
+ for (let id = 0; id < 33; ++id) {
+ if (get_legion_location(id) === army && is_legion_reduced(id)) {
+ gen_action_legion(id)
+ done = true
+ }
}
}
- return true
+ return done
}
states.assign_hits_on_attacker = {