diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 268 |
1 files changed, 134 insertions, 134 deletions
@@ -16,7 +16,7 @@ exports.roles = [ "York", "Lancaster" ] const { CARDS, BLOCKS, AREAS, BORDERS, block_index, area_index } = require('./data') const first_area = 6 // first real area (skip pools and seas) -const last_area = AREAS.length - 4 // skip layout areas at end +const last_area = AREAS.length - 5 // skip layout areas at end const block_count = BLOCKS.length @@ -25,10 +25,12 @@ const LANCASTER = "Lancaster" const YORK = "York" const ENEMY = { Lancaster: "York", York: "Lancaster" } const OBSERVER = "Observer" -const BOTH = "Both" + +const MA_BOTH = [ "Lancaster", "York" ] +const MA_LANCASTER = [ "Lancaster" ] +const MA_YORK = [ "York" ] const PLAYER_ID = { "": 0, Lancaster: 1, York: 2 } -const ID_PLAYER = [ "", "Lancaster", "York" ] // areas const NOWHERE = 0 @@ -177,8 +179,12 @@ function print_turn_log(text) { delete game.turn_log } +function is_active_player(current) { + return (game.active === current) || (Array.isArray(game.active) && game.active.includes(current)) +} + function is_inactive_player(current) { - return current === OBSERVER || (game.active !== current && game.active !== BOTH) + return !is_active_player(current) } function remove_from_array(array, item) { @@ -777,7 +783,7 @@ function count_pinned(where) { return count } -function is_pinned(who, from) { +function is_pinned(from) { if (game.active === game.p2) { if (count_pinned(from) <= count_pinning(from)) return true @@ -803,7 +809,7 @@ function can_block_sea_move(who) { if (can_activate(who)) { let from = game.location[who] if (from !== NOWHERE) { - if (is_pinned(who, from)) + if (is_pinned(from)) return false for (let to of AREAS[from].exits) if (can_block_sea_move_to(who, from, to)) @@ -813,7 +819,7 @@ function can_block_sea_move(who) { return false } -function can_block_use_border(who, from, to) { +function can_block_use_border(from, to) { if (game.active === game.surprise) { switch (border_type(from, to)) { case 'major': return border_limit(from, to) < 5 @@ -839,12 +845,12 @@ function count_borders_crossed(to) { return count } -function can_block_land_move_to(who, from, to) { +function can_block_land_move_to(from, to) { if (is_enemy_exile_area(to)) return false if (game.active === game.piracy) return false - if (can_block_use_border(who, from, to)) { + if (can_block_use_border(from, to)) { // limit number of borders used to attack/reinforce let contested = is_contested_area(to) if (contested && !border_was_last_used_by_active(from, to)) { @@ -873,17 +879,17 @@ function can_block_land_move(who) { if (can_activate(who)) { let from = game.location[who] if (from !== NOWHERE) { - if (is_pinned(who, from)) + if (is_pinned(from)) return false for (let to of AREAS[from].exits) - if (can_block_land_move_to(who, from, to)) + if (can_block_land_move_to(from, to)) return true } } return false } -function can_block_continue(who, from, to) { +function can_block_continue(from, to) { if (is_contested_area(to)) return false if (border_type(from, to) === 'minor') @@ -905,7 +911,7 @@ function can_block_retreat_to(who, to) { return false if (is_friendly_area(to) || is_vacant_area(to)) { let from = game.location[who] - if (can_block_use_border(who, from, to)) { + if (can_block_use_border(from, to)) { if (border_was_last_used_by_enemy(from, to)) return false return true @@ -919,7 +925,7 @@ function can_block_regroup_to(who, to) { return false if (is_friendly_area(to) || is_vacant_area(to)) { let from = game.location[who] - if (can_block_use_border(who, from, to)) + if (can_block_use_border(from, to)) return true } return false @@ -935,13 +941,13 @@ function can_block_regroup(who) { return false } -function can_block_muster_via(who, from, next, muster) { - if (can_block_land_move_to(who, from, next) && is_friendly_or_vacant_area(next)) { +function can_block_muster_via(from, next, muster) { + if (can_block_land_move_to(from, next) && is_friendly_or_vacant_area(next)) { if (next === muster) return true if (border_type(from, next) !== 'minor') { if (set_has(AREAS[next].exits, muster)) - if (can_block_land_move_to(who, next, muster)) + if (can_block_land_move_to(next, muster)) return true } } @@ -953,10 +959,10 @@ function can_block_muster(who, muster) { if (from === muster) return false if (can_activate(who) && is_block_on_map(who)) { - if (is_pinned(who, from)) + if (is_pinned(from)) return false for (let next of AREAS[from].exits) - if (can_block_muster_via(who, from, next, muster)) + if (can_block_muster_via(from, next, muster)) return true } return false @@ -1438,22 +1444,22 @@ function goto_card_phase() { game.y_card = 0 game.show_cards = false game.state = 'play_card' - game.active = BOTH + game.active = MA_BOTH } function resume_play_card() { if (game.l_card > 0 && game.y_card > 0) reveal_cards() else if (game.l_card > 0) - game.active = YORK + game.active = MA_YORK else if (game.y_card > 0) - game.active = LANCASTER + game.active = MA_LANCASTER else - game.active = BOTH + game.active = MA_BOTH } states.play_card = { - prompt: function (view, current) { + prompt(view, current) { if (current === OBSERVER) return view.prompt = "Waiting for players to play a card." if (current === LANCASTER) { @@ -1475,7 +1481,7 @@ states.play_card = { } } }, - play: function (card, current) { + play(card, current) { if (current === LANCASTER) { remove_from_array(game.l_hand, card) game.l_card = card @@ -1486,7 +1492,7 @@ states.play_card = { } resume_play_card() }, - undo: function (_, current) { + undo(_, current) { if (current === LANCASTER) { game.l_hand.push(game.l_card) game.l_card = 0 @@ -1590,7 +1596,7 @@ function goto_event_card(event) { } states.plague_event = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Plague: Waiting for " + game.active + " to choose a city." view.prompt = "Plague: Choose an enemy city area." @@ -1599,7 +1605,7 @@ states.plague_event = { if (is_enemy_area(where) && has_city(where)) gen_action(view, 'area', where) }, - area: function (where) { + area(where) { log("Plague ravaged " + has_city(where) + "!") game.where = where game.plague = [] @@ -1609,20 +1615,20 @@ states.plague_event = { game.active = ENEMY[game.active] game.state = 'apply_plague' }, - pass: function () { + pass() { end_player_turn() } } states.apply_plague = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Plague: Waiting for " + game.active + " to reduce blocks in " + has_city(game.where) + "." view.prompt = "Plague: Reduce blocks in " + has_city(game.where) + "." for (let b of game.plague) gen_action(view, 'block', b) }, - block: function (b) { + block(b) { reduce_block(b) set_delete(game.plague, b) if (game.plague.length === 0) { @@ -1641,7 +1647,7 @@ function goto_muster_event() { } states.muster_event = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Muster: Waiting for " + game.active + " to muster." view.prompt = "Muster: Choose one friendly or vacant muster area." @@ -1653,12 +1659,12 @@ states.muster_event = { gen_action(view, 'area', where) } }, - area: function (where) { + area(where) { push_undo() game.where = where game.state = 'muster_who' }, - end_action_phase: function () { + end_action_phase() { clear_undo() print_turn_log(game.active + " mustered:") end_player_turn() @@ -1667,7 +1673,7 @@ states.muster_event = { } states.muster_who = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Muster: Waiting for " + game.active + " to muster." view.prompt = "Muster: Move blocks to the designated muster area." @@ -1677,12 +1683,12 @@ states.muster_who = { if (can_block_muster(b, game.where)) gen_action(view, 'block', b) }, - block: function (who) { + block(who) { push_undo() game.who = who game.state = 'muster_move_1' }, - end_action_phase: function () { + end_action_phase() { game.where = NOWHERE clear_undo() print_turn_log(game.active + " mustered:") @@ -1692,7 +1698,7 @@ states.muster_who = { } states.muster_move_1 = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Muster: Waiting for " + game.active + " to muster." view.prompt = "Muster: Move " + block_name(game.who) + " to the designated muster area." @@ -1700,11 +1706,11 @@ states.muster_move_1 = { gen_action(view, 'block', game.who) let from = game.location[game.who] for (let to of AREAS[from].exits) { - if (can_block_muster_via(game.who, from, to, game.where)) + if (can_block_muster_via(from, to, game.where)) gen_action(view, 'area', to) } }, - area: function (to) { + area(to) { let from = game.location[game.who] log_move_start(from) log_move_continue(to) @@ -1723,14 +1729,14 @@ states.muster_move_1 = { } states.muster_move_2 = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Muster: Waiting for " + game.active + " to muster." view.prompt = "Muster: Move " + block_name(game.who) + " to the designated muster area." gen_action_undo(view) gen_action(view, 'area', game.where) }, - area: function (to) { + area(to) { log_move_continue(to) log_move_end() move_block(game.who, game.location[game.who], to) @@ -1779,7 +1785,7 @@ function goto_action_phase(moves) { } states.action_phase = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) { if (game.active === game.piracy) return view.prompt = "Piracy: Waiting for " + game.active + "." @@ -1831,7 +1837,7 @@ states.action_phase = { } } }, - block: function (who) { + block(who) { push_undo() game.who = who game.origin = game.location[who] @@ -1843,7 +1849,7 @@ states.action_phase = { game.state = 'move_to' } }, - end_action_phase: function () { + end_action_phase() { if (game.moves > 0 && game.turn_log.length === 0 && game.recruit_log.length === 0) logp("did nothing.") @@ -1865,7 +1871,7 @@ states.action_phase = { } states.recruit_where = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Action Phase: Waiting for " + game.active + "." view.prompt = "Recruit " + block_name(game.who) + " where?" @@ -1875,7 +1881,7 @@ states.recruit_where = { if (can_recruit_to(game.who, to)) gen_action(view, 'area', to) }, - area: function (to) { + area(to) { game.recruit_log.push(["#" + to]) --game.moves game.location[game.who] = to @@ -1887,7 +1893,7 @@ states.recruit_where = { } states.move_to = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Action Phase: Waiting for " + game.active + "." view.prompt = "Move " + block_name(game.who) + "." @@ -1897,7 +1903,7 @@ states.move_to = { if (game.distance > 0) gen_action(view, 'area', from) for (let to of AREAS[from].exits) { - if (to !== game.last_from && can_block_land_move_to(game.who, from, to)) + if (to !== game.last_from && can_block_land_move_to(from, to)) gen_action(view, 'area', to) else if (game.distance === 0 && can_block_sea_move_to(game.who, from, to)) { let has_destination_port = false @@ -1918,13 +1924,13 @@ states.move_to = { } } }, - block: function () { + block() { if (game.distance === 0) pop_undo() else end_move() }, - area: function (to) { + area(to) { let from = game.location[game.who] if (to === from) { end_move() @@ -1941,7 +1947,7 @@ states.move_to = { } else { let mark = move_block(game.who, from, to) log_move_continue(to, mark) - if (!can_block_continue(game.who, from, to)) + if (!can_block_continue(from, to)) end_move() } }, @@ -1949,7 +1955,7 @@ states.move_to = { } states.sea_move_to = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Action Phase: Waiting for " + game.active + "." if (game.active === game.piracy) { @@ -1976,7 +1982,7 @@ states.sea_move_to = { } } }, - area: function (to) { + area(to) { // XXX use_border(game.location[game.who], to) // if displaying sea moves game.location[game.who] = to @@ -2045,7 +2051,7 @@ function goto_battle_phase() { } states.battle_phase = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to choose a battle." view.prompt = "Choose the next battle to fight!" @@ -2053,7 +2059,7 @@ states.battle_phase = { if (is_area_on_map(where) && is_contested_area(where)) gen_action(view, 'area', where) }, - area: function (where) { + area(where) { start_battle(where) }, } @@ -2099,7 +2105,7 @@ function end_battle() { states.treason_event = { show_battle: true, - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Treason: Waiting for " + game.active + " to choose a target." view.prompt = "Treason: Choose a target or pass." @@ -2118,19 +2124,19 @@ states.treason_event = { } } }, - battle_treachery: function (target) { + battle_treachery(target) { delete game.treason attempt_treachery(NOBODY, target) game.state = 'battle_round' start_battle_round() }, - block: function (target) { + block(target) { delete game.treason attempt_treachery(NOBODY, target) game.state = 'battle_round' start_battle_round() }, - pass: function () { + pass() { game.state = 'battle_round' start_battle_round() } @@ -2428,7 +2434,7 @@ function can_heir_charge() { states.battle_round = { show_battle: true, - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to choose a combat action." view.prompt = "Battle: Choose a combat action with an army." @@ -2470,24 +2476,24 @@ states.battle_round = { gen_action(view, 'battle_treachery', B_WARWICK_Y) } }, - battle_fire: function (who) { + battle_fire(who) { fire_with_block(who) }, - battle_retreat: function (who) { + battle_retreat(who) { retreat_with_block(who) }, - battle_pass: function (who) { + battle_pass(who) { pass_with_block(who) }, - battle_charge: function (who) { + battle_charge(who) { game.who = who game.state = 'battle_charge' }, - battle_treachery: function (who) { + battle_treachery(who) { game.who = who game.state = 'battle_treachery' }, - block: function (who) { + block(who) { if (can_block_fire(who)) fire_with_block(who) else if (can_retreat_with_block(who)) @@ -2502,7 +2508,7 @@ states.battle_round = { states.battle_charge = { show_battle: true, - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Heir Charge: Waiting for " + game.active + " to choose a target." view.prompt = "Heir Charge: Choose a target." @@ -2521,20 +2527,20 @@ states.battle_charge = { } } }, - battle_charge: function (target) { + battle_charge(target) { charge_with_block(game.who, target) }, - block: function (target) { + block(target) { charge_with_block(game.who, target) }, - undo: function () { + undo() { resume_battle() } } states.battle_treachery = { show_battle: true, - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Treachery: Waiting for " + game.active + " to choose a target." view.prompt = "Treachery: Choose a target." @@ -2553,15 +2559,15 @@ states.battle_treachery = { } } }, - battle_treachery: function (target) { + battle_treachery(target) { attempt_treachery(game.who, target) resume_battle() }, - block: function (target) { + block(target) { attempt_treachery(game.who, target) resume_battle() }, - undo: function () { + undo() { resume_battle() } } @@ -2613,7 +2619,7 @@ function list_victims(p) { states.battle_hits = { show_battle: true, - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to assign hits." view.prompt = "Assign " + game.hits + (game.hits !== 1 ? " hits" : " hit") + " to your armies." @@ -2622,16 +2628,16 @@ states.battle_hits = { gen_action(view, 'block', b) } }, - battle_hit: function (who) { + battle_hit(who) { apply_hit(who) }, - block: function (who) { + block(who) { apply_hit(who) }, } states.retreat_in_battle = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to retreat." gen_action(view, 'undo') @@ -2648,7 +2654,7 @@ states.retreat_in_battle = { gen_action(view, 'area', to) } }, - area: function (to) { + area(to) { if (is_sea_area(to)) { game.location[game.who] = to game.state = 'sea_retreat_to' @@ -2661,21 +2667,21 @@ states.retreat_in_battle = { resume_battle() } }, - eliminate: function () { + eliminate() { game.flash = "" eliminate_block(game.who) resume_battle() }, - block: function () { + block() { resume_battle() }, - undo: function () { + undo() { resume_battle() } } states.sea_retreat_to = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to retreat." view.prompt = "Retreat: Move the army to a friendly or vacant area in the same sea zone." @@ -2686,7 +2692,7 @@ states.sea_retreat_to = { if (is_friendly_or_vacant_area(to)) gen_action(view, 'area', to) }, - area: function (to) { + area(to) { let sea = game.location[game.who] game.turn_log.push([game.active, "#" + sea, "#" + to]) game.flash = block_name(game.who) + " retreated." @@ -2694,12 +2700,12 @@ states.sea_retreat_to = { game.location[game.who] = to resume_battle() }, - eliminate: function () { + eliminate() { game.flash = "" eliminate_block(game.who) resume_battle() }, - undo: function () { + undo() { game.location[game.who] = game.where resume_battle() } @@ -2716,7 +2722,7 @@ function goto_regroup() { } states.regroup = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to regroup." view.prompt = "Regroup: Choose an army to move." @@ -2733,12 +2739,12 @@ states.regroup = { } } }, - block: function (who) { + block(who) { push_undo() game.who = who game.state = 'regroup_to' }, - end_regroup: function () { + end_regroup() { game.where = NOWHERE clear_undo() print_turn_log(game.active + " regrouped:") @@ -2748,7 +2754,7 @@ states.regroup = { } states.regroup_to = { - prompt: function (view, current) { + prompt(view, current) { if (game.active === game.piracy && set_has(game.is_pirate, game.who)) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to regroup." @@ -2769,7 +2775,7 @@ states.regroup_to = { gen_action(view, 'area', to) } }, - area: function (to) { + area(to) { if (is_sea_area(to)) { log_move_start(game.where) log_move_continue(to) @@ -2787,7 +2793,7 @@ states.regroup_to = { } states.sea_regroup_to = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to regroup." view.prompt = "Regroup: Move the army to a friendly or vacant area in the same sea zone." @@ -2797,7 +2803,7 @@ states.sea_regroup_to = { if (is_friendly_or_vacant_area(to)) gen_action(view, 'area', to) }, - area: function (to) { + area(to) { log_move_continue(to) log_move_end() game.location[game.who] = to @@ -2835,14 +2841,14 @@ function goto_execute_clarence() { } states.execute_clarence = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to execute Clarence." view.prompt = "Supply Phase: Execute enemy heir Clarence?" gen_action(view, 'execute_clarence') gen_action(view, 'pass') }, - execute_clarence: function () { + execute_clarence() { logp("executed Clarence.") eliminate_block(B_CLARENCE_L) game.who = NOBODY @@ -2850,7 +2856,7 @@ states.execute_clarence = { return goto_game_over() goto_execute_exeter() }, - pass: function () { + pass() { game.who = NOBODY goto_execute_exeter() } @@ -2867,14 +2873,14 @@ function goto_execute_exeter() { } states.execute_exeter = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to execute Exeter." view.prompt = "Supply Phase: Execute enemy heir Exeter?" gen_action(view, 'execute_exeter') gen_action(view, 'pass') }, - execute_exeter: function () { + execute_exeter() { logp("executed Exeter.") eliminate_block(B_EXETER_Y) game.who = NOBODY @@ -2882,7 +2888,7 @@ states.execute_exeter = { return goto_game_over() goto_enter_pretender_heir() }, - pass: function () { + pass() { game.who = NOBODY goto_enter_pretender_heir() } @@ -2900,7 +2906,7 @@ function goto_enter_pretender_heir() { } states.enter_pretender_heir = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to enter pretender heirs." view.prompt = "Death of an Heir: Enter " + block_name(game.who) + " in an exile area." @@ -2908,7 +2914,7 @@ states.enter_pretender_heir = { if (is_pretender_exile_area(where)) gen_action(view, 'area', where) }, - area: function (to) { + area(to) { logbr() log(block_name(game.who) + " came of age in #" + to + ".") --game.killed_heirs[game.active] @@ -2933,7 +2939,7 @@ function goto_supply_limits_pretender() { } states.supply_limits_pretender = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to check supply limits." view.prompt = "Supply Phase: Reduce blocks in over-stacked areas." @@ -2943,14 +2949,14 @@ states.supply_limits_pretender = { for (let b of game.supply) gen_action(view, 'block', b) }, - block: function (who) { + block(who) { push_undo() game.turn_log.push(["#" + game.location[who]]) set_add(game.reduced, who) reduce_block(who) check_supply_penalty() }, - end_supply_phase: function () { + end_supply_phase() { delete game.supply delete game.reduced clear_undo() @@ -2974,7 +2980,7 @@ function goto_enter_royal_heir() { } states.enter_royal_heir = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to enter royal heirs." view.prompt = "Death of an Heir: Enter " + block_name(game.who) + " in a Crown area." @@ -2988,7 +2994,7 @@ states.enter_royal_heir = { if (!can_enter) gen_action(view, 'pass') }, - area: function (to) { + area(to) { logbr() log(block_name(game.who) + " came of age in #" + to + ".") --game.killed_heirs[game.active] @@ -2996,7 +3002,7 @@ states.enter_royal_heir = { game.who = NOBODY goto_enter_royal_heir() }, - pass: function () { + pass() { game.who = NOBODY goto_supply_limits_king() } @@ -3017,7 +3023,7 @@ function goto_supply_limits_king() { } states.supply_limits_king = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to check supply limits." view.prompt = "Supply Phase: Reduce blocks in over-stacked areas." @@ -3027,14 +3033,14 @@ states.supply_limits_king = { for (let b of game.supply) gen_action(view, 'block', b) }, - block: function (who) { + block(who) { push_undo() game.turn_log.push(["#" + game.location[who]]) set_add(game.reduced, who) reduce_block(who) check_supply_penalty() }, - end_supply_phase: function () { + end_supply_phase() { delete game.supply delete game.reduced clear_undo() @@ -3150,7 +3156,7 @@ function goto_pretender_goes_home() { } states.pretender_goes_home = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for the Pretender to go to exile." gen_action_undo(view) @@ -3188,12 +3194,12 @@ states.pretender_goes_home = { view.prompt = "Pretender Goes Home: Move the pretender and his heirs to exile, and nobles to home." } }, - block: function (who) { + block(who) { push_undo() game.who = who game.state = 'pretender_goes_home_to' }, - end_political_turn: function () { + end_political_turn() { clear_undo() print_turn_log_no_count("Pretender went home:") goto_exile_limits_pretender() @@ -3202,7 +3208,7 @@ states.pretender_goes_home = { } states.pretender_goes_home_to = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for the Pretender to go to exile." if (is_heir(game.who)) @@ -3221,7 +3227,7 @@ states.pretender_goes_home_to = { } } }, - area: function (to) { + area(to) { if (is_exile_area(to)) game.turn_log.push([block_name(game.who), "#" + to]) // TODO: "Exile"? else @@ -3247,7 +3253,7 @@ function goto_exile_limits_pretender() { } states.exile_limits_pretender = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to check exile limits." view.prompt = "Campaign Reset: Disband one block in each over-stacked exile area." @@ -3257,14 +3263,14 @@ states.exile_limits_pretender = { for (let b of game.exiles) gen_action(view, 'block', b) }, - block: function (who) { + block(who) { push_undo() let where = game.location[who] logp("disbanded in #" + where + ".") game.exiles = game.exiles.filter(b => game.location[b] !== where) disband(who) }, - end_exile_limits: function () { + end_exile_limits() { goto_king_goes_home() }, undo: pop_undo, @@ -3290,7 +3296,7 @@ function goto_king_goes_home() { } states.king_goes_home = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for the King to go home." gen_action_undo(view) @@ -3325,12 +3331,12 @@ states.king_goes_home = { view.prompt = "King Goes Home: Move the King, the royal heirs, and nobles to home." } }, - block: function (who) { + block(who) { push_undo() game.who = who game.state = 'king_goes_home_to' }, - end_political_turn: function () { + end_political_turn() { clear_undo() print_turn_log_no_count("King went home:") goto_exile_limits_king() @@ -3339,7 +3345,7 @@ states.king_goes_home = { } states.king_goes_home_to = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for the King to go home." view.prompt = "King Goes Home: Move " + block_name(game.who) + " to home." @@ -3349,7 +3355,7 @@ states.king_goes_home_to = { if (is_available_home_for(where, game.who)) gen_action(view, 'area', where) }, - area: function (to) { + area(to) { game.turn_log.push([block_name(game.who), "#" + to]) // TODO: "Home"? set_add(game.moved, game.who) game.location[game.who] = to @@ -3372,7 +3378,7 @@ function goto_exile_limits_king() { } states.exile_limits_king = { - prompt: function (view, current) { + prompt(view, current) { if (is_inactive_player(current)) return view.prompt = "Waiting for " + game.active + " to check exile limits." view.prompt = "Campaign Reset: Disband one block in each over-stacked exile area." @@ -3382,14 +3388,14 @@ states.exile_limits_king = { for (let b of game.exiles) gen_action(view, 'block', b) }, - block: function (who) { + block(who) { push_undo() let where = game.location[who] logp("disbanded in #" + where + ".") game.exiles = game.exiles.filter(b => game.location[b] !== where) disband(who) }, - end_exile_limits: function () { + end_exile_limits() { end_political_turn() }, undo: pop_undo, @@ -3419,7 +3425,7 @@ function goto_game_over() { } states.game_over = { - prompt: function (view) { + prompt(view) { view.prompt = game.victory } } @@ -3517,12 +3523,6 @@ function observer_hand() { return hand } -exports.dont_snap = function(state) { - if (state.state === "play_card" && state.active !== BOTH) - return true - return false -} - exports.view = function(state, current) { game = state |