Ignore destination terrain penalties on paid Roads moves

This commit is contained in:
coyotte508 2026-10-11 21:10:10 +02:00
commit dd22fe7f0a
6 changed files with 51 additions and 5 deletions

View file

@ -154,6 +154,17 @@ pub(crate) fn move_units(
units: &[u32],
to: Position,
embark_carrier_id: Option<u32>,
) {
move_units_with_terrain(game, player_index, units, to, embark_carrier_id, false);
}
fn move_units_with_terrain(
game: &mut Game,
player_index: usize,
units: &[u32],
to: Position,
embark_carrier_id: Option<u32>,
ignore_terrain: bool,
) {
let p = game.player(player_index);
let nomad = p
@ -194,7 +205,8 @@ pub(crate) fn move_units(
unit.carrier_id = embark_carrier_id;
if let Some(terrain) = terrain_movement_restriction(&game.map, to, unit) {
if !(hannibal && terrain == MovementRestriction::Mountain)
if !(ignore_terrain && matches!(terrain, MovementRestriction::Mountain | MovementRestriction::Forest))
&& !(hannibal && terrain == MovementRestriction::Mountain)
&& !(terracing
&& terrain == MovementRestriction::Mountain
&& (unit.is_settler() || unit.unit_type.is_leader()))
@ -420,6 +432,7 @@ fn execute_move_action(game: &mut Game, player: &EventPlayer, m: &MoveUnits) ->
)?;
result?;
let ignore_terrain = dest.ignore_terrain_movement_restrictions;
let c = &dest.cost;
if c.is_free() {
assert_eq!(m.payment, ResourcePile::empty(), "payment should be empty");
@ -499,6 +512,10 @@ fn execute_move_action(game: &mut Game, player: &EventPlayer, m: &MoveUnits) ->
}
if dest_terrain == Unexplored {
move_to_unexplored_tile(game, player, &m.units, starting_position, m.destination);
} else if ignore_terrain && game.enemy_player(player.index, m.destination).is_none() {
// Roads ignore the arrival penalty too, not only existing restrictions
// while validating the route. Battles still impose their own stop.
move_units_with_terrain(game, player.index, &m.units, m.destination, m.embark_carrier_id, true);
} else {
move_with_possible_combat(game, player.index, m);
}

View file

@ -246,7 +246,7 @@ pub fn movement(game: &Game, seat: usize, units: Vec<u32>) -> Result<Value, Stri
.contains(&crate::events::EventOrigin::Incident(
crate::content::incidents::great_diplomat::DIPLOMAT_ID,
));
let offer = json!({"position":route.destination,"terrain":game.map.get(route.destination),"terrainNotes":terrain_notes(game,p,&units,route.destination),"payment":payment,"carrier":carrier,"attack":game.enemy_player(seat,route.destination).is_some(),"breaksDiplomacy":breaks_diplomacy,
let offer = json!({"position":route.destination,"terrain":game.map.get(route.destination),"terrainNotes":if route.ignore_terrain_movement_restrictions { vec!["Roads: ignores Mountain and Forest penalties. These units can move again in a new Move action unless they fight a battle."] } else { terrain_notes(game,p,&units,route.destination) },"payment":payment,"carrier":carrier,"attack":game.enemy_player(seat,route.destination).is_some(),"breaksDiplomacy":breaks_diplomacy,
"action":Action::Movement(MovementAction::Move(MoveUnits::new(units.clone(),route.destination,carrier,payment)))});
if !destinations.contains(&offer) {
destinations.push(offer);

View file

@ -151,3 +151,7 @@ Philosophy awards its Science idea before Free Education offers the optional ext
# Viewer 0.1.59
Attack destinations now use the exploration-style preview: the first click shows the defending units, leaders and city buildings; clicking the destination again or the Attack button commits the move. Changing the group, route or game state requires a fresh preview. Diplomatic costs remain visible before committing. Ordinary movement remains immediate. Engine 0.4.57 is unchanged.
# Viewer 0.1.60 / engine 0.4.58
Paid Roads moves no longer add Mountain or Forest restrictions at their destination. A group can move again in a new Move action during the same turn, provided it has not fought a battle; unrelated existing restrictions remain intact. The route preview states that Roads ignores those terrain penalties instead of incorrectly warning of a destination stop.

View file

@ -1,12 +1,12 @@
{
"name": "@boardgamers/clash-web-client",
"version": "0.1.59",
"version": "0.1.60",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@boardgamers/clash-web-client",
"version": "0.1.59",
"version": "0.1.60",
"dependencies": {
"@boardgamers/protocol": "0.9.0",
"lucide-svelte": "^0.577.0",

View file

@ -1,6 +1,6 @@
{
"name": "@boardgamers/clash-web-client",
"version": "0.1.59",
"version": "0.1.60",
"private": true,
"type": "module",
"scripts": {

View file

@ -136,3 +136,28 @@ test('a newly recruited leader needs Tactics to move, and the unit explains why'
assert(routes(state).length > 0, 'Recruitment does not prevent movement');
assert.doesNotThrow(() => engine.tryMove(state, JSON.stringify(routes(state)[0].action), seat));
});
test('paid Roads ignore both crossed and destination terrain, then allow a new Move action', () => {
for (const terrain of ['Mountain', 'Forest']) {
const g = fixture('Mountain');
g.actions_left = 3;
g.players[0].advances.push('Roads');
g.players[0].resources = { food: 5, ore: 5 };
for (const tile of g.map.tiles) if (['A1', 'B1', 'B2'].includes(tile[0])) tile[1] = terrain;
g.players[0].units[0].movement_restrictions = ['Fertile'];
const destinations = (raw: string) => JSON.parse(engine.webQuery(engine.stripSecret(raw, 0), 0,
JSON.stringify({ kind: 'movement', units: [0] }))).destinations;
const option = destinations(JSON.stringify(g)).find((d: any) => d.position === 'A1');
assert.deepEqual(option.payment, { food: 1, ore: 1 });
const moved = engine.tryMove(JSON.stringify(g), JSON.stringify(option.action), 0);
const state = JSON.parse(moved), unit = state.players[0].units.find((u: any) => u.id === 0);
assert.equal(unit.position, 'A1');
assert.deepEqual(unit.movement_restrictions, ['Fertile'], 'Roads does not add Mountain/Forest or erase unrelated restrictions');
assert.equal(state.players[0].resources.food, 4);
assert.equal(state.players[0].resources.ore, 4);
assert.doesNotMatch(option.terrainNotes.join(' '), /cannot move again|cannot make a later attack/);
const v = JSON.parse(engine.webView(engine.stripSecret(moved, 0), 0));
const next = v.stopMovement ? engine.tryMove(moved, JSON.stringify(v.stopMovement), 0) : moved;
assert.ok(destinations(next).some((d: any) => !Object.values(d.payment).some(Boolean)), 'can move again without paying for Roads again');
}
});