diff options
-rw-r--r-- | play.css | 3 | ||||
-rw-r--r-- | play.js | 15 | ||||
-rw-r--r-- | rules.js | 47 |
3 files changed, 47 insertions, 18 deletions
@@ -144,6 +144,9 @@ body.Saracens header.your_turn { background-color: lightgreen; } opacity: 0.6; z-index: 9; } +.town.highlight.bad { + border-style: dashed; +} .town.tip { opacity: 1; border-color: yellow; @@ -181,7 +181,7 @@ function on_blur_town(evt) { function on_click_town(evt) { let where = evt.target.town - send_action('town', where) + send_action('town', where) || send_action('townb', where) } const STEP_TEXT = [ 0, "I", "II", "III", "IIII" ] @@ -652,11 +652,20 @@ function update_map() { if (ui.towns[t]) { ui.towns[t].classList.remove('highlight') ui.towns[t].classList.remove('muster') + ui.towns[t].classList.remove('bad') } } - if (view.actions && view.actions.town) - for (let t of view.actions.town) + if (view.actions && view.actions.town) { + for (let t of view.actions.town) { ui.towns[t].classList.add('highlight') + } + } + if (view.actions && view.actions.townb) { + for (let t of view.actions.townb) { + ui.towns[t].classList.add('highlight') + ui.towns[t].classList.add('bad') + } + } if (view.muster) ui.towns[view.muster].classList.add('muster') @@ -93,6 +93,27 @@ const ATTACK_MARK = "*" const RESERVE_MARK_1 = "\u2020" const RESERVE_MARK_2 = "\u2021" +const block_seats = [] +const block_seat_names = [] +const block_seat_names_or = [] + +function list_seats(who) { + if (block_type(who) === 'nomads') + return [ block_home(who) ] + let list = [] + for (let town = first_town; town <= last_town; ++town) + if (set_has(SHIELDS[town], who)) + list.push(town) + return list +} + +for (let b = 0; b <= last_block; ++b) { + block_seats[b] = list_seats(b) + let names = block_seats[b].map(town_name) + block_seat_names[b] = names.join(", ") + block_seat_names_or[b] = join(names, "or") +} + let states = {} let game = null @@ -279,16 +300,6 @@ function block_home(who) { return BLOCKS[who].home } -function list_seats(who) { - if (block_type(who) === 'nomads') - return [ block_home(who) ] - let list = [] - for (let town = first_town; town <= last_town; ++town) - if (set_has(SHIELDS[town], who)) - list.push(town) - return list -} - function is_home_seat(where, who) { if (block_type(who) === 'nomads') return where === block_home(who) @@ -1009,7 +1020,7 @@ states.frank_deployment = { gen_action(view, 'next') for (let b = 0; b <= last_block; ++b) { if (block_owner(b) === game.active && is_block_on_land(b)) - if (list_seats(b).length > 1) + if (block_seats[b].length > 1) gen_action(view, 'block', b) } if (errors.length > 0) @@ -1033,11 +1044,11 @@ states.frank_deployment_to = { prompt: function (view, current) { if (is_inactive_player(current)) return view.prompt = "Deployment: Waiting for " + game.active + "." - view.prompt = "Deployment: Move " + game.who + " to " + join(list_seats(game.who).map(town_name), "or") + "." + view.prompt = "Deployment: Move " + game.who + " to " + block_seat_names_or[game.who] + "." gen_action_undo(view) gen_action(view, 'block', game.who) let from = game.location[game.who] - for (let town of list_seats(game.who)) + for (let town of block_seats[game.who]) if (town !== from) gen_action(view, 'town', town) }, @@ -3263,13 +3274,16 @@ states.draw_phase = { case 'emirs': case 'nomads': view.prompt = "Draw Phase: Place " + block_name(game.who) + " at full strength in " - + list_seats(game.who).map(town_name).join(", ") + " or at strength 1 in any friendly town." + + block_seat_names[game.who] + " or at strength 1 in any friendly town." for (let town = first_town; town <= last_town; ++town) { if (town === ENGLAND || town === FRANCE || town === GERMANIA) continue // FAQ claims besieger controls town for draw purposes if (is_friendly_field(town)) { - gen_action(view, 'town', town) + if (set_has(block_seats[game.who], town)) + gen_action(view, 'town', town) + else + gen_action(view, 'townb', town) can_place = true } } @@ -3278,6 +3292,9 @@ states.draw_phase = { if (!can_place) gen_action(view, 'next') }, + townb: function (where) { + this.town(where) + }, town: function (where) { let type = block_type(game.who) |