summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js64
1 files changed, 38 insertions, 26 deletions
diff --git a/rules.js b/rules.js
index bbc4923..410cb39 100644
--- a/rules.js
+++ b/rules.js
@@ -20,14 +20,13 @@ game.battle -> game.battle / game.count + game.where
[x] disperse mob
-[ ] combat victory
-[ ] combat remove general if army is eliminated
-[ ] combat battle screen - splay stack / dialog for watching contents and taking hits
-[ ] combat retreat out of capital
-[ ] combat retreat barbarians to homeland
-[ ] combat advance into capital
+[x] combat victory
+[x] combat remove general if army is eliminated
+[x] combat retreat out of capital
+[x] combat retreat barbarians to homeland
+[x] combat advance into capital
[ ] combat flanking maneuver
-[ ] combat - select both inactive/active barbarian for hits
+[ ] combat battle screen - splay stack / dialog for watching contents and taking hits
[x] quaestor
[x] place
@@ -39,7 +38,7 @@ game.battle -> game.battle / game.count + game.where
[x] remove at start
[x] remove when move/attack
[ ] move militia to general at end of turn
- [ ] remove when retreat
+ [x] remove when retreat
[x] support check
@@ -924,6 +923,12 @@ function eliminate_barbarian(id) {
set_barbarian_inactive(id)
}
+function eliminate_militia(where) {
+ remove_militia(where)
+ clear_militia_battled(where)
+ remove_militia_castra(where)
+}
+
function flip_discard_to_available() {
game.draw[game.current] = game.discard[game.current]
game.discard[game.current] = []
@@ -1027,8 +1032,6 @@ function goto_upkeep() {
// === CRISIS ===
-// TODO: manual barbarian invasions!
-
function goto_crisis() {
game.dice[0] = roll_die()
game.dice[1] = roll_die()
@@ -1391,7 +1394,18 @@ states.take_actions = {
end_actions() {
push_undo()
- // TODO: move militia castra to castra with stacked general
+
+ // If a castra is on lone militia, but general is now in the space, move it to the general.
+ for (let where = 0; where < 12; ++where) {
+ if (is_own_province(where) && has_militia_castra(where)) {
+ let id = get_capital_general(where)
+ if (is_own_general(id)) {
+ remove_militia_castra(where)
+ add_general_castra(id)
+ }
+ }
+ }
+
game.selected_governor = -1
game.selected_general = -1
goto_support_check()
@@ -1551,17 +1565,17 @@ states.take_actions = {
barbarian(id) {
push_undo()
- goto_battle_vs_barbarian(get_general_location(game.selected_general), game.selected_general, id)
+ goto_battle_vs_barbarian(get_selected_region(), game.selected_general, id)
},
rival_emperor(id) {
push_undo()
- goto_battle_vs_rival_emperor(get_general_location(game.selected_general), game.selected_general, id)
+ goto_battle_vs_rival_emperor(get_selected_region(), game.selected_general, id)
},
militia(where) {
push_undo()
- goto_battle_vs_militia(get_general_location(game.selected_general), game.selected_general)
+ goto_battle_vs_militia(get_selected_region(), game.selected_general)
},
}
@@ -1618,10 +1632,8 @@ function increase_support(where) {
function remove_governor(where) {
log("Removed Governor from S" + where)
+ eliminate_militia(where)
remove_all_mobs(where)
- remove_militia(where)
- clear_militia_battled(where)
- remove_militia_castra(where)
remove_quaestor(where)
let old_governor = get_province_governor(where)
@@ -1638,10 +1650,8 @@ function remove_governor(where) {
}
function place_governor(where, new_governor) {
+ eliminate_militia(where)
remove_all_mobs(where)
- remove_militia(where)
- clear_militia_battled(where)
- remove_militia_castra(where)
remove_quaestor(where)
let old_governor = get_province_governor(where)
@@ -2048,8 +2058,9 @@ function goto_battle_vs_general(where, attacker, target) {
}
function goto_battle_vs_barbarian(where, attacker, target) {
- log("Initiate Battle vs " + BARBARIAN_NAME[target] + " in S" + where)
- goto_battle("barbarians", where, attacker, get_barbarian_tribe(target))
+ let tribe = get_barbarian_tribe(target)
+ log("Initiate Battle vs " + BARBARIAN_NAME[tribe] + " in S" + where)
+ goto_battle("barbarians", where, attacker, tribe)
}
function goto_battle_vs_rival_emperor(where, attacker, target) {
@@ -2068,9 +2079,12 @@ function goto_battle(type, where, attacker, target) {
game.battle = { type, attacker, target }
game.state = "battle"
if (attacker >= 0) {
+ if (is_general_inside_capital(attacker))
+ remove_militia_castra(where)
remove_general_castra(attacker)
set_general_battled(attacker)
} else {
+ remove_militia_castra(where)
set_militia_battled(where)
}
}
@@ -2354,8 +2368,7 @@ states.assign_hits_on_attacker = {
},
militia(where) {
game.battle.ataken += 1
- remove_militia(where)
- clear_militia_battled(where)
+ eliminate_militia(where)
goto_assign_hits_on_attacker()
},
legion(id) {
@@ -2390,8 +2403,7 @@ states.assign_hits_on_defender = {
},
militia(where) {
game.battle.dtaken += 1
- remove_militia(where)
- clear_militia_battled(where)
+ eliminate_militia(where)
goto_assign_hits_on_defender()
},
legion(id) {