From e746813794c5f2408c4b1269ff1c85a817a8219b Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 6 Jun 2024 14:15:11 +0200 Subject: y --- rules.js | 60 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index e1659f2..8ed1fa8 100644 --- a/rules.js +++ b/rules.js @@ -242,6 +242,11 @@ function log_selected() { log(game.selected.map(p => "P" + p).join(" and ")) } +function log_move_path() { + if (game.move_path.length > 1) + log("@" + game.selected.join(",") + ";" + game.move_path.join(",")) +} + /* OBJECTIVES */ const all_objectives = [] @@ -519,11 +524,6 @@ function eliminate_general(p) { set_in_supply(p) } -function eliminate_train(p) { - log("P" + p + " eliminated.") - game.pos[p] = ELIMINATED -} - /* SEQUENCE OF PLAY */ const POWER_FROM_ACTION_STEP = [ @@ -839,10 +839,9 @@ states.movement = { else prompt("Move your generals and supply trains.") - if (done_trains && done_generals) - view.actions.end_movement = 1 + if (game.moved.length === 0) + view.actions.confirm_end_movement = 1 else - // TODO view.actions.confirm_end_movement = 1 view.actions.end_movement = 1 }, piece(p) { @@ -866,6 +865,7 @@ states.movement = { else game.main = 0 + game.move_path = [ here ] if (is_supply_train(p)) game.state = "move_supply_train" else @@ -951,7 +951,7 @@ function move_general_to(to) { if (is_protected_from_conquest(from)) { set_add(game.retro, from) } else { - game.move_conq.push(from) + set_add(game.move_conq, from) set_add(game.conquest, from) } } @@ -961,7 +961,7 @@ function move_general_to(to) { if (is_protected_from_reconquest(from)) { set_add(game.retro, from) } else { - game.move_reconq.push(from) + set_add(game.move_reconq, from) set_delete(game.conquest, from) } } @@ -969,8 +969,10 @@ function move_general_to(to) { // eliminate supply train for (let p of all_enemy_trains[pow]) { if (game.pos[p] === to) { - eliminate_train(p) - stop = true + if (!game.move_elim) + game.move_elim = [] + set_add(game.move_elim, p) + game.pos[p] = ELIMINATED } } @@ -1019,12 +1021,7 @@ states.move_supply_train = { let who = game.selected[0] let from = game.pos[who] - if (game.count === 0) { - log_selected() - log(">from S" + from) - } - - log(">to S" + to) + game.move_path.push(to) if (!set_has(data.cities.main_roads[from], to)) game.main = 0 @@ -1111,12 +1108,7 @@ states.move_general = { let who = game.selected[0] let from = game.pos[who] - if (game.count === 0) { - log_selected() - log(">from S" + from) - } - - log(">to S" + to) + game.move_path.push(to) if (!set_has(data.cities.main_roads[from], to)) game.main = 0 @@ -1169,6 +1161,15 @@ states.move_give = { } function end_move_piece() { + log_selected_move_path() + + if (game.move_elim) { + for (let p of game.move_elim) + log("P" + p + " eliminated.") + delete game.move_elim + } + + delete game.move_path game.selected = null game.state = "movement" } @@ -1408,10 +1409,12 @@ function end_recruit() { if (game.recruit) { if (game.recruit.used.length > 0) { log_br() - log("Recruited") - log(">" + game.recruit.used.map(format_card).join(", ")) + if (game.recruit.troops > 0) + log("Recruited " + game.recruit.troops + " troops with " + game.recruit.used.map(format_card).join(", ") + ".") + else + log("Recruited with " + game.recruit.used.map(format_card).join(", ") + ".") map_for_each(game.recruit.pieces, (p,s) => { - log(">P" + p + " at S" + s) + log("Re-entered P" + p + " at S" + s) }) if (game.recruit.troops) log(">" + game.recruit.troops + " troops") @@ -2585,6 +2588,9 @@ function mask_hand(player) { view_hand[pow] = game.hand[pow] else view_hand[pow] = game.hand[pow].map(c => c & ~127) + //view_hand[pow] = game.hand[pow].length + //view_hand[pow] = Math.ceil(game.hand[pow].length / 3) * 3 + //view_hand[pow] = Math.ceil(game.hand[pow].length / 5) } return view_hand } -- cgit v1.2.3