diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-06-24 10:07:53 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-07-07 18:39:37 +0200 |
commit | d48c9df15e61ba802de3e7032b81516dab28928b (patch) | |
tree | c287587d178ad5c6d6bdb0338f8eb03e1d2b792d /rules.js | |
parent | caebd7f985f5c15ad7231a4f230542c4421a44b2 (diff) | |
download | time-of-crisis-d48c9df15e61ba802de3e7032b81516dab28928b.tar.gz |
spend_foo() and spend_bar()
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 48 |
1 files changed, 28 insertions, 20 deletions
@@ -782,8 +782,16 @@ function has_available_governor() { return false } -function spend_ip(type, n) { - game.ip[type] -= n +function spend_military(n) { + game.ip[MILITARY] -= n +} + +function spend_senate(n) { + game.ip[SENATE] -= n +} + +function spend_populace(n) { + game.ip[POPULACE] -= n } function can_place_governor(where) { @@ -1836,14 +1844,14 @@ states.take_actions = { recruit_governor() { push_undo() log("Recruited Governor " + (game.selected_governor % 6) + ".") - spend_ip(SENATE, game.selected_governor % 6) + spend_senate(game.selected_governor % 6) set_governor_location(game.selected_governor, AVAILABLE) }, recruit_general() { push_undo() log("Recruited General " + (game.selected_general % 6) + ".") - spend_ip(MILITARY, game.selected_general % 6) + spend_military(game.selected_general % 6) set_general_location(game.selected_general, AVAILABLE) }, @@ -1860,7 +1868,7 @@ states.take_actions = { place_militia() { push_undo() let where = get_governor_location(game.selected_governor) - spend_ip(POPULACE, 2) + spend_populace(2) add_militia(where) }, @@ -1868,13 +1876,13 @@ states.take_actions = { push_undo() let where = get_governor_location(game.selected_governor) log("Held Games in %" + where + ".") - spend_ip(POPULACE, 2) + spend_populace(2) set_mobs(where, get_mobs(where) - 1) }, amphitheater() { push_undo() - spend_ip(POPULACE, get_improvement_cost()) + spend_populace(get_improvement_cost()) let where = get_governor_location(game.selected_governor) add_amphitheater(where) log("Built Amphitheater in %" + where + ".") @@ -1882,7 +1890,7 @@ states.take_actions = { basilica() { push_undo() - spend_ip(POPULACE, get_improvement_cost()) + spend_populace(get_improvement_cost()) let where = get_governor_location(game.selected_governor) add_basilica(where) log("Built Basilica in %" + where + ".") @@ -1890,7 +1898,7 @@ states.take_actions = { limes() { push_undo() - spend_ip(POPULACE, get_improvement_cost()) + spend_populace(get_improvement_cost()) let where = get_governor_location(game.selected_governor) add_limes(where) log("Built Limes in %" + where + ".") @@ -1900,14 +1908,14 @@ states.take_actions = { push_undo() log("Added Legion to Army.") let cost = count_legions_in_army(game.selected_general) + 1 - spend_ip(MILITARY, cost) + spend_military(cost) set_legion_location(find_unused_legion(), ARMY + game.selected_general) }, train_legions() { push_undo() log("Trained Legions.") - spend_ip(MILITARY, 1) + spend_military(1) set_legion_full_strength(find_reduced_legion_in_army(game.selected_general)) }, @@ -1938,7 +1946,7 @@ states.take_actions = { region(where) { push_undo() if (game.selected_governor >= 0) { - spend_ip(SENATE, 1) + spend_senate(1) game.count = 1 game.where = where game.state = "place_governor" @@ -2090,7 +2098,7 @@ function improve_support() { let where = get_governor_location(game.selected_governor) let support = get_support(where) log("Built Support in %" + where + ".") - spend_ip(POPULACE, support + 1) + spend_populace(support + 1) set_support(where, support + 1) } @@ -2099,7 +2107,7 @@ function improve_support() { function recall_governor() { let where = get_governor_location(game.selected_governor) log("Recalled Governor from %" + where + ".") - spend_ip(SENATE, 2) + spend_senate(2) set_placed_governor(where) remove_governor(where) } @@ -2214,7 +2222,7 @@ states.place_governor = { }, spend_senate() { push_undo() - spend_ip(SENATE, 1) + spend_senate(1) game.count += 1 }, roll() { @@ -2240,7 +2248,7 @@ states.praetorian_guard = { }, spend_military() { push_undo() - spend_ip(MILITARY, 1) + spend_military(1) game.count += 1 }, roll() { @@ -2367,7 +2375,7 @@ function can_play_praetorian_guard() { } function play_praetorian_guard() { - spend_ip(MILITARY, 1) + spend_military(1) game.count = 0 game.where = ITALIA game.state = "praetorian_guard" @@ -2384,7 +2392,7 @@ function gen_create_army() { } function create_army(where) { - spend_ip(MILITARY, 1) + spend_military(1) log("Created Army in %" + where + ".") set_general_location(game.selected_general, where) if (can_enter_capital(where)) @@ -2434,7 +2442,7 @@ function move_army_to(who, to) { remove_general_castra(who) - spend_ip(MILITARY, 1) + spend_military(1) set_general_location(who, to) if (is_sea(to)) @@ -2808,7 +2816,7 @@ function goto_battle_vs_militia(where, attacker) { } function goto_battle(type, where, attacker, target) { - spend_ip(MILITARY, 1) + spend_military(1) game.where = where game.battle = { type, attacker, target, flanking: 0, killed: 0 } game.state = "battle" |