diff options
Diffstat (limited to 'play.js')
-rw-r--r-- | play.js | 73 |
1 files changed, 45 insertions, 28 deletions
@@ -1,10 +1,13 @@ "use strict" // TODO: battle dialog popup for rolling and assigning hits! -// TODO: move barbarian dice to current homeland +// TODO: show killed leaders taken for bonus purchase // === SYNC with rules.js === +const LEGION_COUNT = 33 +const BARBARIAN_COUNT = 53 + const CARD_M1 = [ 0, 11 ] const CARD_S1 = [ 12, 23 ] const CARD_P1 = [ 24, 35 ] @@ -77,6 +80,12 @@ const BRITANNIA = 9 const GALATIA = 10 const SYRIA = 11 +const ALAMANNI = 0 +const FRANKS = 1 +const GOTHS = 2 +const NOMADS = 3 +const SASSANIDS = 4 + const ALAMANNI_HOMELAND = 12 const FRANKS_HOMELAND = 13 const GOTHS_HOMELAND = 14 @@ -93,13 +102,15 @@ const UNAVAILABLE = 22 const ARMY = 23 -const TRIBE_COUNT = [ 0, 5, 3, 4, 5 ] -const BARBARIAN_COUNT = [ 0, 50, 30, 40, 50 ] -const first_barbarian = [ 0, 10, 20, 30, 40 ] -const last_barbarian = [ 9, 19, 29, 39, 49 ] +const first_barbarian = [ 0, 10, 20, 31, 41 ] +const last_barbarian = [ 9, 19, 30, 40, 52 ] const first_governor = [ 0, 6, 12, 18 ] const first_general = [ 0, 6, 12, 18 ] +const CNIVA = first_barbarian[GOTHS] + 0 +const ARDASHIR = first_barbarian[SASSANIDS] + 0 +const SHAPUR = first_barbarian[SASSANIDS] + 1 + const REGION_NAME = [ "Italia", "Asia", @@ -740,7 +751,7 @@ function on_init() { ui.event_cards[e] = create("div", { className: "card event event_" + e }) } - for (let i = 0; i < 33; ++i) + for (let i = 0; i < LEGION_COUNT; ++i) ui.legions[i] = create_piece(i, "legion", "legion", "legion_" + i) for (let p = 0; p < 4; ++p) { @@ -754,10 +765,6 @@ function on_init() { } } - ui.barbarian_leaders[0] = create_piece(0, "barbarian_leader", "goths", "cniva") - ui.barbarian_leaders[1] = create_piece(1, "barbarian_leader", "sassanids", "ardashir") - ui.barbarian_leaders[2] = create_piece(2, "barbarian_leader", "sassanids", "shapur") - ui.rival_emperors[0] = create_piece(0, "rival_emperor", "rival_emperor", "postumus") ui.rival_emperors[1] = create_piece(1, "rival_emperor", "rival_emperor", "priest_king") ui.rival_emperors[2] = create_piece(2, "rival_emperor", "rival_emperor", "zenobia") @@ -766,6 +773,10 @@ function on_init() { for (let id = first_barbarian[tribe]; id <= last_barbarian[tribe]; ++id) ui.barbarians[id] = create_piece(id, "barbarian", BARBARIAN_CLASS[tribe]) + ui.barbarians[CNIVA].id = "cniva" + ui.barbarians[SHAPUR].id = "shapur" + ui.barbarians[ARDASHIR].id = "ardashir" + for (let p = 0; p < 4; ++p) { for (let g = 0; g < 6; ++g) { ui.castra[p][g] = create_thing({ className: "castra hide" }) @@ -1013,7 +1024,7 @@ function on_update() { hide(ui.militia[region]) } - for (let i = 0; i < 33; ++i) { + for (let i = 0; i < LEGION_COUNT; ++i) { if (is_legion_unused(i)) hide(ui.legions[i]) else @@ -1024,28 +1035,27 @@ function on_update() { ui.legions[i].classList.toggle("reduced", false) } - // TODO: Cniva, Ardashir, and Shapur - // TODO: Zenobia, Postumus, Priest King - - for (let id = 0; id < BARBARIAN_COUNT[player_count]; ++id) { - show(ui.barbarians[id]) + for (let id = 0; id < BARBARIAN_COUNT; ++id) { + let loc = get_barbarian_location(id) + if (loc === UNAVAILABLE) + hide(ui.barbarians[id]) + else + show(ui.barbarians[id]) if (is_barbarian_inactive(id)) ui.barbarians[id].classList.toggle("inactive", true) else ui.barbarians[id].classList.toggle("inactive", false) } - for (let id = BARBARIAN_COUNT[player_count]; id < ui.barbarians.length; ++id) - hide(ui.barbarians[id]) - stack_count.fill(0) for (let region = 0; region < 12 + 5; ++region) { - for (let tribe = 0; tribe < TRIBE_COUNT[player_count]; ++tribe) { + for (let tribe = 0; tribe < 5; ++tribe) { let active_barbarians = [] let inactive_barbarians = [] - // TODO: Cniva, Ardashir, and Shapur for (let id = first_barbarian[tribe]; id <= last_barbarian[tribe]; ++id) { + if (id === CNIVA || id === ARDASHIR || id === SHAPUR) + continue let loc = get_barbarian_location(id) let inactive = is_barbarian_inactive(id) if (loc === region) { @@ -1065,13 +1075,19 @@ function on_update() { } } - for (let re = 0; re < 3; ++re) { - let loc = get_rival_emperor_location(re) + for (let id of [ CNIVA, ARDASHIR, SHAPUR ]) { + let loc = get_barbarian_location(id) + if (loc !== UNAVAILABLE) + layout_stack(-1, [ ui.barbarians[id] ], loc, false, 8, 8) + } + + for (let id = 0; id < 3; ++id) { + let loc = get_rival_emperor_location(id) if (loc === UNAVAILABLE) - hide(ui.rival_emperors[re]) + hide(ui.rival_emperors[id]) else { - show(ui.rival_emperors[re]) - layout_stack(-1, [ ui.rival_emperors[re] ], loc, false, 8, 8) + show(ui.rival_emperors[id]) + layout_stack(-1, [ ui.rival_emperors[id] ], loc, false, 8, 8) } } @@ -1144,13 +1160,13 @@ function on_update() { stack.push(e) - for (let i = 0; i < 33; ++i) { + for (let i = 0; i < LEGION_COUNT; ++i) { let loc = get_legion_location(i) if (loc === army) stack.push(ui.legions[i]) } - for (let tribe = 0; tribe < TRIBE_COUNT[player_count]; ++tribe) { + for (let tribe = 0; tribe < 5; ++tribe) { for (let id = first_barbarian[tribe]; id <= last_barbarian[tribe]; ++id) { let loc = get_barbarian_location(id) if (loc === army) @@ -1287,6 +1303,7 @@ function on_update() { action_button("end_actions", "End Actions") + action_button("save", "Save") action_button("pass", "Pass") action_button("done", "Done") action_button("undo", "Undo") |