summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.css40
-rw-r--r--play.html1
-rw-r--r--play.js14
-rw-r--r--rules.js106
4 files changed, 94 insertions, 67 deletions
diff --git a/play.css b/play.css
index 93df297..59ae809 100644
--- a/play.css
+++ b/play.css
@@ -161,7 +161,8 @@ header.your_turn.austria { background-color: var(--color-light-austria); }
min-height: 6px;
}
-.city_tip, .piece_tip, .move_tip { cursor: pointer; }
+.city_tip, .piece_tip, .move_tip, .card_tip { cursor: pointer; }
+.card_tip { font-style: italic }
.city_tip:hover, .piece_tip:hover, .move_tip:hover { text-decoration: underline; }
#log .h {
@@ -460,21 +461,12 @@ body.shift span.value.deck_4 { background-color: #f002 }
}
@media (hover: hover) {
- .card.action:hover {
+ .card.tc.action:hover {
margin-top: -10px;
margin-bottom: 10px;
}
}
-.card.zoom {
- width: 330px;
- height: 514px;
- border-radius: 16px;
-}
-
-.card.polcard { cursor: zoom-in }
-.card.polcard.zoom { cursor: zoom-out }
-
.draw-break { margin-left: 167px; }
.card.tc { margin-right: calc(-167px + 40px); }
.card.tc.reverse { margin-right: calc(-167px + 20px); }
@@ -570,32 +562,6 @@ body.shift span.value.deck_4 { background-color: #f002 }
.card.polcard.reverse.deck_3 { background-image: url(cards/Maria.PolCard.reverse.deck_3.075.jpg) }
.card.polcard.reverse.deck_4 { background-image: url(cards/Maria.PolCard.reverse.deck_4.075.jpg) }
-.card.polcard.c1.zoom { background-image: url(cards/Maria.PolCard.01.150.jpg) }
-.card.polcard.c2.zoom { background-image: url(cards/Maria.PolCard.02.150.jpg) }
-.card.polcard.c3.zoom { background-image: url(cards/Maria.PolCard.03.150.jpg) }
-.card.polcard.c4.zoom { background-image: url(cards/Maria.PolCard.04.150.jpg) }
-.card.polcard.c5.zoom { background-image: url(cards/Maria.PolCard.05.150.jpg) }
-.card.polcard.c6.zoom { background-image: url(cards/Maria.PolCard.06.150.jpg) }
-.card.polcard.c7.zoom { background-image: url(cards/Maria.PolCard.07.150.jpg) }
-.card.polcard.c8.zoom { background-image: url(cards/Maria.PolCard.08.150.jpg) }
-.card.polcard.c9.zoom { background-image: url(cards/Maria.PolCard.09.150.jpg) }
-.card.polcard.c10.zoom { background-image: url(cards/Maria.PolCard.10.150.jpg) }
-.card.polcard.c11.zoom { background-image: url(cards/Maria.PolCard.11.150.jpg) }
-.card.polcard.c12.zoom { background-image: url(cards/Maria.PolCard.12.150.jpg) }
-.card.polcard.c13.zoom { background-image: url(cards/Maria.PolCard.13.150.jpg) }
-.card.polcard.c14.zoom { background-image: url(cards/Maria.PolCard.14.150.jpg) }
-.card.polcard.c15.zoom { background-image: url(cards/Maria.PolCard.15.150.jpg) }
-.card.polcard.c16.zoom { background-image: url(cards/Maria.PolCard.16.150.jpg) }
-.card.polcard.c17.zoom { background-image: url(cards/Maria.PolCard.17.150.jpg) }
-.card.polcard.c18.zoom { background-image: url(cards/Maria.PolCard.18.150.jpg) }
-.card.polcard.c19.zoom { background-image: url(cards/Maria.PolCard.19.150.jpg) }
-.card.polcard.c20.zoom { background-image: url(cards/Maria.PolCard.20.150.jpg) }
-.card.polcard.c21.zoom { background-image: url(cards/Maria.PolCard.21.150.jpg) }
-.card.polcard.c22.zoom { background-image: url(cards/Maria.PolCard.22.150.jpg) }
-.card.polcard.c23.zoom { background-image: url(cards/Maria.PolCard.23.150.jpg) }
-.card.polcard.c24.zoom { background-image: url(cards/Maria.PolCard.24.150.jpg) }
-.card.polcard.c25.zoom { background-image: url(cards/Maria.PolCard.ImpElection.150.jpg) }
-
/* @2x */
@media (min-resolution: 97dpi) {
diff --git a/play.html b/play.html
index 1152bce..15f403c 100644
--- a/play.html
+++ b/play.html
@@ -12,6 +12,7 @@
<link rel="stylesheet" href="play.css">
<script defer src="/common/client.js"></script>
<script defer src="data.js"></script>
+<script defer src="cards.js"></script>
<script defer src="play.js"></script>
</head>
<body>
diff --git a/play.js b/play.js
index f34d5f6..6a76f5f 100644
--- a/play.js
+++ b/play.js
@@ -496,12 +496,10 @@ function make_tc_deck_hand(n) {
return list
}
-function make_political_card(pc) {
+function make_political_card(id) {
let e = document.createElement("div")
- if (pc === 0)
- e.className = "card polcard reverse"
- else
- e.className = "card polcard c" + pc
+ e.className = "card polcard c" + id
+ register_action(e, "political", id)
return e
}
@@ -1100,7 +1098,7 @@ function on_update() {
ui.pc_display[pow].replaceChildren()
for (let tc of view.saved[pow])
ui.pc_display[pow].appendChild(show_tc(tc))
- if (view.display[pow] >= 0)
+ if (view.display && view.display[pow] >= 0)
ui.pc_display[pow].appendChild(show_tc(view.display[pow]))
}
@@ -1215,8 +1213,8 @@ function on_update() {
function sub_political(match, p1) {
let x = p1 | 0
- let n = political_name[x]
- return `<span class="political_tip ${p}" onmouseenter="on_focus_political_tip(${x})" onmouseleave="on_blur_political_tip(${x})">${n}</span>`
+ let n = political_cards[x].title
+ return `<span class="card_tip" onmouseenter="on_focus_political_tip(${x})" onmouseleave="on_blur_political_tip(${x})">${n}</span>`
}
function sub_piece(match, p1) {
diff --git a/rules.js b/rules.js
index 357fe73..6a6d9d9 100644
--- a/rules.js
+++ b/rules.js
@@ -61,7 +61,8 @@ exports.roles = [
exports.scenarios = [ "Advanced" ]
-const data = require("./data")
+const data = require("./data.js")
+const political_cards = require("./cards.js")
var game
var view
@@ -955,7 +956,6 @@ function goto_end_turn() {
function goto_start_turn() {
game.turn += 1
- game.stage = 0
log("# " + TURN_NAME[game.turn])
@@ -1004,6 +1004,8 @@ function end_place_hussars() {
log("=" + P_AUSTRIA + " Hussars")
for (let p of all_hussars)
log("Hussar at S" + game.pos[p] + ".")
+
+ game.stage = 0
goto_action_stage()
}
@@ -1149,13 +1151,13 @@ function total_discard_list() {
return discard
}
-function draw_tc(n) {
+function draw_tc(n, verbose = true) {
game.draw = []
let k = 0
while (n > 0) {
if (game.deck.length === 0) {
- if (k > 0)
+ if (verbose && k > 0)
log(power_name[game.power] + " " + k + " TC.")
k = 0
next_tactics_deck()
@@ -1169,7 +1171,7 @@ function draw_tc(n) {
--n
}
- if (k > 0)
+ if (verbose && k > 0)
log(power_name[game.power] + " " + k + " TC.")
}
@@ -2300,6 +2302,7 @@ function goto_winter_turn() {
// TODO: winter scoring
+ game.stage = 0
goto_winter_stage()
}
@@ -3227,17 +3230,22 @@ const POWER_FROM_POLITICAL_STAGE = [
P_AUSTRIA,
]
-function set_active_political_power() {
- set_active_to_power(POWER_FROM_POLITICAL_STAGE[game.stage])
-}
+const INFLUENCE_ORDER = [
+ P_AUSTRIA,
+ P_PRAGMATIC,
+ P_FRANCE,
+ P_PRUSSIA,
+]
function goto_politics() {
game.political = []
game.display = [ 0, 0, 0, 0 ]
game.stage = 0
+ log("Reveal")
while (game.political.length < 2) {
let pc = game.pol_deck.pop()
+ log(">C" + pc)
if (pc === IMPERIAL_ELECTION)
game.flags |= F_IMPERIAL_ELECTION
else
@@ -3249,7 +3257,7 @@ function goto_politics() {
game.state = "determine_trump_suit"
} else {
for (;;) {
- draw_tc(1)
+ draw_tc(1, false)
log("Trump " + format_card(game.draw[0]) + ".")
if (!is_reserve(game.draw[0])) {
game.trump = to_suit(game.draw[0])
@@ -3257,6 +3265,7 @@ function goto_politics() {
}
delete game.draw
}
+ log_br()
goto_place_tc_on_display()
}
}
@@ -3268,13 +3277,15 @@ states.determine_trump_suit = {
view.actions.suit = [ 0, 1, 2, 3 ]
},
suit(s) {
+ log(power_name[game.power] + " chose " + suit_name[game.trump] + " as trump.")
+ log_br()
game.trump = s
goto_place_tc_on_display()
}
}
function goto_place_tc_on_display() {
- set_active_political_power()
+ set_active_to_power(POWER_FROM_POLITICAL_STAGE[game.stage])
game.state = "place_tc_on_display"
}
@@ -3318,30 +3329,67 @@ function end_place_tc_on_display() {
}
function goto_determine_order_of_influence() {
+ log_br()
+ log("Influence")
+
// Turn cards face-up and return bluff cards
- for (let pow of all_major_powers) {
+ for (let pow of POWER_FROM_POLITICAL_STAGE) {
let c = game.display[pow]
if (c > 0) {
if (to_suit(c) === game.trump) {
- log(power_name[pow] + " played " + format_card(c) + ".")
+ log(">" + format_card(c) + " " + power_name[pow])
set_add(game.saved[pow], c)
} else {
- log(power_name[pow] + " bluffed " + format_card(c) + ".")
+ log(">" + format_card(c) + " " + power_name[pow] + "(bluff)")
set_add(game.hand[pow], c)
}
}
}
delete game.display
- game.stage = 4
- goto_select_political_cards()
+ log_br()
+ game.stage = 0
+ goto_select_political_card()
}
-function goto_select_political_cards() {
- if (--game.stage < 0)
+function count_influence(pow) {
+ let n = 0
+ for (let c of game.saved[pow])
+ if (is_reserve(c))
+ n += 16
+ else
+ n += to_value(c)
+ return n
+}
+
+function most_influence() {
+ let p_most = -1
+ let n_most = 0
+ for (let pow of INFLUENCE_ORDER) {
+ if (game.stage & (1 << pow))
+ continue
+ let n = count_influence(pow)
+ if (n > n_most) {
+ n_most = n
+ p_most = pow
+ }
+ }
+ return p_most
+}
+
+function goto_select_political_card() {
+ if (game.political.length > 0) {
+ let pow = most_influence()
+ if (pow < 0) {
+ end_politics()
+ } else {
+ game.stage |= 1 << pow
+ set_active_to_power(pow)
+ game.state = "select_political_card"
+ }
+ } else {
end_politics()
- set_active_to_power(most_influence())
- game.state = "select_political_card"
+ }
}
states.select_political_card = {
@@ -3349,7 +3397,8 @@ states.select_political_card = {
prompt() {
prompt(`Select a political card or save your TC.`)
for (let pc of game.political)
- gen_action_political(pc)
+ if (set_has(political_cards[pc].powers, game.power))
+ gen_action_political(pc)
view.actions.pass = 1
},
political(pc) {
@@ -3359,14 +3408,25 @@ states.select_political_card = {
},
pass() {
log(power_name[game.power] + " saved its TC.")
- goto_select_political_cards()
+ goto_select_political_card()
},
}
function end_politics() {
delete game.political
+
+ // did not take a turn; take cards back into hand
+ for (let pow of all_major_powers) {
+ if (!(game.stage & (1 << pow))) {
+ for (let c of game.saved[pow])
+ set_add(game.hand, c)
+ game.saved[pow] = []
+ }
+ }
+
if (check_instant_victory())
return
+
goto_place_hussars()
}
@@ -3780,7 +3840,7 @@ exports.view = function (state, player) {
discard: total_discard_list(),
pol_deck: mask_pol_deck(),
- saved: mask_saved(player),
+ saved: game.saved,
power: game.power,
retro: game.retro,
@@ -3791,6 +3851,8 @@ exports.view = function (state, player) {
view.defender = game.defender
}
+ if (game.political)
+ view.political = game.political
if (game.display)
view.display = mask_display(player)