summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
Diffstat (limited to 'play.js')
-rw-r--r--play.js165
1 files changed, 130 insertions, 35 deletions
diff --git a/play.js b/play.js
index d35e3d3..fbc92d4 100644
--- a/play.js
+++ b/play.js
@@ -4,6 +4,77 @@
global view, data, player, send_action, action_button, scroll_with_middle_mouse
*/
+const first_piece = data.first_piece
+const last_piece = data.last_piece
+
+// :r !python3 tools/genlayout.py
+const LAYOUT = {
+ "Andhra DS": [785, 1014],
+ "Andhra BK": [678, 1060],
+ "Andhra VE": [653, 1165],
+ "Andhra mongols": [748, 1215],
+ "Bengal DS": [1148, 455],
+ "Bengal BK": [1079, 536],
+ "Bengal VE": [1122, 626],
+ "Bengal mongols": [1209, 663],
+ "Gondwana DS": [992, 685],
+ "Gondwana BK": [848, 695],
+ "Gondwana VE": [864, 842],
+ "Gondwana mongols": [990, 743],
+ "Gujarat DS": [362, 611],
+ "Gujarat BK": [250, 601],
+ "Gujarat VE": [386, 723],
+ "Gujarat mongols": [134, 611],
+ "Jaunpur DS": [979, 422],
+ "Jaunpur BK": [788, 526],
+ "Jaunpur VE": [915, 586],
+ "Jaunpur mongols": [867, 385],
+ "Karnataka DS": [551, 1213],
+ "Karnataka BK": [651, 1298],
+ "Karnataka VE": [572, 1390],
+ "Karnataka mongols": [483, 1254],
+ "Madhyadesh DS": [724, 746],
+ "Madhyadesh BK": [571, 868],
+ "Madhyadesh VE": [653, 941],
+ "Madhyadesh mongols": [613, 770],
+ "Maharashtra DS": [465, 907],
+ "Maharashtra BK": [531, 997],
+ "Maharashtra VE": [525, 1084],
+ "Maharashtra mongols": [387, 900],
+ "Malwa DS": [682, 574],
+ "Malwa BK": [515, 623],
+ "Malwa VE": [511, 735],
+ "Malwa mongols": [537, 557],
+ "Orissa DS": [1168, 798],
+ "Orissa BK": [1082, 800],
+ "Orissa VE": [955, 929],
+ "Orissa mongols": [935, 991],
+ "Rajput Kingdoms DS": [427, 367],
+ "Rajput Kingdoms BK": [205, 483],
+ "Rajput Kingdoms VE": [433, 502],
+ "Rajput Kingdoms mongols": [229, 383],
+ "Sindh DS": [110, 327],
+ "Sindh BK": [40, 492],
+ "Sindh VE": [42, 544],
+ "Sindh mongols": [36, 344],
+ "Tamilakam DS": [756, 1338],
+ "Tamilakam BK": [648, 1478],
+ "Tamilakam VE": [657, 1543],
+ "Tamilakam mongols": [752, 1394],
+ "Delhi DS": [718, 316],
+ "Delhi BK": [571, 422],
+ "Delhi VE": [724, 414],
+ "Delhi mongols": [573, 324],
+ "Mountain Passes DS": [404, 106],
+ "Mountain Passes BK": [236, 110],
+ "Mountain Passes VE": [318, 105],
+ "Mountain Passes mongols": [263, 183],
+ "Punjab DS": [504, 170],
+ "Punjab BK": [279, 262],
+ "Punjab VE": [477, 266],
+ "Punjab mongols": [370, 233],
+}
+
/* COMMON */
function set_has(set, item) {
@@ -40,23 +111,6 @@ function map_get(map, key, missing) {
/* DATA */
-// Factions
-const DS = 0
-const BK = 1
-const VE = 2
-
-const NAME_DS = "DS"
-const NAME_BK = "BK"
-const NAME_VE = "VE"
-
-// Sequence of Play options
-const ELIGIBLE = 0
-const SOP_LIMITED_COMMAND = 1
-const SOP_COMMAND_DECREE = 2
-const SOP_EVENT_OR_COMMAND = 3
-const SOP_PASS = 4
-const INELIGIBLE = 5
-
// Spaces
const S_ANDHRA = 0
const S_BENGAL = 1
@@ -528,6 +582,18 @@ function init_ui() {
ui.pieces = []
+ create_piece_list(DS, DISC, "piece ds disc", -4, 10)
+ create_piece_list(DS, ELITE, "piece ds governor", 100, 100)
+ create_piece_list(DS, TROOPS, "piece ds cube", 0, 4)
+
+ create_piece_list(BK, DISC, "piece bk disc", -4, 10)
+ create_piece_list(BK, ELITE, "piece bk amir", 2, 0)
+
+ create_piece_list(VE, DISC, "piece ve disc", -4, 10)
+ create_piece_list(VE, ELITE, "piece ve raja", 2, 0)
+
+ create_piece_list(MI, TROOPS, "piece mongol cube", 2, 0)
+
return
/*
@@ -542,9 +608,7 @@ return
*/
- create_piece_list(DS, DISK, "piece ds disk", -4, 10)
- create_piece_list(DS, GOVERNOR, "piece ds governor", 0, 4)
- create_piece_list(DS, CUBE, "piece ds cube", 0, 4)
+
create_piece_list(BK, DISK, "piece ve disk", -4, 10)
create_piece_list(BK, AMIR, "piece ve amir", 2, 0)
@@ -552,7 +616,7 @@ return
create_piece_list(VE, DISK, "piece ve disk", -4, 10)
create_piece_list(VE, RAJA, "piece ve raja", 2, 0)
- create_piece_list(MONGOLS, CUBE, "piece mongol cube", 2, 0)
+ create_piece_list(MI, CUBE, "piece mongol cube", 2, 0)
}
/* UPDATE */
@@ -578,12 +642,10 @@ function action_menu(menu, action_list) {
const LAYOUT_CACHE = {
Center: [],
- Govt: [],
- FARC: [],
- AUC: [],
- Cartels: [],
- COIN: [],
- INSURGENTS: [],
+ DS: [],
+ BK: [],
+ VE: [],
+ mongols: [],
}
function get_layout_xy(s, f = "Center") {
@@ -606,7 +668,7 @@ function layout_available(faction, type, xorig, yorig) {
layout_pieces(list, xorig, yorig + 35, null, AVAILABLE)
}
-function layout_pieces(list, xorig, yorig, bases, shipments, s, faction) {
+function layout_pieces(list, xorig, yorig, discs, s) {
const dx = 17
const dy = 11
let off_x = 0
@@ -635,18 +697,18 @@ function layout_pieces(list, xorig, yorig, bases, shipments, s, faction) {
let ncol = Math.ceil(list.length / nrow)
let z = 50
let i = 0
- if ((s >= 0 && s <= last_city) || s >= first_loc) {
- off_x = (nrow - ncol) * 6
- off_y = (nrow - 1) * 8
- }
+ // if ((s >= 0 && s <= last_city) || s >= first_loc) {
+ // off_x = (nrow - ncol) * 6
+ // off_y = (nrow - 1) * 8
+ // }
for (let row = 0; row < nrow; ++row)
for (let col = 0; col < ncol; ++col)
if (i < list.length)
layout_piece_rowcol(nrow, ncol, row, col, list[list.length-(++i)], z--)
}
- if (bases)
- layout_dept_bases(bases, xorig + off_x, yorig + 12 + off_y, s)
+ // if (discs)
+ // layout_discs(discs, xorig + off_x, yorig + 12 + off_y, s)
}
function place_piece(p, x, y, z) {
@@ -659,7 +721,7 @@ function place_piece(p, x, y, z) {
p.my_z = z
}
-function layout_dept_bases(list, xc, yc, s) {
+function layout_discs(list, xc, yc, s) {
if (list.length === 1) {
place_piece(list[0], xc - 20 + 32, yc - 10, 52)
}
@@ -855,6 +917,39 @@ function on_update() {
layout_score()
+ let items = [ ]
+ let discs = [ ]
+ for (let s = 0; s < data.spaces.length; ++s) {
+ let xy
+
+ items.length = discs.length = 0
+ filter_piece_list(discs, s, DS, DISC)
+ filter_piece_list(items, s, DS, ELITE)
+ filter_piece_list(items, s, DS, TROOPS)
+ xy = get_layout_xy(s, "DS")
+ console.log(xy)
+ console.log(items)
+ layout_pieces(items, xy[0], xy[1], discs, DS)
+
+ items.length = discs.length = 0
+ filter_piece_list(discs, s, BK, DISC)
+ filter_piece_list(items, s, BK, ELITE)
+ xy = get_layout_xy(s, "BK")
+ layout_pieces(items, xy[0], xy[1], discs, BK)
+
+ items.length = discs.length = 0
+ filter_piece_list(discs, s, VE, DISC)
+ filter_piece_list(items, s, VE, ELITE)
+ xy = get_layout_xy(s, "VE")
+ layout_pieces(items, xy[0], xy[1], discs, VE)
+
+ items.length = discs.length = 0
+ filter_piece_list(items, s, MI, TROOPS)
+ xy = get_layout_xy(s, "mongols")
+ layout_pieces(items, xy[0], xy[1], discs, MI)
+
+ }
+
return
layout_sop()