Restrict Fanaticism infantry to losses at Temple cities

This commit is contained in:
coyotte508 2026-10-10 16:28:32 +02:00
commit 92c19b1bba
12 changed files with 55 additions and 11 deletions

View file

@ -342,6 +342,8 @@ pub(crate) fn combat_round_end(game: &mut Game, r: CombatRoundEnd) -> Option<Com
}
fn attacker_wins(game: &mut Game, mut c: Combat) {
// Also recover the condition for combats saved before this field existed.
c.stats.city_has_temple |= c.defender_temple(game);
log_winner(game, c.attacker(), None);
move_units(
game,
@ -378,7 +380,9 @@ pub(crate) fn draw(game: &mut Game, c: Combat) {
}
fn end_combat_and_store_stats(game: &mut Game, e: CombatEnd) {
let city_has_temple = e.combat.defender_temple(game);
let mut stats = e.combat.stats;
stats.city_has_temple |= city_has_temple;
stats.result = Some(e.result.clone());
end_combat(game, stats);
}

View file

@ -102,6 +102,8 @@ pub struct CombatStats {
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub city_mood: Option<MoodState>, // before capture
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub city_has_temple: bool, // before capture or removal of city pieces
}
impl CombatStats {
@ -125,6 +127,7 @@ impl CombatStats {
selected_card: None,
round: 1,
city_mood,
city_has_temple: false,
}
}
@ -260,7 +263,7 @@ pub(crate) fn new_combat_stats(
"Combat in a shared space requires pirate ships or a converted army unit"
);
CombatStats::new(
let mut stats = CombatStats::new(
battleground,
battleground.is_land() && game.map.is_sea(attacker_position),
CombatPlayerStats::new(attacker, to_units(attackers, a), attacker_position),
@ -274,7 +277,9 @@ pub(crate) fn new_combat_stats(
),
result,
city.map(|c| c.mood_state.clone()),
)
);
stats.city_has_temple = city.is_some_and(|c| c.pieces.temple.is_some());
stats
}
fn to_units(units: &[u32], p: &Player) -> Units {

View file

@ -130,7 +130,7 @@ fn fanaticism() -> AdvanceBuilder {
"Fanaticism",
"During a battle in a city with a Temple, \
whether you are the attacker or defender, you add +2 combat value to your first combat roll. \
If you lose the battle, you get 1 free Infantry Unit after the battle and \
If you lose that battle, you get 1 free Infantry Unit and \
place it in one of your cities.",
)
.add_combat_strength_listener(1, |game, c, s, _role| {
@ -145,7 +145,8 @@ fn fanaticism() -> AdvanceBuilder {
104,
|game, p, i| {
let player_index = p.index;
if i.is_loser(player_index)
if i.city_has_temple
&& i.is_loser(player_index)
&& !game.player(player_index).cities.is_empty()
&& game.player(player_index).available_units().infantry > 0
{

View file

@ -260,6 +260,32 @@ fn test_combat_fanaticism() {
);
}
#[test]
fn fanaticism_infantry_requires_a_temple_at_the_battle_city() {
for temple in [true, false] {
let mut game = JSON.load_game("combat_fanaticism");
game.player_mut(1)
.get_city_mut(Position::from_offset("C1"))
.pieces
.temple = temple.then_some(1);
let game = execute(
game,
move_action(vec![0, 1, 2, 3, 4, 5], Position::from_offset("C1")),
0,
);
// C1 is captured before Fanaticism resolves. The replacement is placed
// in C2, which has no Temple: only the battle city needs one.
assert_eq!(
game.player(1)
.units
.iter()
.filter(|u| u.unit_type == UnitType::Infantry)
.count(),
usize::from(temple),
);
}
}
#[test]
fn test_retreat() {
JSON.test(

View file

@ -262,7 +262,8 @@
}
},
"result": "AttackerWins",
"city_mood": "Angry"
"city_mood": "Angry",
"city_has_temple": true
},
"items": [
{

View file

@ -411,7 +411,8 @@
}
},
"result": "AttackerWins",
"city_mood": "Angry"
"city_mood": "Angry",
"city_has_temple": true
},
"items": [
{

View file

@ -439,7 +439,8 @@
}
},
"result": "AttackerWins",
"city_mood": "Angry"
"city_mood": "Angry",
"city_has_temple": true
},
"items": [
{

View file

@ -94,3 +94,6 @@ Viewer 0.1.47 and engine 0.4.52 label active effects with their source event or
# Viewer 0.1.48
Component styles are bundled into the viewer script because BGS does not load a separate stylesheet. This restores active-effect spacing and source-label layout, as well as the cultural-influence warning styles, in the published game.
# Viewer 0.1.49 / engine 0.4.53
Fanaticism's free infantry now requires losing a battle fought in a city with a Temple. The engine records the Temple condition before capture, so it still applies when that city changes hands. The destination may be any eligible city you own. The advance text now says “If you lose that battle” to make the shared condition explicit. Source: official Monumental Edition rulebook, page 31.

View file

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

View file

@ -204,7 +204,7 @@ const advances = {
],
Fanaticism: [
Zap,
'Attacking or defending a city with a Temple: +2 combat value in round 1. After losing a battle, place 1 infantry from your supply in one of your cities.',
'Attacking or defending a city with a Temple: +2 combat value in round 1. If you lose that battle, place 1 infantry from your supply in one of your cities.',
],
} as const;

View file

@ -24,6 +24,8 @@ async function capture() {
});
game.players[0].units = game.players[0].units.filter((u: any) => [0, 2].includes(u.id));
game.players[1].units = game.players[1].units.slice(0, 1);
// Fanaticism only replaces infantry after losing a battle at a Temple city.
game.players[1].cities.find((city: any) => city.position === 'C1').city_pieces = { temple: 1 };
game.players[1].cities.push(
{ position: 'B1', mood_state: 'Neutral' },
{ position: 'D2', mood_state: 'Neutral' },