summaryrefslogtreecommitdiff
path: root/play.js
diff options
context:
space:
mode:
authorJoël Simoneau <simoneaujoel@gmail.com>2024-10-24 09:10:39 -0400
committerJoël Simoneau <simoneaujoel@gmail.com>2024-10-24 09:10:39 -0400
commit9e162f6ec4e9d215b84026f4f5de40a9abedb0f0 (patch)
tree4b24b1373dfb56af9797ff63fd3e3d210082ae94 /play.js
parent3654f1e6e0d9f3ce204c34ba8d090f23d30ee59d (diff)
downloadvijayanagara-9e162f6ec4e9d215b84026f4f5de40a9abedb0f0.tar.gz
Full setup and positioning
Diffstat (limited to 'play.js')
-rw-r--r--play.js107
1 files changed, 71 insertions, 36 deletions
diff --git a/play.js b/play.js
index ed1cc7f..2dd8d7f 100644
--- a/play.js
+++ b/play.js
@@ -73,6 +73,12 @@ const LAYOUT = {
"Punjab BK": [279, 262],
"Punjab VE": [477, 266],
"Punjab mongols": [370, 233],
+ "BK_DI_2" : [160 + 30, 1186 + 40],
+ "BK_DI_4" : [302 + 30, 1186 + 40],
+ "VE_DI_1" : [ 89 + 30, 1292 + 40],
+ "VE_DI_2" : [160 + 30, 1292 + 40],
+ "VE_DI_3" : [231 + 30, 1292 + 40],
+ "VE_DI_4" : [302 + 30, 1292 + 40],
}
/* COMMON */
@@ -139,6 +145,8 @@ const S_VE_INF_2 = 23
const S_VE_INF_3 = 24
const S_VE_INF_4 = 25
+const last_province = S_PUNJAB
+
const space_name = [
"Andhra",
"Bengal",
@@ -583,8 +591,8 @@ 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(DS, ELITE, "piece ds governor", 0, 0)
+ create_piece_list(DS, TROOPS, "piece ds cube", 0, 0)
create_piece_list(BK, DISC, "piece bk disc", -4, 10)
create_piece_list(BK, ELITE, "piece bk amir", 2, 0)
@@ -673,10 +681,6 @@ function layout_pieces(list, xorig, yorig, discs, s) {
const dy = 11
let off_x = 0
let off_y = 0
- let rotate = 0
-
- if (s >= 0)
- rotate = (data.spaces[s].type === "mountain") ? 1 : 0
function layout_piece_rowcol(nrow, ncol, row, col, e, z) {
// basic piece size = 29x36
@@ -697,10 +701,10 @@ function layout_pieces(list, xorig, yorig, discs, s) {
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_province) {
+ 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)
@@ -737,7 +741,7 @@ function layout_discs(list, xc, yc, s) {
}
}
-function layout_available_bases(list, x0, y0, cols, rows, dx, dy) {
+function layout_available_bases(list, x0, y0, rows, dx, dy) {
let x = x0
let y = y0
for (let i = 0; i < list.length; ++i) {
@@ -902,34 +906,65 @@ function on_update() {
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)
+ if (s <= last_province) {
+ 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")
+ 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)
+ } else if (s <= S_VE_AVAILABLE) {
+ // Nothing ?
+ } else if (s <= S_BK_INF_4) {
+ items.length = discs.length = 0
+ filter_piece_list(items, s, BK, ELITE)
+ xy = get_layout_xy(s)
+ layout_pieces(items, xy[0], xy[1], discs, BK)
+
+ } else if (s <= S_VE_INF_4) {
+ items.length = discs.length = 0
+ filter_piece_list(items, s, VE, ELITE)
+ xy = get_layout_xy(s)
+ layout_pieces(items, xy[0], xy[1], discs, VE)
+ }
}
+ items.length = 0
+ filter_piece_list(items, AVAILABLE, DS, DISC)
+ layout_available_bases(items, 1050, 250, 1, 45, 0)
+ layout_available(DS, TROOPS, 875, 200)
+ layout_available(DS, ELITE, 1075, 200)
+
+ items.length = 0
+ filter_piece_list(items, AVAILABLE, BK, DISC)
+ layout_available_bases(items, 258, 1060, 1, 45, 0)
+ layout_available(BK, ELITE, 135, 975)
+
+ items.length = 0
+ filter_piece_list(items, AVAILABLE, VE, DISC)
+ layout_available_bases(items, 258, 1560, 1, 45, 0)
+ layout_available(VE, ELITE, 135, 1475)
+
+ layout_available(MI, TROOPS, 100, 155)
+
layout_sop()
action_button("pass", "Pass")