summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-07-09 14:23:47 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-09 14:24:17 +0200
commit20acf7157cbeb49d8a684313eb7de659603c84fe (patch)
tree5468b65684480499f52241b70d5959d9622fe084
parentb85a18d3e482e3d313c469411ad9668bdc51b683 (diff)
downloadtime-of-crisis-20acf7157cbeb49d8a684313eb7de659603c84fe.tar.gz
Lint.
-rw-r--r--rules.js88
1 files changed, 25 insertions, 63 deletions
diff --git a/rules.js b/rules.js
index 4d9d680..c601859 100644
--- a/rules.js
+++ b/rules.js
@@ -172,13 +172,6 @@ const SHAPUR_BONUS = 1 << 5
const RIVAL_EMPEROR_NAME = [ "Postumus", "Priest King", "Zenobia" ]
-const GENERAL_NAME = [
- "Red General", "Red General", "Red General", "Red General", "Red General", "Red General",
- "Blue General", "Blue General", "Blue General", "Blue General", "Blue General", "Blue General",
- "Yellow General", "Yellow General", "Yellow General", "Yellow General", "Yellow General", "Yellow General",
- "Green General", "Green General", "Green General", "Green General", "Green General", "Green General",
-]
-
const BARBARIAN_NAME = [
"Alamanni",
"Franks",
@@ -1414,7 +1407,6 @@ states.barbarian_crisis = {
gen_action_barbarian(find_inactive_barbarian_at_home(tribe))
},
barbarian(id) {
- let tribe = game.crisis[0]
set_barbarian_active(id)
roll_barbarian_crisis()
},
@@ -2345,13 +2337,13 @@ function count_units_in_capital(where) {
return n
}
-function calc_needed_votes(where, praetorian_guard) {
- let n = get_support(where) * 2 // base number of votes
- let old_governor = get_province_governor(where)
+function calc_needed_votes(praetorian_guard) {
+ let n = get_support(game.where) * 2 // base number of votes
+ let old_governor = get_province_governor(game.where)
let old_player = (old_governor < 0) ? -1 : (old_governor / 6 | 0)
// Praetorian Guard ignores units in capital
if (!praetorian_guard) {
- let army_general = get_capital_general(where)
+ let army_general = get_capital_general(game.where)
if (army_general >= 0) {
let army_player = army_general / 6 | 0
let army_size = count_units_in_army(army_general)
@@ -2360,7 +2352,7 @@ function calc_needed_votes(where, praetorian_guard) {
else if (army_player === game.current)
n -= army_size
}
- if (has_militia(where))
+ if (has_militia(game.where))
n += 1
}
@@ -2368,7 +2360,7 @@ function calc_needed_votes(where, praetorian_guard) {
return Math.max(1, n)
}
-function calc_extra_votes(where) {
+function calc_extra_votes() {
let n = game.ambitus
// Populace Emperor disadvantage votes
if (game.where === ITALIA && is_populace_emperor())
@@ -2376,7 +2368,7 @@ function calc_extra_votes(where) {
return n
}
-function calc_used_dice(where) {
+function calc_used_dice() {
let dice = game.count
if (game.where === ITALIA)
dice += count_own_basilicas()
@@ -2394,9 +2386,9 @@ function format_votes(need, extra, dice) {
states.place_governor = {
inactive: "Place Governor",
prompt() {
- let need = calc_needed_votes(game.where, false)
- let extra = calc_extra_votes(game.where)
- let dice = calc_used_dice(game.where)
+ let need = calc_needed_votes(false)
+ let extra = calc_extra_votes()
+ let dice = calc_used_dice()
view.color = SENATE
view.selected_region = game.where
view.selected_governor = game.selected_governor
@@ -2430,9 +2422,9 @@ states.place_governor = {
},
spend_enough() {
push_undo()
- let need = calc_needed_votes(game.where, false)
- let extra = calc_extra_votes(game.where)
- let dice = calc_used_dice(game.where)
+ let need = calc_needed_votes(false)
+ let extra = calc_extra_votes()
+ let dice = calc_used_dice()
let enough = Math.max(0, need - extra - dice)
spend_senate(enough)
game.count += enough
@@ -2447,9 +2439,9 @@ states.place_governor = {
states.praetorian_guard = {
inactive: "Praetorian Guard",
prompt() {
- let need = calc_needed_votes(game.where, true)
- let extra = calc_extra_votes(game.where)
- let dice = calc_used_dice(game.where)
+ let need = calc_needed_votes(true)
+ let extra = calc_extra_votes()
+ let dice = calc_used_dice()
view.color = MILITARY
view.selected_region = game.where
view.selected_governor = game.selected_governor
@@ -2483,9 +2475,9 @@ states.praetorian_guard = {
},
spend_enough() {
push_undo()
- let need = calc_needed_votes(game.where, true)
- let extra = calc_extra_votes(game.where)
- let dice = calc_used_dice(game.where)
+ let need = calc_needed_votes(true)
+ let extra = calc_extra_votes()
+ let dice = calc_used_dice()
let enough = Math.max(0, need - extra - dice)
spend_military(enough)
game.count += enough
@@ -2498,9 +2490,9 @@ states.praetorian_guard = {
}
function roll_to_place_governor(praetorian_guard) {
- let need = calc_needed_votes(game.where, praetorian_guard)
- let have = calc_extra_votes(game.where)
- let dice = calc_used_dice(game.where)
+ let need = calc_needed_votes(praetorian_guard)
+ let have = calc_extra_votes()
+ let dice = calc_used_dice()
set_placed_governor(game.where)
@@ -2542,9 +2534,8 @@ function roll_to_place_governor(praetorian_guard) {
}
function auto_replace_neutral_governor(praetorian_guard) {
- let need = calc_needed_votes(game.where, praetorian_guard)
- let have = calc_extra_votes(game.where)
- let dice = calc_used_dice(game.where)
+ let need = calc_needed_votes(praetorian_guard)
+ let dice = calc_used_dice()
log_br()
if (praetorian_guard)
@@ -2601,22 +2592,6 @@ function can_play_praetorian_guard() {
return false
}
-function play_praetorian_guard_auto() {
- game.selected_general = -1
- if (game.selected_governor < 0 || get_governor_location(game.selected_governor) !== AVAILABLE) {
- for (let i = 0; i < 6; ++i) {
- let id = game.current * 6 + i
- if (get_governor_location(id) === AVAILABLE)
- game.selected_governor = id
- }
- }
- spend_military(1)
- game.ambitus = 0
- game.count = 1
- game.where = ITALIA
- game.state = "praetorian_guard"
-}
-
function play_praetorian_guard() {
game.state = "praetorian_guard_governor"
}
@@ -2646,7 +2621,7 @@ states.praetorian_guard_italia = {
view.color = MILITARY
gen_action_region(ITALIA)
},
- region(where) {
+ region(_) {
push_undo()
spend_military(1)
game.count = 1
@@ -2728,10 +2703,6 @@ function is_military_emperor() {
return game.emperor >= ARMY
}
-function is_military_emperor_general(id) {
- return game.emperor === ARMY + id
-}
-
function is_province_of_populace_emperor(where) {
return is_populace_emperor() && (get_province_player(where) === get_province_player(ITALIA))
}
@@ -3534,7 +3505,6 @@ states.frumentarii = {
inactive: "Frumentarii",
prompt() {
prompt("Frumentarii: Draw 2 cards.")
- let hand = current_hand()
let draw = current_draw()
for (let c of draw)
gen_action_card(c)
@@ -4656,10 +4626,6 @@ function is_any_rival_emperor_or_pretender() {
return false
}
-function needs_any_support_check() {
- return needs_support_check() || needs_support_check_emperor() || needs_support_check_mobs()
-}
-
function needs_support_check() {
for (let where = 0; where < 12; ++where)
if ((game.count & (1 << where)) === 0)
@@ -5581,10 +5547,6 @@ function gen_action_capital(where) {
gen_action("capital", where)
}
-function gen_action_recall(where) {
- gen_action("recall", where)
-}
-
function gen_action_support(where, level) {
gen_action("support", where << 3 | level)
}