summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-05-07 19:59:46 +0200
committerTor Andersson <tor@ccxvii.net>2023-05-24 21:06:18 +0200
commitbe19735002ca0a9b488acad6cbc3e6391cb9347d (patch)
treeb7659c638d7d3790a52e0602adc8be322148aafb
parent2b711de811295cdf79b8d8cb4b3be77faa41df15 (diff)
downloadred-flag-over-paris-be19735002ca0a9b488acad6cbc3e6391cb9347d.tar.gz
Remove dead code.
-rw-r--r--rules.js276
1 files changed, 7 insertions, 269 deletions
diff --git a/rules.js b/rules.js
index 1c58754..93a3c6e 100644
--- a/rules.js
+++ b/rules.js
@@ -1254,32 +1254,6 @@ function goto_operations(count, spaces) {
goto_operations_remove()
}
-function goto_final_crisis_discard(c, spaces) {
- log("Played C" + c + ".")
- game.state = "discard_final_crisis"
- game.count = 4
- game.spaces = spaces
-}
-
-states.discard_final_crisis = {
- inactive: "discard a card to play final crisis",
- prompt() {
- view.prompt = "Discard a card to play Final Crisis card for ops."
- let hand = player_hand()
- for (let c of hand)
- gen_action("card", c)
- },
- card(c) {
- push_undo()
- log(`Discarded C${c} to play Final Crisis card for ops.`)
- array_remove_item(player_hand(), c)
- game.discard = c
- goto_operations_remove()
- },
-}
-
-// OPERATIONS: REMOVE
-
function goto_operations_remove() {
update_presence_and_control()
if (can_operations_remove())
@@ -1418,8 +1392,6 @@ function resume_operations_remove() {
goto_operations_place()
}
-// OPERATIONS: PLACE
-
function goto_operations_place() {
update_presence_and_control()
if (can_operations_place())
@@ -1475,8 +1447,6 @@ function resume_operations_place() {
goto_operations_done()
}
-// OPERATIONS: DONE
-
function goto_operations_done() {
game.state = "operations_done"
}
@@ -2208,28 +2178,20 @@ function vm_may_place_disc() {
game.vm.count = 1
game.vm.spaces = vm_operand_spaces(1)
game.state = "vm_place_disc"
+ goto_vm_place_disc()
}
function vm_place_disc() {
game.vm.count = 1
game.vm.spaces = vm_operand_spaces(1)
- game.state = "vm_place_disc"
+ goto_vm_place_disc()
}
function vm_move_up_to() {
game.vm.count = vm_operand(1)
game.vm.a = vm_operand_spaces(2)
game.vm.b = vm_operand_spaces(3)
- game.who = -1
- game.state = "vm_move"
-}
-
-function vm_move_between_up_to() {
- game.vm.count = vm_operand(1)
- game.vm.a = vm_operand_spaces(2)
- game.vm.b = vm_operand_spaces(3)
- game.who = -1
- game.state = "vm_move_between"
+ goto_vm_move()
}
// === EVENT STATES ===
@@ -2402,7 +2364,7 @@ states.vm_move_disc = {
},
piece(p) {
push_undo()
- remove_disc(p)
+ remove_piece(p)
game.state = "vm_place_disc"
},
skip() {
@@ -2514,6 +2476,7 @@ function can_vm_move() {
}
function goto_vm_move() {
+ game.who = -1
if (can_vm_move())
game.state = "vm_move"
else
@@ -2551,45 +2514,6 @@ states.vm_move = {
},
}
-states.vm_move_between = {
- prompt() {
- event_prompt("Move up to " + game.vm.count + " cubes between spaces.")
- view.actions.skip = 1
- if (game.who < 0) {
- for (let s of game.vm.a)
- for_each_friendly_cube(s, gen_action_piece)
- for (let s of game.vm.b)
- for_each_friendly_cube(s, gen_action_piece)
- } else {
- game.selected_cube = game.who
- let from = game.pieces[game.who]
- if (game.vm.a.includes(from)) {
- for (let s of game.vm.b)
- if (count_friendly_cubes(s) < 4)
- gen_action_space(s)
- } else {
- for (let s of game.vm.a)
- if (count_friendly_cubes(s) < 4)
- gen_action_space(s)
- }
- }
- },
- piece(p) {
- push_undo()
- game.who = p
- },
- space(s) {
- move_piece(game.who, s)
- game.who = -1
- if (--game.vm.count === 0 || !can_vm_move())
- vm_next()
- },
- skip() {
- push_undo()
- vm_next()
- },
-}
-
// === COMPLICATED EVENT STATES ===
function can_play_freemason_parade() {
@@ -2798,7 +2722,7 @@ exports.resign = function (state, player) {
if (player === COMMUNE)
goto_game_over(VERSAILLES, "Commune resigned.");
if (player === VERSAILLES)
- goto_game_over(COMMON, "Versailles resigned.");
+ goto_game_over(COMMUNE, "Versailles resigned.");
}
return game
}
@@ -2826,7 +2750,7 @@ states.game_over = {
function gen_action(action, argument) {
if (!(action in view.actions))
view.actions[action] = []
- set_add(view.actions[action], argument)
+ view.actions[action].push(argument)
}
function gen_action_card(c) {
@@ -2906,14 +2830,6 @@ function random(range) {
return (game.seed = game.seed * 200105 % 34359738337) % range
}
-function random_bigint(range) {
- // Largest MLCG that will fit its state in a double.
- // Uses BigInt for arithmetic, so is an order of magnitude slower.
- // https://www.ams.org/journals/mcom/1999-68-225/S0025-5718-99-00996-5/S0025-5718-99-00996-5.pdf
- // m = 2**53 - 111
- return (game.seed = Number(BigInt(game.seed) * 5667072534355537n % 9007199254740881n)) % range
-}
-
function shuffle(list) {
// Fisher-Yates shuffle
for (let i = list.length - 1; i > 0; --i) {
@@ -2924,16 +2840,6 @@ function shuffle(list) {
}
}
-function shuffle_bigint(list) {
- // Fisher-Yates shuffle
- for (let i = list.length - 1; i > 0; --i) {
- let j = random_bigint(i + 1)
- let tmp = list[j]
- list[j] = list[i]
- list[i] = tmp
- }
-}
-
// Fast deep copy for objects without cycles
function object_copy(original) {
if (Array.isArray(original)) {
@@ -2976,174 +2882,6 @@ function array_remove(array, index) {
array.length = n - 1
}
-function array_insert(array, index, item) {
- for (let i = array.length; i > index; --i)
- array[i] = array[i - 1]
- array[index] = item
-}
-
-function array_remove_pair(array, index) {
- let n = array.length
- for (let i = index + 2; i < n; ++i)
- array[i - 2] = array[i]
- array.length = n - 2
-}
-
-function array_insert_pair(array, index, key, value) {
- for (let i = array.length; i > index; i -= 2) {
- array[i] = array[i-2]
- array[i+1] = array[i-1]
- }
- array[index] = key
- array[index+1] = value
-}
-
-// Set as plain sorted array
-
-function set_clear(set) {
- set.length = 0
-}
-
-function set_has(set, item) {
- let a = 0
- let b = set.length - 1
- while (a <= b) {
- let m = (a + b) >> 1
- let x = set[m]
- if (item < x)
- b = m - 1
- else if (item > x)
- a = m + 1
- else
- return true
- }
- return false
-}
-
-function set_add(set, item) {
- let a = 0
- let b = set.length - 1
- while (a <= b) {
- let m = (a + b) >> 1
- let x = set[m]
- if (item < x)
- b = m - 1
- else if (item > x)
- a = m + 1
- else
- return
- }
- array_insert(set, a, item)
-}
-
-function set_delete(set, item) {
- let a = 0
- let b = set.length - 1
- while (a <= b) {
- let m = (a + b) >> 1
- let x = set[m]
- if (item < x)
- b = m - 1
- else if (item > x)
- a = m + 1
- else {
- array_remove(set, m)
- return
- }
- }
-}
-
-function set_toggle(set, item) {
- let a = 0
- let b = set.length - 1
- while (a <= b) {
- let m = (a + b) >> 1
- let x = set[m]
- if (item < x)
- b = m - 1
- else if (item > x)
- a = m + 1
- else {
- array_remove(set, m)
- return
- }
- }
- array_insert(set, a, item)
-}
-
-// Map as plain sorted array of key/value pairs
-
-function map_clear(map) {
- map.length = 0
-}
-
-function map_has(map, key) {
- let a = 0
- let b = (map.length >> 1) - 1
- while (a <= b) {
- let m = (a + b) >> 1
- let x = map[m<<1]
- if (key < x)
- b = m - 1
- else if (key > x)
- a = m + 1
- else
- return true
- }
- return false
-}
-
-function map_get(map, key, missing) {
- let a = 0
- let b = (map.length >> 1) - 1
- while (a <= b) {
- let m = (a + b) >> 1
- let x = map[m<<1]
- if (key < x)
- b = m - 1
- else if (key > x)
- a = m + 1
- else
- return map[(m<<1)+1]
- }
- return missing
-}
-
-function map_set(map, key, value) {
- let a = 0
- let b = (map.length >> 1) - 1
- while (a <= b) {
- let m = (a + b) >> 1
- let x = map[m<<1]
- if (key < x)
- b = m - 1
- else if (key > x)
- a = m + 1
- else {
- map[(m<<1)+1] = value
- return
- }
- }
- array_insert_pair(map, a<<1, key, value)
-}
-
-function map_delete(map, item) {
- let a = 0
- let b = (map.length >> 1) - 1
- while (a <= b) {
- let m = (a + b) >> 1
- let x = map[m<<1]
- if (item < x)
- b = m - 1
- else if (item > x)
- a = m + 1
- else {
- array_remove_pair(map, m<<1)
- return
- }
- }
-}
-
// === GENERATED EVENT CODE ===
const CODE = []