summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js52
1 files changed, 40 insertions, 12 deletions
diff --git a/rules.js b/rules.js
index fedecc7..84c6929 100644
--- a/rules.js
+++ b/rules.js
@@ -16,6 +16,11 @@ var view = null
const POOL = -1
+const RED = 0
+const PINK = 1
+const BLUE = 2
+const DKBLUE = 3
+
exports.scenarios = {
"": [ "Random" ],
}
@@ -537,16 +542,19 @@ function can_place_dice(c) {
throw Error("bad pattern definition: " + pattern)
let wing = data.cards[c].wing
+ let n_wing = 0
for (let i = 0; i < game.placed.length; i += 2) {
let x = game.placed[i]
if (x !== c) {
- // TODO: place_2_on_WING ability
let i_wing = data.cards[x].wing
if (i_wing === wing)
- return false
+ n_wing ++
}
}
+ if (n_wing >= game.place_max[wing])
+ return false
+
if (place_dice_once[pattern]) {
if (map_has(game.placed, c))
return false
@@ -746,6 +754,23 @@ function goto_roll_phase() {
game.target = -1
game.action = 0
game.state = "roll"
+
+ game.place_max = [ 1, 1, 1, 1 ]
+
+ let p = player_index()
+ for (let c of game.front[p]) {
+ let rules = data.cards[c].rules
+ if (rules) {
+ if (rules.place_2_blue)
+ game.place_max[BLUE] = 2
+ if (rules.place_2_red)
+ game.place_max[RED] = 2
+ if (rules.place_2_pink)
+ game.place_max[PINK] = 2
+ if (rules.place_2_dkblue)
+ game.place_max[DKBLUE] = 2
+ }
+ }
}
states.roll = {
@@ -829,6 +854,7 @@ states.place_on_card = {
function end_roll_phase() {
clear_undo()
map_clear(game.placed)
+ game.place_max = null
// Remove placed dice to add cube on special cards.
for (let c of game.front[player_index()]) {
@@ -1504,16 +1530,18 @@ function resume_routing() {
}
function end_routing() {
- // Morale loss
- if ((game.routed[0] > 0 && !game.routed[1]) || (game.routed[1] > 0 && !game.routed[0])) {
- if (game.routed[0]) {
- game.routed[0] = Math.min(game.routed[0], game.morale[0])
- game.morale[0] -= game.routed[0]
- game.morale[1] += game.routed[0]
- } else {
- game.routed[1] = Math.min(game.routed[1], game.morale[1])
- game.morale[1] -= game.routed[1]
- game.morale[0] += game.routed[1]
+ // Morale loss and gain (except for S3 - Plains of Abraham)
+ if (game.morale[0] >= 0 && game.morale[1] >= 0) {
+ if ((game.routed[0] > 0 && !game.routed[1]) || (game.routed[1] > 0 && !game.routed[0])) {
+ if (game.routed[0]) {
+ game.routed[0] = Math.min(game.routed[0], game.morale[0])
+ game.morale[0] -= game.routed[0]
+ game.morale[1] += game.routed[0]
+ } else {
+ game.routed[1] = Math.min(game.routed[1], game.morale[1])
+ game.morale[1] -= game.routed[1]
+ game.morale[0] += game.routed[1]
+ }
}
}