Add atomic local multi-carrier boarding and release regression coverage
This commit is contained in:
parent
b9bdc1e37a
commit
60484d3d4c
40 changed files with 693 additions and 70 deletions
2
.github/workflows/web-viewer.yml
vendored
2
.github/workflows/web-viewer.yml
vendored
|
|
@ -26,6 +26,8 @@ jobs:
|
|||
working-directory: web-client
|
||||
- run: node scripts/resource-journal-smoke.mjs && node scripts/famine-journal-smoke.mjs && node scripts/construction-smoke.mjs && node scripts/research-card-smoke.mjs
|
||||
working-directory: web-client
|
||||
- run: npm run test:boarding && node scripts/embark-smoke.mjs && node scripts/ship-landing-smoke.mjs
|
||||
working-directory: web-client
|
||||
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
|
||||
with:
|
||||
name: clash-viewer
|
||||
|
|
|
|||
39
docs/fleet-boarding.md
Normal file
39
docs/fleet-boarding.md
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# Local multi-carrier boarding
|
||||
|
||||
A land group can board multiple ships in the **same adjacent sea space** through
|
||||
one confirmed movement action. Selecting the destination opens the normal movement
|
||||
panel's passenger assignments; it does not submit a move. Carrier labels identify
|
||||
the ship and account for existing cargo. Confirm with **Board ship**.
|
||||
|
||||
`Movement.Move.boarding` is an optional array of assignments. The outer `units`
|
||||
list must match the assignment union exactly, without duplicates. Each assignment
|
||||
has its own owned `embark_carrier_id` or neutral `embark_pirate`; the namespaces are
|
||||
separate. Nested assignments, payments, attacks, different destinations, already
|
||||
transported passengers and transfers within a sea space are rejected. Execution
|
||||
uses a disposable game clone, so a rejected later assignment cannot leave an
|
||||
earlier load or pirate claim behind. Valid assignments use the existing embark
|
||||
movement group and therefore share one movement allocation.
|
||||
|
||||
Carthage's Pirate Allies claims all neutral ships at the destination, mapping each
|
||||
neutral ID to a newly owned ID. These claims must respect the four-ship space limit
|
||||
and eight-ship total limit. The normal movement validation still applies, including
|
||||
Tactics, moved-unit restrictions, Navigator and civilization-specific capacity
|
||||
(Viking Longships carry three passengers).
|
||||
|
||||
Old movement payloads omit `boarding` when empty, preserving their serialization.
|
||||
There is no save migration or production-history repair.
|
||||
|
||||
## Regression checks
|
||||
|
||||
- `npm test` includes durable WASM assignment, invalid-later-assignment,
|
||||
deterministic retry, log/action count, undo/redo/branch, queue projection,
|
||||
Tactics, Navigator, Longships, namespace and pirate limit checks.
|
||||
- `npm run test:boarding` rebuilds the bridge and viewer and exercises physical
|
||||
clicks on a normal-size map at desktop and mobile widths, for owned and neutral
|
||||
fleets with two and four passengers. It uses the supported Strategy map account
|
||||
preference, not forced or synthetic click events.
|
||||
- Web viewer CI also runs the existing embark and ship-landing browser regressions.
|
||||
|
||||
The separate old-history replay and hidden-state prediction suites remain required
|
||||
release checks; the edited local boarding fixtures do not purport to be generated
|
||||
production histories.
|
||||
|
|
@ -29,6 +29,8 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
|
||||
pub struct MoveUnits {
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub boarding: Vec<MoveUnits>,
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub attack_pirates: bool,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
|
|
@ -54,6 +56,7 @@ impl MoveUnits {
|
|||
payment: ResourcePile,
|
||||
) -> Self {
|
||||
Self {
|
||||
boarding: vec![],
|
||||
city: None,
|
||||
attack_pirates: false,
|
||||
embark_pirate: None,
|
||||
|
|
@ -345,6 +348,11 @@ pub(crate) fn execute_movement_action(
|
|||
action: MovementAction,
|
||||
player_index: usize,
|
||||
) -> Result<(), String> {
|
||||
if let Move(m) = &action {
|
||||
if !m.boarding.is_empty() {
|
||||
return execute_boarding(game, player_index, m);
|
||||
}
|
||||
}
|
||||
let player = EventPlayer::new(player_index, move_event_origin());
|
||||
match &action {
|
||||
Move(m) if m.city.is_some() => player.log(
|
||||
|
|
@ -413,6 +421,108 @@ fn has_any_moves_left(game: &mut Game) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
// Validate and execute on a disposable state: no payment, claims or partial loads
|
||||
// survive a rejected fleet assignment. Carrier namespaces remain distinct.
|
||||
fn execute_boarding(game: &mut Game, player: usize, m: &MoveUnits) -> Result<(), String> {
|
||||
let invalid = || "Invalid fleet boarding assignment".to_string();
|
||||
if m.city.is_some()
|
||||
|| m.attack_pirates
|
||||
|| m.embark_pirate.is_some()
|
||||
|| m.embark_carrier_id.is_some()
|
||||
|| !m.payment.is_empty()
|
||||
|| m.units.is_empty()
|
||||
{
|
||||
return Err(invalid());
|
||||
}
|
||||
let p = game.player(player);
|
||||
let start = p.try_get_unit(m.units[0]).ok_or_else(invalid)?.position;
|
||||
if !game.map.is_land(start)
|
||||
|| !game.map.is_sea(m.destination)
|
||||
|| !start.is_neighbor(m.destination)
|
||||
{
|
||||
return Err(invalid());
|
||||
}
|
||||
let mut seen = HashSet::new();
|
||||
for group in &m.boarding {
|
||||
if !group.boarding.is_empty()
|
||||
|| group.city.is_some()
|
||||
|| group.attack_pirates
|
||||
|| !group.payment.is_empty()
|
||||
|| group.destination != m.destination
|
||||
|| group.units.is_empty()
|
||||
|| (group.embark_carrier_id.is_some() == group.embark_pirate.is_some())
|
||||
{
|
||||
return Err(invalid());
|
||||
}
|
||||
for id in &group.units {
|
||||
let u = p.try_get_unit(*id).ok_or_else(invalid)?;
|
||||
if !seen.insert(*id)
|
||||
|| !u.is_land_based()
|
||||
|| u.carrier_id.is_some()
|
||||
|| u.position != start
|
||||
{
|
||||
return Err(invalid());
|
||||
}
|
||||
}
|
||||
if let Some(id) = group.embark_carrier_id {
|
||||
let ship = p.try_get_unit(id).ok_or_else(invalid)?;
|
||||
if !ship.is_ship() || ship.position != m.destination {
|
||||
return Err(invalid());
|
||||
}
|
||||
}
|
||||
}
|
||||
if seen.len() != m.units.len() || m.units.iter().any(|id| !seen.remove(id)) {
|
||||
return Err(invalid());
|
||||
}
|
||||
let mut preview = game.clone();
|
||||
let mut claimed = std::collections::HashMap::new();
|
||||
if m.boarding.iter().any(|g| g.embark_pirate.is_some()) {
|
||||
if !p.has_special_advance(SpecialAdvance::PirateAllies) {
|
||||
return Err(invalid());
|
||||
}
|
||||
let pirates = crate::content::civilizations::carthage::pirate_player(game);
|
||||
let ships: Vec<_> = game
|
||||
.player(pirates)
|
||||
.units
|
||||
.iter()
|
||||
.filter(|u| u.is_ship() && u.position == m.destination)
|
||||
.map(|u| u.id)
|
||||
.collect();
|
||||
if m.boarding
|
||||
.iter()
|
||||
.filter_map(|g| g.embark_pirate)
|
||||
.any(|id| !ships.contains(&id))
|
||||
{
|
||||
return Err(invalid());
|
||||
}
|
||||
if p.units.iter().filter(|u| u.is_ship()).count() + ships.len() > 8
|
||||
|| p.units
|
||||
.iter()
|
||||
.filter(|u| u.is_ship() && u.position == m.destination)
|
||||
.count()
|
||||
+ ships.len()
|
||||
> 4
|
||||
{
|
||||
return Err(invalid());
|
||||
}
|
||||
for id in ships {
|
||||
claimed.insert(
|
||||
id,
|
||||
crate::content::civilizations::carthage::claim_pirate(&mut preview, player, id),
|
||||
);
|
||||
}
|
||||
}
|
||||
for group in &m.boarding {
|
||||
let mut group = group.clone();
|
||||
if let Some(id) = group.embark_pirate.take() {
|
||||
group.embark_carrier_id = Some(claimed[&id]);
|
||||
}
|
||||
execute_movement_action(&mut preview, Move(group), player)?;
|
||||
}
|
||||
*game = preview;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn execute_move_action(game: &mut Game, player: &EventPlayer, m: &MoveUnits) -> Result<(), String> {
|
||||
let p = player.get(game);
|
||||
let starting_position =
|
||||
|
|
|
|||
|
|
@ -297,7 +297,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":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,
|
||||
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,"carrierCapacity":crate::unit::ship_capacity(p),"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)))});
|
||||
let mut offer = offer;
|
||||
if carrier.is_none()
|
||||
|
|
@ -343,7 +343,7 @@ pub fn movement(game: &Game, seat: usize, units: Vec<u32>) -> Result<Value, Stri
|
|||
let mut action =
|
||||
MoveUnits::new(units.clone(), route.destination, None, payment.clone());
|
||||
action.embark_pirate = Some(ship.id);
|
||||
destinations.push(json!({"position":route.destination,"terrain":game.map.get(route.destination),"payment":payment,"carrier":null,"pirateCarrier":ship.id,"label":"Board allied pirate","attack":false,"action":Action::Movement(MovementAction::Move(action))}));
|
||||
destinations.push(json!({"position":route.destination,"terrain":game.map.get(route.destination),"payment":payment,"carrier":null,"pirateCarrier":ship.id,"carrierCapacity":crate::unit::ship_capacity(p),"label":"Board allied pirate","attack":false,"action":Action::Movement(MovementAction::Move(action))}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -433,3 +433,139 @@ fn exhaustion_still_blocks_collection_and_founding() {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fleet_boarding_assignments_are_atomic_and_share_a_movement_group() {
|
||||
use server::{
|
||||
action::try_execute_action,
|
||||
advance::Advance,
|
||||
game::GameState,
|
||||
map::Terrain,
|
||||
unit::{Unit, UnitType},
|
||||
};
|
||||
for pirates in [false, true] {
|
||||
for split in [false, true] {
|
||||
for count in [2, 4] {
|
||||
let mut game = JSON.load_game("movement");
|
||||
game.state = GameState::Playing;
|
||||
game.actions_left = 3;
|
||||
let start = Position::from_offset("C8");
|
||||
let sea = Position::from_offset("D8");
|
||||
game.map.tiles.clear();
|
||||
game.map.tiles.insert(start, Terrain::Barren);
|
||||
game.map.tiles.insert(sea, Terrain::Water);
|
||||
game.map
|
||||
.tiles
|
||||
.insert(Position::from_offset("E8"), Terrain::Water);
|
||||
for p in &mut game.players {
|
||||
p.units.clear();
|
||||
p.cities.clear();
|
||||
}
|
||||
game.player_mut(0).advances.insert(Advance::Tactics);
|
||||
for id in 0..count {
|
||||
game.player_mut(0).units.push(Unit::new(
|
||||
0,
|
||||
start,
|
||||
if id < 2 {
|
||||
UnitType::Infantry
|
||||
} else {
|
||||
UnitType::Elephant
|
||||
},
|
||||
id,
|
||||
));
|
||||
}
|
||||
game.player_mut(0).next_unit_id = 22;
|
||||
if pirates {
|
||||
game.player_mut(0).civilization = game.cache.get_civilization("Carthage");
|
||||
game.player_mut(0).advances.insert(Advance::Navigation);
|
||||
game.players.push(server::player::Player::new(
|
||||
game.cache.get_civilization("Pirates"),
|
||||
2,
|
||||
));
|
||||
game.player_mut(0)
|
||||
.special_advances
|
||||
.insert(serde_json::from_value(serde_json::json!("PirateAllies")).unwrap());
|
||||
let owner = game
|
||||
.players
|
||||
.iter()
|
||||
.position(|p| p.civilization.name == "Pirates")
|
||||
.unwrap();
|
||||
for id in [2, 3] {
|
||||
game.player_mut(owner).units.push(Unit::new(
|
||||
owner,
|
||||
sea,
|
||||
UnitType::Ship,
|
||||
id,
|
||||
));
|
||||
}
|
||||
} else {
|
||||
for id in [10, 11] {
|
||||
game.player_mut(0)
|
||||
.units
|
||||
.push(Unit::new(0, sea, UnitType::Ship, id));
|
||||
}
|
||||
}
|
||||
let mut m = MoveUnits::new((0..count).collect(), sea, None, ResourcePile::empty());
|
||||
let first = if split { vec![0] } else { vec![0, 1] };
|
||||
let second: Vec<_> = (0..count).filter(|id| !first.contains(id)).collect();
|
||||
m.boarding.push(MoveUnits::new(
|
||||
first.clone(),
|
||||
sea,
|
||||
Some(10),
|
||||
ResourcePile::empty(),
|
||||
));
|
||||
if !second.is_empty() {
|
||||
m.boarding.push(MoveUnits::new(
|
||||
second.clone(),
|
||||
sea,
|
||||
Some(11),
|
||||
ResourcePile::empty(),
|
||||
));
|
||||
}
|
||||
if pirates {
|
||||
for group in &mut m.boarding {
|
||||
group.embark_pirate = group.embark_carrier_id.take().map(|id| id - 8);
|
||||
}
|
||||
}
|
||||
let before = serde_json::to_value(game.clone().data()).unwrap();
|
||||
let result = try_execute_action(game.clone(), Action::Movement(Move(m.clone())), 0);
|
||||
if count == 4 && split {
|
||||
assert!(result.is_err());
|
||||
assert_eq!(serde_json::to_value(game.clone().data()).unwrap(), before);
|
||||
continue;
|
||||
}
|
||||
game = result.unwrap();
|
||||
assert_eq!(game.actions_left, 2);
|
||||
for id in first {
|
||||
assert_eq!(
|
||||
game.player(0).get_unit(id).carrier_id,
|
||||
Some(if pirates { 22 } else { 10 })
|
||||
);
|
||||
}
|
||||
for id in second {
|
||||
assert_eq!(
|
||||
game.player(0).get_unit(id).carrier_id,
|
||||
Some(if pirates { 23 } else { 11 })
|
||||
);
|
||||
}
|
||||
if let GameState::Movement(state) = &game.state {
|
||||
assert_eq!(state.movement_actions_left, 2);
|
||||
} else {
|
||||
panic!("expected movement");
|
||||
}
|
||||
// A repeated assignment cannot transfer passengers at sea or charge again.
|
||||
let before = serde_json::to_value(game.clone().data()).unwrap();
|
||||
assert!(try_execute_action(game.clone(), Action::Movement(Move(m)), 0).is_err());
|
||||
assert_eq!(serde_json::to_value(game.clone().data()).unwrap(), before);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_move_payload_omits_optional_fleet_assignment() {
|
||||
let legacy = serde_json::json!({"units":[1],"destination":"D8","embark_carrier_id":10});
|
||||
let action: MoveUnits = serde_json::from_value(legacy.clone()).unwrap();
|
||||
assert!(action.boarding.is_empty());
|
||||
assert_eq!(serde_json::to_value(action).unwrap(), legacy);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1740,3 +1740,26 @@ Preserve catalog revision 8 (46 definitions), artwork revision 4, all 60 named
|
|||
asset bytes, gallery, preferences/settings and Standard options. The faction
|
||||
artwork manifest's lockfile integrity hash changes only for the viewer version
|
||||
bump; no artwork is republished. No production moves, history edits or rewinds.
|
||||
|
||||
# Viewer 0.1.234 / engine 0.4.165 — local multi-carrier boarding
|
||||
|
||||
Adds an optional, backward-compatible `MoveUnits.boarding` assignment list. A
|
||||
single confirmed move boards one land group onto multiple adjacent co-located
|
||||
ships, validating atomically on a cloned game before committing. Pirate IDs map
|
||||
into the owned namespace only during successful all-space claims. Existing cargo,
|
||||
Longships, Tactics, Navigator, movement allocations and pirate ship limits remain
|
||||
validated. The old sequential client queue is removed; the normal movement panel
|
||||
shows passenger selectors and requires **Board ship** confirmation.
|
||||
|
||||
See [fleet boarding](../../docs/fleet-boarding.md) for payload constraints and
|
||||
regression coverage. Web viewer CI runs the durable WASM suite and desktop/mobile
|
||||
physical-click boarding, existing embark and landing smokes. The civilization
|
||||
smoke uses the current `Abilities` control label rather than its obsolete name.
|
||||
|
||||
Release gate: push matching source to main and require green Check and Web viewer
|
||||
CI **before** BGS publication. Verify all hosted viewer files and downloaded engine
|
||||
bytes, run boarding on those actual artifacts, and preserve catalog revision 8 /
|
||||
46 definitions, artwork revision 4, all 60 named assets and gallery/settings/
|
||||
preferences/Standard options. Only the frozen artwork manifest's lockfile integrity
|
||||
pin changes for the viewer version bump; no artwork or catalog is republished.
|
||||
No production moves, migrations, history edits or rewinds are involved.
|
||||
|
|
|
|||
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.233",
|
||||
"version": "0.1.234",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.233",
|
||||
"version": "0.1.234",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.11.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.233",
|
||||
"version": "0.1.234",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --host 127.0.0.1 --port 8643",
|
||||
"build": "vite build",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"test": "node --experimental-strip-types --test src/*.test.ts && node --test scripts/publish-gallery.test.mjs && npm run test:achievement-assets && npm run test:locales && node scripts/exhausted-movement-check.mjs && CLASH_WASM=\"$PWD/.engine/server.js\" node --test ../scripts/status-phase-battle.test.cjs ../scripts/postcombat-queue.test.cjs ../scripts/tributes.test.cjs",
|
||||
"test": "node --experimental-strip-types --test src/*.test.ts && node --test scripts/publish-gallery.test.mjs scripts/boarding.test.mjs && npm run test:achievement-assets && npm run test:locales && node scripts/exhausted-movement-check.mjs && CLASH_WASM=\"$PWD/.engine/server.js\" node --test ../scripts/status-phase-battle.test.cjs ../scripts/postcombat-queue.test.cjs ../scripts/tributes.test.cjs",
|
||||
"test:boarding": "npm run build:bridge && npm run build && node --test scripts/boarding.test.mjs && node scripts/boarding-smoke.mjs",
|
||||
"test:home-orientation": "npm run build && node scripts/home-orientation-smoke.mjs",
|
||||
"build:achievement-assets": "node scripts/build-achievement-assets.mjs",
|
||||
"test:achievement-assets": "node --test scripts/achievement-assets.test.mjs scripts/publish-achievement-assets.test.mjs scripts/publish-achievement-backups.test.mjs",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
"web-client/src/civilization-emblems.ts": "01b0cbf3fa77a8466532ccd73d63c1a3ddc9bbc79fc06ce7224b425322a9c9f0",
|
||||
"web-client/src/civilization-flags.ts": "cd176076bfe05b3059093b80c88596b7ae46b77898695c6c7406cbe1a3a0f78b",
|
||||
"server/src/content/civilizations.rs": "73602f3db506f3dc2dbc6de43d01179440fd3bb034c997ff209336faaef2a332",
|
||||
"web-client/package-lock.json": "38bdad294151ea0429b09c241e112014a445b77918914886e5a431d268739df5",
|
||||
"web-client/package-lock.json": "e13672f16b16cb39d284f0ba017084769a75fbb4e2ddcc3bc37aefc0e98811d8",
|
||||
"web-client/node_modules/lucide-svelte/dist/Icon.svelte": "f7b49ab842c143fa680fa8bd9a54a9efdc48c2e2d49fa574bd5ccf8f6cfca5be",
|
||||
"web-client/node_modules/lucide-svelte/dist/defaultAttributes.js": "5b8981c6e3434ae6538716af9e0403554e7708c4087f18d060950a7bef00d96a",
|
||||
"web-client/node_modules/lucide-svelte/LICENSE": "668dcc52803480e0a026b31140a4cae668772663cd764e5991d252eef03f98db"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-server",
|
||||
"version": "0.4.164",
|
||||
"version": "0.4.165",
|
||||
"description": "Clash of Cultures: Monumental edition engine for Boardgamers Space",
|
||||
"license": "MIT",
|
||||
"type": "commonjs",
|
||||
|
|
|
|||
22
web-client/scripts/boarding-fixture.mjs
Normal file
22
web-client/scripts/boarding-fixture.mjs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { readFile } from 'node:fs/promises';
|
||||
import { createRequire } from 'node:module';
|
||||
export const engine = createRequire(import.meta.url)('../.engine/server.js');
|
||||
const base = JSON.parse(await readFile(new URL('../../server/tests/test_games/movement/movement.json', import.meta.url), 'utf8'));
|
||||
const fullMap = JSON.parse(await readFile(new URL('../../server/tests/test_games/movement/ship_navigation_unit_test.json', import.meta.url), 'utf8')).map;
|
||||
const npcs = JSON.parse(await engine.init(2, [], {}, 'boarding', {})).players.slice(2);
|
||||
export function fixture(pirates, count) {
|
||||
const state = structuredClone(base);
|
||||
state.state = 'Playing'; state.actions_left = 3;
|
||||
state.players.push(...structuredClone(npcs));
|
||||
for (const p of state.players) { p.units = []; p.cities = []; }
|
||||
const p = state.players[0];
|
||||
p.civilization = pirates ? 'Carthage' : 'Rome';
|
||||
p.advances = ['Farming','Mining','Tactics','Navigation'];
|
||||
p.next_unit_id = 22;
|
||||
p.units = Array.from({length:count}, (_,id) => ({id,position:'F7',unit_type:id < 2 ? 'Infantry' : 'Elephant'}));
|
||||
const owner = pirates ? state.players.find(p => p.civilization === 'Pirates') : p;
|
||||
owner.units.push(...(pirates ? [2,3] : [10,11]).map(id => ({id,position:'F6',unit_type:'Ship'})));
|
||||
state.map = structuredClone(fullMap);
|
||||
state.map.tiles = state.map.tiles.map(([position]) => [position, ['F6','G7'].includes(position) ? 'Water' : 'Fertile']);
|
||||
return state;
|
||||
}
|
||||
84
web-client/scripts/boarding-smoke.mjs
Normal file
84
web-client/scripts/boarding-smoke.mjs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { chromium } from 'playwright';
|
||||
import { engine, fixture } from './boarding-fixture.mjs';
|
||||
// Existing cargo must count, even when the client forges an oversized load.
|
||||
{
|
||||
const state = fixture(false, 3);
|
||||
state.players[0].units.find(u => u.id === 10).carried_units = [{id:9,unit_type:'Infantry'}];
|
||||
const action = {Movement:{Move:{units:[0,1,2],destination:'F6',boarding:[
|
||||
{units:[0],destination:'F6',embark_carrier_id:10},
|
||||
{units:[1,2],destination:'F6',embark_carrier_id:11},
|
||||
]}}};
|
||||
const after = JSON.parse(engine.tryMove(JSON.stringify(state),JSON.stringify(action),0));
|
||||
assert.deepEqual(after.players[0].units.filter(u => u.unit_type === 'Ship').map(u => u.carried_units.length),[2,2]);
|
||||
action.Movement.Move.boarding[0].units = [0,1];
|
||||
action.Movement.Move.boarding[1].units = [2];
|
||||
assert.throws(() => engine.tryMove(JSON.stringify(state),JSON.stringify(action),0));
|
||||
state.players[0].units.find(u => u.id === 10).carried_units.push({id:8,unit_type:'Infantry'});
|
||||
assert.throws(() => engine.tryMove(JSON.stringify(state),JSON.stringify(action),0));
|
||||
}
|
||||
const browser = await chromium.launch({headless:true,args:['--use-gl=angle','--use-angle=swiftshader']});
|
||||
try {
|
||||
for (const width of [1400,390]) for (const pirates of [false,true]) for (const count of [2,4]) {
|
||||
const state = fixture(pirates,count), sent = [], errors = [];
|
||||
const page = await browser.newPage({viewport:{width,height:900}});
|
||||
page.on('pageerror', e => { errors.push(e.message); console.error(e.message); });
|
||||
await page.exposeFunction('captureMove', move => sent.push(JSON.parse(move)));
|
||||
await page.route('**/*', async route => {
|
||||
const path = new URL(route.request().url()).pathname;
|
||||
if (path === '/') return route.fulfill({contentType:'text/html',body:'<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><div id="app"></div><script src="/viewer.js"></script>'});
|
||||
if (!['/viewer.js','/server_bg.wasm'].includes(path)) return route.abort();
|
||||
return route.fulfill({contentType:path.endsWith('.wasm') ? 'application/wasm':'text/javascript',body:await readFile(new URL('../dist'+path,import.meta.url))});
|
||||
});
|
||||
await page.goto('http://clash.test/');
|
||||
await page.evaluate(raw => {
|
||||
window.host = clash3d.launch('#app');
|
||||
host.on('move', m => window.captureMove(m));
|
||||
host.emit('player',{index:0}); host.emit('preferences',{sound:false,mapView:'strategy',homeAtBottom:false}); host.emit('state',raw);
|
||||
},engine.stripSecret(JSON.stringify(state),0));
|
||||
await page.waitForTimeout(800);
|
||||
await page.getByRole('button',{name:'Move units and found cities',exact:true}).click();
|
||||
|
||||
async function tap(position) {
|
||||
await page.locator(`.strategy-map-tile[data-position="${position}"]`).click();
|
||||
await page.waitForTimeout(200);
|
||||
}
|
||||
await tap('F7');
|
||||
|
||||
await tap('F6');
|
||||
const assignments = page.locator('.boarding-assignment select');
|
||||
await assignments.first().waitFor();
|
||||
assert.equal(await assignments.count(),count);
|
||||
assert.equal(sent.length,0,'destination opens cargo choices without submitting');
|
||||
if (count === 2) {
|
||||
await assignments.nth(1).selectOption(String(pirates ? -4 : 11));
|
||||
assert.notEqual(await assignments.nth(0).inputValue(),await assignments.nth(1).inputValue());
|
||||
}
|
||||
await page.getByRole('region',{name:'Unit movement',exact:true}).getByRole('button',{name:/^Board ship/}).click();
|
||||
assert.equal(sent.length,1);
|
||||
const invalid = structuredClone(sent[0]);
|
||||
invalid.Movement.Move.boarding[0].units.push(invalid.Movement.Move.boarding[0].units[0]);
|
||||
assert.throws(() => engine.tryMove(JSON.stringify(state),JSON.stringify(invalid),0));
|
||||
const unknown = structuredClone(sent[0]);
|
||||
unknown.Movement.Move.boarding[0].embark_carrier_id = 9999;
|
||||
delete unknown.Movement.Move.boarding[0].embark_pirate;
|
||||
assert.throws(() => engine.tryMove(JSON.stringify(state),JSON.stringify(unknown),0));
|
||||
if (pirates) {
|
||||
const ordinary = structuredClone(state); ordinary.players[0].civilization = 'Rome';
|
||||
assert.throws(() => engine.tryMove(JSON.stringify(ordinary),JSON.stringify(sent[0]),0));
|
||||
}
|
||||
let after = JSON.parse(engine.tryMove(JSON.stringify(state),JSON.stringify(sent[0]),0));
|
||||
const ships = after.players[0].units.filter(u => u.unit_type === 'Ship');
|
||||
assert.deepEqual(ships.map(u => u.carried_units.length), count === 2 ? [1,1] : [2,2]);
|
||||
assert.equal(after.actions_left,2);
|
||||
assert.equal(after.state.Movement.movement_actions_left,2);
|
||||
assert.throws(() => engine.tryMove(JSON.stringify(after),JSON.stringify(sent[0]),0), 'no same-sea reassignment');
|
||||
after = JSON.parse(engine.tryMove(JSON.stringify(after),JSON.stringify({Movement:{Move:{units:ships.map(u=>u.id),destination:'G7'}}}),0));
|
||||
assert(after.players[0].units.every(u => u.position === 'G7'));
|
||||
assert.deepEqual(errors,[]);
|
||||
assert(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth));
|
||||
console.log('Fleet boarding browser/WASM passed',{width,pirates,count});
|
||||
await page.close();
|
||||
}
|
||||
} finally { await browser.close(); }
|
||||
112
web-client/scripts/boarding.test.mjs
Normal file
112
web-client/scripts/boarding.test.mjs
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { engine, fixture } from './boarding-fixture.mjs';
|
||||
const move = (raw, action) => engine.tryMove(raw, JSON.stringify(action), 0);
|
||||
const assignment = (pirates) => ({Movement:{Move:{units:[0,1,2,3],destination:'F6',boarding:[
|
||||
{units:[0,1],destination:'F6',[pirates?'embark_pirate':'embark_carrier_id']:pirates?2:10},
|
||||
{units:[2,3],destination:'F6',[pirates?'embark_pirate':'embark_carrier_id']:pirates?3:11},
|
||||
]}}});
|
||||
for (const pirates of [false,true]) {
|
||||
test(`compound boarding ${pirates?'pirates':'owned'}: invalid later load leaves all state and subsequent execution unchanged`, () => {
|
||||
const state = fixture(pirates,4), action = assignment(pirates), raw = JSON.stringify(state);
|
||||
const expected = move(raw, action);
|
||||
for (const change of [
|
||||
a => { a.boarding[1].units.push(0); },
|
||||
a => { a.boarding[1][pirates?'embark_pirate':'embark_carrier_id'] = 9999; },
|
||||
a => { a.boarding[0].units = [0]; a.boarding[1].units = [1,2,3]; },
|
||||
a => { a.boarding[1].destination = 'G7'; },
|
||||
a => { a.boarding[1].payment = {gold:1}; },
|
||||
]) {
|
||||
const bad = structuredClone(action); change(bad.Movement.Move);
|
||||
assert.throws(() => move(raw,bad));
|
||||
assert.equal(JSON.stringify(state),raw);
|
||||
// Includes RNG state, claims, logs, action count, history and all private hands.
|
||||
assert.equal(move(raw,action),expected);
|
||||
for (const seat of [0,1,undefined]) assert.equal(engine.stripSecret(raw,seat),engine.stripSecret(JSON.stringify(state),seat));
|
||||
}
|
||||
const after = JSON.parse(expected);
|
||||
assert.equal(after.actions_left,2);
|
||||
assert.equal(after.state.Movement.movement_actions_left,2);
|
||||
assert.deepEqual(after.players[0].units.filter(u=>u.unit_type==='Ship').map(u=>u.carried_units.length),[2,2]);
|
||||
assert.equal(engine.logLength(expected),engine.logLength(raw)+1);
|
||||
const undone = move(expected,'Undo');
|
||||
assert.deepEqual(JSON.parse(undone).players,JSON.parse(engine.setPlayerSettings(raw,0,state.players[0].settings ?? {})).players);
|
||||
const redone = move(undone,'Redo');
|
||||
assert.deepEqual(JSON.parse(redone).players,after.players);
|
||||
assert.equal(JSON.parse(redone).actions_left,after.actions_left);
|
||||
const branched = move(undone,action);
|
||||
assert.deepEqual(JSON.parse(branched).players,after.players);
|
||||
assert.throws(()=>move(expected,action),'no same-space transfers');
|
||||
});
|
||||
test(`compound boarding ${pirates?'pirates':'owned'}: Tactics and per-passenger restrictions are not bypassed`, () => {
|
||||
const state = fixture(pirates,4);
|
||||
state.players[0].advances = state.players[0].advances.filter(a=>a!=='Tactics');
|
||||
assert.throws(()=>move(JSON.stringify(state),assignment(pirates)));
|
||||
const moved = fixture(pirates,4);
|
||||
moved.state = {Movement:{movement_actions_left:2,moved_units:[2]}};
|
||||
assert.throws(()=>move(JSON.stringify(moved),assignment(pirates)));
|
||||
});
|
||||
}
|
||||
|
||||
test('Viking Longships retain three-passenger capacity in a compound assignment', () => {
|
||||
const state = fixture(false,4);
|
||||
state.players[0].civilization = 'Vikings';
|
||||
state.players[0].advances.push('WarShips');
|
||||
const action = assignment(false);
|
||||
action.Movement.Move.boarding[0].units = [0];
|
||||
action.Movement.Move.boarding[1].units = [1,2,3];
|
||||
const after = JSON.parse(move(JSON.stringify(state),action));
|
||||
assert.deepEqual(after.players[0].units.filter(u=>u.unit_type==='Ship').map(u=>u.carried_units.length),[1,3]);
|
||||
});
|
||||
|
||||
for (const pirates of [false,true]) test(`compound boarding projects as one undoable queue entry (${pirates})`, async () => {
|
||||
const { ActionQueue } = await import('../src/action-queue.ts');
|
||||
const raw = JSON.stringify(fixture(pirates,4));
|
||||
const queue = new ActionQueue(engine,0,raw);
|
||||
const before = queue.projected;
|
||||
assert.deepEqual(queue.append(assignment(pirates)),{ok:true});
|
||||
assert.equal(queue.count,1);
|
||||
assert.equal(JSON.parse(queue.projected).actions_left,2);
|
||||
const result = queue.replay(raw);
|
||||
assert.equal(result.applied,1);
|
||||
assert.deepEqual(result.remaining,[]);
|
||||
assert.deepEqual(JSON.parse(result.raw).players,JSON.parse(move(raw,assignment(pirates))).players);
|
||||
queue.undo();
|
||||
assert.equal(queue.count,0);
|
||||
assert.equal(queue.projected,before);
|
||||
});
|
||||
|
||||
test('pirate boarding claims the whole space, maps IDs separately, and enforces 4 per space / 8 total', () => {
|
||||
const state = fixture(true,4);
|
||||
const neutral = state.players.find(p=>p.civilization==='Pirates');
|
||||
// A colored carrier with a numerically colliding ID is never mistaken for a pirate.
|
||||
// Free passenger ID 2 before giving that same numeric ID to an owned ship.
|
||||
state.players[0].units[2].id = 4;
|
||||
state.players[0].units.push({id:2,position:'G7',unit_type:'Ship'});
|
||||
neutral.units.push({id:5,position:'F6',unit_type:'Ship'},{id:6,position:'F6',unit_type:'Ship'});
|
||||
const action = assignment(true);
|
||||
action.Movement.Move.units = [0,1,4,3];
|
||||
action.Movement.Move.boarding[1].units = [4,3];
|
||||
for(let id=30;id<33;id++)state.players[0].units.push({id,position:'G7',unit_type:'Ship'});
|
||||
state.players[0].next_unit_id=40;
|
||||
const after = JSON.parse(move(JSON.stringify(state),action));
|
||||
assert.equal(after.players[0].units.filter(u=>u.unit_type==='Ship').length,8);
|
||||
assert.equal(after.players.find(p=>p.civilization==='Pirates').units?.length??0,0);
|
||||
assert.equal(after.players[0].units.find(u=>u.id===2).position,'G7');
|
||||
assert.deepEqual(after.players[0].units.filter(u=>u.position==='F6').map(u=>u.id),[40,41,42,43]);
|
||||
const ninth = structuredClone(state);
|
||||
ninth.players[0].units.push({id:34,position:'G7',unit_type:'Ship'});
|
||||
assert.throws(()=>move(JSON.stringify(ninth),action));
|
||||
const fifth = structuredClone(state);
|
||||
fifth.players.find(p=>p.civilization==='Pirates').units.push({id:7,position:'F6',unit_type:'Ship'});
|
||||
fifth.players[0].units = fifth.players[0].units.filter(u=>u.id!==32);
|
||||
assert.throws(()=>move(JSON.stringify(fifth),action));
|
||||
});
|
||||
|
||||
test('Navigator cannot be used to embark fresh land passengers', () => {
|
||||
const state = fixture(false,4);
|
||||
state.players[0].civilization = 'Carthage';
|
||||
state.players[0].event_info = {'Navigator active':'yes'};
|
||||
state.state = {Movement:{movement_actions_left:1,unit_only:true}};
|
||||
assert.throws(()=>move(JSON.stringify(state),assignment(false)));
|
||||
});
|
||||
|
|
@ -125,7 +125,7 @@ try {
|
|||
az.players[enemy].held_units = { infantry: 2 };
|
||||
app = await load(width, dark, az);
|
||||
page = app.page;
|
||||
await page.getByRole('button', { name: 'Abilities and cultural influence', exact: true }).click();
|
||||
await page.getByRole('button', { name: 'Abilities', exact: true }).click();
|
||||
await page.getByRole('button', { name: /Use Human Sacrifice/ }).click();
|
||||
const decision = page.getByRole('region', { name: 'Human Sacrifice', exact: true });
|
||||
await decision.waitFor();
|
||||
|
|
|
|||
|
|
@ -48,8 +48,10 @@ try {
|
|||
assert.match(await panel.innerText(), /3 selected/);
|
||||
await tap('C3');
|
||||
assert.equal(await panel.getByRole('button',{name:/Board all/}).count(),0);
|
||||
assert.equal(await page.evaluate(() => sent.length),0,'destination only opens passenger assignments');
|
||||
await panel.getByRole('button',{name:/^Board ship/}).click();
|
||||
let raw=JSON.stringify(state);
|
||||
for(let i=0;i<2;i++) {
|
||||
for(let i=0;i<1;i++) {
|
||||
await page.waitForFunction(i=>sent.length>i,i);
|
||||
const action=await page.evaluate(i=>sent[i],i);
|
||||
raw=engine.tryMove(raw,typeof action==='string'?action:JSON.stringify(action),0);
|
||||
|
|
|
|||
|
|
@ -12,11 +12,18 @@ const input = JSON.parse(
|
|||
'utf8',
|
||||
),
|
||||
);
|
||||
// Old native fixture predates the always-present NPC seats. Do not rewrite
|
||||
// optional exported saves: only complete this local test fixture.
|
||||
if (!process.argv[2]) {
|
||||
const npcs = JSON.parse(await engine.init(2, [], {}, 'undo-smoke', {})).players.slice(2);
|
||||
for (const npc of npcs) if (!input.players.some(p => p.civilization === npc.civilization))
|
||||
input.players.push({ ...npc, id: input.players.length });
|
||||
}
|
||||
const initial = input.data ?? JSON.stringify(input);
|
||||
const seat = engine.currentPlayer(initial);
|
||||
const view = (state) => JSON.parse(engine.webView(state, seat));
|
||||
const freeEconomy = (state) =>
|
||||
view(state).collectActions.some((a) => a.value?.Custom === 'FreeEconomyCollect');
|
||||
view(state).collectActions.some((a) => a.value?.Special?.Modifier === 'FreeEconomyCollect');
|
||||
assert(freeEconomy(initial), 'Free Economy must be available after undo');
|
||||
const city = view(initial).cities.find((c) => c.canActivate && c.choices.length);
|
||||
const choice = city.choices[0];
|
||||
|
|
@ -41,7 +48,12 @@ const redone = advance(undone, 'Redo');
|
|||
assert.equal(engine.logLength(redone), engine.logLength(collected));
|
||||
assert.deepEqual(engine.logSlice(redone, { start: 0 }), engine.logSlice(collected, { start: 0 }));
|
||||
const rewound = advance(redone, 'Undo');
|
||||
let free = advance(rewound, collect({ Custom: 'FreeEconomyCollect' }));
|
||||
const freeVariant = view(rewound).collectActions.find(a => a.free);
|
||||
const freeAction = JSON.parse(engine.webQuery(engine.stripSecret(rewound,seat),seat,JSON.stringify({
|
||||
kind:'collect',city:city.position,variant:freeVariant.value,
|
||||
selections:[{position:choice.position,pile:choice.pile,times:1}],
|
||||
}))).action;
|
||||
let free = advance(rewound, freeAction);
|
||||
free = advance(free, { Response: { Payment: [{ mood_tokens: 1 }] } });
|
||||
assert.equal(JSON.parse(free).actions_left, JSON.parse(initial).actions_left);
|
||||
assert.equal(
|
||||
|
|
@ -119,9 +131,11 @@ try {
|
|||
(before) => document.querySelector('[aria-label="Journal"]').innerText === before,
|
||||
baseline,
|
||||
);
|
||||
await page.getByRole('button', { name: 'Close table activity', exact: true }).click();
|
||||
const closeActivity = page.getByRole('button', { name: 'Close table activity', exact: true });
|
||||
if (width < 600) { await closeActivity.focus(); await closeActivity.press('Enter'); }
|
||||
else await closeActivity.click();
|
||||
await page.getByRole('button', { name: 'Collect resources', exact: true }).click();
|
||||
const freeButton = page.getByRole('button', { name: 'Free Economy', exact: true });
|
||||
const freeButton = page.locator('.variant-picker button').filter({ hasText: 'Free Economy' });
|
||||
await freeButton.click();
|
||||
assert.equal(await freeButton.getAttribute('aria-pressed'), 'true');
|
||||
await page.screenshot({ path: '/tmp/clash-undo-free-economy-' + width + '.png' });
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { boardingCarrier } from './boarding';
|
||||
import CombatEstimate from './CombatEstimate.svelte';
|
||||
import { onDestroy } from 'svelte';
|
||||
import {
|
||||
|
|
@ -258,20 +259,40 @@
|
|||
{#if settler && !$session.game?.players.some((p) => p.cities?.some((c) => c.position === settler.position))}
|
||||
<FoundCityAction {controller} {settler} />
|
||||
{/if}
|
||||
{#if destination?.boarding}
|
||||
<div class="boarding-assignment">
|
||||
{#each destination.boarding.flatMap(g => g.units) as id (id)}
|
||||
<label>
|
||||
{units.find(u => u.id === id)?.type} #{id}
|
||||
<select disabled={$session.pending || !!$session.playback}
|
||||
value={destination.boarding.find(g => g.units.includes(id))?.carrier}
|
||||
onchange={e => controller.assignPassenger(id, Number(e.currentTarget.value))}>
|
||||
{#each controller.boardingOptions(id, destination.position) as offer}
|
||||
{@const carrier = boardingCarrier(offer)!}
|
||||
<option value={carrier}>
|
||||
{carrier < 0 ? 'Allied pirate' : 'Board ship'} #{carrier < 0 ? -carrier - 1 : carrier}
|
||||
({units.filter(u => u.carrier === carrier).length} + {destination.boarding.find(g => g.carrier === carrier)?.units.length ?? 0} / {offer.carrierCapacity ?? 2})
|
||||
</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
{#if !units.length && !$session.view?.nomadCities?.length}<p>Recruit units in a city to explore.</p>{/if}
|
||||
{#if $session.error}<p class="inline-error" role="alert">{$session.error}</p>{/if}
|
||||
</div>
|
||||
{#if destination && !destination.boarding && destination.terrain !== 'Unexplored'}<div class="settler-confirm">
|
||||
{#if destination && destination.terrain !== 'Unexplored'}<div class="settler-confirm">
|
||||
<button
|
||||
class="primary wide"
|
||||
disabled={!!$session.playback || $session.pending}
|
||||
onclick={() => controller.submit(destination.action)}
|
||||
onclick={() => destination.boarding ? controller.boardSelectedUnits() : controller.submit(destination.action)}
|
||||
>
|
||||
{destination.breaksDiplomacy
|
||||
? 'Break agreement & attack'
|
||||
: destination.attack
|
||||
? 'Attack'
|
||||
: destination.carrier != null || destination.pirateCarrier != null
|
||||
: destination.boarding || destination.carrier != null || destination.pirateCarrier != null
|
||||
? 'Board ship'
|
||||
: disembarking
|
||||
? 'Disembark'
|
||||
|
|
@ -285,6 +306,9 @@
|
|||
</section>
|
||||
|
||||
<style>
|
||||
.boarding-assignment { display: grid; gap: .5rem; margin: .5rem 0; }
|
||||
.boarding-assignment label { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem; }
|
||||
.boarding-assignment select { max-width: 100%; padding: .4rem; }
|
||||
.movement-body { min-height: 0; overflow-y: auto; }
|
||||
.movement-heading, .settler-confirm { flex-shrink: 0; }
|
||||
.settler-confirm { border-top: 1px solid var(--line); padding-top: 0.5rem; }
|
||||
|
|
|
|||
|
|
@ -17,3 +17,17 @@ test('boarding can redistribute a passenger but cannot bypass a unit restriction
|
|||
assert.equal(boardingPlan([1,2,3], 'E6', query([2,2],[2])),null);
|
||||
assert.equal(boardingPlan([1,2,3], 'E6', query([2,2]),{unit:1,carrier:9}),null);
|
||||
});
|
||||
test('explicit passenger choice preserves the other passenger (1+1 and 2+0)', () => {
|
||||
const initial = boardingPlan([1,2], 'E6', query([2,2]))!;
|
||||
const split = boardingPlan([1,2], 'E6', query([2,2]), {unit:2,carrier:1}, initial)!;
|
||||
assert.deepEqual(split.find(g => g.carrier === 0)?.units, [1]);
|
||||
assert.deepEqual(split.find(g => g.carrier === 1)?.units, [2]);
|
||||
const packed = boardingPlan([1,2], 'E6', query([2,2]), {unit:2,carrier:0}, split)!;
|
||||
assert.equal(packed.length, 1);
|
||||
assert.equal(packed[0].units.length, 2);
|
||||
});
|
||||
test('neutral and owned carrier IDs occupy separate namespaces', () => {
|
||||
const pirateQuery = (ids: number[]) => query([2,2])(ids).map((d,i) => i ? {...d,carrier:null,pirateCarrier:0} : d);
|
||||
const plan = boardingPlan([1,2,3,4], 'E6', pirateQuery)!;
|
||||
assert.deepEqual(plan.map(g => [g.carrier,g.units.length]), [[0,2],[-1,2]]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import type { MoveDestination } from './types';
|
||||
export const boardingCarrier = (d: MoveDestination) => d.pirateCarrier != null ? -d.pirateCarrier - 1 : d.carrier;
|
||||
export interface BoardingGroup { carrier: number; units: number[] }
|
||||
// Ask the engine about each partial load: this includes existing passengers,
|
||||
// civilization capacity bonuses and every selected unit's movement restrictions.
|
||||
export function boardingPlan(ids: number[], position: string,
|
||||
query: (ids: number[]) => MoveDestination[], forced?: { unit: number; carrier: number }): BoardingGroup[] | null {
|
||||
const options = new Map(ids.map(id => [id, query([id]).filter(d => d.position === position && d.carrier != null && !Object.values(d.payment).some(Boolean))]));
|
||||
query: (ids: number[]) => MoveDestination[], forced?: { unit: number; carrier: number }, preferred: BoardingGroup[] = []): BoardingGroup[] | null {
|
||||
const options = new Map(ids.map(id => [id, query([id]).filter(d => d.position === position && boardingCarrier(d) != null && !Object.values(d.payment).some(Boolean))]));
|
||||
const groups: BoardingGroup[] = [];
|
||||
const ordered = [...ids].sort((a,b) => Number(b === forced?.unit) - Number(a === forced?.unit));
|
||||
const cache = new Map<string, boolean>();
|
||||
|
|
@ -14,13 +15,15 @@ export function boardingPlan(ids: number[], position: string,
|
|||
const state = index + ':' + groups.map(g => g.carrier + '=' + [...g.units].sort((a,b)=>a-b).join(',')).sort().join(';');
|
||||
if (failed.has(state)) return false;
|
||||
const id = ordered[index];
|
||||
for (const offer of options.get(id) ?? []) {
|
||||
const carrier = offer.carrier!;
|
||||
const prior = preferred.find(g => g.units.includes(id))?.carrier;
|
||||
const offers = [...(options.get(id) ?? [])].sort((a,b) => Number(boardingCarrier(b) === prior) - Number(boardingCarrier(a) === prior));
|
||||
for (const offer of offers) {
|
||||
const carrier = boardingCarrier(offer)!;
|
||||
if (forced?.unit === id && forced.carrier !== carrier) continue;
|
||||
const existing = groups.find(g => g.carrier === carrier);
|
||||
const units = [...(existing?.units ?? []), id];
|
||||
const key = carrier + ':' + [...units].sort((a,b)=>a-b).join(',');
|
||||
if (!cache.has(key)) cache.set(key, query(units).some(d => d.position === position && d.carrier === carrier && !Object.values(d.payment).some(Boolean)));
|
||||
if (!cache.has(key)) cache.set(key, query(units).some(d => d.position === position && boardingCarrier(d) === carrier && !Object.values(d.payment).some(Boolean)));
|
||||
if (!cache.get(key)) continue;
|
||||
if (existing) existing.units.push(id); else groups.push({carrier, units:[id]});
|
||||
if (assign(index+1)) return true;
|
||||
|
|
|
|||
|
|
@ -2659,12 +2659,13 @@ for (const predictions of [true, false]) test(`boarding across two ships spends
|
|||
assert(destination?.boarding);
|
||||
assert.equal(destination.boarding.length,2);
|
||||
c.chooseMoveDestination('C3');
|
||||
assert.equal(app.sent.length,1,'Clicking the fleet starts boarding immediately');
|
||||
for (let i=0; i<2; i++) {
|
||||
assert(app.sent[i], 'Boarding continues after server acknowledgement');
|
||||
raw = engine.tryMove(raw,app.sent[i],0);
|
||||
await c.load(engine.stripSecret(raw,0));
|
||||
}
|
||||
assert.equal(app.sent.length,0,'Destination opens assignment before the existing confirmation');
|
||||
c.assignPassenger(0,8);
|
||||
c.boardSelectedUnits();
|
||||
assert.equal(app.sent.length,1,'The whole fleet is submitted atomically');
|
||||
raw = engine.tryMove(raw,app.sent[0],0);
|
||||
await c.load(engine.stripSecret(raw,0));
|
||||
assert.equal(app.sent.length,1,'No queued follow-up with stale carrier IDs');
|
||||
const after = JSON.parse(raw);
|
||||
assert.equal(after.state.Movement.movement_actions_left,g.state.Movement.movement_actions_left-1);
|
||||
assert.equal(after.players[0].units.filter((u:any) => u.unit_type==='Ship').flatMap((u:any)=>u.carried_units??[]).length,3);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { ActionQueue } from './action-queue';
|
|||
import { liveActionMessages } from './live-actions';
|
||||
import { eventNotices, liveEventNotices } from './event-notices';
|
||||
import { publicActions } from './replay-actions';
|
||||
import { boardingPlan, type BoardingGroup } from './boarding';
|
||||
import { boardingCarrier, boardingPlan } from './boarding';
|
||||
import { activeInfluence, influenceKey, influenceDestinationKey, influenceDestinations, influenceMapPick, influencePaymentMatches } from './influence';
|
||||
import { defaultCity, type CollectionPotential } from './default-city';
|
||||
import { nextCollectionSelection } from './collection-yield';
|
||||
|
|
@ -138,7 +138,6 @@ export class Controller {
|
|||
private migratedSkipRaze = false;
|
||||
private keepCitiesRequest: { seat: number; raw: string } | null = null;
|
||||
private movePreviewSelection: string | null = null;
|
||||
private boardingQueue: { position: string; group: BoardingGroup }[] = [];
|
||||
private moveCache = new Map<string, Session['moveDestinations']>();
|
||||
private engine: Bridge | null = null;
|
||||
private timer: ReturnType<typeof setTimeout> | undefined;
|
||||
|
|
@ -287,7 +286,6 @@ export class Controller {
|
|||
clearTimeout(this.refreshTimer);
|
||||
// A rejected move invalidates its prediction and every move queued behind it.
|
||||
this.outbox = [];
|
||||
this.boardingQueue = [];
|
||||
this.showConfirmed();
|
||||
this.keepCitiesRequest = null;
|
||||
this.cardContinuation = null;
|
||||
|
|
@ -667,7 +665,6 @@ export class Controller {
|
|||
this.migrateRazeSetting();
|
||||
}
|
||||
if (automaticPayment) this.submit(automaticPayment);
|
||||
else if (!quiet) this.continueBoarding();
|
||||
}
|
||||
private seenKey() {
|
||||
const s = get(this.session);
|
||||
|
|
@ -1320,7 +1317,6 @@ export class Controller {
|
|||
if (!destination) return;
|
||||
if (destination.boarding) {
|
||||
this.patch({ moveTarget: destination.position, moveDestination: index });
|
||||
this.boardSelectedUnits();
|
||||
return;
|
||||
}
|
||||
const selection = this.raw + JSON.stringify(destination.action);
|
||||
|
|
@ -1355,35 +1351,35 @@ export class Controller {
|
|||
movementDestinations(ids: number[], city: string | null = null) {
|
||||
const destinations = this.rawMovementDestinations(ids, city);
|
||||
const s = get(this.session);
|
||||
if (city || !ids.length || ids.some(id => s.view?.units?.find(u => u.id === id)?.type === 'Ship')) return destinations;
|
||||
const positions = new Set(this.rawMovementDestinations([ids[0]]).filter(d => d.carrier != null).map(d => d.position));
|
||||
if (city || !ids.length || ids.some(id => { const u = s.view?.units?.find(u => u.id === id); return !u || u.type === 'Ship' || u.carrier != null; })) return destinations;
|
||||
const positions = new Set(this.rawMovementDestinations([ids[0]]).filter(d => boardingCarrier(d) != null).map(d => d.position));
|
||||
const extra: Session['moveDestinations'] = [];
|
||||
for (const position of positions) {
|
||||
const ships = s.view?.units?.filter(u => u.type === 'Ship' && u.position === position) ?? [];
|
||||
const ships = this.rawMovementDestinations([ids[0]]).filter(d => d.position === position && boardingCarrier(d) != null);
|
||||
if (ships.length < 2) continue;
|
||||
const boarding = boardingPlan(ids, position, units => this.rawMovementDestinations(units));
|
||||
const offer = this.rawMovementDestinations([ids[0]]).find(d => d.position === position && d.carrier != null);
|
||||
const offer = this.rawMovementDestinations([ids[0]]).find(d => d.position === position && boardingCarrier(d) != null);
|
||||
if (boarding && offer) extra.push({ ...offer, boarding, carrier: null });
|
||||
}
|
||||
return [...destinations.filter(d => !(d.carrier != null && extra.some(e => e.position === d.position))), ...extra];
|
||||
return [...destinations.filter(d => !(boardingCarrier(d) != null && extra.some(e => e.position === d.position))), ...extra];
|
||||
}
|
||||
private boardSelectedUnits() {
|
||||
boardingOptions(unit: number, position: string) {
|
||||
return this.rawMovementDestinations([unit]).filter(d => d.position === position && boardingCarrier(d) != null);
|
||||
}
|
||||
assignPassenger(unit: number, carrier: number) {
|
||||
const s = get(this.session), index = s.moveDestination;
|
||||
if (s.pending || s.playback || index == null) return;
|
||||
const destination = s.moveDestinations[index];
|
||||
const ids = destination.boarding?.flatMap(g => g.units) ?? [];
|
||||
const boarding = boardingPlan(ids, destination.position, units => this.rawMovementDestinations(units), {unit, carrier}, destination.boarding);
|
||||
if (boarding) this.patch({moveDestinations: s.moveDestinations.map((d,i) => i === index ? {...d, boarding} : d)});
|
||||
}
|
||||
boardSelectedUnits() {
|
||||
const s = get(this.session), destination = s.moveDestination == null ? null : s.moveDestinations[s.moveDestination];
|
||||
if (s.pending || s.playback || !destination?.boarding) return;
|
||||
this.boardingQueue = destination.boarding.map(group => ({position: destination.position, group}));
|
||||
this.continueBoarding();
|
||||
}
|
||||
private continueBoarding() {
|
||||
const s = get(this.session);
|
||||
if (s.pending || !this.boardingQueue.length) return;
|
||||
const next = this.boardingQueue.shift()!;
|
||||
const offer = this.rawMovementDestinations(next.group.units).find(d => d.position === next.position && d.carrier === next.group.carrier);
|
||||
if (!offer) {
|
||||
this.boardingQueue = [];
|
||||
this.patch({error: 'Boarding stopped because the remaining units can no longer board. Select them again.'});
|
||||
return;
|
||||
}
|
||||
this.submit(offer.action);
|
||||
const boarding = destination.boarding.map(g => ({units: g.units, destination: destination.position,
|
||||
...(g.carrier < 0 ? {embark_pirate: -g.carrier - 1} : {embark_carrier_id: g.carrier})}));
|
||||
this.submit({Movement: {Move: {units: boarding.flatMap(g => g.units), destination: destination.position, boarding}}});
|
||||
}
|
||||
moveOrigins(position: string) {
|
||||
const s = get(this.session);
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Byg Havn · {p0}",
|
||||
"Construct wonder": "Byg vidunder",
|
||||
"Construct, recruit and improve happiness": "Byg, rekruttér og øg lykken",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Hver civilisation har sine egne fremskridt. Rom får Akvædukt, når den forsker i Ingeniørkunst. Åbn Fremskridt, og forsk i Ingeniørkunst; Akvædukt låses automatisk op uden et separat køb."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Hver civilisation har sine egne fremskridt. Rom får Akvædukt, når den forsker i Ingeniørkunst. Åbn Fremskridt, og forsk i Ingeniørkunst; Akvædukt låses automatisk op uden et separat køb.",
|
||||
"Invalid fleet boarding assignment": "Ugyldig fordeling ved ombordstigning",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Hafen bauen · {p0}",
|
||||
"Construct wonder": "Weltwunder errichten",
|
||||
"Construct, recruit and improve happiness": "Bauen, rekrutieren und Stimmung verbessern",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Jede Zivilisation hat eigene Fortschritte. Rom erhält Aquädukt, wenn es Ingenieurwesen erforscht. Öffne Fortschritte und erforsche Ingenieurwesen; Aquädukt wird automatisch freigeschaltet, ohne einen gesonderten Kauf."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Jede Zivilisation hat eigene Fortschritte. Rom erhält Aquädukt, wenn es Ingenieurwesen erforscht. Öffne Fortschritte und erforsche Ingenieurwesen; Aquädukt wird automatisch freigeschaltet, ohne einen gesonderten Kauf.",
|
||||
"Invalid fleet boarding assignment": "Ungültige Zuordnung beim Einschiffen",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Κατασκευή Λιμανιού · {p0}",
|
||||
"Construct wonder": "Κατασκευή θαύματος",
|
||||
"Construct, recruit and improve happiness": "Κατασκευή, στρατολόγηση και αύξηση ευτυχίας",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Κάθε πολιτισμός έχει τις δικές του προόδους. Η Ρώμη αποκτά το Υδραγωγείο όταν ερευνά τη Μηχανική. Άνοιξε τις Προόδους και ερεύνησε τη Μηχανική· το Υδραγωγείο ξεκλειδώνει αυτόματα, χωρίς ξεχωριστή αγορά."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Κάθε πολιτισμός έχει τις δικές του προόδους. Η Ρώμη αποκτά το Υδραγωγείο όταν ερευνά τη Μηχανική. Άνοιξε τις Προόδους και ερεύνησε τη Μηχανική· το Υδραγωγείο ξεκλειδώνει αυτόματα, χωρίς ξεχωριστή αγορά.",
|
||||
"Invalid fleet boarding assignment": "Μη έγκυρη ανάθεση επιβίβασης στον στόλο",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Construct Port · {p0}",
|
||||
"Construct wonder": "Construct wonder",
|
||||
"Construct, recruit and improve happiness": "Construct, recruit and improve happiness",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.",
|
||||
"Invalid fleet boarding assignment": "Invalid fleet boarding assignment",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "ساخت بندر · {p0}",
|
||||
"Construct wonder": "ساخت شگفتی",
|
||||
"Construct, recruit and improve happiness": "ساخت، جذب نیرو و افزایش شادی",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "هر تمدن پیشرفتهای مخصوص خود را دارد. روم با پژوهش مهندسی، آبگذر را به دست میآورد. پیشرفتها را باز کنید و مهندسی را پژوهش کنید؛ آبگذر خودکار و بدون خرید جداگانه باز میشود."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "هر تمدن پیشرفتهای مخصوص خود را دارد. روم با پژوهش مهندسی، آبگذر را به دست میآورد. پیشرفتها را باز کنید و مهندسی را پژوهش کنید؛ آبگذر خودکار و بدون خرید جداگانه باز میشود.",
|
||||
"Invalid fleet boarding assignment": "تخصیص نامعتبر برای سوار شدن به ناوگان",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Construire un Port · {p0}",
|
||||
"Construct wonder": "Construire une merveille",
|
||||
"Construct, recruit and improve happiness": "Construire, recruter et améliorer le bonheur",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Chaque civilisation possède ses propres avancées. Rome obtient Aqueduc en recherchant Ingénierie. Ouvrez Progrès et recherchez Ingénierie ; Aqueduc se débloque automatiquement, sans achat séparé."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Chaque civilisation possède ses propres avancées. Rome obtient Aqueduc en recherchant Ingénierie. Ouvrez Progrès et recherchez Ingénierie ; Aqueduc se débloque automatiquement, sans achat séparé.",
|
||||
"Invalid fleet boarding assignment": "Affectation d’embarquement invalide",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "बंदरगाह बनाएँ · {p0}",
|
||||
"Construct wonder": "अजूबा बनाएँ",
|
||||
"Construct, recruit and improve happiness": "निर्माण करें, भर्ती करें और खुशहाली बढ़ाएँ",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "हर सभ्यता की अपनी उन्नतियाँ होती हैं। रोम अभियांत्रिकी पर शोध करने पर जलसेतु पाता है। उन्नतियाँ खोलें और अभियांत्रिकी पर शोध करें; जलसेतु अलग खरीद के बिना अपने-आप खुल जाता है।"
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "हर सभ्यता की अपनी उन्नतियाँ होती हैं। रोम अभियांत्रिकी पर शोध करने पर जलसेतु पाता है। उन्नतियाँ खोलें और अभियांत्रिकी पर शोध करें; जलसेतु अलग खरीद के बिना अपने-आप खुल जाता है।",
|
||||
"Invalid fleet boarding assignment": "बेड़े पर चढ़ने का अमान्य आवंटन",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Costruisci Porto · {p0}",
|
||||
"Construct wonder": "Costruisci una meraviglia",
|
||||
"Construct, recruit and improve happiness": "Costruisci, recluta e aumenta la felicità",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Ogni civiltà ha i propri progressi. Roma ottiene Acquedotto quando ricerca Ingegneria. Apri Progressi e ricerca Ingegneria; Acquedotto si sblocca automaticamente, senza un acquisto separato."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Ogni civiltà ha i propri progressi. Roma ottiene Acquedotto quando ricerca Ingegneria. Apri Progressi e ricerca Ingegneria; Acquedotto si sblocca automaticamente, senza un acquisto separato.",
|
||||
"Invalid fleet boarding assignment": "Assegnazione di imbarco sulla flotta non valida",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "항구 건설 · {p0}",
|
||||
"Construct wonder": "불가사의 건설",
|
||||
"Construct, recruit and improve happiness": "건설·모집·행복 개선",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "문명마다 고유 발전이 있습니다. 로마는 공학을 연구하면 수로를 얻습니다. 발전을 열고 공학을 연구하세요. 수로는 따로 구매하지 않아도 자동으로 해금됩니다."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "문명마다 고유 발전이 있습니다. 로마는 공학을 연구하면 수로를 얻습니다. 발전을 열고 공학을 연구하세요. 수로는 따로 구매하지 않아도 자동으로 해금됩니다.",
|
||||
"Invalid fleet boarding assignment": "함대 승선 배정이 유효하지 않습니다",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Haven bouwen · {p0}",
|
||||
"Construct wonder": "Wonder bouwen",
|
||||
"Construct, recruit and improve happiness": "Bouwen, rekruteren en tevredenheid verhogen",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Elke beschaving heeft eigen ontwikkelingen. Rome krijgt Aquaduct wanneer het Bouwkunde onderzoekt. Open Ontwikkelingen en onderzoek Bouwkunde; Aquaduct wordt automatisch ontgrendeld, zonder aparte aankoop."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Elke beschaving heeft eigen ontwikkelingen. Rome krijgt Aquaduct wanneer het Bouwkunde onderzoekt. Open Ontwikkelingen en onderzoek Bouwkunde; Aquaduct wordt automatisch ontgrendeld, zonder aparte aankoop.",
|
||||
"Invalid fleet boarding assignment": "Ongeldige indeling voor inscheping op de vloot",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Zbuduj Port · {p0}",
|
||||
"Construct wonder": "Zbuduj cud",
|
||||
"Construct, recruit and improve happiness": "Buduj, rekrutuj i poprawiaj nastrój",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Każda cywilizacja ma własne postępy. Rzym otrzymuje Akwedukt po zbadaniu Inżynierii. Otwórz Postępy i zbadaj Inżynierię; Akwedukt odblokowuje się automatycznie, bez osobnego zakupu."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Każda cywilizacja ma własne postępy. Rzym otrzymuje Akwedukt po zbadaniu Inżynierii. Otwórz Postępy i zbadaj Inżynierię; Akwedukt odblokowuje się automatycznie, bez osobnego zakupu.",
|
||||
"Invalid fleet boarding assignment": "Nieprawidłowy przydział jednostek do statków",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Construir Porto · {p0}",
|
||||
"Construct wonder": "Construir Maravilha",
|
||||
"Construct, recruit and improve happiness": "Construir, recrutar e melhorar felicidade",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Cada civilização tem seus próprios avanços. Roma ganha Aqueduto ao pesquisar Engenharia. Abra Avanços e pesquise Engenharia; Aqueduto desbloqueia automaticamente, sem uma compra separada."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Cada civilização tem seus próprios avanços. Roma ganha Aqueduto ao pesquisar Engenharia. Abra Avanços e pesquise Engenharia; Aqueduto desbloqueia automaticamente, sem uma compra separada.",
|
||||
"Invalid fleet boarding assignment": "Distribuição inválida para embarque na frota",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Construiește Port · {p0}",
|
||||
"Construct wonder": "Construiește o minune",
|
||||
"Construct, recruit and improve happiness": "Construiește, recrutează și îmbunătățește fericirea",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Fiecare civilizație are propriile progrese. Roma primește Apeduct când cercetează Inginerie. Deschide Progrese și cercetează Inginerie; Apeduct se deblochează automat, fără o achiziție separată."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Fiecare civilizație are propriile progrese. Roma primește Apeduct când cercetează Inginerie. Deschide Progrese și cercetează Inginerie; Apeduct se deblochează automat, fără o achiziție separată.",
|
||||
"Invalid fleet boarding assignment": "Repartizare nevalidă pentru îmbarcare",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Построить порт · {p0}",
|
||||
"Construct wonder": "Построить чудо",
|
||||
"Construct, recruit and improve happiness": "Строительство, найм и повышение счастья",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "У каждой цивилизации свои достижения. Рим получает Акведук, когда исследует Инженерию. Откройте «Достижения» и исследуйте Инженерию; Акведук откроется автоматически, без отдельной покупки."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "У каждой цивилизации свои достижения. Рим получает Акведук, когда исследует Инженерию. Откройте «Достижения» и исследуйте Инженерию; Акведук откроется автоматически, без отдельной покупки.",
|
||||
"Invalid fleet boarding assignment": "Недопустимое распределение при посадке на корабли",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "Xây Cảng · {p0}",
|
||||
"Construct wonder": "Xây Kỳ quan",
|
||||
"Construct, recruit and improve happiness": "Xây dựng, tuyển quân và tăng hạnh phúc",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Mỗi nền văn minh có tiến bộ riêng. La Mã nhận Cầu dẫn nước khi nghiên cứu Kỹ thuật. Mở Các tiến bộ và nghiên cứu Kỹ thuật; Cầu dẫn nước tự mở khóa, không cần mua riêng."
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "Mỗi nền văn minh có tiến bộ riêng. La Mã nhận Cầu dẫn nước khi nghiên cứu Kỹ thuật. Mở Các tiến bộ và nghiên cứu Kỹ thuật; Cầu dẫn nước tự mở khóa, không cần mua riêng.",
|
||||
"Invalid fleet boarding assignment": "Phân bổ lên hạm đội không hợp lệ",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "建造港口 · {p0}",
|
||||
"Construct wonder": "建造奇迹",
|
||||
"Construct, recruit and improve happiness": "建造、招募并提升幸福度",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "各文明都有专属进步。罗马研究工程学时获得引水渠。打开进步并研究工程学,引水渠自动解锁,无需单独购买。"
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "各文明都有专属进步。罗马研究工程学时获得引水渠。打开进步并研究工程学,引水渠自动解锁,无需单独购买。",
|
||||
"Invalid fleet boarding assignment": "舰队登船分配无效",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5306,5 +5306,7 @@
|
|||
"Construct Port · {p0}": "建造港口 · {p0}",
|
||||
"Construct wonder": "建造奇觀",
|
||||
"Construct, recruit and improve happiness": "建造、招募與提升幸福",
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "每個文明都有專屬科技。羅馬研究工程學時獲得水道橋。開啟科技並研究工程學;水道橋會自動解鎖,不需要另行購買。"
|
||||
"Each civilization has its own advances. Rome gains Aqueduct when it researches Engineering. Open Advances and research Engineering; Aqueduct unlocks automatically, without a separate purchase.": "每個文明都有專屬科技。羅馬研究工程學時獲得水道橋。開啟科技並研究工程學;水道橋會自動解鎖,不需要另行購買。",
|
||||
"Invalid fleet boarding assignment": "艦隊登船分配無效",
|
||||
"{p0} #{p1} ({p2} + {p3} / {p4})": "{p0} #{p1} ({p2} + {p3} / {p4})"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,11 @@ function excluded(raw: string, move: unknown, seat: number) {
|
|||
return (game.players ?? []).some(
|
||||
(player: Json) =>
|
||||
player.id !== seat &&
|
||||
// Explicit peaceful fleet boarding claims allied pirates without combat.
|
||||
// The engine still validates Pirate Allies, every assignment and capacity
|
||||
// in both hidden-state samples; other opponents remain excluded.
|
||||
!(player.civilization === 'Pirates' &&
|
||||
(move as Json).Movement?.Move?.boarding?.some((group: Json) => group.embark_pirate !== undefined)) &&
|
||||
player.units?.some((unit: Json) => unit.position === destination && unit.unit_type !== 'Settler'),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -697,6 +697,7 @@ export interface HappinessPreview {
|
|||
reason: string | null;
|
||||
}
|
||||
export interface MoveDestination {
|
||||
carrierCapacity?: number;
|
||||
boarding?: { carrier: number; units: number[] }[];
|
||||
breaksDiplomacy?: boolean;
|
||||
terrainNotes?: string[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue