summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-02-26 18:28:00 +0100
committerTor Andersson <tor@ccxvii.net>2023-02-18 11:54:52 +0100
commit34feb62f68636b4783061c7edf9c14516d396ef7 (patch)
treed47b78a5513ab108c36ee0e11a868aeeee3730cf /rules.js
parentc942b50b204adb68037cf7b516cd5e3675af571c (diff)
downloadwilderness-war-34feb62f68636b4783061c7edf9c14516d396ef7.tar.gz
Fix land/boat movement.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js68
1 files changed, 54 insertions, 14 deletions
diff --git a/rules.js b/rules.js
index 6821be5..0cdf23c 100644
--- a/rules.js
+++ b/rules.js
@@ -881,7 +881,11 @@ function piece_space(p) {
// is piece commanded by a leader (or self)
function is_piece_in_force(p, force) {
- return (p === force) || (piece_node(p) === leader_box(force));
+ if (p === force)
+ return true;
+ if (is_leader(force))
+ return piece_node(p) === leader_box(force);
+ return false;
}
function count_non_british_iroquois_and_mohawk_units_in_force(leader) {
@@ -2137,8 +2141,9 @@ states.activate_individually = {
gen_action_next();
if (game.count >= 1) {
for (let p = first_friendly_leader; p <= last_friendly_leader; ++p) {
- if (is_piece_on_map(p))
+ if (is_piece_on_map(p) && !game.activation.includes(p)) {
gen_action_piece(p);
+ }
}
}
if (game.count > 0) {
@@ -2693,9 +2698,9 @@ function is_carry_connection(from, to) {
return (from_ff && to_ff);
}
-function can_move_by_boat(from, to) {
+function can_move_by_boat_or_land(from, to) {
if (is_land_path(from, to)) {
- if (game.move.type === 'boat-or-land' && game.move.used < land_movement_cost())
+ if (game.move.used < land_movement_cost())
return true;
if (!game.move.did_carry)
return is_carry_connection(from, to);
@@ -2704,6 +2709,15 @@ function can_move_by_boat(from, to) {
return true;
}
+function can_move_by_boat(from, to) {
+ if (is_land_path(from, to)) {
+ if (!game.move.did_carry)
+ return is_carry_connection(from, to);
+ return false;
+ }
+ return true;
+}
+
function can_infiltrate(start) {
// TODO: search paths to see if we have enough movement points left to reach non-infiltration space
console.log("CAN_INFILTRATE", space_name(start), game.move.used, max_movement_cost());
@@ -2731,11 +2745,18 @@ function gen_regular_move() {
}
}
- if (game.move.type === 'boat' || game.move.type === 'boat-or-land') {
+ switch (game.move.type) {
+ case 'boat-or-land':
+ if (can_move_by_boat_or_land(from, to))
+ gen_action_space(to);
+ break;
+ case 'boat':
if (can_move_by_boat(from, to))
gen_action_space(to);
- } else {
+ break;
+ case 'land':
gen_action_space(to);
+ break;
}
});
}
@@ -2767,9 +2788,9 @@ function apply_move(to) {
if (is_carry_connection(from, to))
game.move.did_carry = 1;
else
- game.move.type = 'land'; // NOTE: impossible if type=boat
+ game.move.type = 'land';
} else {
- game.move.type = 'land'; // NOTE: impossible if type=boat
+ game.move.type = 'land';
}
}
}
@@ -2830,16 +2851,35 @@ states.move = {
if (from) {
view.prompt = `Move ${piece_name_and_place(who)}`;
- if (game.move.type === 'boat-or-land') {
+ switch (game.move.type) {
+ case 'boat-or-land':
view.prompt += " by boat or land";
- } else {
- view.prompt += ` by ${game.move.type}`;
+ if (game.move.did_carry)
+ view.prompt += " (carried)";
+ break;
+ case 'boat':
+ view.prompt += " by boat";
+ if (game.move.did_carry)
+ view.prompt += " (carried)";
+ break;
+ case 'land':
+ view.prompt += " by land";
+ break;
+ case 'naval':
+ if (game.move.used > 0)
+ view.prompt += " by ship \u2014 done.";
+ else
+ view.prompt += " by ship.";
+ break;
}
- if (game.move.did_carry)
- view.prompt += " (carried)";
if (game.move.infiltrated)
view.prompt += " (infiltrating)";
- view.prompt += ` \u2014 ${game.move.used}/${max_movement_cost()}.`;
+ if (game.move.type !== 'naval') {
+ if (game.move.used === 9)
+ view.prompt += ` \u2014 done.`;
+ else
+ view.prompt += ` \u2014 ${game.move.used}/${max_movement_cost()}.`;
+ }
} else {
view.prompt = `${piece_name(who)} eliminated.`;
}