summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-09-16 18:06:43 +0100
committeriainp5 <iain.pearce.ip@gmail.com>2024-09-16 18:06:43 +0100
commit7ea1405b1b485f0e63188ff59e7d61350cd71492 (patch)
tree3576824e5db6d151cf4a472913b59f2ee9523f50 /rules.js
parent898061b8c5324f3f974c9e086c96ff8a7db58357 (diff)
download1989-dawn-of-freedom-7ea1405b1b485f0e63188ff59e7d61350cd71492.tar.gz
Fix General Strike when scoring card played
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js92
1 files changed, 85 insertions, 7 deletions
diff --git a/rules.js b/rules.js
index 9c73551..4add39e 100644
--- a/rules.js
+++ b/rules.js
@@ -1672,7 +1672,7 @@ states.general_strike = {
for (let card of available_cards) {
gen_action_card(card)
}
- } else if (game.phase === 1) {
+ } else if (game.phase >= 1) {
view.prompt = 'General Strike: done.'
gen_action('done')
} else if (game.played_card > 0 ) {
@@ -1687,6 +1687,17 @@ states.general_strike = {
let find_card
find_card = game.communist_hand.indexOf(card);
game.communist_hand.splice(find_card, 1);
+
+ //Check if the discarded card is a scoring card
+ if (scoring_cards.includes(game.played_card)) {
+ log(`Played C${card}`)
+ game.return_state = 'general_strike'
+ game.phase = 1
+ goto_vm(card)
+ return
+ }
+
+ // Otherwise, set card ops for the roll
if (game.persistent_events['perestroika'] && game.active === COM) {
log('+1 op from C25')
game.available_ops = cards[card].ops +1
@@ -2573,18 +2584,85 @@ function retain_power(country){
function score_country(country) {
log_h3(`Scoring: ${country}`)
let status
+
+//Get scoring values
+ let value_presence = get_value(country)
+ let value_domination = value_presence*2
+ let value_control
+ if (country !== "Hungary") {
+ value_control = value_presence*3
+ } else {
+ value_control = 4
+ }
+
+//Check for presence
let presence = check_presence(country)
console.log('presence: ', presence)
- if (presence.dem_control) {status = "Democrat has control"}
- else if (presence.com_control) {status = "Communist has control"}
- else if (presence.dem_domination) {status = "Democrat has domination"}
- else if (presence.com_domination) {status = "Communist has domination"}
- else {status = "No domination or control"}
+ if (presence.dem_spaces > 0 ) {log(`Democrat has presence: gains ${value} VP`)}
+ if (presence.dem_spaces > 0 ) {log(`Democrat has presence: gains ${value} VP`)}
+
+//Check for domination or control
+ if (presence.dem_control || presence.dem_domination) {
+ if (presence.dem_control) {
+ log(`Democrat has control: gains ${value_control} VP`)
+ }
+ else {
+ log(`Democrat has domination: gains ${value_domination} VP`)
+ }
+ log(`And ${presence.dem_battlegrounds} battlegrounds: gains ${presence.dem_battlegrounds} VP`)
+ if (presence.com_spaces > 0) {
+ log(`Communist has presence: gains ${value_presence} VP`)
+ } else {
+ log('Communist has no presence')
+ }
+ if (presence.com_battlegrounds >0) {
+ log(`And ${presence.com_battlegrounds} battlegrounds: gains ${presence.com_battlegrounds} VP`)
+ }
+ }
+ else if (presence.com_control || presence.com_domination) {
+ if (presence.com_control) {
+ log(`Communist has control: gains ${value_control} VP`)
+ }
+ else {
+ log(`Communist has domination: gains ${value_domination} VP`)
+ }
+ log(`And ${presence.com_battlegrounds} battlegrounds: gains ${presence.com_battlegrounds} VP`)
+ if (presence.dem_spaces > 0) {
+ log(`Democrat has presence: gains ${value_presence} VP`)
+ } else {
+ log('Democrat has no presence')
+ }
+ if (presence.dem_battlegrounds > 0) {
+ log(`And ${presence.dem_battlegrounds} battlegrounds: gains ${presence.dem_battlegrounds} VP`)
+ }
+ }
+
+// Otherwise, score for battlegrounds
+ else {
+ log("No domination or control")
+ if (presence.com_spaces > 0) {
+ log(`Communist has presence: gains ${value_presence} VP`)
+ } else {
+ log('Communist has no presence')
+ }
+ if (presence.com_battlegrounds >0) {
+ log(`And ${presence.com_battlegrounds} battlegrounds: gains ${presence.com_battlegrounds} VP`)
+ }
+ if (presence.dem_spaces > 0) {
+ log(`Democrat has presence: gains ${value_presence} VP`)
+ } else {
+ log('Democrat has no presence')
+ }
+ if (presence.dem_battlegrounds > 0) {
+ log(`And ${presence.dem_battlegrounds} battlegrounds: gains ${presence.dem_battlegrounds} VP`)
+ }
+
+ }
log(`${status}`)
log(`${presence.dem_battlegrounds} Democrat battlegrounds`)
log(`${presence.com_battlegrounds} Communist battlegrounds`)
- let value = get_value(country)
+
let dem_vp = 0
if (presence.dem_spaces > 0) {dem_vp += value}
if (presence.dem_domination) {dem_vp += value}