summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js39
1 files changed, 32 insertions, 7 deletions
diff --git a/play.js b/play.js
index eaa0869..f8f690c 100644
--- a/play.js
+++ b/play.js
@@ -1119,35 +1119,60 @@ function layout_retro(s, pow) {
ui.markers_element.appendChild(e)
}
-function layout_victory_pool(pow, max, x, y) {
+function elector_majority() {
+ let elector_france = 0
+ let elector_pragmatic = 0
+ for (let i = 0; i < 8; i += 2) {
+ if (view.elector[i+1] === P_FRANCE)
+ elector_france ++
+ else
+ elector_pragmatic ++
+ }
+ if (elector_france >= 3)
+ return P_FRANCE
+ if (elector_pragmatic >= 3)
+ return P_PRAGMATIC
+ return -1
+}
+
+function count_victory_markers(pow) {
let n = view.vp[pow]
- let m = 0
if (pow === P_PRUSSIA) {
- m = view.vp[SET_ASIDE_PRUSSIA]
- n += m
+ n += view.vp[SET_ASIDE_PRUSSIA]
if (view.flags & F_SILESIA_ANNEXED) ++n
}
if (pow === P_FRANCE) {
- m = view.vp[SET_ASIDE_FRANCE]
- n += m
+ n += view.vp[SET_ASIDE_FRANCE]
if (view.flags & F_ITALY_FRANCE) ++n
if (view.flags & F_EMPEROR_FRANCE) ++n
+ if (elector_majority() === P_FRANCE) ++n
}
if (pow === P_AUSTRIA) {
if (view.flags & F_ITALY_AUSTRIA) ++n
if (view.flags & F_EMPEROR_AUSTRIA) ++n
}
+ if (pow === P_PRAGMATIC) {
+ if (elector_majority() === P_PRAGMATIC) ++n
+ }
for (let i = 0; i < view.victory.length; i += 2)
if (view.victory[i+1] === pow)
++n
+ return n
+}
+function layout_victory_pool(pow, max, x, y) {
+ let n = count_victory_markers(pow)
+ let m = 0
+ if (pow === P_PRUSSIA)
+ m = view.vp[SET_ASIDE_PRUSSIA]
+ if (pow === P_FRANCE)
+ m = view.vp[SET_ASIDE_FRANCE]
for (let i = 0; i < max - n; ++i) {
let e = ui.victory[pow][used_victory[pow]++]
e.style.left = (x - 16 + (i%5) * 20) + "px"
e.style.top = (y - 16 + (i/5|0) * 20) + "px"
ui.markers_element.appendChild(e)
}
-
for (let i = 0; i < m; ++i) {
let e = ui.victory[pow][used_victory[pow]++]
if (pow === P_FRANCE) {