summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js139
1 files changed, 80 insertions, 59 deletions
diff --git a/rules.js b/rules.js
index a92d550..9a3d6c8 100644
--- a/rules.js
+++ b/rules.js
@@ -6,55 +6,9 @@
TODO
----
--- castra/quaestor - directly or extra select target step?
-
-[x] crisis ira deorum
-[x] crisis barbarians
[ ] crisis pax deorum
-
-[x] tribute
-[x] foederati
-[x] mobs
-
-[x] disperse mob
-
-[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 battle screen - splay stack / dialog for watching contents and taking hits
-[x] quaestor
- [x] place
- [x] remove at start
- [x] remove when replaced
-
-[x] castra
- [x] place
- [x] remove at start
- [x] remove when move/attack
- [x] move militia to general at end of turn
- [x] remove when retreat
-
-[x] support check
-[x] gain legacy
-
-[x] end turn
- [x] grow mobs
- [x] flip barbarians
-
-[x] praetorian guard
-[ ] damnatio memoriae
-[x] pretender
- [x] place
- [ ] expand
- [x] scoring effects
- [x] occupation effects
-
-[x] game end
-
[ ] rival emperors
[ ] emperor turns
[ ] combat
@@ -419,8 +373,8 @@ const PLAY_CARD_EVENT = {
"Foederati": play_foederati,
"Mob": play_mob,
"Praetorian Guard": play_praetorian_guard,
- // "Damnatio Memoriae": play_damnatio_memoriae,
- // "Damnatio Memoriae (exp)": play_damnatio_memoriae_exp,
+ "Damnatio Memoriae": play_damnatio_memoriae,
+ "Damnatio Memoriae (exp)": play_damnatio_memoriae_exp,
"Pretender": play_pretender,
}
@@ -428,12 +382,12 @@ const CAN_PLAY_CARD_EVENT = {
"Castra": can_play_castra,
"Tribute": can_play_tribute,
"Quaestor": can_play_quaestor,
- // "Flanking Maneuver": can_play_flanking_maneuver,
+ "Flanking Maneuver": null,
"Foederati": can_play_foederati,
"Mob": can_play_mob,
"Praetorian Guard": can_play_praetorian_guard,
- // "Damnatio Memoriae": can_play_damnatio_memoriae,
- // "Damnatio Memoriae (exp)": can_play_damnatio_memoriae_exp,
+ "Damnatio Memoriae": null,
+ "Damnatio Memoriae (exp)": null,
"Pretender": can_play_pretender,
}
@@ -1063,6 +1017,19 @@ function is_expand_pretender_province(from) {
return false
}
+function gen_card_event(event) {
+ for (let c = event[0]; c <= event[1]; ++c)
+ if (set_has(game.played, c) && !set_has(game.used, c))
+ gen_action_card(c)
+}
+
+function has_card_event(event) {
+ for (let c = event[0]; c <= event[1]; ++c)
+ if (set_has(game.played, c) && !set_has(game.used, c))
+ return true
+ return false
+}
+
// === SETUP ===
states.setup_province = {
@@ -1993,14 +1960,73 @@ function roll_to_place_governor(pg) {
if (have >= need) {
logi("Success!")
+ if (game.where === ITALIA) {
+ // Remember for Damnatio Memoriae
+ let old_emperor = get_province_player(ITALIA)
+ if (old_emperor >= 0)
+ game.count = (old_emperor << 3) | get_support(ITALIA)
+ else
+ game.count = 0
+ }
place_governor(game.where, game.selected_governor)
} else {
logi("Failed!")
}
+ if (has_card_event(CARD_S4) || has_card_event(CARD_S4B))
+ game.state = "damnatio_memoriae"
+ else
+ game.state = "take_actions"
+}
+
+// ACTION: DAMNATIO MEMORIAE
+
+states.damnatio_memoriae = {
+ prompt() {
+ prompt("Place Governor: You may play Damnatio Memoriae!")
+ gen_card_event(CARD_S4)
+ gen_card_event(CARD_S4B)
+ },
+ card(c) {
+ push_undo()
+ log(card_name(c))
+ set_add(game.used, c)
+ play_card_event(c)
+ },
+ pass() {
+ push_undo()
+ game.state = "take_actions"
+ },
+}
+
+function play_damnatio_memoriae() {
+ award_legacy(game.count >> 3, "Damnatio Memoriae", -get_support(ITALIA))
+ game.state = "damnatio_memoriae_mobs"
+ game.count = game.count & 7
+}
+
+function play_damnatio_memoriae_exp() {
+ award_legacy(game.count >> 3, "Damnatio Memoriae", -get_support(ITALIA))
game.state = "take_actions"
}
+states.damnatio_memoriae_mobs = {
+ prompt() {
+ prompt("Damnatio Memoriae: Place " + game.count + " Mobs provinces you govern.")
+ view.color = SENATE
+ for (let where = 0; where < 12; ++where)
+ if (is_own_province(where) && game.mobs[where] < 6)
+ gen_action_region(where)
+ },
+ region(where) {
+ push_undo()
+ log("Added Mob to S" + where)
+ add_one_mob(where)
+ if (--game.count === 0)
+ game.state = "take_actions"
+ },
+}
+
// ACTION: PRAETORIAN GUARD
function has_unused_praetorian_guard() {
@@ -2420,12 +2446,6 @@ function gen_initiate_battle(where) {
}
}
-function gen_card_event(event) {
- for (let c of event)
- if (set_has(game.played, c) && !set_has(game.used, c))
- gen_action_card(c)
-}
-
states.battle = {
prompt() {
prompt("Battle!")
@@ -2434,6 +2454,7 @@ states.battle = {
view.actions.roll = 1
},
card(c) {
+ log(card_name(c))
set_add(game.used, c)
play_card_event(c)
},
@@ -2448,7 +2469,7 @@ states.battle = {
}
function format_hits() {
- return `${game.battle.ahits} attacking hits vs ${game.battle.dhits} defending hits`
+ return `${game.battle.ahits} hits to attacker vs ${game.battle.dhits} hits to defender`
}
states.flanking_maneuver = {
@@ -2806,7 +2827,7 @@ function award_legacy(p, reason, n) {
if (n > 0)
log(PLAYER_NAMES[p] + " gained " + n + " Legacy for " + reason + ".")
if (n < 0)
- log(PLAYER_NAMES[p] + " lost " + n + " Legacy for " + reason + ".")
+ log(PLAYER_NAMES[p] + " lost " + (-n) + " Legacy for " + reason + ".")
game.legacy[p] += n
}