summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-02-10 11:54:01 +0100
committerTor Andersson <tor@ccxvii.net>2024-02-10 11:54:01 +0100
commit75ca87f304574b5a7100a85df45a0093fde6690d (patch)
tree0a71215b9148fa7d7469ad2fcb48e7a516a17149
parent6e04b1c1b0e60633a04d8ca5dc84f6ffd833da41 (diff)
downloadtable-battles-75ca87f304574b5a7100a85df45a0093fde6690d.tar.gz
Skip roll button when out of dice.
-rw-r--r--rules.js40
1 files changed, 35 insertions, 5 deletions
diff --git a/rules.js b/rules.js
index 94420fc..c819442 100644
--- a/rules.js
+++ b/rules.js
@@ -1503,8 +1503,13 @@ states.skip_action = {
if (can_shift())
view.actions.shift = 1
- view.actions.roll = 1
- view.actions.end_turn = 0
+ if (count_dice_in_pool() > 0) {
+ view.actions.roll = 1
+ view.actions.end_turn = 0
+ } else {
+ view.actions.roll = 0
+ view.actions.end_turn = 1
+ }
},
shift() {
push_undo()
@@ -1515,6 +1520,11 @@ states.skip_action = {
goto_roll_phase()
roll_dice_in_pool()
},
+ end_turn() {
+ goto_roll_phase()
+ roll_dice_in_pool()
+ end_roll_phase()
+ },
}
states.roll = {
@@ -1845,6 +1855,15 @@ function has_any_cubes_on_card(c) {
return get_cubes(c) >= 1
}
+function count_dice_in_pool() {
+ let n = 0
+ let p = player_index()
+ for (let i = 0; i < 6; ++i)
+ if (get_dice_location(p * 6 + i) < 0)
+ ++n
+ return n
+}
+
function count_dice_on_card(c) {
let n = 0
for (let i = 0; i < 12; ++i)
@@ -2185,8 +2204,14 @@ states.action = {
inactive: "take an action",
prompt() {
view.prompt = "Take an action."
- view.actions.roll = 1
- view.actions.end_turn = 0
+
+ if (count_dice_in_pool() > 0) {
+ view.actions.roll = 1
+ view.actions.end_turn = 0
+ } else {
+ view.actions.roll = 0
+ view.actions.end_turn = 1
+ }
let p = player_index()
for (let c of game.front[p]) {
@@ -2305,7 +2330,12 @@ states.action = {
}
throw new Error("missing rule for special action: " + card_name(c))
- }
+ },
+ end_turn() {
+ goto_roll_phase()
+ roll_dice_in_pool()
+ end_roll_phase()
+ },
}
function can_shift() {