summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-06-24 21:15:54 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-07 18:39:37 +0200
commitef64999e69e54f5477e46439a1be626f9b870679 (patch)
treec0d9187f2cd396178d0a80a2f73951d5ee57ee87 /rules.js
parentc88979589d322a2549109049b51759ab88927533 (diff)
downloadtime-of-crisis-ef64999e69e54f5477e46439a1be626f9b870679.tar.gz
Inactive prompts.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js178
1 files changed, 90 insertions, 88 deletions
diff --git a/rules.js b/rules.js
index 476db80..f79edd0 100644
--- a/rules.js
+++ b/rules.js
@@ -351,28 +351,28 @@ const CARD_INDEX = [
]
const CARD_INFO = [
- { name: "M1", type: 0, value: 1, event: null },
- { name: "S1", type: 1, value: 1, event: null },
- { name: "P1", type: 2, value: 1, event: null },
- { name: "M2", type: 0, value: 2, event: "Castra" },
- { name: "S2", type: 1, value: 2, event: "Tribute" },
- { name: "P2", type: 2, value: 2, event: "Quaestor" },
- { name: "M2X", type: 0, value: 2, event: "Cavalry" },
- { name: "S2X", type: 1, value: 2, event: "Princeps Senatus" },
- { name: "P2X", type: 2, value: 2, event: "Ambitus" },
- { name: "M3", type: 0, value: 3, event: "Flanking Maneuver" },
- { name: "S3", type: 1, value: 3, event: "Foederati" },
- { name: "P3", type: 2, value: 3, event: "Mob" },
- { name: "M3X", type: 0, value: 3, event: "Force March" },
- { name: "S3X", type: 1, value: 3, event: "Frumentarii" },
- { name: "P3X", type: 2, value: 3, event: "Mobile Vulgus" },
- { name: "M4", type: 0, value: 4, event: "Praetorian Guard" },
- { name: "S4", type: 1, value: 4, event: "Damnatio Memoriae" },
- { name: "S4B", type: 1, value: 4, event: "Damnatio Memoriae (exp)" },
- { name: "P4", type: 2, value: 4, event: "Pretender" },
- { name: "M4X", type: 0, value: 4, event: "Spiculum" },
- { name: "S4X", type: 1, value: 4, event: "Triumph" },
- { name: "P4X", type: 2, value: 4, event: "Demagogue" },
+ { name: "M1", type: 0, value: 1, event: "None" },
+ { name: "S1", type: 1, value: 1, event: "None" },
+ { name: "P1", type: 2, value: 1, event: "None" },
+ { name: "M2 - Castra", type: 0, value: 2, event: "Castra" },
+ { name: "S2 - Tribute", type: 1, value: 2, event: "Tribute" },
+ { name: "P2 - Quaestor", type: 2, value: 2, event: "Quaestor" },
+ { name: "M2 - Cavalry", type: 0, value: 2, event: "Cavalry" },
+ { name: "S2 - Princeps Senatus", type: 1, value: 2, event: "Princeps Senatus" },
+ { name: "P2 - Ambitus", type: 2, value: 2, event: "Ambitus" },
+ { name: "M3 - Flanking Maneuver", type: 0, value: 3, event: "Flanking Maneuver" },
+ { name: "S3 - Foederati", type: 1, value: 3, event: "Foederati" },
+ { name: "P3 - Mob", type: 2, value: 3, event: "Mob" },
+ { name: "M3 - Force March", type: 0, value: 3, event: "Force March" },
+ { name: "S3 - Frumentarii", type: 1, value: 3, event: "Frumentarii" },
+ { name: "P3 - Mobile Vulgus", type: 2, value: 3, event: "Mobile Vulgus" },
+ { name: "M4 - Praetorian Guard", type: 0, value: 4, event: "Praetorian Guard" },
+ { name: "S4 - Damnatio Memoriae", type: 1, value: 4, event: "Damnatio Memoriae" },
+ { name: "S4 - Damnatio Memoriae", type: 1, value: 4, event: "Damnatio Memoriae (exp)" },
+ { name: "P4 - Pretender", type: 2, value: 4, event: "Pretender" },
+ { name: "M4 - Spiculum", type: 0, value: 4, event: "Spiculum" },
+ { name: "S4 - Triumph", type: 1, value: 4, event: "Triumph" },
+ { name: "P4 - Demagogue", type: 2, value: 4, event: "Demagogue" },
]
function card_name(c) {
@@ -1114,6 +1114,7 @@ function has_card_event(event) {
// === SETUP ===
states.setup_province = {
+ inactive: "Setup",
prompt() {
view.prompt = "Setup: Choose a province to place your governor and general."
view.selected_governor = game.current * 6
@@ -1141,6 +1142,7 @@ states.setup_province = {
}
states.setup_hand = {
+ inactive: "Setup",
prompt() {
view.prompt = "Setup: Draw cards."
let hand = current_hand()
@@ -1248,6 +1250,7 @@ function goto_ira_deorum() {
}
states.ira_deorum = {
+ inactive: "Ira Deorum",
prompt() {
prompt("Ira Deorum: Activate one barbarian in each tribe's homeland.")
let tribe_count = get_tribe_count()
@@ -1283,6 +1286,7 @@ function resume_pax_deorum() {
}
states.pax_deorum = {
+ inactive: "Pax Deorum",
prompt() {
prompt("Pax Deorum: Draw one card.")
for (let c of game.draw[game.current])
@@ -1297,6 +1301,7 @@ states.pax_deorum = {
}
states.pax_deorum_done = {
+ inactive: "Pax Deorum",
prompt() {
prompt("Pax Deorum: Done.")
view.actions.done = 1
@@ -1322,6 +1327,7 @@ function goto_barbarian_crisis(tribe) {
}
states.barbarian_crisis = {
+ get inactive() { return BARBARIAN_NAME[game.crisis] },
prompt() {
let tribe = game.crisis
prompt(BARBARIAN_NAME[tribe] + ": Activate one barbarian.")
@@ -1371,6 +1377,7 @@ function goto_barbarian_invasion(tribe, black) {
}
states.barbarian_invasion = {
+ get inactive() { return BARBARIAN_NAME[game.crisis] },
prompt() {
let tribe = game.crisis
prompt(BARBARIAN_NAME[tribe] + " invade!")
@@ -1473,6 +1480,7 @@ function goto_crisis_barbarian_leader(id, where) {
}
states.crisis_barbarian_leader = {
+ get inactive() { return EVENT_NAME[game.active_event] },
prompt() {
prompt(EVENT_NAME[game.active_event] + ": Place barbarian leader.")
gen_action_region(game.where)
@@ -1493,6 +1501,7 @@ function goto_crisis_rival_emperor(id, where) {
}
states.crisis_rival_emperor = {
+ get inactive() { return EVENT_NAME[game.active_event] },
prompt() {
prompt(EVENT_NAME[game.active_event] + ": Place rival emperor in " + REGION_NAME[game.where] + ".")
gen_action_region(game.where)
@@ -1524,6 +1533,7 @@ function resume_palmyra_allies() {
}
states.palmyra_allies = {
+ inactive: "Palmyra Allies",
prompt() {
prompt("Palmyra Allies: Remove " + game.count + " active Sassanids.")
let id, where
@@ -1571,6 +1581,7 @@ function goto_ludi_saeculares() {
}
states.ludi_saeculares = {
+ inactive: "Ludi Saeculares",
prompt() {
prompt("Ludi Saeculares: Discard a card to gain legacy equal to twice its value.")
for (let c of current_hand())
@@ -1587,6 +1598,7 @@ states.ludi_saeculares = {
}
states.ludi_saeculares_done = {
+ inactive: "Ludi Saeculares",
prompt() {
prompt("Ludi Saeculares: Done.")
view.actions.done = 1
@@ -1614,21 +1626,25 @@ function goto_take_actions() {
}
states.take_actions = {
+ get inactive() {
+ let [ mip, sip, pip ] = game.ip
+ return `Take Actions \u2013 ${mip} military, ${sip} senate, ${pip} populace`
+ },
prompt() {
let [ mip, sip, pip ] = game.ip
+ let hand = current_hand()
- prompt(`Take Actions: ${mip} Military, ${sip} Senate, ${pip} Populace.`)
+ prompt(`Take Actions: ${mip} military, ${sip} senate, ${pip} populace.`)
let where = UNAVAILABLE
- // XXX
- if (game.selected_governor < 0 && game.selected_general < 0 && current_hand().length > 0 && mip + sip + pip === 0)
+ if (game.selected_governor < 0 && game.selected_general < 0 && hand.length > 0 && mip + sip + pip === 0)
view.actions.play_all = 1
view.actions.end_actions = 1
// Play cards for IP
- for (let c of current_hand())
+ for (let c of hand)
gen_action_card(c)
// Use events on played cards
@@ -1720,24 +1736,14 @@ states.take_actions = {
// Place Governor
if (game.selected_governor >= 0 && where === AVAILABLE) {
- if (sip >= 1) {
- view.prompt += " Choose a province to Place Governor."
+ if (sip >= 1)
gen_place_governor()
- }
- //view.actions.place_governor = 1
- //else
- //view.actions.place_governor = 0
}
// Create Army
if (game.selected_general >= 0 && where === AVAILABLE) {
- if (mip >= 1 && find_unused_legion() >= 0) {
- view.prompt += " Choose a province to Create Army."
+ if (mip >= 1 && find_unused_legion() >= 0)
gen_create_army()
- }
- //view.actions.create_army = 1
- //else
- //view.actions.create_army = 0
}
// Governor Actions
@@ -1765,7 +1771,6 @@ states.take_actions = {
// Hold Games
if (get_mobs(where)) {
- view.actions.hold_games = 0
if (pip >= 2)
view.actions.hold_games = 1
}
@@ -1913,18 +1918,6 @@ states.take_actions = {
recall_governor()
},
- place_governor() {
- push_undo()
- spend_senate(1)
- game.count = 1
- game.state = "place_governor_where"
- },
-
- create_army() {
- push_undo()
- game.state = "create_army"
- },
-
support() {
push_undo()
improve_support()
@@ -1954,7 +1947,7 @@ states.take_actions = {
add_legion_to_army() {
push_undo()
- log("Added Legion to Army.")
+ log("Add Legion to Army.")
let cost = count_legions_in_army(game.selected_general) + 1
spend_military(cost)
set_legion_location(find_unused_legion(), ARMY + game.selected_general)
@@ -2030,6 +2023,7 @@ states.take_actions = {
// ACTION: BUILD IMPROVEMENT
states.build_improvement = {
+ inactive: "Build Improvement",
prompt() {
prompt("Build Improvement in " + REGION_NAME[game.where] + ".")
view.color = POPULACE
@@ -2172,21 +2166,8 @@ function calc_needed_votes(where, pg) {
return Math.max(1, n)
}
-states.place_governor_where = {
- prompt() {
- prompt("Place Governor: Choose a province.")
- view.color = SENATE
- view.selected_governor = game.selected_governor
- gen_place_governor()
- },
- region(where) {
- push_undo()
- game.where = where
- game.state = "place_governor"
- },
-}
-
states.place_governor = {
+ inactive: "Place Governor",
prompt() {
let sip = game.ip[SENATE]
let need = calc_needed_votes(game.where, false)
@@ -2196,7 +2177,7 @@ states.place_governor = {
view.color = SENATE
view.selected_region = game.where
view.selected_governor = game.selected_governor
- prompt(`Place Governor: ${sip} Senate. Rolling ${votes} dice. ${need} votes needed.`)
+ prompt(`Place Governor: ${sip} senate. Rolling ${votes} dice. ${need} votes needed.`)
if (sip >= 1)
view.actions.spend_senate = 1
else
@@ -2215,6 +2196,7 @@ states.place_governor = {
}
states.praetorian_guard = {
+ inactive: "Praetorian Guard",
prompt() {
let mip = game.ip[MILITARY]
let need = calc_needed_votes(game.where, true)
@@ -2323,6 +2305,7 @@ function play_praetorian_guard() {
}
states.praetorian_guard_governor = {
+ inactive: "Praetorian Guard",
prompt() {
prompt("Praetorian Guard: Choose an available governor to place in Italia.")
for (let i = 0; i < 6; ++i) {
@@ -2340,6 +2323,7 @@ states.praetorian_guard_governor = {
}
states.praetorian_guard_italia = {
+ inactive: "Praetorian Guard",
prompt() {
prompt("Praetorian Guard: Place governor in Italia.")
view.color = MILITARY
@@ -2357,6 +2341,7 @@ states.praetorian_guard_italia = {
// CARD: DAMNATIO MEMORIAE
states.damnatio_memoriae = {
+ inactive: "Damnatio Memoriae",
prompt() {
prompt("Place Governor: You may play Damnatio Memoriae.")
gen_card_event(CARD_S4)
@@ -2387,6 +2372,7 @@ function play_damnatio_memoriae_exp() {
}
states.damnatio_memoriae_mobs = {
+ inactive: "Damnatio Memoriae",
prompt() {
prompt("Damnatio Memoriae: Place " + game.count + " mobs in provinces you govern.")
view.color = SENATE
@@ -2396,7 +2382,7 @@ states.damnatio_memoriae_mobs = {
},
region(where) {
push_undo()
- log("Added Mob in %" + where + ".")
+ logi("Mob in %" + where + ".")
set_mobs(where, get_mobs(where) + 1)
if (--game.count === 0)
game.state = "take_actions"
@@ -2422,20 +2408,6 @@ function create_army(where) {
set_legion_location(find_unused_legion(), ARMY + game.selected_general)
}
-states.create_army = {
- prompt() {
- prompt("Create Army: Choose a province you govern.")
- view.color = MILITARY
- view.selected_general = game.selected_general
- gen_create_army()
- },
- region(where) {
- push_undo()
- create_army(where)
- game.state = "take_actions"
- },
-}
-
// ACTION: MOVE ARMY
function gen_move_army() {
@@ -2454,6 +2426,7 @@ function gen_move_army() {
}
states.move_army_at_sea = {
+ inactive: "Move Army",
prompt() {
let mip = game.ip[MILITARY]
prompt("Move Army: " + mip + " Military.")
@@ -2521,8 +2494,9 @@ function resume_occupy_seat_of_power() {
}
states.occupy_seat_of_power_1 = {
+ inactive: "Occupation of a Pretender Provincial Capital",
prompt() {
- prompt("Occupy Pretender Provincial Capital: Remove seat of power marker and governor.")
+ prompt("Occupation of a Pretender Provincial Capital: Remove seat of power marker and governor.")
view.color = POPULACE
gen_action_region(game.where)
},
@@ -2536,8 +2510,9 @@ states.occupy_seat_of_power_1 = {
}
states.occupy_seat_of_power_2 = {
+ inactive: "Occupation of a Pretender Provincial Capital",
prompt() {
- prompt("Occupy Pretender Provincial Capital: Remove breakaway markers.")
+ prompt("Occupation of a Pretender Provincial Capital: Remove breakaway markers.")
view.color = POPULACE
for (let where = 1; where < 12; ++where)
if (is_breakaway(where) && (get_province_governor(where) / 6 | 0) === game.count)
@@ -2552,8 +2527,9 @@ states.occupy_seat_of_power_2 = {
}
states.occupy_breakaway = {
+ inactive: "Occupation of a Pretender Provincial Capital",
prompt() {
- prompt("Occupy Pretender Provincial Capital: Remove breakaway marker and governor.")
+ prompt("Occupation of a Pretender Provincial Capital: Remove breakaway marker and governor.")
view.color = POPULACE
gen_action_region(game.where)
},
@@ -2574,8 +2550,9 @@ function goto_replace_pretender() {
}
states.replace_pretender_governor = {
+ inactive: "Occupation of a Pretender Provincial Capital",
prompt() {
- prompt("Occupy Pretender Provincial Capital: You may place an available governor.")
+ prompt("Occupation of a Pretender Provincial Capital: You may place an available governor.")
view.selected_region = game.where
view.color = SENATE
for (let i = 0; i < 6; ++i) {
@@ -2617,6 +2594,7 @@ function play_castra() {
}
states.castra = {
+ inactive: "Castra",
prompt() {
prompt("Castra: Choose an army you command.")
for (let where = 0; where < 12; ++where)
@@ -2655,6 +2633,7 @@ function play_quaestor() {
}
states.quaestor = {
+ inactive: "Quaestor",
prompt() {
prompt("Quaestor: Choose a province you govern.")
view.color = POPULACE
@@ -2683,6 +2662,7 @@ function play_tribute() {
}
states.tribute = {
+ inactive: "Tribute",
prompt() {
prompt("Tribute: Flip a single tribe to their inactive side in any province.")
let tribe_count = get_tribe_count()
@@ -2760,6 +2740,7 @@ function play_foederati() {
}
states.foederati = {
+ inactive: "Foederati",
prompt() {
prompt("Foederati: Choose an army you command...")
for (let i = 0; i < 6; ++i) {
@@ -2785,6 +2766,7 @@ states.foederati = {
}
states.foederati_general = {
+ inactive: "Foederati",
prompt() {
if (count_legions_in_army(game.count) > count_barbarians_in_army(game.count))
prompt("Foederati: Recruit a barbarian.")
@@ -2809,6 +2791,7 @@ states.foederati_general = {
}
states.foederati_militia = {
+ inactive: "Foederati",
prompt() {
prompt("Foederati: Remove a barbarian.")
view.selected_militia = game.where
@@ -2839,6 +2822,7 @@ function play_mob() {
}
states.mob = {
+ inactive: "Mob",
prompt() {
prompt("Mob: Place a mob in a province with no mobs.")
view.color = POPULACE
@@ -2883,6 +2867,7 @@ function play_pretender() {
}
states.pretender_seat_of_power = {
+ inactive: "Pretender",
prompt() {
prompt("Pretender: Place your seat of power marker.")
view.color = POPULACE
@@ -2912,6 +2897,7 @@ function goto_pretender_breakaway() {
}
states.pretender_breakaway = {
+ inactive: "Pretender",
prompt() {
prompt("Pretender: Place breakaway markers.")
view.color = POPULACE
@@ -3009,6 +2995,7 @@ function format_battle_target() {
}
states.battle = {
+ inactive: "Combat",
prompt() {
prompt("Initiate Battle against " + format_battle_target() + " in " + REGION_NAME[game.where] + ".")
if (!game.battle.flanking && has_card_event(CARD_M3)) {
@@ -3038,6 +3025,7 @@ function format_hits() {
}
states.flanking_maneuver = {
+ inactive: "Flanking Maneuver",
prompt() {
prompt("Flanking Maneuver: " + format_hits() + ".")
view.actions.pass = 1
@@ -3313,6 +3301,7 @@ function goto_assign_hits_on_defender() {
}
states.assign_hits_on_attacker = {
+ inactive: "Combat",
prompt() {
prompt("Combat: " + format_hits() + " \u2013 assign " + (game.battle.ahits - game.battle.ataken) + " hits to attacker!")
if (game.battle.attacker < 0)
@@ -3341,6 +3330,7 @@ states.assign_hits_on_attacker = {
}
states.assign_hits_on_defender = {
+ inactive: "Combat",
prompt() {
prompt("Combat: " + format_hits() + " \u2013 assign " + (game.battle.dhits - game.battle.dtaken) + " hits to defender!")
switch (game.battle.type) {
@@ -3467,6 +3457,7 @@ function goto_combat_victory_attacker() {
}
states.advance_after_combat = {
+ inactive: "Combat",
prompt() {
prompt("Combat: You may advance into provincial capital.")
gen_action_capital(game.where)
@@ -3506,6 +3497,7 @@ function can_free_increase_support_level(where) {
}
states.free_increase_support_level = {
+ inactive: "Combat",
prompt() {
prompt("Combat: Increase support level or keep counter to reduce cost of card?")
view.color = POPULACE
@@ -3570,6 +3562,7 @@ function resume_support_check() {
}
states.support_check = {
+ inactive: "Support Check",
prompt() {
prompt("Support Check: Reduce support where active barbarians, rival emperors or opponent armies in capital.")
view.color = POPULACE
@@ -3596,6 +3589,7 @@ function goto_support_check_emperor() {
}
states.support_check_emperor = {
+ inactive: "Support Check",
prompt() {
prompt("Support Check: Reduce support in Italia for rival emperor and/or pretender on map.")
view.color = POPULACE
@@ -3620,6 +3614,7 @@ function goto_support_check_mobs() {
}
states.support_check_mobs = {
+ inactive: "Support Check",
prompt() {
prompt("Support Check: Remove governors where number of mobs exceed support.")
view.color = POPULACE
@@ -3647,6 +3642,7 @@ function goto_expand_pretender_empire() {
}
states.expand_pretender_empire = {
+ inactive: "Expand Pretender Empire",
prompt() {
prompt("Expand Pretender Empire: Add breakaway markers.")
view.color = POPULACE
@@ -3684,6 +3680,7 @@ function goto_legitimize_claim() {
}
states.legitimize_claim = {
+ inactive: "Gain Legacy",
prompt() {
prompt("Gain Legacy: Remove seat of power and breakaway markers in your provinces.")
for (let where = 1; where < 12; ++where)
@@ -3752,6 +3749,7 @@ function goto_buy_trash_cards() {
}
states.buy_trash_discard = {
+ inactive: "Buy/Trash Cards",
prompt() {
prompt("Buy/Trash Cards: You may discard any number of cards.")
for (let c of current_hand())
@@ -3807,6 +3805,7 @@ function spend_senate_card_bonus() {
}
states.buy_trash = {
+ inactive: "Buy/Trash Cards",
prompt() {
let military_bonus = has_military_card_bonus()
let senate_bonus = has_senate_card_bonus()
@@ -3897,6 +3896,7 @@ function goto_grow_mobs() {
}
states.grow_mobs = {
+ inactive: "End of Turn",
prompt() {
prompt("End of Turn: Add a mob in each province you govern with mob and no amphitheater.")
view.color = POPULACE
@@ -3924,6 +3924,7 @@ function goto_flip_inactive_barbarians() {
}
states.flip_inactive_barbarians = {
+ inactive: "End of Turn",
prompt() {
prompt("End of Turn: Flip all inactive barbarians in your provinces to their active side.")
view.color = POPULACE
@@ -3959,6 +3960,7 @@ function goto_refill_hand() {
}
states.refill_hand = {
+ inactive: "End of Turn",
prompt() {
prompt("End of Turn: Draw cards.")
let hand = current_hand()
@@ -4179,7 +4181,7 @@ exports.setup = function (seed, scenario, options) {
game.hand[player] = []
game.draw[player] = setup_player_deck(player)
game.discard[player] = []
- //for (let i = 0; i < 9; ++i) set_add(game.draw[player], game.market[i].pop())
+ //for (let i = 0; i < game.market.length; ++i) set_add(game.draw[player], game.market[i].pop())
}
update_neutral_italia()
@@ -4246,7 +4248,7 @@ exports.view = function (state, player_name) {
view.prompt = game.victory
} else if (game.current !== player) {
let inactive = states[game.state].inactive || game.state
- view.prompt = `Waiting for ${PLAYER_NAMES[game.current]} \u2014 ${inactive}...`
+ view.prompt = `Waiting for ${PLAYER_NAMES[game.current]}: ${inactive}.`
} else {
view.actions = {}
states[game.state].prompt()