From 1463f4165605d9445a8acd8fedcd7b0843fcbf12 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 4 May 2025 22:27:32 +0200 Subject: Use abbreviated function property syntax. --- rules.js | 204 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 102 insertions(+), 102 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index a694335..0c99a15 100644 --- a/rules.js +++ b/rules.js @@ -1460,7 +1460,7 @@ function resume_play_card() { } 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) { @@ -1482,7 +1482,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 @@ -1493,7 +1493,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 @@ -1597,7 +1597,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." @@ -1606,7 +1606,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 = [] @@ -1616,20 +1616,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) { @@ -1648,7 +1648,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." @@ -1660,12 +1660,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() @@ -1674,7 +1674,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." @@ -1684,12 +1684,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:") @@ -1699,7 +1699,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." @@ -1711,7 +1711,7 @@ states.muster_move_1 = { gen_action(view, 'area', to) } }, - area: function (to) { + area(to) { let from = game.location[game.who] log_move_start(from) log_move_continue(to) @@ -1730,14 +1730,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) @@ -1786,7 +1786,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 + "." @@ -1838,7 +1838,7 @@ states.action_phase = { } } }, - block: function (who) { + block(who) { push_undo() game.who = who game.origin = game.location[who] @@ -1850,7 +1850,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.") @@ -1872,7 +1872,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?" @@ -1882,7 +1882,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 @@ -1894,7 +1894,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) + "." @@ -1925,13 +1925,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() @@ -1956,7 +1956,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) { @@ -1983,7 +1983,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 @@ -2052,7 +2052,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!" @@ -2060,7 +2060,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) }, } @@ -2106,7 +2106,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." @@ -2125,19 +2125,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() } @@ -2435,7 +2435,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." @@ -2477,24 +2477,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)) @@ -2509,7 +2509,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." @@ -2528,20 +2528,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." @@ -2560,15 +2560,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() } } @@ -2620,7 +2620,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." @@ -2629,16 +2629,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') @@ -2655,7 +2655,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' @@ -2668,21 +2668,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." @@ -2693,7 +2693,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." @@ -2701,12 +2701,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() } @@ -2723,7 +2723,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." @@ -2740,12 +2740,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:") @@ -2755,7 +2755,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." @@ -2776,7 +2776,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) @@ -2794,7 +2794,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." @@ -2804,7 +2804,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 @@ -2842,14 +2842,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 @@ -2857,7 +2857,7 @@ states.execute_clarence = { return goto_game_over() goto_execute_exeter() }, - pass: function () { + pass() { game.who = NOBODY goto_execute_exeter() } @@ -2874,14 +2874,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 @@ -2889,7 +2889,7 @@ states.execute_exeter = { return goto_game_over() goto_enter_pretender_heir() }, - pass: function () { + pass() { game.who = NOBODY goto_enter_pretender_heir() } @@ -2907,7 +2907,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." @@ -2915,7 +2915,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] @@ -2940,7 +2940,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." @@ -2950,14 +2950,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() @@ -2981,7 +2981,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." @@ -2995,7 +2995,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] @@ -3003,7 +3003,7 @@ states.enter_royal_heir = { game.who = NOBODY goto_enter_royal_heir() }, - pass: function () { + pass() { game.who = NOBODY goto_supply_limits_king() } @@ -3024,7 +3024,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." @@ -3034,14 +3034,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() @@ -3157,7 +3157,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) @@ -3195,12 +3195,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() @@ -3209,7 +3209,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)) @@ -3228,7 +3228,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 @@ -3254,7 +3254,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." @@ -3264,14 +3264,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, @@ -3297,7 +3297,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) @@ -3332,12 +3332,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() @@ -3346,7 +3346,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." @@ -3356,7 +3356,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 @@ -3379,7 +3379,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." @@ -3389,14 +3389,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, @@ -3426,7 +3426,7 @@ function goto_game_over() { } states.game_over = { - prompt: function (view) { + prompt(view) { view.prompt = game.victory } } -- cgit v1.2.3