summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js1
-rw-r--r--rules.js44
2 files changed, 21 insertions, 24 deletions
diff --git a/play.js b/play.js
index 3bc336f..5b97210 100644
--- a/play.js
+++ b/play.js
@@ -881,6 +881,7 @@ function on_update() {
document.getElementById("discard_panel").classList.add("hide")
ui.removed.replaceChildren()
+ console.log('view.strategy_removed', view.strategy_removed)
for (let c of view.strategy_removed)
ui.removed.appendChild(ui.cards[c])
diff --git a/rules.js b/rules.js
index 370eecb..2c6526c 100644
--- a/rules.js
+++ b/rules.js
@@ -280,7 +280,7 @@ exports.setup = function (seed, scenario, _options) {
vm: null,
vm_event: 0,
- played_card: 0,
+ //played_card: 0,
available_ops: 0,
vm_available_ops: 0,
valid_spaces: [],
@@ -1944,7 +1944,6 @@ states.general_strike = {
silent_discard(card)
game.available_ops = get_card_ops(card)
if (scoring_cards.includes(card)) {
- game.played_card = card
game.vm_event = card
log(`Played C${card} for the event.`)
game.return_state = 'end_round'
@@ -2169,9 +2168,7 @@ states.stasi_play_card = {
card(card) {
push_undo()
game.played_card = card
- let find_card
- find_card = game.democrat_hand.indexOf(card)
- game.democrat_hand.splice(find_card, 1)
+ remove_from_hand(card)
game.available_ops = get_card_ops(card)
if (game.democrat_hand.includes(C_COMMON_EUROPEAN_HOME) && cards[card].side === "C") {
@@ -3362,6 +3359,18 @@ function count_scoring_cards() {
function select_card(card) {
game.played_card = card
game.temp = 0
+ remove_from_hand(card)
+ game.state = 'play_card'
+}
+function finish_select_card() {
+ if (!scoring_cards.includes(game.played_card)) {
+ game.available_ops = get_card_ops(game.played_card)
+ if (game.state !== 'stasi_play_ceh')
+ log(`Played C${game.played_card}.`)
+ }
+}
+
+function remove_from_hand(card) {
let find_card
if (game.active === COM) {
find_card = game.communist_hand.indexOf(card)
@@ -3370,13 +3379,8 @@ function select_card(card) {
find_card = game.democrat_hand.indexOf(card)
game.democrat_hand.splice(find_card, 1)
}
- game.state = 'play_card'
-}
-function finish_select_card() {
- if (!scoring_cards.includes(game.played_card)) {
- game.available_ops = get_card_ops(game.played_card)
- if (game.state !== 'stasi_play_ceh')
- log(`Played C${game.played_card}.`)
+ if (!game.strategy_discard.includes(card)) {
+ game.strategy_discard.push(card)
}
}
@@ -3811,13 +3815,14 @@ function end_round() {
}
// Check if the card needs to be discarded.
+ /*
let discard_check = [...game.strategy_removed, ...game.persistent_events]
if (!discard_check.includes(game.played_card) && game.played_card > 0) {
game.strategy_discard.push(game.played_card)
- }
+ } */
// Reset
- game.played_card = 0
+ delete game.played_card
delete game.temp
delete game.vm_event
delete game.phase
@@ -4191,16 +4196,7 @@ function discard(card) {
function silent_discard(card) {
let find_card
if (!game.is_pwr_struggle) {
- if (game.active === COM) {
- find_card = game.communist_hand.indexOf(card)
- game.communist_hand.splice(find_card, 1)
- } else {
- find_card = game.democrat_hand.indexOf(card)
- game.democrat_hand.splice(find_card, 1)
- }
- if (!game.strategy_discard.includes(card)) {
- game.strategy_discard.push(card)
- }
+ remove_from_hand(card)
} else if (game.is_pwr_struggle) {
if (game.active === COM) {
find_card = game.com_pwr_hand.indexOf(card)