summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.css1
-rw-r--r--play.js16
-rw-r--r--rules.js64
3 files changed, 49 insertions, 32 deletions
diff --git a/play.css b/play.css
index f23699f..00c9cfe 100644
--- a/play.css
+++ b/play.css
@@ -341,6 +341,7 @@ body.p2 #Galatia_NPG { display: block }
.governor.unavailable.n5 { background-position: -250px 0 }
.castra, .quaestor, .mob, .mob_x2, .seat_of_power, .breakaway {
+ pointer-events: none;
width: 54px;
height: 64px;
background-size: 54px 64px;
diff --git a/play.js b/play.js
index e89ca36..7db4efb 100644
--- a/play.js
+++ b/play.js
@@ -934,6 +934,11 @@ function on_update() {
}
for (let region = 0; region < 12; ++region) {
+ if (has_militia_castra(region))
+ show(ui.mcastra[region])
+ else
+ hide(ui.mcastra[region])
+
if (has_militia(region)) {
let lone_militia = true
for (let pi = 0; pi < player_count; ++pi) {
@@ -945,14 +950,10 @@ function on_update() {
}
}
if (lone_militia) {
- let mcastra = has_militia_castra(region)
- if (mcastra) {
- show(ui.mcastra[region])
+ if (has_militia_castra(region))
layout_stack(-1, [ ui.mcastra[region], ui.militia[region] ], region, true, 16, 16)
- } else {
- hide(ui.mcastra[region])
+ else
layout_stack(-1, [ ui.militia[region] ], region, true, 16, 16)
- }
}
}
@@ -992,6 +993,9 @@ function on_update() {
hide(ui.castra[pi][ai])
}
+ if (has_militia_castra(region) && inside)
+ stack.push(ui.mcastra[region])
+
stack.push(e)
for (let i = 0; i < 33; ++i) {
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) {