diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-05 01:37:42 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-06 01:49:09 +0100 |
commit | 7f7d113b4bf743a7706254f83cc3264f491f5864 (patch) | |
tree | 006ec0dbedd98ede6ddf5c8c3af3140d52fe0266 /rules.js | |
parent | 719b7f1cd0917980021f8715c7f5bf8a642254f6 (diff) | |
download | maria-7f7d113b4bf743a7706254f83cc3264f491f5864.tar.gz |
WIP New process for re-entering supply trains.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 94 |
1 files changed, 36 insertions, 58 deletions
@@ -2465,7 +2465,7 @@ states.movement = { for (let p of all_controlled_trains(game.power)) { if ((game.move_re_entered & (1 << piece_power[p])) === 0) { if (can_train_re_enter(p)) - view.actions.re_enter = 1 + gen_action_piece(p) } if (!set_has(game.moved, p)) { if (is_piece_on_map(p)) { @@ -2497,21 +2497,19 @@ states.movement = { view.actions.end_movement = 1 } }, - re_enter() { - push_undo() - goto_re_enter_train() - }, piece(p) { push_undo() - let here = game.pos[p] - set_active_to_power(piece_power[p]) - game.selected = p - game.count = 0 + if (is_piece_eliminated(p)) { + goto_re_enter_train() + return + } + + let here = game.pos[p] if (data.cities.main_roads[here].length > 0) game.main = 1 else @@ -2671,10 +2669,21 @@ states.move_supply_train = { if (can_move_train_to(who, here, next)) gen_action_space_or_piece(next) + if (game.count === 0) { + view.actions.re_enter = 0 + if ((game.move_re_entered & (1 << piece_power[who])) === 0) + if (can_train_re_enter(who)) + view.actions.re_enter = 1 + } + if (game.count > 0) gen_action_piece(who) view.actions.stop = 1 }, + re_enter() { + game.pos[game.selected] = ELIMINATED + goto_re_enter_train() + }, piece(p) { if (p === game.selected) this.stop() @@ -3113,10 +3122,8 @@ states.confirm_flanders_stack_3 = { /* RE-ENTER SUPPLY TRAIN */ function goto_re_enter_train() { - if (all_controlled_powers(game.power).length > 1) - game.state = "re_enter_train_power" - else - game.state = "re_enter_train" + game.move_re_entered |= (1 << game.power) + game.state = "re_enter_train" game.recruit = { pool: [], used: [], @@ -3153,28 +3160,6 @@ function can_re_enter_train_at_power_fortress(pow) { return false } -states.re_enter_train_power = { - inactive: "move", - prompt() { - prompt("Re-enter supply train from which power?") - for (let pow of all_controlled_powers(game.power)) { - if (game.move_re_entered & (1 << pow)) - continue - for (let p of all_power_trains[pow]) { - if (can_train_re_enter(p)) { - gen_action_power(pow) - break - } - } - } - }, - power(pow) { - game.move_re_entered |= (1 << pow) - set_active_to_power(pow) - game.state = "re_enter_train" - }, -} - states.re_enter_train = { inactive: "move", prompt() { @@ -3185,12 +3170,18 @@ states.re_enter_train = { let av_trains = 0 for (let p of all_power_trains[game.power]) { if (can_train_re_enter(p)) { - if (paid >= 4) + if (game.selected < 0 && paid >= 4) gen_action_piece(p) av_trains += 1 } } + if (game.selected >= 0 && paid >= 4) { + gen_re_enter_train_at_power_fortress(game.power) + if (coop_minor_power(game.power) !== game.power) + gen_re_enter_train_at_power_fortress(coop_minor_power(game.power)) + } + if (paid / 4 < av_trains) gen_cards_in_hand() @@ -3204,7 +3195,7 @@ states.re_enter_train = { else if (paid === 1) str += " \u2014 1 point." else - str += "." + str += " \u2014 0 points." } else { str = "Re-enter supply trains done." } @@ -3212,14 +3203,20 @@ states.re_enter_train = { prompt(str) view.draw = game.recruit.pool + view.selected = game.selected }, piece(p) { push_undo() + game.pos[p] = ELIMINATED + game.selected = p + }, + space(to) { + let p = game.selected spend_card_value(game.recruit.pool, game.recruit.used, 4) set_add(game.moved, p) map_set(game.recruit.pieces, p, game.pos[p]) - game.state = "re_enter_train_where" - game.selected = p + enter_train_at(p, to) + game.selected = -1 }, card(c) { push_undo() @@ -3232,25 +3229,6 @@ states.re_enter_train = { }, } -states.re_enter_train_where = { - inactive: "move", - prompt() { - prompt("Re-enter supply train at a major fortress.") - - view.selected = game.selected - view.draw = game.recruit.pool - - gen_re_enter_train_at_power_fortress(game.power) - if (coop_minor_power(game.power) !== game.power) - gen_re_enter_train_at_power_fortress(coop_minor_power(game.power)) - }, - space(to) { - enter_train_at(game.selected, to) - game.selected = -1 - game.state = "re_enter_train" - }, -} - function end_re_enter_train() { if (game.recruit.used.length > 0) { log_br() |