diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 47 |
1 files changed, 32 insertions, 15 deletions
@@ -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) |