diff options
author | teisuru <31881306+teisuru@users.noreply.github.com> | 2023-07-01 06:09:23 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-12-10 18:16:55 +0100 |
commit | eccd4d2712780542f9bf767fc02820ab3adc331d (patch) | |
tree | 857774ade72b7b1395ce328c6e30fc3428706007 | |
parent | 9c6d4931d437626a5a9b269c1c3e0afd1cf57abe (diff) | |
download | plantagenet-eccd4d2712780542f9bf767fc02820ab3adc331d.tar.gz |
track box creation
-rw-r--r-- | play.js | 144 | ||||
-rw-r--r-- | rules.js | 22 |
2 files changed, 105 insertions, 61 deletions
@@ -299,6 +299,7 @@ function max_plan_length() { case SUMMER: return 7 case WINTER: return 4 case SPRING: return 6 + case AUTUMN: return 6 } } @@ -445,56 +446,57 @@ const calendar_boxes = { "box16": [938,423,310,52], } -const track_boxes = [ - [22,1575,48,48], - [71,1575,47,48], - [118,1575,46,48], - [165,1575,46,48], - [211,1575,48,48], - [259,1575,47,48], - [306,1575,48,48], - [354,1575,47,48], - [401,1575,46,48], - [447,1575,47,48], - [494,1575,49,49], - [543,1575,47,49], - [590,1575,47,49], - [637,1575,48,49], - [685,1575,46,48], - [731,1575,48,48], - [779,1575,47,48], - [826,1575,48,48], - [873,1575,46,48], - [920,1575,48,48], - [968,1575,46,49], - [1014,1575,48,49], - [1062,1575,47,49], - [1109,1575,48,49], - [1157,1575,46,49], - [1203,1577,49,47], - [1203,1530,49,47], - [1203,1434,49,47], - [1203,1388,49,46], - [1203,1340,49,48], - [1203,1292,49,48], - [1203,1244,49,48], - [1203,1198,49,46], - [1203,1151,49,47], - [1203,1104,49,47], - [1203,1057,49,46], - [1203,1010,49,47], - [1203,960,49,50], - [1203,914,47,46], - [1203,865,47,48], - [1203,819,47,46], - [1203,774,51,45], - [1203,724,51,50], - [1203,676,51,48], - [1203,630,47,46], -] - -const track_xy = track_boxes.map(([x,y,w,h])=>[x+w/2,y+h/2]) - +const track_boxes = { + "track0": [22,1575,48,48], + "track1": [71,1575,47,48], + "track2": [118,1575,46,48], + "track3": [165,1575,46,48], + "track4": [211,1575,48,48], + "track5": [259,1575,47,48], + "track6": [306,1575,48,48], + "track7": [354,1575,47,48], + "track8": [401,1575,46,48], + "track9": [447,1575,47,48], + "track10": [494,1575,49,49], + "track11": [543,1575,47,49], + "track12": [590,1575,47,49], + "track13": [637,1575,48,49], + "track14": [685,1575,46,48], + "track15": [731,1575,48,48], + "track16": [779,1575,47,48], + "track17": [826,1575,48,48], + "track18": [873,1575,46,48], + "track19": [920,1575,48,48], + "track20": [968,1575,46,49], + "track21": [1014,1575,48,49], + "track22": [1062,1575,47,49], + "track23": [1109,1575,48,49], + "track24": [1157,1575,46,49], + "track25": [1203,1577,49,47], + "track26": [1203,1530,49,47], + "track27": [1203,1488,49,46], + "track28": [1203,1434,49,47], + "track29": [1203,1388,49,46], + "track30": [1203,1340,49,48], + "track31": [1203,1292,49,48], + "track32": [1203,1244,49,48], + "track33": [1203,1198,49,46], + "track34": [1203,1151,49,47], + "track35": [1203,1104,49,47], + "track36": [1203,1057,49,46], + "track37": [1203,1010,49,47], + "track38": [1203,960,49,50], + "track39": [1203,914,47,46], + "track40": [1203,865,47,48], + "track41": [1203,819,47,46], + "track42": [1203,774,51,45], + "track43": [1203,724,51,50], + "track44": [1203,676,51,48], + "track45": [1203,630,47,46], +} + + +const track_xy = [] const calendar_xy = [] const locale_xy = [] @@ -518,6 +520,7 @@ const ui = { lord_feed: [], cards: [], calendar: [], + track: [], plan_panel: document.getElementById("plan_panel"), plan: document.getElementById("plan"), @@ -711,6 +714,25 @@ function build_map() { for (let i = 1; i <= 16; ++i) register_action(ui.calendar[i], "calendar", i) + for (let i = 0; i <= 45; ++i) { + let name = "track" + i + let x = track_boxes[name][0] + let y = track_boxes[name][1] + let w = track_boxes[name][2] + let h = track_boxes[name][3] + track_xy[i] = [ x, y ] + let e = ui.track[i] = document.createElement("div") + e.className = "track box " + name + e.style.left = x + "px" + e.style.top = y + "px" + e.style.width = w + "px" + e.style.height = h + "px" + document.getElementById("boxes").appendChild(e) + } + + for (let i = 1; i <= 45; ++i) + register_action(ui.track[i], "track", i) + build_plan() for (let i = 0; i < 6; ++i) @@ -720,6 +742,7 @@ function build_map() { build_card("york", c) for (let c = first_lancaster_card; c <= last_lancaster_card; ++c) build_card("lancaster", c) + } // === UPDATE UI === @@ -861,6 +884,27 @@ function layout_calendar() { } } } +/* +function layout_track() { + for (let loc = 0; loc <= 45; ++loc) { + let [cx, cy] = track_xy[loc] + let list = track_layout[loc] + for (let i = 0; i < list.length; ++i) { + let e = list[i] + let x = cx, y = cy, z = 60 - i + let d = 46 - 24 + if (loc === expand_track) { + d = 46 + z += 100 + } + x += 10 + y += i * d + e.style.top = y + "px" + e.style.left = x + "px" + e.style.zIndex = z + } + } +}*/ function add_force(parent, type, lord, routed) { let elt @@ -348,6 +348,7 @@ const NOWHERE = -1 const NOTHING = -1 const NEVER = -1 const CALENDAR = 100 +const TRACK = 100 const SUMMER = 0 @@ -527,6 +528,11 @@ function add_spoils(type, n) { game.spoils[type] += n } +function set_item_on_track(item, track_value) { + if (track_value > 45) track_value = 45 + set_lord_locale(item, TRACK + track_value) +} + function get_lord_calendar(lord) { if (is_lord_on_calendar(lord)) return get_lord_locale(lord) - CALENDAR @@ -1381,6 +1387,7 @@ function setup_Ia(first_player, second_player) { set_lord_cylinder_on_calendar(LORD_SALISBURY, 2) set_lord_cylinder_on_calendar(LORD_WARWICK_Y, 3) set_lord_cylinder_on_calendar(LORD_RUTLAND, 5) + set_item_on_track() set_add(game.pieces.favourl, LOC_LONDON) set_add(game.pieces.favourl, LOC_WELLS) @@ -3120,7 +3127,6 @@ function take_spoils(type) { } function take_spoils_prov() { take_spoils(PROV) } -function take_spoils_coin() { take_spoils(COIN) } function take_spoils_cart() { take_spoils(CART) } function goto_spoils_after_avoid_battle() { @@ -3496,23 +3502,18 @@ function goto_forage() { // === ACTION: TAX === -function restore_mustered_forces(lord) { - muster_lord_forces(lord) - for (let v of data.lords[lord].vassals) - if (is_vassal_mustered(v)) - muster_vassal_forces(lord, v) -} - function can_action_tax() { if (game.actions < 1) return false + // Must have space left to hold Coin if (get_lord_assets(game.command, COIN) >= 8) return false - // Must be at own seat + // Must be at own seat TO BE REMOVED return is_lord_at_seat(game.command) + // TODO : Add deplete/exhaust } function goto_tax() { @@ -3527,7 +3528,7 @@ function goto_tax() { add_lord_assets(game.command, COIN, 2) else add_lord_assets(game.command, COIN, 3) - +// TODO : Add deplete/exhaust spend_action(1) resume_command() @@ -5916,7 +5917,6 @@ states.battle_spoils = { }, lord: action_select_lord, take_prov: take_spoils_prov, - take_coin: take_spoils_coin, take_cart: take_spoils_cart, end_spoils() { clear_undo() |