Restore borrowed Great Library effects after loading saves

This commit is contained in:
coyotte508 2026-10-29 15:21:10 +01:00
commit 87e25a98b8
5 changed files with 39 additions and 3 deletions

View file

@ -349,6 +349,7 @@ pub struct PlayerData {
fn initialize_player(player_index: usize, game: &mut Game, builtin_abilities: &[Ability]) {
ability::init_player(game, player_index, builtin_abilities);
advance::init_player(game, player_index);
advance::init_great_library(game, player_index);
if let Some(leader) = game.player(player_index).active_leader() {
Player::with_leader(leader, game, player_index, |game, leader| {

View file

@ -84,6 +84,32 @@ fn test_library() {
);
}
#[test]
fn test_library_borrowed_effect_survives_reload() {
let mut game = JSON.load_game("library");
game.player_mut(0).resources.mood_tokens = 0;
let game = server::game_api::execute(game, custom_action(CustomActionType::GreatLibrary), 0);
let game = server::game_api::execute(
game,
Action::Response(EventResponse::SelectAdvance(Advance::FreeEducation)),
0,
);
// Clone rebuilds runtime listeners from saved data, just like a new request.
let game = game.clone();
assert_eq!(game.player(0).resources.mood_tokens, 0);
let game = server::game_api::execute(
game,
advance_action(Advance::Storage, ResourcePile::ideas(2)),
0,
);
assert!(game.current_event_handler().is_some());
let game = server::game_api::execute(game.clone(), payment_response(ResourcePile::ideas(1)), 0);
assert_eq!(game.player(0).resources.mood_tokens, 2);
let game = server::game_api::execute(game.clone(), Action::Playing(PlayingAction::EndTurn), 0);
assert_eq!(game.player(0).great_library_advance, None);
assert_ne!(game.current_player_index, 0);
}
#[test]
fn test_lighthouse() {
let game = JSON.load_game("lighthouse");

View file

@ -578,3 +578,12 @@ research previously forced Available, while ordinary research forced All. Both
entry points now honor the player's saved preference, including after refresh.
Verified preference persistence tests, Svelte checks and production build.
Engine remains 0.4.118.
## Viewer 0.1.175 / engine 0.4.119
Restore Great Library's borrowed advance listeners when loading saved games.
Borrowed effects such as Free Education remain usable across requests and expire
without crashing End turn. Loading does not grant the advance's one-time bonus.
Verified a reload/payment/end-turn regression and the reported Gemmed-swan save
locally. The existing Great Gardens error-message assertion also fails on the
unchanged baseline. No live game data repair is included.

View file

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