Exclude embarked passengers from naval combat fighters
This commit is contained in:
parent
460c23868b
commit
403a7bda07
5 changed files with 44 additions and 5 deletions
|
|
@ -363,8 +363,8 @@ pub(crate) fn combat_loop(game: &mut Game, mut s: CombatRoundStart) {
|
|||
#[must_use]
|
||||
pub fn can_remove_after_combat(on_water: bool, unit_type: &UnitType) -> bool {
|
||||
if on_water {
|
||||
// carried units may also have to be removed
|
||||
true
|
||||
// Passengers are handled separately after ship losses reduce capacity.
|
||||
unit_type.is_ship()
|
||||
} else {
|
||||
unit_type.is_army_unit()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -455,3 +455,40 @@ fn defending_ships_stop_but_passengers_and_longships_remain_free() {
|
|||
assert!(game.player(1).get_unit(99).movement_restrictions.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn naval_defenders_exclude_passengers_from_dice_and_combat_casualties() {
|
||||
let mut game = JSON.load_game("ship_combat");
|
||||
let mut ship = game.player(1).get_unit(1).clone();
|
||||
ship.id = 2;
|
||||
game.player_mut(1).units.push(ship);
|
||||
for id in 90..94 {
|
||||
let mut passenger = game.player(0).get_unit(0).clone();
|
||||
passenger.id = id;
|
||||
passenger.position = Position::from_offset("D2");
|
||||
passenger.carrier_id = Some(if id < 92 { 1 } else { 2 });
|
||||
game.player_mut(1).units.push(passenger);
|
||||
}
|
||||
assert_eq!(server::combat_stats::active_defenders(&game, 1, Position::from_offset("D2")), vec![1, 2]);
|
||||
// Two dice per side; 3 on each die yields one hit per side.
|
||||
game.dice_roll_outcomes = vec![4; 20];
|
||||
let before = game.dice_roll_log.len();
|
||||
let mut game = execute(game, move_action(vec![7, 8], Position::from_offset("D2")), 0);
|
||||
assert_eq!(game.dice_roll_log.len() - before, 4, "only ships roll");
|
||||
// Resolve the attacker's ship loss and any excess passengers first.
|
||||
for _ in 0..4 {
|
||||
let event = game.current_event();
|
||||
if event.player.index == 1 { break; }
|
||||
let PersistentEventRequest::SelectUnits(req) = &event.player.handler.as_ref().unwrap().request else { panic!("expected casualties"); };
|
||||
let ids = req.request.choices.iter().take(*req.request.needed.start() as usize).copied().collect();
|
||||
game = execute(game, Action::Response(EventResponse::SelectUnits(ids)), 0);
|
||||
}
|
||||
// Identical ships are removed automatically; the remaining prompt is only
|
||||
// for passengers exceeding the surviving ship's two transport spaces.
|
||||
assert_eq!(game.player(1).get_units(Position::from_offset("D2")).iter().filter(|u| u.is_ship()).count(), 1);
|
||||
let event = game.current_event();
|
||||
assert_eq!(event.player.index, 1);
|
||||
let PersistentEventRequest::SelectUnits(req) = &event.player.handler.as_ref().unwrap().request else { panic!("expected excess passengers"); };
|
||||
assert_eq!(req.request.choices, vec![90, 91, 92, 93]);
|
||||
assert_eq!(req.request.needed, 2..=2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,3 +341,5 @@ Viewer 0.1.110 splits cultural influence into map-only hex selection, a building
|
|||
Viewer 0.1.111 replaces influence payment action text with a numeric action cost and the shared action icon, retaining accessible labels and tooltips. Action details and maximum boost share a row on desktop, with responsive wrapping when space is limited. Engine remains 0.4.81.
|
||||
|
||||
Viewer 0.1.112 adds Hand, Discarded actions and Discarded events tabs to Cards. Discards show engine pile order with the top card first, counts and expandable full rules including battle uses. Verified both piles in the local saved-game preview; Svelte and production build pass. Engine remains 0.4.81.
|
||||
|
||||
Viewer 0.1.113 / engine 0.4.82 fixes embarked naval defenders rolling dice and being eligible as direct combat casualties. Sea battles now admit only ships as fighters; excess passengers still resolve separately after ship losses. Verified against the reported Joyful-kraken-3479 battle and all 20 combat integration tests, including ship-only dice and remaining transport capacity.
|
||||
|
|
|
|||
4
web-client/package-lock.json
generated
4
web-client/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.112",
|
||||
"version": "0.1.113",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.112",
|
||||
"version": "0.1.113",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.112",
|
||||
"version": "0.1.113",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue