summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mountain-danger.svg4
-rw-r--r--mountain-highlight.svg4
-rw-r--r--mountain-selected.svg4
-rw-r--r--mountain-supply-both.svg4
-rw-r--r--mountain-supply-british.svg4
-rw-r--r--mountain-supply-french.svg4
-rw-r--r--mountain-tip.svg5
-rw-r--r--play.css136
-rw-r--r--play.js26
-rw-r--r--rules.js64
10 files changed, 152 insertions, 103 deletions
diff --git a/mountain-danger.svg b/mountain-danger.svg
new file mode 100644
index 0000000..fd9cb5d
--- /dev/null
+++ b/mountain-danger.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="210" height="148">
+<path fill="none" stroke="#f00" stroke-width="8" d="m106.203 59.988-3.814 6.645-23.34-22.328L21.15 132h168.596L127.947 22.14l-21.744 37.848Z"/>
+<path fill="none" stroke="#ff0" stroke-width="8" d="M10 138 78 35l23 22 27-47 72 128Z"/>
+</svg>
diff --git a/mountain-highlight.svg b/mountain-highlight.svg
index c499ef5..0473bbd 100644
--- a/mountain-highlight.svg
+++ b/mountain-highlight.svg
@@ -2,7 +2,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="210" height="148">
<path
fill="none"
- stroke="white"
- stroke-width="10"
+ stroke="yellow"
+ stroke-width="8"
d="M 10 138 L 78 35 L 101 57 L 128 10 L 200 138 Z"/>
</svg>
diff --git a/mountain-selected.svg b/mountain-selected.svg
index fb4dfca..3dd60fa 100644
--- a/mountain-selected.svg
+++ b/mountain-selected.svg
@@ -2,7 +2,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="210" height="148">
<path
fill="none"
- stroke="crimson"
- stroke-width="10"
+ stroke="white"
+ stroke-width="8"
d="M 10 138 L 78 35 L 101 57 L 128 10 L 200 138 Z"/>
</svg>
diff --git a/mountain-supply-both.svg b/mountain-supply-both.svg
index e618244..9a63043 100644
--- a/mountain-supply-both.svg
+++ b/mountain-supply-both.svg
@@ -2,12 +2,12 @@
<svg xmlns="http://www.w3.org/2000/svg" width="210" height="148">
<path
fill="none"
- stroke="#f0594e"
+ stroke="red"
stroke-width="10"
d="M 10 138 L 200 138 L 128 10 "/>
<path
fill="none"
- stroke="#0092d5"
+ stroke="blue"
stroke-width="10"
d="M 10 138 L 78 35 L 101 57 L 128 10"/>
</svg>
diff --git a/mountain-supply-british.svg b/mountain-supply-british.svg
index 5808b63..22a60af 100644
--- a/mountain-supply-british.svg
+++ b/mountain-supply-british.svg
@@ -2,7 +2,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="210" height="148">
<path
fill="none"
- stroke="#f0594e"
- stroke-width="10"
+ stroke="red"
+ stroke-width="12"
d="M 10 138 L 200 138 L 128 10 "/>
</svg>
diff --git a/mountain-supply-french.svg b/mountain-supply-french.svg
index 6f8ea17..f4e74d5 100644
--- a/mountain-supply-french.svg
+++ b/mountain-supply-french.svg
@@ -2,7 +2,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="210" height="148">
<path
fill="none"
- stroke="#0092d5"
- stroke-width="10"
+ stroke="blue"
+ stroke-width="12"
d="M 10 138 L 78 35 L 101 57 L 128 10"/>
</svg>
diff --git a/mountain-tip.svg b/mountain-tip.svg
index 50a4aac..3dd60fa 100644
--- a/mountain-tip.svg
+++ b/mountain-tip.svg
@@ -2,8 +2,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="210" height="148">
<path
fill="none"
- stroke="yellow"
- stroke-width="10"
- stroke-dasharray="20 20"
+ stroke="white"
+ stroke-width="8"
d="M 10 138 L 78 35 L 101 57 L 128 10 L 200 138 Z"/>
</svg>
diff --git a/play.css b/play.css
index 303af48..e59cd07 100644
--- a/play.css
+++ b/play.css
@@ -7,6 +7,11 @@ body.Britain header.your_turn { background-color: salmon; }
#role_Britain, #log .h2.britain { background-color: #fcb; }
aside { width: 220px; }
+:root {
+ --highlight-color: yellow;
+ --selected-color: blue;
+}
+
.role_vp { float: right; }
.checked::before { content: "\2714 " }
@@ -232,7 +237,8 @@ body.shift .highlight {
.wilderness, .cultivated, .box, .militia-box, .leader-box {
position: absolute;
- border: 5px solid transparent;
+ box-sizing: border-box;
+ border: 4px solid transparent;
}
.wilderness {
border-radius: 50%;
@@ -244,50 +250,85 @@ body.shift .highlight {
background-size: cover;
background-repeat: no-repeat;
}
-.mountain.tip {
- background-image: url(mountain-tip.svg);
- z-index: 100;
-}
.mountain.highlight {
background-image: url(mountain-highlight.svg);
+ filter: drop-shadow(0 0 2px black);
+}
+.mountain.danger {
+ background-image: url(mountain-danger.svg);
+ filter: drop-shadow(0 0 2px black);
}
.mountain.selected {
background-image: url(mountain-selected.svg);
+ filter: drop-shadow(0 0 2px black);
}
.mountain.british_supply {
background-image: url(mountain-supply-british.svg);
+ filter: none;
}
.mountain.french_supply {
background-image: url(mountain-supply-french.svg);
+ filter: none;
}
.mountain.british_supply.french_supply {
background-image: url(mountain-supply-both.svg);
+ filter: none;
+}
+.mountain.no_supply {
+ background-image: none;
+}
+.mountain.tip {
+ background-image: url(mountain-tip.svg);
+ z-index: 100;
}
-.cultivated.highlight, .box.highlight, .militia-box.highlight {
- border-color: white;
- box-shadow: 0 0 5px white;
+.wilderness.highlight, .cultivated.highlight, .box.highlight, .militia-box.highlight {
+ border-color: yellow;
+ box-shadow: inset 0 0 3px black, 0 0 3px black;
}
-.wilderness.highlight {
+.wilderness.selected, .cultivated.selected, .box.selected, .militia-box.selected {
border-color: white;
+ box-shadow: inset 0 0 3px black, 0 0 3px black;
}
-.wilderness.selected, .cultivated.selected, .box.selected, .militia-box.selected {
- border-color: crimson;
+.wilderness.danger, .cultivated.danger, .box.danger {
+ box-shadow: inset 0 0 0 3px red, inset 0 0 3px 3px black, 0 0 3px black;
}
.wilderness.tip, .cultivated.tip, .box.tip, .militia-box.tip {
- border-color: yellow;
- border-style: dashed;
+ border-color: white;
+ box-shadow: 0 0 3px black, inset 0 0 3px black;
z-index: 100;
}
.wilderness.french_supply, .cultivated.french_supply, .box.french_supply {
- border-top-color: #0092d5;
- border-left-color: #0092d5;
+ border-width: 6px;
+ border-top-color: blue;
+ border-left-color: blue;
+ border-bottom-color: transparent;
+ border-right-color: transparent;
+ box-shadow: none;
}
.wilderness.british_supply, .cultivated.british_supply, .box.british_supply {
- border-bottom-color: #f0594e;
- border-right-color: #f0594e;
+ border-width: 6px;
+ border-top-color: transparent;
+ border-left-color: transparent;
+ border-bottom-color: red;
+ border-right-color: red;
+ box-shadow: none;
+}
+
+.wilderness.british_supply.french_supply, .cultivated.british_supply.french_supply, .box.british_supply.french_supply {
+ border-width: 6px;
+ border-top-color: blue;
+ border-left-color: blue;
+ border-bottom-color: red;
+ border-right-color: red;
+ box-shadow: none;
+}
+
+.wilderness.no_supply, .cultivated.no_supply, .box.no_supply {
+ border-color: transparent;
+ box-shadow: none;
}
/* COUNTERS */
@@ -319,12 +360,13 @@ body.flat .event {
body.flat .leader.highlight,
body.flat .unit.highlight {
- box-shadow:0 0 0 2px yellow;
+ box-shadow: 0 0 0 3px var(--highlight-color);
}
body.flat .leader.selected,
body.flat .unit.selected {
- box-shadow:0 0 0 2px crimson;
+ box-shadow: 0 0 0 3px var(--selected-color);
+ border-color: var(--selected-color) !important;
}
/* BEVEL STYLE ( top right bottom left ) */
@@ -492,120 +534,84 @@ body.bevel .event {
.leader{background-color:#f0f0f0}
body.bevel .leader{border-color:#f5f5f5 #d8d8d8 #d8d8d8 #f5f5f5;box-shadow:0 0 0 1px #707070}
-body.bevel .leader.highlight{box-shadow:0 0 0 1px #707070,0 0 0 3px yellow}
-body.bevel .leader.selected{box-shadow:0 0 0 1px #707070,0 0 0 3px crimson}
body.flat .leader{border-color:#707070}
.event{background-color:#f0f0f0}
body.bevel .event{border-color:#f5f5f5 #d8d8d8 #d8d8d8 #f5f5f5;box-shadow:0 0 0 1px #707070}
-body.bevel .event.highlight{box-shadow:0 0 0 1px #707070,0 0 0 3px yellow}
-body.bevel .event.selected{box-shadow:0 0 0 1px #707070,0 0 0 3px crimson}
body.flat .event{border-color:#707070}
.marker.amphib{background-color:#f0f0f0}
body.bevel .marker.amphib{border-color:#f5f5f5 #d8d8d8 #d8d8d8 #f5f5f5;box-shadow:0 0 0 1px #707070}
-body.bevel .marker.amphib.highlight{box-shadow:0 0 0 1px #707070,0 0 0 3px yellow}
-body.bevel .marker.amphib.selected{box-shadow:0 0 0 1px #707070,0 0 0 3px crimson}
body.flat .marker.amphib{border-color:#707070}
.marker.british_allied{background-color:#ffd990}
body.bevel .marker.british_allied{border-color:#fff8af #dfb86f #dfb86f #fff8af;box-shadow:0 0 0 1px #7f580f}
-body.bevel .marker.british_allied.highlight{box-shadow:0 0 0 1px #7f580f,0 0 0 3px yellow}
-body.bevel .marker.british_allied.selected{box-shadow:0 0 0 1px #7f580f,0 0 0 3px crimson}
body.flat .marker.british_allied{border-color:#7f580f}
.marker.french_allied{background-color:#ffd990}
body.bevel .marker.french_allied{border-color:#fff8af #dfb86f #dfb86f #fff8af;box-shadow:0 0 0 1px #7f580f}
-body.bevel .marker.french_allied.highlight{box-shadow:0 0 0 1px #7f580f,0 0 0 3px yellow}
-body.bevel .marker.french_allied.selected{box-shadow:0 0 0 1px #7f580f,0 0 0 3px crimson}
body.flat .marker.french_allied{border-color:#7f580f}
.marker.british_stockade{background-color:#e7e2c5}
body.bevel .marker.british_stockade{border-color:#ffffe3 #c7c2a4 #c7c2a4 #ffffe3;box-shadow:0 0 0 1px #676244}
-body.bevel .marker.british_stockade.highlight{box-shadow:0 0 0 1px #676244,0 0 0 3px yellow}
-body.bevel .marker.british_stockade.selected{box-shadow:0 0 0 1px #676244,0 0 0 3px crimson}
body.flat .marker.british_stockade{border-color:#676244}
.marker.french_stockade{background-color:#e7e2c5}
body.bevel .marker.french_stockade{border-color:#ffffe3 #c7c2a4 #c7c2a4 #ffffe3;box-shadow:0 0 0 1px #676244}
-body.bevel .marker.french_stockade.highlight{box-shadow:0 0 0 1px #676244,0 0 0 3px yellow}
-body.bevel .marker.french_stockade.selected{box-shadow:0 0 0 1px #676244,0 0 0 3px crimson}
body.flat .marker.french_stockade{border-color:#676244}
.marker.british_raided{background-color:#f78b33}
body.bevel .marker.british_raided{border-color:#ffaa52 #d76a12 #d76a12 #ffaa52;box-shadow:0 0 0 1px #770a00}
-body.bevel .marker.british_raided.highlight{box-shadow:0 0 0 1px #770a00,0 0 0 3px yellow}
-body.bevel .marker.british_raided.selected{box-shadow:0 0 0 1px #770a00,0 0 0 3px crimson}
body.flat .marker.british_raided{border-color:#770a00}
.marker.french_raided{background-color:#f78b33}
body.bevel .marker.french_raided{border-color:#ffaa52 #d76a12 #d76a12 #ffaa52;box-shadow:0 0 0 1px #770a00}
-body.bevel .marker.french_raided.highlight{box-shadow:0 0 0 1px #770a00,0 0 0 3px yellow}
-body.bevel .marker.french_raided.selected{box-shadow:0 0 0 1px #770a00,0 0 0 3px crimson}
body.flat .marker.french_raided{border-color:#770a00}
.marker.siege_0{background-color:#fff460}
body.bevel .marker.siege_0{border-color:#ffff78 #dfd43f #dfd43f #ffff78;box-shadow:0 0 0 1px #7f7400}
-body.bevel .marker.siege_0.highlight{box-shadow:0 0 0 1px #7f7400,0 0 0 3px yellow}
-body.bevel .marker.siege_0.selected{box-shadow:0 0 0 1px #7f7400,0 0 0 3px crimson}
body.flat .marker.siege_0{border-color:#7f7400}
.marker.siege_1{background-color:#fff460}
body.bevel .marker.siege_1{border-color:#ffff78 #dfd43f #dfd43f #ffff78;box-shadow:0 0 0 1px #7f7400}
-body.bevel .marker.siege_1.highlight{box-shadow:0 0 0 1px #7f7400,0 0 0 3px yellow}
-body.bevel .marker.siege_1.selected{box-shadow:0 0 0 1px #7f7400,0 0 0 3px crimson}
body.flat .marker.siege_1{border-color:#7f7400}
.marker.siege_2{background-color:#fff460}
body.bevel .marker.siege_2{border-color:#ffff78 #dfd43f #dfd43f #ffff78;box-shadow:0 0 0 1px #7f7400}
-body.bevel .marker.siege_2.highlight{box-shadow:0 0 0 1px #7f7400,0 0 0 3px yellow}
-body.bevel .marker.siege_2.selected{box-shadow:0 0 0 1px #7f7400,0 0 0 3px crimson}
body.flat .marker.siege_2{border-color:#7f7400}
.marker.fieldworks{background-color:#e3dfd6}
body.bevel .marker.fieldworks{border-color:#fffef5 #c3beb5 #c3beb5 #fffef5;box-shadow:0 0 0 1px #635e55}
-body.bevel .marker.fieldworks.highlight{box-shadow:0 0 0 1px #635e55,0 0 0 3px yellow}
-body.bevel .marker.fieldworks.selected{box-shadow:0 0 0 1px #635e55,0 0 0 3px crimson}
body.flat .marker.fieldworks{border-color:#635e55}
.unit.british{background-color:#eac99e}
body.bevel .unit.british{border-color:#ffe8bd #caa87d #caa87d #ffe8bd;box-shadow:0 0 0 1px #6a481d}
-body.bevel .unit.british.highlight{box-shadow:0 0 0 1px #6a481d,0 0 0 3px yellow}
-body.bevel .unit.british.selected{box-shadow:0 0 0 1px #6a481d,0 0 0 3px crimson}
body.flat .unit.british{border-color:#6a481d}
.marker.british_fort{background-color:#ef473e}
body.bevel .marker.british_fort{border-color:#ff665d #cf261d #cf261d #ff665d;box-shadow:0 0 0 1px #770000}
-body.bevel .marker.british_fort.highlight{box-shadow:0 0 0 1px #770000,0 0 0 3px yellow}
-body.bevel .marker.british_fort.selected{box-shadow:0 0 0 1px #770000,0 0 0 3px crimson}
body.flat .marker.british_fort{border-color:#770000}
.marker.british_fort_uc{background-color:#f15a4f}
body.bevel .marker.british_fort_uc{border-color:#ff796e #d1392e #d1392e #ff796e;box-shadow:0 0 0 1px #710000}
-body.bevel .marker.british_fort_uc.highlight{box-shadow:0 0 0 1px #710000,0 0 0 3px yellow}
-body.bevel .marker.british_fort_uc.selected{box-shadow:0 0 0 1px #710000,0 0 0 3px crimson}
body.flat .marker.british_fort_uc{border-color:#710000}
.unit.french{background-color:#aae0fa}
body.bevel .unit.french{border-color:#c9ffff #89c0da #89c0da #c9ffff;box-shadow:0 0 0 1px #29607a}
-body.bevel .unit.french.highlight{box-shadow:0 0 0 1px #29607a,0 0 0 3px yellow}
-body.bevel .unit.french.selected{box-shadow:0 0 0 1px #29607a,0 0 0 3px crimson}
body.flat .unit.french{border-color:#29607a}
.marker.french_fort{background-color:#007ec5}
body.bevel .marker.french_fort{border-color:#1f9ee5 #005ea5 #005ea5 #1f9ee5;box-shadow:0 0 0 1px #001d64}
-body.bevel .marker.french_fort.highlight{box-shadow:0 0 0 1px #001d64,0 0 0 3px yellow}
-body.bevel .marker.french_fort.selected{box-shadow:0 0 0 1px #001d64,0 0 0 3px crimson}
body.flat .marker.french_fort{border-color:#001d64}
.marker.french_fort_uc{background-color:#0093d6}
body.bevel .marker.french_fort_uc{border-color:#1fb3f6 #0073b6 #0073b6 #1fb3f6;box-shadow:0 0 0 1px #002467}
-body.bevel .marker.french_fort_uc.highlight{box-shadow:0 0 0 1px #002467,0 0 0 3px yellow}
-body.bevel .marker.french_fort_uc.selected{box-shadow:0 0 0 1px #002467,0 0 0 3px crimson}
body.flat .marker.french_fort_uc{border-color:#002467}
.marker.season_french_first{background-color:#0072bb}
body.bevel .marker.season_french_first{border-color:#1f92db #00529b #00529b #1f92db;box-shadow:0 0 0 1px #001963}
-body.bevel .marker.season_french_first.highlight{box-shadow:0 0 0 1px #001963,0 0 0 3px yellow}
-body.bevel .marker.season_french_first.selected{box-shadow:0 0 0 1px #001963,0 0 0 3px crimson}
body.flat .marker.season_french_first{border-color:#001963}
.marker.season_british_first{background-color:#da2127}
body.bevel .marker.season_british_first{border-color:#fa4046 #ba0006 #ba0006 #fa4046;box-shadow:0 0 0 1px #810000}
-body.bevel .marker.season_british_first.highlight{box-shadow:0 0 0 1px #810000,0 0 0 3px yellow}
-body.bevel .marker.season_british_first.selected{box-shadow:0 0 0 1px #810000,0 0 0 3px crimson}
body.flat .marker.season_british_first{border-color:#810000}
.marker.provincial_assemblies{background-color:#004892}
body.bevel .marker.provincial_assemblies{border-color:#1f68b2 #002872 #002872 #1f68b2;box-shadow:0 0 0 1px #000d57}
-body.bevel .marker.provincial_assemblies.highlight{box-shadow:0 0 0 1px #000d57,0 0 0 3px yellow}
-body.bevel .marker.provincial_assemblies.selected{box-shadow:0 0 0 1px #000d57,0 0 0 3px crimson}
body.flat .marker.provincial_assemblies{border-color:#000d57}
.marker.vps{background-color:#b4883d}
body.bevel .marker.vps{border-color:#d4a75c #94671c #94671c #d4a75c;box-shadow:0 0 0 1px #340700}
-body.bevel .marker.vps.highlight{box-shadow:0 0 0 1px #340700,0 0 0 3px yellow}
-body.bevel .marker.vps.selected{box-shadow:0 0 0 1px #340700,0 0 0 3px crimson}
body.flat .marker.vps{border-color:#340700}
+/* action highlight */
+body.bevel .leader.highlight{box-shadow:0 0 0 1px #707070,0 0 0 4px var(--highlight-color)}
+body.bevel .unit.british.highlight{box-shadow:0 0 0 1px #6a481d,0 0 0 4px var(--highlight-color)}
+body.bevel .unit.french.highlight{box-shadow:0 0 0 1px #29607a,0 0 0 4px var(--highlight-color)}
+
+/* selected */
+body.bevel .leader.selected{box-shadow:0 0 0 3px var(--selected-color)}
+body.bevel .unit.british.selected{box-shadow:0 0 0 3px var(--selected-color)}
+body.bevel .unit.french.selected{box-shadow:0 0 0 3px var(--selected-color)}
+
/* MOBILE PHONE LAYOUT */
@media (max-width: 640px) {
diff --git a/play.js b/play.js
index 920b31e..ca342df 100644
--- a/play.js
+++ b/play.js
@@ -138,6 +138,7 @@ function show_supply(supply) {
for (let s = 1; s <= last_space; ++s) {
spaces[s].element.classList.toggle("french_supply", supply.french.includes(s))
spaces[s].element.classList.toggle("british_supply", supply.british.includes(s))
+ spaces[s].element.classList.toggle("no_supply", !supply.british.includes(s) && !supply.french.includes(s))
}
}
@@ -147,6 +148,7 @@ function hide_supply() {
for (let s = 1; s <= last_space; ++s) {
spaces[s].element.classList.remove("french_supply")
spaces[s].element.classList.remove("british_supply")
+ spaces[s].element.classList.remove("no_supply")
}
}
}
@@ -884,17 +886,16 @@ function destroy_faction_marker(space_id, faction, what) {
function build_space(id) {
let space = spaces[id]
+
/* Make space for border */
let x = space.x
let y = space.y
let w = space.w
let h = space.h
- if (space.type === 'box') { x -= 1; y -= 1; w -= 9; h -= 9; }
- if (space.type === 'militia-box') { x -= 1; y -= 1; w -= 9; h -= 9; }
- if (space.type === 'cultivated') { x -= 1; y -= 1; w -= 9; h -= 9; }
- if (space.type === 'wilderness') { x -= 1; y -= 1; w -= 9; h -= 9; }
- if (space.type === 'leader-box') { x -= 1; y -= 1; w -= 9; h -= 9; }
+ if (space.type !== 'mountain') {
+ x -= 1; y -= 1; w += 2; h += 2;
+ }
space.fstack = []
space.fstack.name = spaces[id].name + "/french"
@@ -1014,17 +1015,17 @@ function is_different_piece(a, b) {
const style_dims = {
flat: {
width: 47,
- gap: 2,
+ gap: 3,
thresh: [ 24, 16, 10, 8, 6, 0 ],
offset: [ 1, 2, 3, 4, 5, 6 ],
- focus_margin: 5,
+ focus_margin: 6,
},
bevel: {
width: 49,
- gap: 4,
+ gap: 5,
thresh: [ 24, 16, 10, 8, 6, 0 ],
offset: [ 1, 2, 3, 4, 5, 6 ],
- focus_margin: 6,
+ focus_margin: 7,
},
}
@@ -1049,7 +1050,7 @@ function layout_stack(stack, x, y, dx) {
if (stack === focus && is_small_stack(stack))
focus = null
- if (stack === focus) {
+ if (stack === focus && layout < 2) {
let w, h
if (layout === 0) {
h = (dim.width + dim.gap) * (n-1)
@@ -1304,6 +1305,11 @@ function update_space(s) {
else
space.element.classList.remove("highlight")
+ if (view.danger && view.danger.includes(s))
+ space.element.classList.add("danger")
+ else
+ space.element.classList.remove("danger")
+
if (view.where === s)
space.element.classList.add("selected")
else
diff --git a/rules.js b/rules.js
index 575a055..fbb1b0e 100644
--- a/rules.js
+++ b/rules.js
@@ -1,5 +1,7 @@
"use strict"
+// TODO: "danger_space" action for moving into interception/battle
+
// WONTFIX
// TODO: select leader for defense instead of automatically picking the best
// TODO: remove old 7 command leader(s) immediately as they're drawn, before placing reinforcements
@@ -2961,6 +2963,40 @@ function has_friendly_fortifications_or_cultivated(s) {
return has_friendly_fortifications(s) || is_originally_friendly(s)
}
+function add_danger_space(s) {
+ if (!view.danger)
+ view.danger = []
+ set_add(view.danger, s)
+}
+
+// Check if this move may lead to intercept/battle/other loss of control that prevents undo
+function is_danger_move(from, to) {
+ // Lake Schooner
+ if (is_enemy_card_available(LAKE_SCHOONER))
+ if (has_enemy_fortifications(to) && is_lake_connection(from, to))
+ return true
+
+ // Battle (and interception if infiltrating)
+ if (has_unbesieged_enemy_units(to))
+ return true
+
+ // Retreat Lone Leader
+ if (has_unbesieged_enemy_leader(to))
+ return true
+
+ // Interception
+ if (can_be_intercepted(from, to))
+ return true
+
+ return false
+}
+
+function gen_action_move(from, to) {
+ if (is_danger_move(from, to))
+ add_danger_space(to)
+ gen_action_space(to)
+}
+
function gen_naval_move() {
let from = moving_piece_space()
if (!piece_can_naval_move_from(moving_piece(), from))
@@ -2968,19 +3004,19 @@ function gen_naval_move() {
if (game.active === BRITAIN) {
game.amphib.forEach(to => {
if (to !== from)
- gen_action_space(to)
+ gen_action_move(from, to)
})
ports.forEach(to => {
if (to !== from && !set_has(game.amphib, to))
if (is_friendly_controlled_space(to))
- gen_action_space(to)
+ gen_action_move(from, to)
})
}
if (game.active === FRANCE) {
if (from !== LOUISBOURG && is_friendly_controlled_space(LOUISBOURG))
- gen_action_space(LOUISBOURG)
+ gen_action_move(from, LOUISBOURG)
if (from !== QUEBEC && is_friendly_controlled_space(QUEBEC))
- gen_action_space(QUEBEC)
+ gen_action_move(from, QUEBEC)
}
}
@@ -3110,14 +3146,14 @@ function gen_regular_move() {
switch (game.move.type) {
case 'boat-or-land':
if (can_move_by_boat_or_land(game.move.used, game.move.did_carry, from, to))
- gen_action_space(to)
+ gen_action_move(from, to)
break
case 'boat':
if (can_move_by_boat(game.move.used, game.move.did_carry, from, to))
- gen_action_space(to)
+ gen_action_move(from, to)
break
case 'land':
- gen_action_space(to)
+ gen_action_move(from, to)
break
}
})
@@ -3572,12 +3608,12 @@ states.amphibious_landing = {
view.prompt = `Amphibious Landing: Select a destination for ${piece_name_and_place(who)}.`
view.who = who
if (from === HALIFAX) {
- gen_action_space(LOUISBOURG)
+ gen_action_move(from, LOUISBOURG)
}
if (from === LOUISBOURG) {
- gen_action_space(BAIE_ST_PAUL)
- gen_action_space(RIVIERE_OUELLE)
- gen_action_space(ILE_D_ORLEANS)
+ gen_action_move(from, BAIE_ST_PAUL)
+ gen_action_move(from, RIVIERE_OUELLE)
+ gen_action_move(from, ILE_D_ORLEANS)
}
},
space(to) {
@@ -3676,12 +3712,10 @@ function end_move() {
// INTERCEPT
-function can_be_intercepted() {
+function can_be_intercepted(came_from, here) {
let result = false
let who = moving_piece()
- let here = moving_piece_space()
- let came_from = moving_piece_came_from()
// 6.723 Leaders moving alone can NOT be intercepted
if (is_lone_leader(who))
@@ -3779,7 +3813,7 @@ function goto_intercept() {
}
}
- if (can_be_intercepted()) {
+ if (can_be_intercepted(moving_piece_came_from(), moving_piece_space())) {
game.move.intercepting = 0
set_active_enemy()
game.state = 'intercept_who'