summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-11-26 00:14:53 +0100
committerTor Andersson <tor@ccxvii.net>2024-11-28 23:33:22 +0100
commit41df873b95bd489975cb69f37ba024f2fdb479eb (patch)
treef0d4c0aae5eca31e66755ead6b7f177895253238 /rules.js
parent902f03c38dac77a64e1259f04c4f04c2227c3b84 (diff)
downloadmaria-41df873b95bd489975cb69f37ba024f2fdb479eb.tar.gz
separate expiration dates for promises
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/rules.js b/rules.js
index 16f9481..8143afd 100644
--- a/rules.js
+++ b/rules.js
@@ -83,13 +83,14 @@ const turn_name = [
"Winter 1744",
]
-const DI_TURN = 0
-const DI_A_POWER = 1
-const DI_B_POWER = 2
-const DI_A_PROMISE = 3
-const DI_B_PROMISE = 4
-const DI_A_PHASE = 5
-const DI_B_PHASE = 6
+const DI_A_POWER = 0
+const DI_B_POWER = 1
+const DI_A_TURN = 2
+const DI_B_TURN = 3
+const DI_A_PHASE = 4
+const DI_B_PHASE = 5
+const DI_A_PROMISE = 6
+const DI_B_PROMISE = 7
const F_EMPEROR_FRANCE = 1
const F_EMPEROR_AUSTRIA = 2
@@ -1405,7 +1406,7 @@ function goto_start_turn() {
}
// remove expired deals
- game.deals = game.deals.filter(deal => deal[DI_TURN] >= game.turn)
+ game.deals = game.deals.filter(deal => deal[DI_A_TURN] >= game.turn || deal[DI_B_TURN] >= game.turn)
}
function goto_end_turn() {
@@ -6617,9 +6618,9 @@ states.pong = {
function should_validate_promise(me, you, phase) {
for (let deal of game.deals) {
- if (deal[DI_A_POWER] === me && deal[DI_B_POWER] === you && (deal[DI_A_PHASE] & phase))
+ if (deal[DI_A_POWER] === me && deal[DI_B_POWER] === you && (deal[DI_A_PHASE] & phase) && game.turn <= deal[DI_A_TURN])
return true
- if (deal[DI_B_POWER] === me && deal[DI_A_POWER] === you && (deal[DI_B_PHASE] & phase))
+ if (deal[DI_B_POWER] === me && deal[DI_A_POWER] === you && (deal[DI_B_PHASE] & phase) && game.turn <= deal[DI_B_TURN])
return true
}
return false