summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.js2
-rw-r--r--play.js12
-rw-r--r--rules.js264
3 files changed, 243 insertions, 35 deletions
diff --git a/data.js b/data.js
index 1d777c7..fab4aa3 100644
--- a/data.js
+++ b/data.js
@@ -4,6 +4,8 @@
const data = {}
data.map = {
+ rows: 31,
+ cols: 42,
roads: [[1007,1006,1105,1104,1204],[1007,1107,1207],[1012,1112],[1012,1111],[1018,1019,1020],[1018,1117],[1022,1023],[1022,1121],[1023,1024],[1100,1000],[1100,1201],[1109,1009],[1109,1110,1111],[1109,1209],[1111,1011],[1111,1112],[1111,1211,1311,1411,1511],[1112,1113,1214,1314],[1117,1218],[1117,1017],[1117,1116,1216,1215],[1118,1119,1220],[1118,1219,1318],[1118,1218],[1121,1221],[1129,1029],[1129,1128,1127,1027,1026,1126,1226,1227,1327],[1129,1130],[1130,1030],[1130,1031,1131],[1130,1231],[1131,1032,1033,1034,1134],[1131,1232,1233,1332,1333],[1131,1231],[1134,1035,1135],[1135,1036],[1135,1235,1335,1435,1434],[1201,1200],[1201,1202,1302],[1201,1301],[1204,1203,1302],[1204,1304],[1207,1206,1305,1304],[1207,1208,1209],[1209,1309,1410],[1215,1115,1015],[1215,1314],[1217,1218],[1217,1317],[1217,1316],[1220,1221],[1220,1319],[1221,1321,1422,1423,1522,1622],[1231,1330,1430,1529,1528,1428,1327],[1301,1302],[1301,1402,1403,1503],[1301,1401],[1302,1303,1404,1405],[1304,1405],[1314,1315,1316],[1314,1415,1416],[1314,1414,1514],[1316,1416],[1317,1318],[1317,1417],[1318,1319],[1318,1419],[1319,1419],[1327,1427,1526],[1333,1434],[1333,1433],[1340,1339,1239],[1340,1341,1441,1440],[1340,1440],[1401,1400],[1401,1500,1601],[1405,1406,1407],[1405,1505,1506],[1407,1408],[1407,1506],[1408,1409,1410],[1408,1508,1609,1708],[1416,1417],[1416,1516],[1417,1418,1419],[1417,1516],[1419,1420,1520],[1419,1518],[1434,1534,1635,1636,1736,1737],[1440,1539,1639,1738,1737],[1506,1607],[1511,1612],[1514,1513,1512,1612],[1514,1515,1516],[1514,1614,1713],[1516,1517,1518],[1516,1617,1716],[1518,1618],[1520,1521,1622],[1520,1621,1721],[1601,1602,1603],[1601,1701,1802],[1607,1608,1708],[1607,1707,1807,1906],[1612,1613,1713],[1612,1711,1812],[1618,1619,1719,1720],[1618,1717],[1622,1623],[1622,1721],[1623,1723,1724,1725],[1623,1722,1823,1922],[1708,1709],[1708,1809,1908],[1709,1610],[1709,1710,1811,1812],[1709,1810,1909],[1713,1714,1815,1915],[1713,1813],[1716,1717],[1716,1817,1917],[1717,1718,1819,1820],[1720,1721],[1720,1821],[1720,1820],[1721,1822,1922],[1725,1726,1727,1728],[1725,1825,1925],[1728,1729,1830],[1728,1828,1927],[1737,1838],[1737,1837,1836],[1801,1800],[1801,1802],[1801,1901,2001],[1802,1803,1903],[1806,1705,1605],[1806,1906],[1806,1905],[1812,1813],[1812,1911],[1813,1913,1914],[1813,1912,1911],[1820,1821],[1820,1919],[1821,1921,1922],[1830,1730,1631,1731,1732,1833],[1830,1831,1931],[1830,1929],[1833,1834,1835,1836],[1833,1932],[1836,1935,2035],[1838,1938,1939,2039,2139,2240,2339],[1838,1937,2037,2136,2236],[1903,1904,1905],[1903,2003,2103,2203],[1905,1805,1704],[1905,1906],[1906,1907,1908],[1906,2007,2107,2208,2308],[1908,1909],[1908,2009,2109,2210,2309,2410,2509],[1909,1910,1911],[1914,1915],[1914,2015],[1915,1916,1917],[1915,2015],[1917,1918,1919],[1917,2018],[1919,1920,2021,2121,2222],[1919,2019],[1922,1923,1924,1925],[1922,2023,2122],[1925,1926,1927],[1925,2026],[1927,1928,1929],[1927,2027],[1929,2030],[1931,1932],[1931,2031,2030],[1932,2033],[2001,2000],[2001,2101,2202,2203],[2001,2100,2200,2300,2400,2500],[2015,2016,2017,2117],[2015,2114,2215,2314,2414,2513,2613],[2018,2019],[2018,2117],[2019,2119,2219],[2026,2027],[2026,2125,2225],[2027,2127,2228],[2030,2129],[2035,2135,2236],[2117,2118,2219],[2117,2218,2317],[2122,2123,2224,2225],[2122,2222],[2129,2128,2228],[2129,2230,2329],[2133,2234,2333,2434,2534],[2133,2233,2332,2432,2431],[2203,2303,2404],[2203,2302,2403,2502],[2219,2220,2320,2321],[2219,2319,2420,2519],[2222,2223],[2222,2322],[2222,2321],[2223,2323],[2223,2322],[2225,2226],[2225,2324],[2226,2227,2228],[2226,2326,2427],[2236,2237,2337],[2236,2336],[2307,2308],[2307,2407,2406,2405],[2308,2409,2509],[2317,2316,2315,2415,2514,2615,2714],[2317,2418],[2321,2322],[2321,2421],[2322,2323],[2322,2423],[2322,2422,2421],[2323,2324],[2324,2325,2425],[2329,2328,2327,2427],[2329,2430],[2336,2337],[2336,2436],[2337,2438],[2339,2340,2441,2541],[2339,2440],[2404,2405],[2404,2504],[2405,2504],[2418,2518,2619],[2418,2517,2618],[2421,2521,2522],[2421,2520,2519],[2423,2424,2425],[2423,2522],[2425,2525,2526],[2427,2527,2628],[2430,2431],[2430,2530],[2430,2529],[2431,2530],[2436,2536],[2436,2535,2534],[2437,2438],[2437,2537,2638,2639,2739,2840],[2437,2536],[2438,2439,2440],[2440,2539,2640],[2500,2501,2502],[2500,2601],[2502,2503],[2502,2603,2702],[2503,2504],[2503,2604],[2509,2610],[2519,2620,2621,2721],[2519,2619],[2522,2623,2723],[2526,2627,2628],[2526,2626],[2529,2530],[2529,2630,2730],[2530,2531,2632,2633,2733],[2534,2635],[2534,2634,2733],[2536,2636],[2601,2701],[2601,2700],[2604,2605],[2604,2704],[2605,2606,2607,2608,2609],[2605,2705,2805,2806,2906,3007],[2605,2704],[2609,2610],[2609,2708,2809,2810],[2610,2710],[2613,2713,2714],[2613,2712,2812,2911],[2618,2619],[2619,2719,2720,2721],[2626,2726,2827],[2626,2725,2825],[2628,2728,2729],[2635,2636],[2635,2735,2836],[2636,2736,2836],[2640,2740,2840],[2701,2702],[2701,2802],[2702,2703,2704],[2702,2803,2903,3004],[2702,2802],[2710,2811,2911],[2710,2810],[2714,2715],[2715,2716],[2715,2815,2814,2913],[2721,2722,2823,2723],[2723,2724,2825],[2729,2830,2930],[2729,2829],[2730,2731,2732,2733],[2730,2831],[2733,2834,2835,2935],[2733,2833,2932],[2802,2902],[2810,2909],[2818,2819,2919,3020,3120],[2818,2917,3018],[2825,2826,2827],[2825,2925,3026,3125],[2827,2828],[2828,2829],[2829,2928],[2831,2832,2932],[2831,2930],[2836,2935],[2840,2940,3040,3140],[2840,2939,3039],[2902,2901,2801,2800],[2902,3002],[2909,2910,2911],[2909,3009,3008],[2911,2912,2913],[2911,3012],[2911,3011,3111,3211,3311],[2913,2914,2915,2916,3017],[2928,3028],[2930,2931,2932],[2930,3030],[2932,2933,2934,3035],[2932,3033,3133,3234],[2935,2936,2937,3038],[2935,3036],[3001,3000],[3001,3002],[3001,3101,3202],[3001,3100,3200],[3002,3003],[3002,3102,3203],[3003,3004],[3003,3103],[3004,3005,3006,3007],[3007,3008],[3007,3106,3107,3208],[3008,3108,3208],[3012,3013,3113,3114,3215,3216],[3012,3112,3213,3313],[3017,3018],[3017,3117],[3018,3019,3119,3120],[3018,3117],[3028,3127],[3030,3031,3130,3231],[3030,3129],[3035,3036],[3035,3135],[3036,3037],[3037,3038],[3037,3137,3138],[3037,3136,3135],[3038,3039],[3039,3138],[3103,3204,3304],[3103,3203],[3117,3116,3216],[3120,3121,3022,3122,3123,3024,3124,3125],[3125,3126,3127],[3125,3226,3326],[3127,3227,3326],[3129,3230,3231],[3129,3229,3228],[3135,3134,3234],[3135,3236,3237,3337],[3138,3139,3140],[3138,3238,3337],[3140,3241],[3140,3240,3339],[3202,3203],[3202,3302],[3202,3301],[3203,3303],[3208,3308,3408],[3216,3316],[3228,3328,3428],[3228,3327],[3231,3232,3233,3333],[3231,3331,3432,3532],[3234,3334,3435,3436],[3234,3333],[3301,3300],[3301,3302],[3301,3402],[3302,3303],[3302,3402],[3303,3304],[3303,3404],[3304,3305,3206,3306,3407,3408],[3304,3405,3505],[3311,3412],[3311,3411],[3313,3414,3514,3615],[3313,3413],[3316,3417,3418,3419,3319,3320,3321,3422,3423,3523,3524,3525,3526],[3316,3416,3515],[3326,3327],[3326,3426,3526],[3327,3428],[3333,3434,3433,3532],[3337,3336,3436],[3337,3338],[3338,3339],[3338,3438],[3339,3440,3540],[3339,3439,3539],[3402,3502,3603],[3402,3501,3602,3701,3801],[3404,3504,3605],[3404,3503,3603],[3408,3507,3608],[3411,3410],[3411,3511,3512],[3411,3510,3509],[3412,3413],[3412,3512],[3413,3513,3614],[3428,3528,3628,3728],[3436,3535],[3505,3606,3607,3608],[3505,3605],[3509,3609,3708],[3512,3613],[3515,3516,3617,3717,3718],[3515,3616],[3526,3626,3725],[3532,3531,3631,3630,3729],[3532,3633],[3535,3636],[3535,3635],[3539,3540],[3539,3640,3740,3841],[3540,3441],[3540,3541],[3603,3703,3804],[3605,3705],[3608,3708],[3613,3614],[3613,3713],[3614,3615],[3614,3713],[3615,3616],[3615,3715],[3616,3715],[3633,3634,3635],[3633,3732,3731],[3635,3636],[3635,3734,3834,3933,4034,3934,3935],[3636,3736,3836,3935],[3705,3704,3804],[3705,3805,3905],[3708,3709,3710,3711],[3708,3808],[3711,3812,3813],[3711,3811,3911,4012],[3713,3712,3813],[3713,3814],[3715,3714,3814],[3715,3816,3817,3917],[3715,3815,3915],[3718,3819],[3718,3818],[3722,3721,3720,3719,3819],[3722,3723],[3722,3822,3921,4022],[3723,3724,3825,3925],[3723,3824,3924,3925],[3728,3729],[3728,3828],[3729,3730,3731],[3729,3829],[3731,3832,3932,4032],[3801,3700],[3801,3802],[3802,3803,3903],[3802,3901,3900],[3804,3903],[3808,3908,4008],[3808,3907,3906,4006],[3813,3814],[3814,3914,3915],[3814,3913,4014],[3818,3917],[3819,3919],[3828,3827],[3828,3829],[3828,3927,4028],[3829,3929,4029],[3841,3840,3939,3938,4038,4037,3936,3935],[3841,3940,4041],[3900,4001],[3900,4000],[3903,3904,4005],[3903,4003,4002],[3905,4006],[3905,4005],[3915,4015],[3917,4018,4019,3919],[3917,4017,4016],[3919,4020],[3925,4026],[3925,4025],[3935,4036],[4005,4006],[1603,1604,1704],[1503,1604,1605],[1221,1120,1020],[1121,1120,1021],[1410,1510,1610],[1410,1510,1511],[2035,2034,2033],[2035,2034,2133],[2529,2629,2628],[2529,2629,2729],[2618,2717,2818],[2618,2717,2716],[3129,3029,2928],[3129,3029,3028],[3408,3409,3410],[3408,3409,3509],[3925,3826,3827],[3925,3826,3725]],
rivers: [[1012,1013],[1013,1113],[1013,1112],[1014,1113],[1018,1118],[1019,1119],[1019,1118],[1020,1119],[1038,1039],[1039,1138],[1113,1114],[1114,1214],[1116,1217],[1117,1118],[1117,1218],[1117,1217],[1119,1120],[1120,1221],[1120,1220],[1121,1221],[1138,1139],[1138,1239],[1214,1215],[1215,1315],[1215,1314],[1216,1217],[1216,1316],[1216,1315],[1221,1222],[1222,1322],[1222,1321],[1223,1323],[1223,1322],[1238,1239],[1238,1338],[1323,1324],[1323,1424],[1324,1425],[1325,1425],[1337,1338],[1337,1438],[1423,1424],[1423,1523],[1424,1425],[1424,1524],[1425,1426],[1426,1525],[1427,1527],[1428,1527],[1430,1530],[1431,1530],[1432,1532],[1433,1532],[1437,1438],[1437,1537],[1522,1523],[1523,1524],[1523,1624],[1523,1623],[1525,1526],[1525,1626],[1526,1527],[1526,1627],[1527,1528],[1528,1629],[1528,1628],[1529,1530],[1529,1629],[1530,1531],[1530,1630],[1531,1532],[1531,1632],[1531,1631],[1532,1533],[1533,1634],[1533,1633],[1534,1634],[1536,1537],[1537,1637],[1625,1626],[1626,1627],[1626,1726],[1626,1725],[1628,1629],[1629,1630],[1630,1631],[1630,1730],[1630,1729],[1634,1635],[1635,1735],[1635,1734],[1636,1735],[1637,1638],[1637,1737],[1638,1737],[1735,1736],[1736,1737],[1736,1837],[1736,1836],[1737,1738],[1738,1839],[1738,1838],[1739,1840],[1739,1839],[1740,1840],[1840,1841],[1841,1941],[1841,1940]],
bridges: [[1117,1218],[1121,1221],[1215,1314],[1736,1737],[1737,1738],[1221,1120]],
diff --git a/play.js b/play.js
index 2ccc276..c269c8e 100644
--- a/play.js
+++ b/play.js
@@ -3,8 +3,6 @@
const last_corps = 22
const piece_count = 39
-const map_w = 42
-const map_h = 31
const first_hex = 1000
const last_hex = 4041
@@ -108,8 +106,8 @@ function build_hexes() {
let hex_dy = 68
let hex_r = 62 >> 1
- for (let y = 0; y < map_h; ++y) {
- for (let x = 0; x < map_w; ++x) {
+ for (let y = 0; y < data.map.rows; ++y) {
+ for (let x = 0; x < data.map.cols; ++x) {
let hex_id = first_hex + 100 * y + x
let hex_x = ui.hex_x[hex_id] = Math.floor(xoff + hex_dx * (x + (y & 1) * 0.5 + 0.5))
let hex_y = ui.hex_y[hex_id] = Math.floor(yoff - hex_dy * 3 / 4 * y + hex_dy/2)
@@ -170,8 +168,8 @@ function find_hex_side(a, b) {
function on_update() {
ui.stack.fill(0)
- for (let row = 0; row < map_h; ++row) {
- for (let col = 0; col < map_w; ++col) {
+ for (let row = 0; row < data.map.rows; ++row) {
+ for (let col = 0; col < data.map.cols; ++col) {
let id = first_hex + row * 100 + col
ui.hexes[id].classList.toggle("action", is_action("hex", id))
}
@@ -181,7 +179,7 @@ function on_update() {
let hex = view.pieces[id]
if (hex >= first_hex) {
ui.pieces[id].classList.remove("hide")
- ui.pieces[id].classList.toggle("flip", !!view.flip[id])
+ ui.pieces[id].classList.toggle("flip", !!view.mode[id])
let x = ui.hex_x[hex] - ui.stack[hex] * 18
let y = ui.hex_y[hex] + ui.stack[hex] * 12
ui.stack[hex] += 1
diff --git a/rules.js b/rules.js
index 4732d8b..92ea536 100644
--- a/rules.js
+++ b/rules.js
@@ -3,7 +3,11 @@
const FRENCH = "French"
const COALITION = "Coalition"
-exports.roles = [ FRENCH, COALITION ]
+const P1 = FRENCH
+const P2 = COALITION
+
+exports.roles = [ P1, P2 ]
+
exports.scenarios = [ "June 16-18", "June 15-18" ]
const data = require("./data")
@@ -16,25 +20,99 @@ const OPEN = 0
const TOWN = 1
const STREAM = 2
-const DET_OLD_GUARD = 25
-const DET_GRAND_BATTERY = 28
-
-const first_hq = 0
-const last_hq = 4
-const first_french_corps = 5
-const last_french_corps = 12
-const first_anglo_corps = 13
-const last_anglo_corps = 17
-const first_prussian_corps = 18
-const last_prussian_corps = 22
-const last_corps = 22
-const first_french_detachment = 23
-const last_french_detachment = 28
-const first_anglo_detachment = 29
-const last_anglo_detachment = 32
-const first_prussian_detachment = 33
-const last_prussian_detachment = 38
-const piece_count = data.pieces.length
+const OLD_GUARD = 25
+const GRAND_BATTERY = 28
+
+function make_piece_list(f) {
+ let list = []
+ for (let p = 0; p < data.pieces.length; ++p)
+ if (f(data.pieces[p]))
+ list.push(p)
+ return list
+}
+
+const p1_hqs = make_piece_list(p => p.side === P1 && p.type === "hq")
+const p2_hqs = make_piece_list(p => p.side !== P1 && p.type === "hq")
+const p1_cav = make_piece_list(p => p.side === P1 && p.type === "cav")
+const p2_cav = make_piece_list(p => p.side !== P1 && p.type === "cav")
+const p1_inf = make_piece_list(p => p.side === P1 && p.type === "inf")
+const p2_inf = make_piece_list(p => p.side !== P1 && p.type === "inf")
+const p1_det = make_piece_list(p => p.side === P1 && p.type === "det")
+const p2_det = make_piece_list(p => p.side !== P1 && p.type === "det")
+const p1_corps = make_piece_list(p => p.side === P1 && (p.type === "inf" || p.type === "cav"))
+const p2_corps = make_piece_list(p => p.side !== P1 && (p.type === "inf" || p.type === "cav"))
+const p1_units = make_piece_list(p => p.side === P1 && (p.type === "inf" || p.type === "cav" || p.type === "det"))
+const p2_units = make_piece_list(p => p.side !== P1 && (p.type === "inf" || p.type === "cav" || p.type === "det"))
+
+function friendly_hqs() { return (game.active === P1) ? p1_hqs : p2_hqs }
+function enemy_hqs() { return (game.active !== P1) ? p1_hqs : p2_hqs }
+function friendly_cavalry_corps() { return (game.active === P1) ? p1_cav : p2_cav }
+function enemy_cavalry_corps() { return (game.active !== P1) ? p1_cav : p2_cavalry_corps }
+function friendly_infantry_corps() { return (game.active === P1) ? p1_inf : p2_inf }
+function enemy_infantry_corps() { return (game.active !== P1) ? p1_inf : p2_inf }
+function friendly_detachments() { return (game.active === P1) ? p1_det : p2_det }
+function enemy_detachments() { return (game.active !== P1) ? p1_det : p2_det }
+function friendly_corps() { return (game.active === P1) ? p1_corps : p2_corps }
+function enemy_corps() { return (game.active !== P1) ? p1_corps : p2_corps }
+function friendly_units() { return (game.active === P1) ? p1_units : p2_units }
+function enemy_units() { return (game.active !== P1) ? p1_units : p2_units }
+
+function set_piece_hex(p, hex) {
+ game.hex[p] = hex
+}
+
+function set_piece_mode(p, mode) {
+ game.mode[p] = mode
+}
+
+function piece_hex(p) {
+ return game.hex[p]
+}
+
+function piece_mode(p) {
+ return game.mode[p]
+}
+
+// === ZONE OF CONTROL / INFLUENCE ===
+
+var zoc_valid = false
+var p1_zoc = new Array(data.map.rows * 100).fill(0)
+var p1_zoi = new Array(data.map.rows * 100).fill(0)
+var p2_zoc = new Array(data.map.rows * 100).fill(0)
+var p2_zoi = new Array(data.map.rows * 100).fill(0)
+
+function is_friendly_zoc(x) { return game.active === P1 ? p1_zoc[x] : p2_zoc[x] }
+function is_friendly_zoi(x) { return game.active === P1 ? p1_zoi[x] : p2_zoi[x] }
+function is_enemy_zoc(x) { return game.active !== P1 ? p1_zoc[x] : p2_zoc[x] }
+function is_enemy_zoi(x) { return game.active !== P1 ? p1_zoi[x] : p2_zoi[x] }
+
+function update_zoc_imp(zoc, zoi, units) {
+ zoc.fill(0)
+ zoi.fill(0)
+ for (let p of units) {
+ for_each_adjacent(piece_hex(p), x => {
+ // TODO: river
+ zoc[x - 1000] = 1
+ for_each_adjacent(x, y => {
+ // TODO: bridge
+ zoi[y - 1000] = 1
+ })
+ })
+ }
+}
+
+function update_zoc() {
+ if (!zoc_valid) {
+ zoc_valid = true
+ update_zoc_imp(p1_zoc, p1_zoi, p1_units)
+ update_zoc_imp(p2_zoc, p2_zoi, p2_units)
+ }
+}
+
+function is_not_in_enemy_zoc_or_zoi(p) {
+ let x = piece_hex(p)
+ return !is_enemy_zoc(x) && !is_enemy_zoi(x)
+}
function is_map_hex(row, col) {
return row >= 10 && row <= 40 && col >= 0 && col <= 41
@@ -84,6 +162,134 @@ function for_each_adjacent(hex, fn) {
}
}
+function prompt(str) {
+ view.prompt = str
+}
+
+// === === COMMAND PHASE === ===
+
+function goto_command_phase() {
+ log("Command Phase")
+ log("")
+ goto_hq_placement_step()
+}
+
+function goto_hq_placement_step() {
+ game.active = P1
+ game.state = "hq_placement_step"
+}
+
+function goto_blown_unit_return_step() {
+ game.active = P1
+ game.state = "blown_unit_return_step"
+ game.count = 2
+}
+
+function end_blown_unit_return_step() {
+ if (game.active === P1) {
+ game.active = P2
+ game.count = 2
+ } else {
+ goto_cavalry_corps_recovery_step()
+ }
+}
+
+function goto_cavalry_corps_recovery_step() {
+ game.active = P1
+ game.state = "cavalry_corps_recovery_step"
+ resume_cavalry_corps_recovery_step()
+}
+
+function resume_cavalry_corps_recovery_step() {
+ update_zoc()
+ for (let p of friendly_cavalry_corps())
+ if (is_not_in_enemy_zoc_or_zoi(p))
+ return
+ end_cavalry_corps_recovery_step()
+}
+
+function end_cavalry_corps_recovery_step() {
+ if (game.active === P1) {
+ game.active = P2
+ resume_cavalry_corps_recovery_step()
+ } else {
+ goto_detachment_placement_step()
+ }
+}
+
+function goto_detachment_placement_step() {
+ game.active = P1
+ game.state = "detachment_placement_step"
+ game.count = 0
+}
+
+function end_detachment_placement_step() {
+ if (game.active === P1) {
+ game.active = P2
+ game.count = 0
+ } else {
+ goto_detachment_recall_step()
+ }
+}
+
+function goto_detachment_recall_step() {
+ game.active = P1
+ game.state = "detachment_recall_step"
+}
+
+function end_detachment_recall_step() {
+ if (game.active === P1) {
+ game.active = P2
+ } else {
+ goto_british_line_of_communication_angst()
+ }
+}
+
+function goto_british_line_of_communication_angst() {
+ game.active = P2
+ game.state = "british_line_of_communication_angst"
+}
+
+/*
+
+command phase:
+
+ remove hq
+ place hq
+ return up to 2 blown corps
+ flip exhausted cav to fresh (move to organization?)
+ place 1 detachment per hq
+ recall all, some, or no detachments
+ angst: substitute Hill unit
+
+organization
+ advance formation: flip infantry corps to advance
+ battle formation: flip infantry corps to battle
+ alternate withdrawal: retreat or pass (3 remain)
+
+movement
+ alternate corps movement: move corps or pass
+
+attack
+ alternate corps to attack in zoc or pass
+
+end phase
+ if last turn - victory
+ recall french grand battery
+ new turn
+
+*/
+
+
+// === A: HQ PLACEMENT STEP ===
+
+
+states.hq_placement_step = {
+ prompt() {
+ prompt("HQ Placement")
+ },
+}
+
states.setup = {
prompt() {
},
@@ -97,12 +303,12 @@ states.edit_town = {
// === SETUP ===
-function setup_piece(side, name, hex, flip = 0) {
+function setup_piece(side, name, hex, mode = 0) {
let id = data.pieces.findIndex(pc => pc.side === side && pc.name === name)
if (id < 0)
throw new Error("INVALID PIECE NAME: " + name)
- game.pieces[id] = hex
- game.flip[id] = flip
+ set_piece_hex(id, hex)
+ set_piece_mode(id, mode)
}
exports.setup = function (seed, scenario, options) {
@@ -111,12 +317,12 @@ exports.setup = function (seed, scenario, options) {
scenario,
undo: [],
log: [],
- active: FRENCH,
+ active: P1,
+ state: null,
turn: 3,
pieces: new Array(piece_count).fill(0),
- flip: new Array(piece_count).fill(0),
+ mode: new Array(piece_count).fill(0),
remain: 0,
- state: "setup",
}
setup("French", "Napoleon HQ", 1217)
@@ -148,6 +354,8 @@ exports.setup = function (seed, scenario, options) {
setup("Prussian", "IV Corps (Bulow)", 3)
setup("Prussian", "I Detachment (Lutzow)", 1623)
+ goto_command_phase()
+
return game
}
@@ -158,8 +366,8 @@ exports.view = function (state, player) {
prompt: null,
actions: null,
log: game.log,
- pieces: game.pieces,
- flip: game.flip,
+ hex: game.hex,
+ mode: game.mode,
}
if (game.state === "game_over") {