summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-05-07 20:08:25 +0200
committerTor Andersson <tor@ccxvii.net>2023-05-24 21:06:18 +0200
commit19be33a825a75f6912ac242055d244e1817f3cf7 (patch)
tree6c9fa34afc0c7b6249e95c26594fcc4605bb0077
parentbe19735002ca0a9b488acad6cbc3e6391cb9347d (diff)
downloadred-flag-over-paris-19be33a825a75f6912ac242055d244e1817f3cf7.tar.gz
Place (removed) cubes with event.
-rw-r--r--events.txt3
-rw-r--r--rules.js25
2 files changed, 16 insertions, 12 deletions
diff --git a/events.txt b/events.txt
index 6ffdc66..dd2076d 100644
--- a/events.txt
+++ b/events.txt
@@ -285,10 +285,9 @@ CARD 48 - Revolution in the Press
endswitch
CARD 49 - Pius IX
- prompt "Replace in 2 differet Political or remove 1 from any space."
+ prompt "Replace in 2 different Political or remove 1 from any space."
switch ["replace","remove"]
case "replace"
- # SPECIAL
replace_different 2 POLITICAL
case "remove"
remove 1 ANY
diff --git a/rules.js b/rules.js
index 93a3c6e..036684d 100644
--- a/rules.js
+++ b/rules.js
@@ -678,8 +678,8 @@ function can_replace_cube_in_any(list) {
return false
}
-function can_place_cube(s) {
- return find_available_cube() >= 0 && count_friendly_cubes(s) < 4
+function can_place_cube(s, removed=0) {
+ return find_available_cube(removed) >= 0 && count_friendly_cubes(s) < 4
}
function can_place_disc(s) {
@@ -719,8 +719,8 @@ function move_piece(p, s) {
game.pieces[p] = s
}
-function place_cube(s) {
- game.pieces[find_available_cube()] = s
+function place_cube(s, removed=0) {
+ game.pieces[find_available_cube(removed)] = s
}
function place_disc(s) {
@@ -733,9 +733,14 @@ function replace_cube(p) {
place_cube(s)
}
-function find_available_cube() {
+function find_available_cube(removed=0) {
let p = -1
if (game.active === COMMUNE) {
+ if (removed) {
+ p = find_commune_cube(OUT_OF_PLAY)
+ if (p >= 0)
+ return p
+ }
for (let i = 0; i < 3; ++i) {
p = find_commune_cube(RED_CUBE_POOL[i])
if (p >= 0)
@@ -2299,13 +2304,13 @@ states.vm_decrease_prussian_collaboration = {
function can_vm_place() {
for (let s of game.vm.spaces)
- if (can_place_cube(s))
+ if (can_place_cube(s, game.vm.removed))
return true
return false
}
function goto_vm_place() {
- if (can_vm_place())
+ if (can_vm_place(game.vm.removed))
game.state = "vm_place"
else
vm_next()
@@ -2322,8 +2327,8 @@ states.vm_place = {
},
space(s) {
push_undo()
- place_cube(s)
- if (--game.vm.count === 0 || !can_vm_place())
+ place_cube(s, game.vm.removed)
+ if (--game.vm.count === 0 || !can_vm_place(game.vm.removed))
vm_next()
},
skip() {
@@ -3248,7 +3253,7 @@ CODE[48] = [ // Revolution in the Press
]
CODE[49] = [ // Pius IX
- [ vm_prompt, "Replace in 2 differet Political or remove 1 from any space." ],
+ [ vm_prompt, "Replace in 2 different Political or remove 1 from any space." ],
[ vm_switch, ["replace","remove"] ],
[ vm_case, "replace" ],
[ vm_replace_different, 2, POLITICAL ],