summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js123
1 files changed, 86 insertions, 37 deletions
diff --git a/rules.js b/rules.js
index 15b79ab..a92d550 100644
--- a/rules.js
+++ b/rules.js
@@ -6,8 +6,6 @@
TODO
----
-game.battle -> game.battle / game.count + game.where
-
-- castra/quaestor - directly or extra select target step?
[x] crisis ira deorum
@@ -53,7 +51,7 @@ game.battle -> game.battle / game.count + game.where
[x] place
[ ] expand
[x] scoring effects
- [ ] occupation effects
+ [x] occupation effects
[x] game end
@@ -415,27 +413,27 @@ function card_event_name(c) {
const PLAY_CARD_EVENT = {
"Castra": play_castra,
- // "Flanking Maneuver": play_flanking_maneuver,
- "Praetorian Guard": play_praetorian_guard,
"Tribute": play_tribute,
+ "Quaestor": play_quaestor,
+ "Flanking Maneuver": play_flanking_maneuver,
"Foederati": play_foederati,
+ "Mob": play_mob,
+ "Praetorian Guard": play_praetorian_guard,
// "Damnatio Memoriae": play_damnatio_memoriae,
// "Damnatio Memoriae (exp)": play_damnatio_memoriae_exp,
- "Quaestor": play_quaestor,
- "Mob": play_mob,
"Pretender": play_pretender,
}
const CAN_PLAY_CARD_EVENT = {
"Castra": can_play_castra,
- // "Flanking Maneuver": can_play_flanking_maneuver,
- "Praetorian Guard": can_play_praetorian_guard,
"Tribute": can_play_tribute,
+ "Quaestor": can_play_quaestor,
+ // "Flanking Maneuver": can_play_flanking_maneuver,
"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,
- "Quaestor": can_play_quaestor,
- "Mob": can_play_mob,
"Pretender": can_play_pretender,
}
@@ -1070,6 +1068,9 @@ function is_expand_pretender_province(from) {
states.setup_province = {
prompt() {
view.prompt = "Select a starting Province."
+ view.selected_governor = game.current * 6
+ view.selected_general = game.current * 6
+ view.color = SENATE
for (let where = 2; where <= 12; ++where)
if (is_neutral_province(where) && !is_no_place_governor(where))
gen_action("capital", where)
@@ -1555,6 +1556,7 @@ states.take_actions = {
game.selected_governor = -1
game.selected_general = id
} else {
+ push_undo()
goto_battle_vs_general(get_general_location(game.selected_general), game.selected_general, id)
}
},
@@ -2210,12 +2212,14 @@ function can_foederati_from_region_and_adjacent(from) {
function can_play_foederati() {
let where = get_selected_region()
- if (game.selected_general >= 0)
- if (can_foederati_from_region_and_adjacent(where))
- return true
- if (game.selected_governor >= 0)
- if (has_lone_militia(where) && can_foederati_from_region_and_adjacent(where))
- return true
+ if (is_region(where)) {
+ if (game.selected_general >= 0)
+ if (can_foederati_from_region_and_adjacent(where))
+ return true
+ if (game.selected_governor >= 0)
+ if (has_lone_militia(where) && can_foederati_from_region_and_adjacent(where))
+ return true
+ }
return false
}
@@ -2351,6 +2355,10 @@ states.pretender_breakaway = {
// === COMBAT ===
+function play_flanking_maneuver() {
+ game.battle.flanking = 1
+}
+
function goto_battle_vs_general(where, attacker, target) {
log("Initiate Battle vs " + GENERAL_NAME[target] + " in S" + where)
goto_battle("general", where, attacker, target)
@@ -2375,7 +2383,7 @@ function goto_battle_vs_militia(where, attacker) {
function goto_battle(type, where, attacker, target) {
spend_ip(MILITARY, 1)
game.where = where
- game.battle = { type, attacker, target }
+ game.battle = { type, attacker, target, flanking: 0 }
game.state = "battle"
if (attacker >= 0) {
if (is_general_inside_capital(attacker))
@@ -2412,34 +2420,75 @@ 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!")
- // TODO: play "Flanking Maneuver"
+ if (!game.battle.flanking)
+ gen_card_event(CARD_M3)
view.actions.roll = 1
},
+ card(c) {
+ set_add(game.used, c)
+ play_card_event(c)
+ },
roll() {
// clear_undo()
+ roll_combat_dice()
+ if (game.battle.flanking)
+ game.state = "flanking_maneuver"
+ else
+ goto_assign_hits()
+ },
+}
- game.battle.dhits = roll_attacker_dice()
- game.battle.dtaken = 0
-
- if (game.battle.type === "militia" && has_militia_castra(game.where)) {
- log("Castra reduces 1 hit")
- if (game.battle.dhits > 0)
- game.battle.dhits -= 1
- }
- if (game.battle.type === "general" && has_general_castra(game.battle.target)) {
- log("Castra reduces 1 hit")
- if (game.battle.dhits > 0)
- game.battle.dhits -= 1
- }
-
- game.battle.ahits = roll_defender_dice()
- game.battle.ataken = 0
+function format_hits() {
+ return `${game.battle.ahits} attacking hits vs ${game.battle.dhits} defending hits`
+}
+states.flanking_maneuver = {
+ prompt() {
+ prompt("Flanking Maneuver: " + format_hits() + ".")
+ view.actions.reroll = 1
+ view.actions.pass = 1
+ },
+ pass() {
goto_assign_hits()
},
+ reroll() {
+ roll_flanking_maneuver_dice()
+ goto_assign_hits()
+ },
+}
+
+function roll_combat_dice() {
+ game.battle.dhits = roll_attacker_dice()
+ game.battle.dtaken = 0
+
+ if (game.battle.type === "militia" && has_militia_castra(game.where)) {
+ log("Castra reduces 1 hit")
+ if (game.battle.dhits > 0)
+ game.battle.dhits -= 1
+ }
+ if (game.battle.type === "general" && has_general_castra(game.battle.target)) {
+ log("Castra reduces 1 hit")
+ if (game.battle.dhits > 0)
+ game.battle.dhits -= 1
+ }
+
+ game.battle.ahits = roll_defender_dice()
+ game.battle.ataken = 0
+}
+
+function roll_flanking_maneuver_dice() {
+ log("Flanking Maneuver Reroll")
+ game.battle.ahits = roll_defender_dice()
+ game.battle.ataken = 0
}
function roll_general_dice(general) {
@@ -2659,7 +2708,7 @@ function goto_assign_hits_on_defender() {
states.assign_hits_on_attacker = {
prompt() {
- prompt("Assign " + (game.battle.ahits - game.battle.ataken) + " hits to attacker!")
+ prompt("Combat: " + format_hits() + " \u2013 assign " + (game.battle.ahits - game.battle.ataken) + " hits to attacker!")
if (game.battle.attacker < 0)
gen_hits_militia()
else
@@ -2684,7 +2733,7 @@ states.assign_hits_on_attacker = {
states.assign_hits_on_defender = {
prompt() {
- prompt("Assign " + (game.battle.dhits - game.battle.dtaken) + " hits to defender!")
+ prompt("Combat: " + format_hits() + " \u2013 assign " + (game.battle.dhits - game.battle.dtaken) + " hits to defender!")
switch (game.battle.type) {
case "militia":
gen_hits_militia()