Clarify permanent piece-loss journals; release viewer 0.1.217 engine 0.4.149

This commit is contained in:
coyotte508 2026-11-13 22:11:14 +00:00
commit 5813ff1216
47 changed files with 559 additions and 39 deletions

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} ofrer {p1} for Bueskytter",
"{p0} was selected to gain 1 settler.": "{p0} blev valgt til at få 1 nybygger.",
"{p0} withdraws to {p1}": "{p0} trækker sig tilbage til {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Du har vundet et slag mod barbarer i en by og dræbt mindst 2 af deres enheder."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Du har vundet et slag mod barbarer i en by og dræbt mindst 2 af deres enheder.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Bycenter ved {p0} permanent ødelagt; bygrænse reduceret til {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} ved {p1} permanent ødelagt; samlet grænse for disse brikker reduceret til {p2}",
"Razed {p0} because no city centers were available": "{p0} nedbrændt, fordi ingen bycentre var tilgængelige",
"Obelisk total piece limit reduced to {p0}": "Samlet grænse for obelisker reduceret til {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} opfert {p1} für Bogenschützen",
"{p0} was selected to gain 1 settler.": "{p0} wurde ausgewählt, um 1 Siedler zu erhalten.",
"{p0} withdraws to {p1}": "{p0} zieht sich nach {p1} zurück",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Du hast einen Kampf gegen Barbaren in einer Stadt gewonnen und mindestens 2 ihrer Einheiten getötet."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Du hast einen Kampf gegen Barbaren in einer Stadt gewonnen und mindestens 2 ihrer Einheiten getötet.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Stadtzentrum bei {p0} dauerhaft zerstört; Stadtlimit auf {p1} reduziert",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} bei {p1} dauerhaft zerstört; Gesamtlimit dieser Bauteile auf {p2} reduziert",
"Razed {p0} because no city centers were available": "{p0} zerstört, da keine Stadtzentren verfügbar waren",
"Obelisk total piece limit reduced to {p0}": "Gesamtlimit der Obelisken auf {p0} reduziert"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} θυσιάζει {p1} για Τοξότες",
"{p0} was selected to gain 1 settler.": "{p0} επιλέχθηκε να κερδίσει 1 άποικο.",
"{p0} withdraws to {p1}": "{p0} αποσύρεται στο {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Κερδίσατε μάχη εναντίον Βαρβάρων σε πόλη και σκοτώσατε τουλάχιστον 2 μονάδες τους."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Κερδίσατε μάχη εναντίον Βαρβάρων σε πόλη και σκοτώσατε τουλάχιστον 2 μονάδες τους.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Το κέντρο πόλης στο {p0} καταστράφηκε οριστικά· το όριο πόλεων μειώθηκε σε {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} στο {p1} καταστράφηκε οριστικά· το συνολικό όριο αυτών των κομματιών μειώθηκε σε {p2}",
"Razed {p0} because no city centers were available": "Η πόλη {p0} ισοπεδώθηκε επειδή δεν υπήρχαν διαθέσιμα κέντρα πόλης",
"Obelisk total piece limit reduced to {p0}": "Το συνολικό όριο οβελίσκων μειώθηκε σε {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} sacrifices {p1} for Archers",
"{p0} was selected to gain 1 settler.": "{p0} was selected to gain 1 settler.",
"{p0} withdraws to {p1}": "{p0} withdraws to {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "You won a battle against Barbarians in a city and killed at least 2 of their units."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "You won a battle against Barbarians in a city and killed at least 2 of their units.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "City center at {p0} permanently destroyed; city limit reduced to {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}",
"Razed {p0} because no city centers were available": "Razed {p0} because no city centers were available",
"Obelisk total piece limit reduced to {p0}": "Obelisk total piece limit reduced to {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} برای کمانداران، {p1} را قربانی می‌کند",
"{p0} was selected to gain 1 settler.": "{p0} برای دریافت ۱ مهاجر انتخاب شد.",
"{p0} withdraws to {p1}": "{p0} به {p1} عقب‌نشینی می‌کند",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "در شهری علیه بربرها پیروز شدید و دست‌کم ۲ واحد آن‌ها را کشتید."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "در شهری علیه بربرها پیروز شدید و دست‌کم ۲ واحد آن‌ها را کشتید.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "مرکز شهر در {p0} برای همیشه نابود شد؛ سقف شهرها به {p1} کاهش یافت",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} در {p1} برای همیشه نابود شد؛ سقف کل این نوع قطعات به {p2} کاهش یافت",
"Razed {p0} because no city centers were available": "{p0} ویران شد زیرا هیچ مرکز شهری در دسترس نبود",
"Obelisk total piece limit reduced to {p0}": "سقف کل قطعات ابلیسک به {p0} کاهش یافت"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} sacrifie {p1} pour des Archers",
"{p0} was selected to gain 1 settler.": "{p0} a été choisi pour gagner 1 colon.",
"{p0} withdraws to {p1}": "{p0} se replie vers {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Vous avez remporté une bataille contre les Barbares dans une ville et éliminé au moins 2 de leurs unités."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Vous avez remporté une bataille contre les Barbares dans une ville et éliminé au moins 2 de leurs unités.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centre-ville en {p0} détruit définitivement ; limite de villes réduite à {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} en {p1} détruit définitivement ; limite totale de ces pièces réduite à {p2}",
"Razed {p0} because no city centers were available": "{p0} rasée car aucun centre-ville n’était disponible",
"Obelisk total piece limit reduced to {p0}": "Limite totale des obélisques réduite à {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} तीरंदाजों के लिए {p1} का बलिदान देता है",
"{p0} was selected to gain 1 settler.": "{p0} को 1 बसने वाला प्राप्त करने के लिए चुना गया।",
"{p0} withdraws to {p1}": "{p0} {p1} की ओर पीछे हटता है",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "आपने एक शहर में बर्बरों के विरुद्ध लड़ाई जीती और उनकी कम से कम 2 इकाइयाँ मारीं।"
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "आपने एक शहर में बर्बरों के विरुद्ध लड़ाई जीती और उनकी कम से कम 2 इकाइयाँ मारीं।",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "{p0} पर शहर केंद्र स्थायी रूप से नष्ट; शहरों की सीमा घटकर {p1} हुई",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p1} पर {p0} स्थायी रूप से नष्ट; इस प्रकार के टुकड़ों की कुल सीमा घटकर {p2} हुई",
"Razed {p0} because no city centers were available": "कोई शहर केंद्र उपलब्ध न होने के कारण {p0} ध्वस्त किया गया",
"Obelisk total piece limit reduced to {p0}": "ओबिलिस्क टुकड़ों की कुल सीमा घटकर {p0} हुई"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} sacrifica {p1} per gli Arcieri",
"{p0} was selected to gain 1 settler.": "{p0} è stato scelto per ottenere 1 colono.",
"{p0} withdraws to {p1}": "{p0} si ritira a {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Hai vinto una battaglia contro i Barbari in una città ed eliminato almeno 2 delle loro unità."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Hai vinto una battaglia contro i Barbari in una città ed eliminato almeno 2 delle loro unità.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centro città in {p0} distrutto permanentemente; limite di città ridotto a {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} in {p1} distrutto permanentemente; limite totale di questi pezzi ridotto a {p2}",
"Razed {p0} because no city centers were available": "{p0} rasa al suolo perché non erano disponibili centri città",
"Obelisk total piece limit reduced to {p0}": "Limite totale degli obelischi ridotto a {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0}이(가) 궁수를 위해 {p1}을(를) 희생합니다",
"{p0} was selected to gain 1 settler.": "{p0}이(가) 개척자 1명을 얻도록 선택되었습니다.",
"{p0} withdraws to {p1}": "{p0}이(가) {p1}(으)로 철수합니다",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "도시에서 야만인과의 전투에 승리하고 야만인 유닛을 최소 2개 처치했습니다."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "도시에서 야만인과의 전투에 승리하고 야만인 유닛을 최소 2개 처치했습니다.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "{p0}의 도시 중심부가 영구 파괴됨; 도시 한도가 {p1}(으)로 감소",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p1}의 {p0} 영구 파괴됨; 해당 부품의 총 한도가 {p2}(으)로 감소",
"Razed {p0} because no city centers were available": "사용 가능한 도시 중심부가 없어 {p0} 파괴",
"Obelisk total piece limit reduced to {p0}": "오벨리스크 부품 총 한도가 {p0}(으)로 감소"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} offert {p1} voor Boogschutters",
"{p0} was selected to gain 1 settler.": "{p0} is geselecteerd om 1 kolonist te krijgen.",
"{p0} withdraws to {p1}": "{p0} trekt zich terug naar {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Je hebt een gevecht tegen Barbaren in een stad gewonnen en minstens 2 van hun eenheden gedood."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Je hebt een gevecht tegen Barbaren in een stad gewonnen en minstens 2 van hun eenheden gedood.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Stadscentrum bij {p0} permanent vernietigd; stadslimiet verlaagd naar {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} bij {p1} permanent vernietigd; totale limiet voor deze stukken verlaagd naar {p2}",
"Razed {p0} because no city centers were available": "{p0} verwoest omdat er geen stadscentra beschikbaar waren",
"Obelisk total piece limit reduced to {p0}": "Totale limiet voor obelisken verlaagd naar {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} poświęca {p1} dla Łuczników",
"{p0} was selected to gain 1 settler.": "{p0} został wybrany, aby zdobyć 1 osadnika.",
"{p0} withdraws to {p1}": "{p0} wycofuje się do {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Wygrałeś bitwę z barbarzyńcami w mieście i zabiłeś co najmniej 2 ich jednostki."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Wygrałeś bitwę z barbarzyńcami w mieście i zabiłeś co najmniej 2 ich jednostki.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centrum miasta na {p0} trwale zniszczone; limit miast zmniejszony do {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} na {p1} trwale zniszczone; łączny limit tych elementów zmniejszony do {p2}",
"Razed {p0} because no city centers were available": "Zburzono {p0}, ponieważ nie było dostępnych centrów miast",
"Obelisk total piece limit reduced to {p0}": "Łączny limit obelisków zmniejszony do {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} sacrifica {p1} para Arqueiros",
"{p0} was selected to gain 1 settler.": "{p0} foi selecionado para ganhar 1 colono.",
"{p0} withdraws to {p1}": "{p0} recua para {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Você venceu uma batalha contra Bárbaros em uma cidade e eliminou pelo menos 2 das unidades deles."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Você venceu uma batalha contra Bárbaros em uma cidade e eliminou pelo menos 2 das unidades deles.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centro da cidade em {p0} destruído permanentemente; limite de cidades reduzido para {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} em {p1} destruído permanentemente; limite total dessas peças reduzido para {p2}",
"Razed {p0} because no city centers were available": "{p0} arrasada porque não havia centros de cidade disponíveis",
"Obelisk total piece limit reduced to {p0}": "Limite total de obeliscos reduzido para {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} sacrifică {p1} pentru Arcași",
"{p0} was selected to gain 1 settler.": "{p0} a fost selectat pentru a primi 1 colonist.",
"{p0} withdraws to {p1}": "{p0} se retrage la {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Ai câștigat o luptă împotriva barbarilor într-un oraș și ai eliminat cel puțin 2 dintre unitățile lor."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Ai câștigat o luptă împotriva barbarilor într-un oraș și ai eliminat cel puțin 2 dintre unitățile lor.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centrul orașului de la {p0} distrus permanent; limita de orașe redusă la {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} de la {p1} distrus permanent; limita totală a acestor piese redusă la {p2}",
"Razed {p0} because no city centers were available": "{p0} distrus deoarece nu erau disponibile centre de oraș",
"Obelisk total piece limit reduced to {p0}": "Limita totală de obeliscuri redusă la {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} приносит в жертву {p1} ради лучников",
"{p0} was selected to gain 1 settler.": "{p0} выбран, чтобы получить 1 поселенца.",
"{p0} withdraws to {p1}": "{p0} отступает в {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Вы выиграли бой против варваров в городе и уничтожили не менее 2 их отрядов."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Вы выиграли бой против варваров в городе и уничтожили не менее 2 их отрядов.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Центр города в {p0} уничтожен навсегда; предел числа городов снижен до {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} в {p1} уничтожено навсегда; общий предел этих элементов снижен до {p2}",
"Razed {p0} because no city centers were available": "Город {p0} разрушен, так как не было доступных центров городов",
"Obelisk total piece limit reduced to {p0}": "Общий предел обелисков снижен до {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} hiến tế {p1} cho Cung thủ",
"{p0} was selected to gain 1 settler.": "{p0} được chọn để nhận 1 người định cư.",
"{p0} withdraws to {p1}": "{p0} rút lui về {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Bạn đã thắng một trận chiến với Người man rợ trong một thành phố và tiêu diệt ít nhất 2 đơn vị của họ."
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "Bạn đã thắng một trận chiến với Người man rợ trong một thành phố và tiêu diệt ít nhất 2 đơn vị của họ.",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Trung tâm thành phố tại {p0} bị phá hủy vĩnh viễn; giới hạn thành phố giảm còn {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} tại {p1} bị phá hủy vĩnh viễn; tổng giới hạn loại quân cờ này giảm còn {p2}",
"Razed {p0} because no city centers were available": "Đã phá hủy {p0} vì không còn trung tâm thành phố khả dụng",
"Obelisk total piece limit reduced to {p0}": "Tổng giới hạn Đài Tưởng Niệm giảm còn {p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0}为弓箭手牺牲{p1}",
"{p0} was selected to gain 1 settler.": "{p0}被选中获得1个移民。",
"{p0} withdraws to {p1}": "{p0}撤退至{p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "你在城市中战胜蛮族,并杀死至少 2 个蛮族单位。"
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "你在城市中战胜蛮族,并杀死至少 2 个蛮族单位。",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "{p0}的城市中心被永久摧毁;城市上限降至{p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p1}的{p0}被永久摧毁;此类配件总数上限降至{p2}",
"Razed {p0} because no city centers were available": "因没有可用的城市中心,夷平了{p0}",
"Obelisk total piece limit reduced to {p0}": "方尖碑配件总数上限降至{p0}"
}

View file

@ -2281,5 +2281,9 @@
"{p0} sacrifices {p1} for Archers": "{p0} 為發動弓箭手而犧牲 {p1}",
"{p0} was selected to gain 1 settler.": "{p0} 被選中獲得1個移民。",
"{p0} withdraws to {p1}": "{p0} 撤退至 {p1}",
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "你在城市中擊敗野蠻人,並消滅至少 2 個野蠻人單位。"
"You won a battle against Barbarians in a city and killed at least 2 of their units.": "你在城市中擊敗野蠻人,並消滅至少 2 個野蠻人單位。",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "{p0}的城市中心被永久摧毀;城市上限降至{p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p1}的{p0}被永久摧毀;此類配件總數上限降至{p2}",
"Razed {p0} because no city centers were available": "因沒有可用的城市中心,夷平了{p0}",
"Obelisk total piece limit reduced to {p0}": "方尖碑配件總數上限降至{p0}"
}

View file

@ -400,6 +400,10 @@ pub(crate) fn conquer_city(
ResourcePile::gold(defender.get(game).get_city(position).size() as u8),
);
}
attacker.log(
game,
&format!("Razed {position} because no city centers were available"),
);
raze_city(game, defender, position);
}
}

View file

@ -284,10 +284,12 @@ fn runes() -> SpecialAdvanceInfo {
let p = game.player_mut(s.player_index);
p.destroyed_structures.add_building(Building::Obelisk);
p.gain_objective_victory_points(1.0, &s.origin);
let limit = p.building_piece_limit(Building::Obelisk);
s.log(
game,
"Converted an Obelisk to a Rune Stone for 1 objective point",
);
s.log(game, &format!("Obelisk total piece limit reduced to {limit}"));
} else {
s.log(game, "Did not convert an Obelisk to a Rune Stone");
}

View file

@ -183,6 +183,12 @@ fn destroy_city_center(game: &mut Game, position: Position, origin: &EventOrigin
);
p.gain_event_victory_points(2.0, origin);
p.destroyed_structures.cities += 1;
let limit = p.city_limit();
game.log(
owner,
origin,
&format!("City center at {position} permanently destroyed; city limit reduced to {limit}"),
);
game.log(
owner,
origin,
@ -200,8 +206,14 @@ fn destroy_building(game: &mut Game, b: Building, position: Position, origin: &E
let o = game.player_mut(owner);
o.gain_event_victory_points(2.0, origin);
o.destroyed_structures.add_building(b);
let limit = o.building_piece_limit(b);
let player = EventPlayer::new(city_owner, origin.clone());
lose_building(game, &player, b, position);
game.log(
owner,
origin,
&format!("{b} at {position} permanently destroyed; total piece limit reduced to {limit}"),
);
game.log(
owner,
origin,

View file

@ -310,12 +310,24 @@ impl Player {
.flat_map(|city| city.pieces.building_owners())
.filter(|(b, owner)| b == &building && owner.is_some_and(|owner| owner == self.index))
.count()
< CITY_PIECE_LIMIT - self.destroyed_structures.get_building(building)
< self.building_piece_limit(building)
}
/// Total surviving pieces, including pieces already on the board.
#[must_use]
pub fn building_piece_limit(&self, building: Building) -> usize {
CITY_PIECE_LIMIT - self.destroyed_structures.get_building(building)
}
/// Total surviving city centers, including cities already on the board.
#[must_use]
pub fn city_limit(&self) -> usize {
(CITY_LIMIT - self.destroyed_structures.cities) as usize
}
#[must_use]
pub fn is_city_available(&self) -> bool {
self.cities.len() < (CITY_LIMIT - self.destroyed_structures.cities) as usize
self.cities.len() < self.city_limit()
}
#[must_use]

View file

@ -0,0 +1,118 @@
use server::action::Action;
use server::advance::Advance;
use server::city_pieces::Building;
use server::content::persistent_events::{EventResponse, SelectedStructure};
use server::game::Game;
use server::game_api::execute;
use server::position::Position;
use server::resource_pile::ResourcePile;
use server::structure::Structure;
mod common;
use common::{JsonTest, advance_action, move_action};
fn notes(game: &Game) -> Vec<(usize, String)> {
let log = serde_json::to_value(&game.log).unwrap();
log.as_array()
.unwrap()
.iter()
.flat_map(|a| a["rounds"].as_array().unwrap())
.flat_map(|r| r["turns"].as_array().unwrap())
.flat_map(|t| t["actions"].as_array().unwrap())
.flat_map(|a| a["items"].as_array().unwrap())
.filter_map(|i| {
Some((
i["player"].as_u64()? as usize,
i["Text"].as_str()?.to_owned(),
))
})
.collect()
}
#[test]
fn earthquake_reports_surviving_capacity_for_the_actual_piece_owner() {
let mut game = JsonTest::child("incidents", "earthquake").load_game("earthquake");
game.player_mut(0).destroyed_structures.cities = 2;
game = execute(
game,
advance_action(Advance::Storage, ResourcePile::gold(2)),
0,
);
let points = |g: &Game, p| {
g.player(p)
.special_victory_points
.iter()
.map(|v| v.points)
.sum::<f32>()
};
let before = [points(&game, 0), points(&game, 1)];
game = execute(
game,
Action::Response(EventResponse::SelectStructures(vec![
SelectedStructure::new(Position::from_offset("B2"), Structure::CityCenter),
SelectedStructure::new(
Position::from_offset("C2"),
Structure::Building(Building::Temple),
),
])),
0,
);
assert_eq!(game.player(0).city_limit(), 4);
assert_eq!(game.player(0).cities.len(), 3);
assert!(game.player(0).is_city_available());
assert_eq!(game.player(1).building_piece_limit(Building::Temple), 4);
assert_eq!(game.player(0).building_piece_limit(Building::Temple), 5);
assert_eq!(points(&game, 0) - before[0], 2.0);
assert_eq!(points(&game, 1) - before[1], 2.0);
let notes = notes(&game);
assert!(notes.contains(&(
0,
"City center at B2 permanently destroyed; city limit reduced to 4".into()
)));
assert!(notes.contains(&(
1,
"Temple at C2 permanently destroyed; total piece limit reduced to 4".into()
)));
assert!(
!notes
.iter()
.any(|(p, text)| *p == 0 && text.starts_with("Temple at"))
);
}
#[test]
fn forced_raze_explains_unavailable_centers_without_permanent_loss() {
let fixture = JsonTest::new("combat");
for forced in [true, false] {
let mut game = fixture.load_game("capture_and_raze_city");
if !forced {
game.player_mut(0).destroyed_structures.cities = 0;
}
let limits = [game.player(0).city_limit(), game.player(1).city_limit()];
game = execute(
game,
move_action(vec![0, 1, 2, 3], Position::from_offset("C1")),
0,
);
let notes = notes(&game);
assert_eq!(
notes
.iter()
.any(|(p, text)| *p == 0
&& text == "Razed C1 because no city centers were available"),
forced
);
assert!(
!notes
.iter()
.any(|(_, text)| text.contains("permanently destroyed"))
);
assert_eq!(
[game.player(0).city_limit(), game.player(1).city_limit()],
limits
);
assert_eq!(
game.try_get_any_city(Position::from_offset("C1")).is_none(),
forced
);
}
}

View file

@ -409,6 +409,13 @@
"Ability": "Raze captured city"
}
},
{
"player": 0,
"Text": "Razed C1 because no city centers were available",
"origin": {
"Ability": "Combat"
}
},
{
"player": 1,
"Structure": {

View file

@ -343,6 +343,13 @@
"Incident": 31
}
},
{
"player": 0,
"Text": "Fortress at C2 permanently destroyed; total piece limit reduced to 4",
"origin": {
"Incident": 31
}
},
{
"player": 0,
"Text": "Gain 2 points for the Fortress at C2",
@ -371,6 +378,13 @@
"Incident": 31
}
},
{
"player": 0,
"Text": "City center at B2 permanently destroyed; city limit reduced to 6",
"origin": {
"Incident": 31
}
},
{
"player": 0,
"Text": "Gain 2 points for the city center at B2",
@ -452,6 +466,13 @@
"Incident": 31
}
},
{
"player": 0,
"Text": "Fortress at A1 permanently destroyed; total piece limit reduced to 3",
"origin": {
"Incident": 31
}
},
{
"player": 0,
"Text": "Gain 2 points for the Fortress at A1",
@ -459,6 +480,13 @@
"Incident": 31
}
},
{
"player": 1,
"Text": "City center at A1 permanently destroyed; city limit reduced to 6",
"origin": {
"Incident": 31
}
},
{
"player": 1,
"Text": "Gain 2 points for the city center at A1",
@ -466,6 +494,13 @@
"Incident": 31
}
},
{
"player": 1,
"Text": "City center at A3 permanently destroyed; city limit reduced to 5",
"origin": {
"Incident": 31
}
},
{
"player": 1,
"Text": "Gain 2 points for the city center at A3",

View file

@ -273,6 +273,13 @@
"Incident": 29
}
},
{
"player": 0,
"Text": "Fortress at C2 permanently destroyed; total piece limit reduced to 4",
"origin": {
"Incident": 29
}
},
{
"player": 0,
"Text": "Gain 2 points for the Fortress at C2",
@ -294,6 +301,13 @@
"Incident": 29
}
},
{
"player": 1,
"Text": "Temple at C2 permanently destroyed; total piece limit reduced to 4",
"origin": {
"Incident": 29
}
},
{
"player": 1,
"Text": "Gain 2 points for the Temple at C2",
@ -322,6 +336,13 @@
"Incident": 29
}
},
{
"player": 0,
"Text": "City center at C2 permanently destroyed; city limit reduced to 6",
"origin": {
"Incident": 29
}
},
{
"player": 0,
"Text": "Gain 2 points for the city center at C2",

View file

@ -1290,3 +1290,29 @@ cases cover Japan/Rome and both cards through real card play, culture payment,
map city selection and Settler confirmation. Packed-engine protocol and split
WASM bundle checks pass. Existing Clippy warnings and expected rejected-move
WASM diagnostics remain.
# Viewer 0.1.217 / engine 0.4.149
Permanent piece-loss journal notes now name the destroyed city center or building
and its owner's remaining total capacity, including pieces already on the board.
Earthquake, Major Earthquake and Vulcan retain their structure and victory-point
entries. Rune Stone conversion reports the reduced Obelisk capacity without
calling conversion destruction. Automatic capture razing explicitly explains
when no city center is available; normal captures and voluntary razing are unchanged.
All 17 locales in both clients include the four new messages.
Publish the matching engine, bridge and viewer. Piece availability calculations,
ownership, points and rules are unchanged; existing history is not rewritten.
Preserve the real-game gallery and unrelated BGS metadata, including game-length
labels/order and Standard as default. No live moves, history repairs or Fossil
refresh are part of this release.
Verified with Rust 1.94.1: 503 native workspace tests pass (one existing ignored),
1,066 frontend tests against the packed engine, gallery and both 17-locale
catalogs, extraction checks, Svelte with zero errors/warnings, formatting and
production build. Desktop/mobile browser checks exercise actual engine journal
notes, foreign building ownership, prior capacity losses and forced razing;
protocol, split-WASM bundle and combat journal checks also pass. Existing Clippy
warnings and expected rejected-move WASM diagnostics remain. The first native
random-actions run hit the existing Tributes eligibility rejection; a complete
workspace rerun passed. No Tributes rules or unrelated snapshots were changed.

View file

@ -1,12 +1,12 @@
{
"name": "@boardgamers/clash-web-client",
"version": "0.1.216",
"version": "0.1.217",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@boardgamers/clash-web-client",
"version": "0.1.216",
"version": "0.1.217",
"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.216",
"version": "0.1.217",
"private": true,
"type": "module",
"scripts": {

View file

@ -0,0 +1,87 @@
// Offline built-viewer check: npm run build:bridge && npm run build && node scripts/piece-loss-journal-smoke.mjs
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
import { chromium } from 'playwright';
const engine = createRequire(import.meta.url)('../.engine/server.js');
const fixture = async (name) =>
JSON.parse(await readFile(new URL(`../../server/tests/test_games/${name}.json`, import.meta.url), 'utf8'));
const move = (state, action) => engine.tryMove(state, JSON.stringify(action), 0);
const raw = await fixture('incidents/earthquake/earthquake');
raw.players[0].destroyed_structures = { cities: 2 };
let quake = move(JSON.stringify(raw), { Playing: { Advance: { advance: 'Storage', payment: { gold: 2 } } } });
quake = move(quake, {
Response: {
SelectStructures: [
{ position: 'B2', structure: 'CityCenter' },
{ position: 'C2', structure: { Building: 'Temple' } },
],
},
});
const raze = move(JSON.stringify(await fixture('combat/capture_and_raze_city')), {
Movement: { Move: { units: [0, 1, 2, 3], destination: 'C1', payment: {} } },
});
const browser = await chromium.launch({
headless: true,
args: ['--use-gl=angle', '--use-angle=swiftshader'],
});
try {
for (const [width, height] of [
[1400, 900],
[390, 844],
]) {
const page = await browser.newPage({ viewport: { width, height } });
const errors = [];
page.on('pageerror', (e) => errors.push(e.message));
await page.route('**/*', async (route) => {
const url = new URL(route.request().url());
if (url.hostname !== 'clash.test') return route.abort();
if (url.pathname === '/')
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(url.pathname)) return route.abort();
return route.fulfill({
contentType: url.pathname.endsWith('.wasm') ? 'application/wasm' : 'text/javascript',
body: await readFile(new URL('../dist' + url.pathname, import.meta.url)),
});
});
await page.goto('http://clash.test/');
await page.evaluate(() => {
window.host = clash3d.launch('#app');
host.emit('player', {});
host.emit('preferences', { sound: false });
});
for (const [name, state, messages] of [
[
'earthquake',
quake,
[
'City center at B2 permanently destroyed; city limit reduced to 4',
'Temple at C2 permanently destroyed; total piece limit reduced to 4',
],
],
['raze', raze, ['Razed C1 because no city centers were available']],
]) {
await page.evaluate((state) => host.emit('state', state), engine.stripSecret(state));
const toggle = page.getByRole('button', { name: 'Open journal', exact: true });
await toggle.waitFor();
if ((await toggle.getAttribute('aria-expanded')) !== 'true') await toggle.click();
for (const message of messages) {
const note = page.locator('.journal').getByText(message, { exact: false });
await note.first().waitFor();
await note.first().scrollIntoViewIfNeeded();
}
assert.ok(await page.locator('.journal').evaluate((el) => el.scrollWidth <= el.clientWidth + 1));
await page.screenshot({ path: `/tmp/clash-piece-loss-${name}-${width}.png` });
}
assert.deepEqual(errors, []);
console.log(
`${width}px: earthquake capacity, foreign building, and forced-raze journal notes visible without overflow`,
);
await page.close();
}
} finally {
await browser.close();
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Byt mål",
"Keep current objectives": "Behold nuværende mål",
"Keep": "Behold",
"Return": "Returnér"
"Return": "Returnér",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Bycenter ved {p0} permanent ødelagt; bygrænse reduceret til {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} ved {p1} permanent ødelagt; samlet grænse for disse brikker reduceret til {p2}",
"Razed {p0} because no city centers were available": "{p0} nedbrændt, fordi ingen bycentre var tilgængelige",
"Obelisk total piece limit reduced to {p0}": "Samlet grænse for obelisker reduceret til {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Ziele tauschen",
"Keep current objectives": "Aktuelle Ziele behalten",
"Keep": "Behalten",
"Return": "Zurückgeben"
"Return": "Zurückgeben",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Stadtzentrum bei {p0} dauerhaft zerstört; Stadtlimit auf {p1} reduziert",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} bei {p1} dauerhaft zerstört; Gesamtlimit dieser Bauteile auf {p2} reduziert",
"Razed {p0} because no city centers were available": "{p0} zerstört, da keine Stadtzentren verfügbar waren",
"Obelisk total piece limit reduced to {p0}": "Gesamtlimit der Obelisken auf {p0} reduziert"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Ανταλλαγή στόχων",
"Keep current objectives": "Κράτησε τους τρέχοντες στόχους",
"Keep": "Κράτησε",
"Return": "Επίστρεψε"
"Return": "Επίστρεψε",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Το κέντρο πόλης στο {p0} καταστράφηκε οριστικά· το όριο πόλεων μειώθηκε σε {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} στο {p1} καταστράφηκε οριστικά· το συνολικό όριο αυτών των κομματιών μειώθηκε σε {p2}",
"Razed {p0} because no city centers were available": "Η πόλη {p0} ισοπεδώθηκε επειδή δεν υπήρχαν διαθέσιμα κέντρα πόλης",
"Obelisk total piece limit reduced to {p0}": "Το συνολικό όριο οβελίσκων μειώθηκε σε {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Exchange objectives",
"Keep current objectives": "Keep current objectives",
"Keep": "Keep",
"Return": "Return"
"Return": "Return",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "City center at {p0} permanently destroyed; city limit reduced to {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}",
"Razed {p0} because no city centers were available": "Razed {p0} because no city centers were available",
"Obelisk total piece limit reduced to {p0}": "Obelisk total piece limit reduced to {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "تعویض هدف‌ها",
"Keep current objectives": "نگه داشتن هدف‌های فعلی",
"Keep": "نگه داشتن",
"Return": "برگرداندن"
"Return": "برگرداندن",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "مرکز شهر در {p0} برای همیشه نابود شد؛ سقف شهرها به {p1} کاهش یافت",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} در {p1} برای همیشه نابود شد؛ سقف کل این نوع قطعات به {p2} کاهش یافت",
"Razed {p0} because no city centers were available": "{p0} ویران شد زیرا هیچ مرکز شهری در دسترس نبود",
"Obelisk total piece limit reduced to {p0}": "سقف کل قطعات ابلیسک به {p0} کاهش یافت"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Échanger les objectifs",
"Keep current objectives": "Garder les objectifs actuels",
"Keep": "Garder",
"Return": "Rendre"
"Return": "Rendre",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centre-ville en {p0} détruit définitivement ; limite de villes réduite à {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} en {p1} détruit définitivement ; limite totale de ces pièces réduite à {p2}",
"Razed {p0} because no city centers were available": "{p0} rasée car aucun centre-ville n’était disponible",
"Obelisk total piece limit reduced to {p0}": "Limite totale des obélisques réduite à {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "उद्देश्य बदलें",
"Keep current objectives": "मौजूदा उद्देश्य रखें",
"Keep": "रखें",
"Return": "लौटाएँ"
"Return": "लौटाएँ",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "{p0} पर शहर केंद्र स्थायी रूप से नष्ट; शहरों की सीमा घटकर {p1} हुई",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p1} पर {p0} स्थायी रूप से नष्ट; इस प्रकार के टुकड़ों की कुल सीमा घटकर {p2} हुई",
"Razed {p0} because no city centers were available": "कोई शहर केंद्र उपलब्ध न होने के कारण {p0} ध्वस्त किया गया",
"Obelisk total piece limit reduced to {p0}": "ओबिलिस्क टुकड़ों की कुल सीमा घटकर {p0} हुई"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Scambia obiettivi",
"Keep current objectives": "Mantieni gli obiettivi attuali",
"Keep": "Tieni",
"Return": "Restituisci"
"Return": "Restituisci",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centro città in {p0} distrutto permanentemente; limite di città ridotto a {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} in {p1} distrutto permanentemente; limite totale di questi pezzi ridotto a {p2}",
"Razed {p0} because no city centers were available": "{p0} rasa al suolo perché non erano disponibili centri città",
"Obelisk total piece limit reduced to {p0}": "Limite totale degli obelischi ridotto a {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "목표 교환",
"Keep current objectives": "현재 목표 유지",
"Keep": "보관",
"Return": "반환"
"Return": "반환",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "{p0}의 도시 중심부가 영구 파괴됨; 도시 한도가 {p1}(으)로 감소",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p1}의 {p0} 영구 파괴됨; 해당 부품의 총 한도가 {p2}(으)로 감소",
"Razed {p0} because no city centers were available": "사용 가능한 도시 중심부가 없어 {p0} 파괴",
"Obelisk total piece limit reduced to {p0}": "오벨리스크 부품 총 한도가 {p0}(으)로 감소"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Doelen ruilen",
"Keep current objectives": "Huidige doelen behouden",
"Keep": "Houden",
"Return": "Teruggeven"
"Return": "Teruggeven",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Stadscentrum bij {p0} permanent vernietigd; stadslimiet verlaagd naar {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} bij {p1} permanent vernietigd; totale limiet voor deze stukken verlaagd naar {p2}",
"Razed {p0} because no city centers were available": "{p0} verwoest omdat er geen stadscentra beschikbaar waren",
"Obelisk total piece limit reduced to {p0}": "Totale limiet voor obelisken verlaagd naar {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Wymień cele",
"Keep current objectives": "Zachowaj obecne cele",
"Keep": "Zachowaj",
"Return": "Oddaj"
"Return": "Oddaj",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centrum miasta na {p0} trwale zniszczone; limit miast zmniejszony do {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} na {p1} trwale zniszczone; łączny limit tych elementów zmniejszony do {p2}",
"Razed {p0} because no city centers were available": "Zburzono {p0}, ponieważ nie było dostępnych centrów miast",
"Obelisk total piece limit reduced to {p0}": "Łączny limit obelisków zmniejszony do {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Trocar objetivos",
"Keep current objectives": "Manter objetivos atuais",
"Keep": "Manter",
"Return": "Devolver"
"Return": "Devolver",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centro da cidade em {p0} destruído permanentemente; limite de cidades reduzido para {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} em {p1} destruído permanentemente; limite total dessas peças reduzido para {p2}",
"Razed {p0} because no city centers were available": "{p0} arrasada porque não havia centros de cidade disponíveis",
"Obelisk total piece limit reduced to {p0}": "Limite total de obeliscos reduzido para {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Schimbă obiective",
"Keep current objectives": "Păstrează obiectivele actuale",
"Keep": "Păstrează",
"Return": "Returnează"
"Return": "Returnează",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Centrul orașului de la {p0} distrus permanent; limita de orașe redusă la {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} de la {p1} distrus permanent; limita totală a acestor piese redusă la {p2}",
"Razed {p0} because no city centers were available": "{p0} distrus deoarece nu erau disponibile centre de oraș",
"Obelisk total piece limit reduced to {p0}": "Limita totală de obeliscuri redusă la {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Обменять цели",
"Keep current objectives": "Сохранить текущие цели",
"Keep": "Оставить",
"Return": "Вернуть"
"Return": "Вернуть",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Центр города в {p0} уничтожен навсегда; предел числа городов снижен до {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} в {p1} уничтожено навсегда; общий предел этих элементов снижен до {p2}",
"Razed {p0} because no city centers were available": "Город {p0} разрушен, так как не было доступных центров городов",
"Obelisk total piece limit reduced to {p0}": "Общий предел обелисков снижен до {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "Đổi mục tiêu",
"Keep current objectives": "Giữ mục tiêu hiện tại",
"Keep": "Giữ",
"Return": "Trả lại"
"Return": "Trả lại",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "Trung tâm thành phố tại {p0} bị phá hủy vĩnh viễn; giới hạn thành phố giảm còn {p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p0} tại {p1} bị phá hủy vĩnh viễn; tổng giới hạn loại quân cờ này giảm còn {p2}",
"Razed {p0} because no city centers were available": "Đã phá hủy {p0} vì không còn trung tâm thành phố khả dụng",
"Obelisk total piece limit reduced to {p0}": "Tổng giới hạn Đài Tưởng Niệm giảm còn {p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "交换目标",
"Keep current objectives": "保留当前目标",
"Keep": "保留",
"Return": "归还"
"Return": "归还",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "{p0}的城市中心被永久摧毁;城市上限降至{p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p1}的{p0}被永久摧毁;此类配件总数上限降至{p2}",
"Razed {p0} because no city centers were available": "因没有可用的城市中心,夷平了{p0}",
"Obelisk total piece limit reduced to {p0}": "方尖碑配件总数上限降至{p0}"
}

View file

@ -5288,5 +5288,9 @@
"Exchange objectives": "交換目標",
"Keep current objectives": "保留目前目標",
"Keep": "保留",
"Return": "歸還"
"Return": "歸還",
"City center at {p0} permanently destroyed; city limit reduced to {p1}": "{p0}的城市中心被永久摧毀;城市上限降至{p1}",
"{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}": "{p1}的{p0}被永久摧毀;此類配件總數上限降至{p2}",
"Razed {p0} because no city centers were available": "因沒有可用的城市中心,夷平了{p0}",
"Obelisk total piece limit reduced to {p0}": "方尖碑配件總數上限降至{p0}"
}

View file

@ -0,0 +1,60 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync, readdirSync } from 'node:fs';
import { journal } from './journal.ts';
import { journalParts } from './model.ts';
import { localizedParts } from './localized-parts.ts';
import { createTranslator } from './localization/runtime.js';
import type { Game } from './types.ts';
const fixture = (name: string): Game =>
JSON.parse(readFileSync(new URL(`../../server/tests/test_games/${name}.json`, import.meta.url), 'utf8'));
test('journal preserves permanent loss notes, their owner, and forced raze reason without changing history', () => {
for (const [name, expected] of [
[
'incidents/earthquake/volcano.outcome1',
'Temple at C2 permanently destroyed; total piece limit reduced to 4',
],
[
'incidents/earthquake/earthquake.outcome3',
'City center at A3 permanently destroyed; city limit reduced to 5',
],
['combat/capture_and_raze_city.outcome', 'Razed C1 because no city centers were available'],
]) {
const game = fixture(name);
const before = JSON.stringify(game);
const entries = journal(game);
assert.ok(JSON.stringify(entries).includes(expected), name);
assert.equal(JSON.stringify(game), before);
if (name.includes('volcano')) {
const outcome = entries.flatMap((e) => e.event?.outcomes ?? []).find((e) => e.notes.includes(expected));
assert.equal(outcome?.player, 1, 'foreign-owned Temple belongs to Greece');
assert.equal(outcome?.civilization, 'Greece');
}
}
});
test('piece capacity and forced raze notes translate as complete messages in all locales', () => {
const samples: [string, string[]][] = [
['City center at {p0} permanently destroyed; city limit reduced to {p1}', ['C1', '6']],
['{p0} at {p1} permanently destroyed; total piece limit reduced to {p2}', ['Temple', 'C2', '4']],
['Razed {p0} because no city centers were available', ['C1']],
['Obelisk total piece limit reduced to {p0}', ['4']],
];
const directory = new URL('./localization/', import.meta.url);
for (const file of readdirSync(directory).filter((n) => n.endsWith('.json'))) {
const locale = file.slice(0, -5);
const catalog = JSON.parse(readFileSync(new URL(file, directory), 'utf8'));
const translator = createTranslator({ [locale]: catalog }, locale);
for (const [template, values] of samples) {
const source = template.replace(/\{p(\d+)\}/g, (_, i) => values[Number(i)]);
const expected = catalog[template].replace(/\{p(\d+)\}/g, (_: string, i: string) =>
translator.translate(values[Number(i)]),
);
assert.equal(translator.translate(source), expected, `${locale}: ${source}`);
const parts = localizedParts(source, journalParts(source), translator.translate);
assert.equal(parts.map((p) => p.text).join(''), expected, locale);
}
}
});