diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 93 |
1 files changed, 56 insertions, 37 deletions
@@ -2494,7 +2494,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)) - gen_action_piece(p) + view.actions.re_enter = 1 } if (!set_has(game.moved, p)) { if (is_piece_on_map(p)) { @@ -2554,24 +2554,23 @@ states.movement = { view.actions.end_movement = DEBUG } }, + re_enter() { + push_undo() + goto_re_enter_train() + }, piece(p) { push_undo() - 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 (is_flanders_space(game.pos[p])) + if (is_flanders_space(here)) game.flags |= F_MOVE_FLANDERS else game.flags &= ~F_MOVE_FLANDERS - let here = game.pos[p] if (data.cities.main_roads[here].length > 0) game.main = 1 else @@ -2774,21 +2773,10 @@ 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() @@ -3224,8 +3212,10 @@ states.confirm_flanders_stack_3 = { /* RE-ENTER SUPPLY TRAIN */ function goto_re_enter_train() { - game.move_re_entered |= (1 << game.power) - game.state = "re_enter_train" + if (all_controlled_powers(game.power).length > 1) + game.state = "re_enter_train_power" + else + game.state = "re_enter_train" game.recruit = { pool: [], used: [], @@ -3262,6 +3252,28 @@ 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() { @@ -3272,18 +3284,12 @@ states.re_enter_train = { let av_trains = 0 for (let p of all_power_trains[game.power]) { if (can_train_re_enter(p)) { - if (game.selected < 0 && paid >= 4) + if (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() @@ -3297,7 +3303,7 @@ states.re_enter_train = { else if (paid === 1) str += " \u2014 1 point." else - str += " \u2014 0 points." + str += "." } else { str = "Re-enter supply trains done." } @@ -3305,20 +3311,14 @@ 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]) - enter_train_at(p, to) - game.selected = -1 + game.state = "re_enter_train_where" + game.selected = p }, card(c) { push_undo() @@ -3331,6 +3331,25 @@ 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() |