From 111f2e18a351bb5c8439643378b8b5afb2447fe8 Mon Sep 17 00:00:00 2001 From: Joël Simoneau Date: Tue, 8 Apr 2025 17:32:25 -0400 Subject: Correcting placement --- play.js | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/play.js b/play.js index 4b3c4a3..e8d45ef 100644 --- a/play.js +++ b/play.js @@ -18,6 +18,7 @@ const faction_flags = [ ] // :r !python3 tools/genlayout.py +// modified const LAYOUT = { "Andhra DS": [785, 1014], "Andhra BK": [678, 1060], @@ -79,7 +80,7 @@ const LAYOUT = { "Mountain Passes BK": [236, 110], "Mountain Passes VE": [318, 105], "Mountain Passes mongols": [263, 183], - "Punjab DS": [504, 170], + "Punjab DS": [515, 164], "Punjab BK": [279, 262], "Punjab VE": [477, 266], "Punjab mongols": [370, 233], @@ -732,7 +733,7 @@ function layout_influence() { e.style.left = 25 + 71 * view.inf[VE] + "px" } -function layout_pieces(mains, xorig, yorig, discs, s, others) { +function layout_pieces(mains, xorig, yorig, discs, f, others) { const dx = 17 const dy = 11 let off_x = 0 @@ -757,10 +758,6 @@ function layout_pieces(mains, xorig, yorig, discs, s, others) { let ncol = Math.ceil(list.length / nrow) let z = 50 let i = 0 - 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) @@ -769,14 +766,12 @@ function layout_pieces(mains, xorig, yorig, discs, s, others) { if (mains.length > 0) { layout_p(mains) } - if (discs) - layout_discs(discs, xorig + off_x, yorig + 12 + off_y, s) + if (discs && discs.length > 0) + layout_discs(discs, xorig + off_x, yorig + 12 + off_y, f) if (others && others.length > 0) { - let nrow = Math.round(Math.sqrt(mains.length)) - let ncol = Math.ceil(mains.length / nrow) - console.log(nrow, ncol) - layout_p(others, 21 + 5*nrow, 17 + 9*ncol) + let nrow = Math.round(Math.sqrt(others.length)) + layout_p(others, 12 + nrow*12, 26) } } @@ -791,20 +786,9 @@ function place_piece(p, x, y, z) { p.my_z = z } -function layout_discs(list, xc, yc, s) { - if (list.length === 1) { - place_piece(list[0], xc - 20 - 32, yc - 10, 52) - } - if (list.length === 2) { - place_piece(list[0], xc - 20 + 18, yc - 0, 52) - place_piece(list[1], xc - 20 + 18 + 32, yc - 21, 51) - } - if (list.length === 3) { - // TODO - place_piece(list[0], xc - 20 + 18, yc - 0, 52) - place_piece(list[1], xc - 20 + 18 + 32, yc - 21, 51) - place_piece(list[2], xc - 20 + 18 + 32, yc - 21, 100) - } +function layout_discs(list, xc, yc, f) { + let x_corr = f === DS ? -32 : 32 + place_piece(list[0], xc - 20 + x_corr, yc - 10, 52) } function layout_available_bases(list, x0, y0, rows, dx, dy) { -- cgit v1.2.3