summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js184
1 files changed, 92 insertions, 92 deletions
diff --git a/rules.js b/rules.js
index ab3bade..fb7e342 100644
--- a/rules.js
+++ b/rules.js
@@ -163,7 +163,7 @@ function remove_from_array(array, item) {
array.splice(i, 1)
}
-function gen_action_undo(view) {
+function gen_action_undo() {
if (!view.actions)
view.actions = {}
if (game.undo && game.undo.length > 0)
@@ -172,13 +172,13 @@ function gen_action_undo(view) {
view.actions.undo = 0
}
-function gen_action_pass(view, text) {
+function gen_action_pass(text) {
if (!view.actions)
view.actions = {}
- view.actions["pass"] = text
+ view.actions.pass = text
}
-function gen_action(view, action, argument) {
+function gen_action(action, argument) {
if (!view.actions)
view.actions = {}
if (argument !== undefined) {
@@ -190,16 +190,16 @@ function gen_action(view, action, argument) {
}
}
-function gen_action_battle(view, action, b) {
- gen_action(view, action, b)
+function gen_action_battle(action, b) {
+ gen_action(action, b)
}
-function gen_action_block(view, b) {
- gen_action(view, "block", b)
+function gen_action_block(b) {
+ gen_action("block", b)
}
-function gen_action_space(view, s) {
- gen_action(view, "space", s)
+function gen_action_space(s) {
+ gen_action("space", s)
}
function edge_id(A, B) {
@@ -842,7 +842,7 @@ function validate_free_deployment() {
}
}
-function format_deployment_error(view) {
+function format_deployment_error() {
view.prompt = "Free Deployment: " + game.setup_error.join(", ")
}
@@ -850,16 +850,16 @@ states.free_deployment = {
prompt(current) {
if (is_inactive_player(current))
return (view.prompt = "Waiting for " + game.active + " to redeploy blocks...")
- gen_action_undo(view)
+ gen_action_undo()
if (game.setup_error.length === 0) {
view.prompt = "Free Deployment: You may rearrange blocks on the map."
- gen_action_pass(view, "End deployment")
+ gen_action_pass("End deployment")
} else {
- format_deployment_error(view)
+ format_deployment_error()
}
for (let b = 0; b < block_count; ++b)
if (block_owner(b) === game.active && is_map_space(game.location[b]))
- gen_action_block(view, b)
+ gen_action_block(b)
},
block(who) {
push_undo()
@@ -888,18 +888,18 @@ states.free_deployment_to = {
if (game.setup_error.length === 0) {
view.prompt = "Free Deployment: You may rearrange blocks on the map."
} else {
- format_deployment_error(view)
+ format_deployment_error()
}
- gen_action_undo(view)
- gen_action_block(view, game.who)
+ gen_action_undo()
+ gen_action_block(game.who)
for (let space = first_map_space; space < space_count; ++space) {
if (game.setup_limit[space] > 0 && space !== game.location[game.who]) {
if (!is_enemy_city(space)) {
if (block_type(game.who) === "navis") {
if (is_port(space))
- gen_action_space(view, space)
+ gen_action_space(space)
} else {
- gen_action_space(view, space)
+ gen_action_space(space)
}
}
}
@@ -953,13 +953,13 @@ states.discard_and_play_card = {
if (!game.c_discard) {
view.prompt = "Discard a card."
for (let c of game.c_hand)
- gen_action(view, "card", c)
+ gen_action("card", c)
} else if (!game.c_card) {
view.prompt = "Play a card."
for (let c of game.c_hand)
if (c !== APOLLO)
- gen_action(view, "card", c)
- gen_action(view, "undo")
+ gen_action("card", c)
+ gen_action("undo")
} else {
view.prompt = "Waiting for Pompeius..."
}
@@ -967,13 +967,13 @@ states.discard_and_play_card = {
if (!game.p_discard) {
view.prompt = "Discard a card."
for (let c of game.p_hand)
- gen_action(view, "card", c)
+ gen_action("card", c)
} else if (!game.p_card) {
view.prompt = "Play a card."
for (let c of game.p_hand)
if (c !== APOLLO)
- gen_action(view, "card", c)
- gen_action(view, "undo")
+ gen_action("card", c)
+ gen_action("undo")
} else {
view.prompt = "Waiting for Caesar..."
}
@@ -1078,7 +1078,7 @@ states.play_card = {
view.prior_c_card = game.prior_c_card
view.prompt = "Play a card."
for (let c of game.c_hand)
- gen_action(view, "card", c)
+ gen_action("card", c)
}
}
if (current === POMPEIUS) {
@@ -1089,7 +1089,7 @@ states.play_card = {
view.prior_p_card = game.prior_p_card
view.prompt = "Play a card."
for (let c of game.p_hand)
- gen_action(view, "card", c)
+ gen_action("card", c)
}
}
},
@@ -1260,10 +1260,10 @@ states.jupiter = {
if (is_friendly_city(s)) {
for (let to of SPACES[s].exits)
if (is_enemy_city(to) || is_contested_city(to))
- gen_action_space(view, to)
+ gen_action_space(to)
}
}
- gen_action_pass(view, "Pass")
+ gen_action_pass("Pass")
},
space(where) {
/* pick a random block */
@@ -1287,7 +1287,7 @@ states.jupiter_to = {
let from = game.location[game.who]
for (let to of SPACES[from].exits)
if (is_friendly_city(to))
- gen_action_space(view, to)
+ gen_action_space(to)
},
space(to) {
log(block_name(game.who) + " joined " + game.active + ":")
@@ -1305,7 +1305,7 @@ states.vulcan = {
view.prompt = "Vulcan: Choose an enemy city to suffer a volcanic eruption."
for (let s = first_map_space; s < space_count; ++s)
if (is_enemy_city(s))
- gen_action_space(view, s)
+ gen_action_space(s)
},
space(city) {
log("Vulcan struck #" + city + "!")
@@ -1330,7 +1330,7 @@ states.apply_vulcan = {
return (view.prompt = "Waiting for " + game.active + "...")
view.prompt = "Apply Vulcan hits in " + space_name(game.where) + "."
for (let i = 0; i < game.vulcan.length; ++i)
- gen_action_block(view, game.vulcan[i])
+ gen_action_block(game.vulcan[i])
},
block(who) {
reduce_block(who)
@@ -1370,7 +1370,7 @@ states.mars_and_neptune = {
return (view.prompt = god + ": Waiting for " + game.active + ".")
view.prompt = god + "Select battle for surprise attack."
for (let space of game.surprise_list)
- gen_action_space(view, space)
+ gen_action_space(space)
},
space(where) {
game.surprise = where
@@ -1431,7 +1431,7 @@ states.move_who = {
let from = game.location[b]
if (game.activated.includes(from))
if (can_block_move(b))
- gen_action_block(view, b)
+ gen_action_block(b)
}
} else {
let have_amphibious = false
@@ -1444,13 +1444,13 @@ states.move_who = {
if (can_block_move(b))
can_move = true
if (can_move)
- gen_action_block(view, b)
+ gen_action_block(b)
}
if (!have_amphibious)
game.amphibious_available = false
}
- gen_action_pass(view, "End movement phase")
- gen_action_undo(view)
+ gen_action_pass("End movement phase")
+ gen_action_undo()
},
block(who) {
push_undo()
@@ -1480,10 +1480,10 @@ states.move_where = {
if (can_block_move_to(game.who, to))
can_move_to = true
if (can_move_to)
- gen_action_space(view, to)
+ gen_action_space(to)
}
- gen_action_block(view, game.who) // for canceling move
- gen_action_undo(view)
+ gen_action_block(game.who) // for canceling move
+ gen_action_undo()
},
space(to) {
let from = game.location[game.who]
@@ -1533,9 +1533,9 @@ states.move_where_2 = {
let from = game.location[game.who]
for (let to of SPACES[from].exits)
if (to !== game.last_from && can_block_continue_to(game.who, to))
- gen_action_space(view, to)
- gen_action_space(view, from) // For ending move early.
- gen_action_undo(view)
+ gen_action_space(to)
+ gen_action_space(from) // For ending move early.
+ gen_action_undo()
},
space(to) {
let from = game.location[game.who]
@@ -1559,8 +1559,8 @@ states.amphibious_move_to = {
let from = game.location[game.who]
for (let to of SPACES[from].exits)
if (to !== game.last_from && can_amphibious_move_to(game.who, from, to))
- gen_action_space(view, to)
- gen_action_undo(view)
+ gen_action_space(to)
+ gen_action_undo()
},
space(to) {
let from = game.location[game.who]
@@ -1588,8 +1588,8 @@ states.mercury_move_1 = {
let from = game.location[game.who]
for (let to of SPACES[from].exits)
if (can_block_move_to(game.who, to))
- gen_action_space(view, to)
- gen_action_undo(view)
+ gen_action_space(to)
+ gen_action_undo()
},
space(to) {
let from = game.location[game.who]
@@ -1619,9 +1619,9 @@ states.mercury_move_2 = {
let from = game.location[game.who]
for (let to of SPACES[from].exits)
if (to !== game.last_from && can_block_move_to(game.who, to))
- gen_action_space(view, to)
- gen_action_space(view, from) // For ending move early.
- gen_action_undo(view)
+ gen_action_space(to)
+ gen_action_space(from) // For ending move early.
+ gen_action_undo()
},
space(to) {
let from = game.location[game.who]
@@ -1654,9 +1654,9 @@ states.mercury_move_3 = {
let from = game.location[game.who]
for (let to of SPACES[from].exits)
if (to !== game.last_from && can_block_continue_to(game.who, to))
- gen_action_space(view, to)
- gen_action_space(view, from) // For ending move early.
- gen_action_undo(view)
+ gen_action_space(to)
+ gen_action_space(from) // For ending move early.
+ gen_action_undo()
},
space(to) {
let from = game.location[game.who]
@@ -1696,14 +1696,14 @@ states.levy = {
if (game.levies > 0) {
for (let b = 0; b < block_count; ++b) {
if (can_levy(b)) {
- gen_action_block(view, b)
+ gen_action_block(b)
is_levy_possible = true
}
}
}
if (!is_levy_possible)
- gen_action_pass(view, "End levy phase")
- gen_action_undo(view)
+ gen_action_pass("End levy phase")
+ gen_action_undo()
},
block(who) {
push_undo()
@@ -1738,9 +1738,9 @@ states.levy_where = {
view.prompt = "Choose a friendly city to levy " + block_name(game.who) + " in."
for (let s = first_map_space; s < space_count; ++s)
if (can_levy_to(game.who, s))
- gen_action_space(view, s)
- gen_action_block(view, game.who) // for canceling levy
- gen_action_undo(view)
+ gen_action_space(s)
+ gen_action_block(game.who) // for canceling levy
+ gen_action_undo()
},
space(to) {
log_levy(to)
@@ -1784,7 +1784,7 @@ states.pick_battle = {
view.prompt = "Choose the next battle to fight!"
for (let s = first_map_space; s < space_count; ++s)
if (is_contested_city(s) || is_contested_sea(s))
- gen_action_space(view, s)
+ gen_action_space(s)
},
space(where) {
game.where = where
@@ -1883,8 +1883,8 @@ states.disrupt_reserves = {
return (view.prompt = "Waiting for " + game.active + " to apply disruption hits...")
view.prompt = "Apply disruption hits to reserves."
for (let b of game.disrupted) {
- gen_action_battle(view, "battle_hit", b)
- gen_action_block(view, b)
+ gen_action_battle("battle_hit", b)
+ gen_action_block(b)
}
},
block: disrupt_block,
@@ -2158,15 +2158,15 @@ states.battle_round = {
view.prompt = "Retreat with an army."
for (let b of game.battle_list) {
if (can_fire)
- gen_action_battle(view, "battle_fire", b)
+ gen_action_battle("battle_fire", b)
if (must_retreat || (can_retreat && can_retreat_with_block(b)))
- gen_action_battle(view, "battle_retreat", b)
+ gen_action_battle("battle_retreat", b)
if (can_pass)
- gen_action_battle(view, "battle_pass", b)
- gen_action_block(view, b)
+ gen_action_battle("battle_pass", b)
+ gen_action_block(b)
}
if (game.hits > 0)
- gen_action(view, "assign")
+ gen_action("assign")
},
assign() {
game.active = enemy(game.active)
@@ -2263,8 +2263,8 @@ states.battle_hits = {
return (view.prompt = "Waiting for " + game.active + " to apply hits...")
view.prompt = "Assign " + game.hits + (game.hits !== 1 ? " hits" : " hit") + " to your armies."
for (let b of game.battle_list) {
- gen_action_battle(view, "battle_hit", b)
- gen_action_block(view, b)
+ gen_action_battle("battle_hit", b)
+ gen_action_block(b)
}
},
block(who) {
@@ -2285,14 +2285,14 @@ states.retreat = {
for (let to of SPACES[from].exits) {
if (block_owner(game.who) === get_attacker(from)) {
if (can_attacker_retreat_to(game.who, from, to))
- gen_action_space(view, to)
+ gen_action_space(to)
} else {
if (can_defender_retreat_to(game.who, from, to))
- gen_action_space(view, to)
+ gen_action_space(to)
}
}
- gen_action(view, "undo")
- gen_action_block(view, game.who)
+ gen_action("undo")
+ gen_action_block(game.who)
},
space(to) {
let from = game.location[game.who]
@@ -2327,9 +2327,9 @@ states.sea_retreat = {
let from = game.location[game.who]
for (let to of SPACES[from].exits) {
if (is_friendly_city(to))
- gen_action_space(view, to)
+ gen_action_space(to)
}
- gen_action(view, "undo")
+ gen_action("undo")
},
space(to) {
clear_undo()
@@ -2362,11 +2362,11 @@ states.regroup = {
for (let b = 0; b < block_count; ++b) {
if (game.location[b] === game.where) {
if (can_regroup(b))
- gen_action_block(view, b)
+ gen_action_block(b)
}
}
- gen_action_pass(view, "End regroup")
- gen_action_undo(view)
+ gen_action_pass("End regroup")
+ gen_action_undo()
},
block(who) {
push_undo()
@@ -2390,10 +2390,10 @@ states.regroup_to = {
let from = game.location[game.who]
for (let to of SPACES[from].exits) {
if (can_regroup_to(game.who, from, to))
- gen_action_space(view, to)
+ gen_action_space(to)
}
- gen_action_block(view, game.who) // for canceling move
- gen_action_undo(view)
+ gen_action_block(game.who) // for canceling move
+ gen_action_undo()
},
space(to) {
let from = game.location[game.who]
@@ -2504,7 +2504,7 @@ states.navis_to_port = {
if (block_owner(b) === game.active && BLOCKS[b].type === "navis") {
if (SPACES[game.location[b]].type === "sea") {
if (can_navis_move_to_port(b)) {
- gen_action_block(view, b)
+ gen_action_block(b)
++count
}
}
@@ -2513,8 +2513,8 @@ states.navis_to_port = {
if (count > 0)
view.prompt += " " + count + " left."
if (count === 0)
- gen_action_pass(view, "End navis to port")
- gen_action_undo(view)
+ gen_action_pass("End navis to port")
+ gen_action_undo()
},
block(who) {
push_undo()
@@ -2536,10 +2536,10 @@ states.navis_to_port_where = {
let from = game.location[game.who]
for (let to of SPACES[from].exits) {
if (is_friendly_city(to))
- gen_action_space(view, to)
+ gen_action_space(to)
}
- gen_action_block(view, game.who) // for canceling move
- gen_action_undo(view)
+ gen_action_block(game.who) // for canceling move
+ gen_action_undo()
},
space(to) {
let from = game.location[game.who]
@@ -2568,7 +2568,7 @@ states.disband = {
if (block_owner(b) === game.active && is_map_space(game.location[b]) && b !== B_CLEOPATRA) {
if (is_over_supply_limit(game.location[b])) {
okay_to_end = false
- gen_action_block(view, b)
+ gen_action_block(b)
}
}
}
@@ -2580,11 +2580,11 @@ states.disband = {
for (let b = 0; b < block_count; ++b) {
if (is_map_space(game.location[b]))
if (block_owner(b) === game.active && b !== B_CLEOPATRA)
- gen_action_block(view, b)
+ gen_action_block(b)
}
- gen_action_pass(view, "End disbanding")
+ gen_action_pass("End disbanding")
}
- gen_action_undo(view)
+ gen_action_undo()
},
block(who) {
push_undo()