summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-12-04 00:35:38 +0100
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-12-04 00:35:38 +0100
commitc932d2242db64cf42ff2fa88ec164e89b1210328 (patch)
treefafef3548553d9b347ce16b3d6c4ff6aecb6d9d8
parentc8c93245c6d88a80a7a5f8acb87b092f1d404dde (diff)
downloadvotes-for-women-c932d2242db64cf42ff2fa88ec164e89b1210328.tar.gz
offer intelligent reroll suggestions during final voting
-rw-r--r--rules.js48
1 files changed, 43 insertions, 5 deletions
diff --git a/rules.js b/rules.js
index e151672..cb5703c 100644
--- a/rules.js
+++ b/rules.js
@@ -1218,6 +1218,12 @@ function goto_final_voting() {
log_h1("Final Voting")
log(`Suffragist has ${count_green_checks()} of ${GREEN_CHECK_VICTORY} States.`)
log(`Opposition has ${count_red_xs()} of ${RED_X_VICTORY} States.`)
+ if (game.persistent_ballot.includes(MISS_FEBB_WINS_THE_LAST_VOTE)) {
+ log("Suffragist wins all ties.")
+ } else {
+ log("Opposition wins all ties.")
+ }
+
game.active = SUF
game.state = "final_voting_select_state"
}
@@ -1276,6 +1282,20 @@ function goto_final_voting_roll() {
game.state = "final_voting_roll"
}
+function should_reroll() {
+ // not if you have already rolled your max
+ if (game.roll === game.dice)
+ return false
+ // not if your have already won, because they are broke and cant reroll
+ if (!opponent_buttons() && (game.roll > game.opponent_roll || (player_wins_ties() && game.roll === game.opponent_roll)))
+ return false
+ // not if your have already won, because they cant roll any higher
+ if (game.roll > game.opponent_dice || (player_wins_ties() && game.roll === game.opponent_dice))
+ return false
+ // you could give it a shot
+ return true
+}
+
states.final_voting_roll = {
inactive: "do Final Voting.",
prompt() {
@@ -1298,7 +1318,7 @@ states.final_voting_roll = {
view.prompt += '.'
// only reroll when you can and when it makes sense
- if (player_buttons() > 0 && game.roll < game.dice)
+ if (player_buttons() > 0 && should_reroll())
gen_action("reroll")
gen_action("next")
}
@@ -1318,6 +1338,20 @@ states.final_voting_roll = {
}
}
+function should_opponent_reroll() {
+ // not if you have already rolled your max
+ if (game.opponent_roll === game.opponent_dice)
+ return false
+ // not if your have already won
+ if (game.opponent_roll > game.roll || (player_wins_ties() && game.opponent_roll === game.roll))
+ return false
+ // not if you cant roll a win
+ if (game.roll > game.opponent_dice || (!player_wins_ties() && game.roll === game.opponent_dice))
+ return false
+ // you could give it a shot
+ return true
+}
+
states.final_voting_opponent = {
inactive: "do Final Voting.",
prompt() {
@@ -1331,7 +1365,7 @@ states.final_voting_opponent = {
view.prompt += '.'
// only reroll when you can and when it makes sense
- if (player_buttons() > 0 && game.opponent_roll < game.opponent_dice)
+ if (player_buttons() > 0 && should_opponent_reroll())
gen_action("reroll")
gen_action("next")
},
@@ -1346,6 +1380,10 @@ states.final_voting_opponent = {
const MISS_FEBB_WINS_THE_LAST_VOTE = find_card("Miss Febb Wins the Last Vote")
+function player_wins_ties() {
+ return game.active === OPP || game.persistent_ballot.includes(MISS_FEBB_WINS_THE_LAST_VOTE)
+}
+
function goto_final_voting_result() {
clear_undo()
let support_roll = game.active === OPP ? game.roll : game.opponent_roll
@@ -1376,9 +1414,9 @@ function goto_final_voting_result() {
else
reject_nineteenth_amendment(game.selected_us_state)
- log_br()
- log(`Suffragist won ${count_green_checks()} of ${GREEN_CHECK_VICTORY} States.`)
- log(`Opposition won ${count_red_xs()} of ${RED_X_VICTORY} States.`)
+ // log_br()
+ // log(`Suffragist won ${count_green_checks()} of ${GREEN_CHECK_VICTORY} States.`)
+ // log(`Opposition won ${count_red_xs()} of ${RED_X_VICTORY} States.`)
game.state = "final_voting_result"
}