Scope Great Gardens to its city and restore mobile replay chat
This commit is contained in:
parent
5771749219
commit
787c7671f1
9 changed files with 143 additions and 9 deletions
|
|
@ -350,7 +350,13 @@ pub fn possible_resource_collections(
|
|||
.events
|
||||
.transient
|
||||
.terrain_collect_options;
|
||||
let modifiers = event.trigger_with_modifiers(&mut terrain_options, &(), &(), &mut (), trigger);
|
||||
let modifiers = event.trigger_with_modifiers(
|
||||
&mut terrain_options,
|
||||
game.player(player_index).get_city(city_pos),
|
||||
&(),
|
||||
&mut (),
|
||||
trigger,
|
||||
);
|
||||
|
||||
let collect_options = city_pos
|
||||
.neighbors()
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ fn irrigation() -> AdvanceBuilder {
|
|||
.add_transient_event_listener(
|
||||
|event| &mut event.terrain_collect_options,
|
||||
0,
|
||||
|m, (), (), _| {
|
||||
|m, _, (), _| {
|
||||
m.insert(Barren, HashSet::from([ResourcePile::food(1)]));
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -309,7 +309,10 @@ fn great_gardens() -> WonderInfo {
|
|||
.add_transient_event_listener(
|
||||
|events| &mut events.terrain_collect_options,
|
||||
1,
|
||||
|m, (), (), _| {
|
||||
|m, city, (), _| {
|
||||
if !city.pieces.wonders.contains(&Wonder::GreatGardens) {
|
||||
return;
|
||||
}
|
||||
m.insert(
|
||||
Fertile,
|
||||
HashSet::from([
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ pub(crate) struct TransientEvents {
|
|||
|
||||
pub is_playing_action_available: Event<Result<(), String>, Game, PlayingActionType>,
|
||||
|
||||
pub terrain_collect_options: Event<HashMap<Terrain, HashSet<ResourcePile>>>,
|
||||
pub terrain_collect_options: Event<HashMap<Terrain, HashSet<ResourcePile>>, City>,
|
||||
pub collect_options: Event<CollectInfo, CollectContext, Game>,
|
||||
pub collect_total: Event<CollectInfo, Game, Vec<PositionCollection>>,
|
||||
|
||||
|
|
|
|||
|
|
@ -159,6 +159,127 @@ fn test_great_gardens() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn great_gardens_collection_is_scoped_to_its_city() {
|
||||
use server::cache::Cache;
|
||||
use server::collect::{
|
||||
PositionCollection, get_total_collection, possible_resource_collections,
|
||||
};
|
||||
use server::events::{EventOrigin, check_event_origin};
|
||||
use server::game::{Game, GameContext};
|
||||
use server::game_data::GameData;
|
||||
use server::player::CostTrigger;
|
||||
use std::collections::HashSet;
|
||||
|
||||
// Both cities can collect the same Plains tile. Owning the wonder elsewhere
|
||||
// must not change that city's choices or allow an invalid submitted action.
|
||||
for wonder_city in [0, 1] {
|
||||
let mut data: serde_json::Value =
|
||||
serde_json::from_str(include_str!("test_games/wonders/great_gardens.json")).unwrap();
|
||||
data["players"][0]["cities"][wonder_city]["city_pieces"] =
|
||||
serde_json::json!({"wonders": ["GreatGardens"]});
|
||||
let data: GameData = serde_json::from_value(data).unwrap();
|
||||
let cache = Cache::new(&data.options);
|
||||
let mut game = Game::from_data(data, cache, GameContext::Play);
|
||||
game.map
|
||||
.tiles
|
||||
.insert(Position::from_offset("A2"), server::map::Terrain::Forest);
|
||||
let plains = Position::from_offset("B1");
|
||||
let resources = [
|
||||
ResourcePile::food(1),
|
||||
ResourcePile::wood(1),
|
||||
ResourcePile::ore(1),
|
||||
ResourcePile::ideas(1),
|
||||
ResourcePile::gold(1),
|
||||
];
|
||||
for (index, name) in ["A1", "C2"].iter().enumerate() {
|
||||
let city = Position::from_offset(name);
|
||||
let options = possible_resource_collections(
|
||||
&game,
|
||||
city,
|
||||
0,
|
||||
&check_event_origin(),
|
||||
CostTrigger::WithModifiers,
|
||||
);
|
||||
let expected = if index == wonder_city {
|
||||
resources.clone().into_iter().collect()
|
||||
} else {
|
||||
HashSet::from([ResourcePile::food(1)])
|
||||
};
|
||||
assert_eq!(options.choices[&plains], expected, "Collecting with {name}");
|
||||
assert_eq!(
|
||||
options
|
||||
.modifiers
|
||||
.contains(&EventOrigin::Wonder(Wonder::GreatGardens)),
|
||||
index == wonder_city,
|
||||
);
|
||||
// Forest still provides only wood, even for the wonder's city.
|
||||
assert_eq!(
|
||||
options.choices[&Position::from_offset(if index == 0 { "A2" } else { "B2" })],
|
||||
HashSet::from([ResourcePile::wood(1)])
|
||||
);
|
||||
for resource in &resources {
|
||||
let result = get_total_collection(
|
||||
&game,
|
||||
0,
|
||||
&check_event_origin(),
|
||||
city,
|
||||
&[PositionCollection::new(plains, resource.clone())],
|
||||
CostTrigger::NoModifiers,
|
||||
);
|
||||
assert_eq!(
|
||||
result.is_ok(),
|
||||
index == wonder_city || *resource == ResourcePile::food(1),
|
||||
"{name}: {resource:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn great_gardens_applies_to_plains_reached_with_husbandry() {
|
||||
use server::cache::Cache;
|
||||
use server::collect::{PositionCollection, get_total_collection};
|
||||
use server::events::check_event_origin;
|
||||
use server::game::{Game, GameContext};
|
||||
use server::game_data::GameData;
|
||||
use server::map::Terrain;
|
||||
use server::player::CostTrigger;
|
||||
|
||||
let mut data: serde_json::Value =
|
||||
serde_json::from_str(include_str!("test_games/wonders/great_gardens.json")).unwrap();
|
||||
data["players"][0]["cities"][0]["city_pieces"] =
|
||||
serde_json::json!({"wonders": ["GreatGardens"]});
|
||||
data["players"][0]["advances"]
|
||||
.as_array_mut()
|
||||
.unwrap()
|
||||
.push(serde_json::json!("Husbandry"));
|
||||
let data: GameData = serde_json::from_value(data).unwrap();
|
||||
let cache = Cache::new(&data.options);
|
||||
let mut game = Game::from_data(data, cache, GameContext::Play);
|
||||
game.map
|
||||
.tiles
|
||||
.insert(Position::from_offset("A2"), Terrain::Forest);
|
||||
game.map
|
||||
.tiles
|
||||
.insert(Position::from_offset("A3"), Terrain::Fertile);
|
||||
assert!(
|
||||
get_total_collection(
|
||||
&game,
|
||||
0,
|
||||
&check_event_origin(),
|
||||
Position::from_offset("A1"),
|
||||
&[PositionCollection::new(
|
||||
Position::from_offset("A3"),
|
||||
ResourcePile::gold(1)
|
||||
)],
|
||||
CostTrigger::NoModifiers,
|
||||
)
|
||||
.is_ok()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_great_mausoleum() {
|
||||
JSON.test(
|
||||
|
|
|
|||
|
|
@ -403,3 +403,7 @@ Viewer 0.1.143 uses printed card names in waiting-status labels, matching event
|
|||
Viewer 0.1.144 / engine 0.4.100 adds combat estimates to attack confirmation and selected tactics, Siegecraft and Steel Weapons choices. An isolated worker runs 2,048 battles with the real engine, an independent random stream, public information only, and explicit no-retreat / no-additional-tactics and casualty assumptions. Attack previews compare affordable Siegecraft options and declining Steel Weapons. Unsupported decisions show no estimate. Results are cached, selection changes cancel old workers, and simulations stop before capture rewards.
|
||||
|
||||
Viewer 0.1.145 enriches cultural-influence recap captions with success/failure, target civilization and building (or unit), without coordinates. Pending rolls stay pending until the boost response resolves; existing public recordings are supported. No engine or saved-data changes.
|
||||
|
||||
Viewer 0.1.147 / engine 0.4.101 restricts Great Gardens' resource choices to the city containing the wonder. Plains reached through Husbandry still qualify, other terrain keeps its normal resources, and both previews and submitted collections use the same city-specific rule. The rule applies to existing saves when loaded; completed historical collections are unchanged.
|
||||
|
||||
Full-game replay no longer reserves room below chat for the hidden last-turn recap. On mobile this restores a usable message viewport and composer. Last-turn recaps retain their panel spacing. Verified with collection/wonder regressions, 827 frontend tests, all locales, type checking, production build, and phone-sized embedded chat previews. The broader advances test suite still has an unrelated stale cultural-influence log expectation (`rolls a 2` versus `rolls a 1 (+1)`).
|
||||
|
|
|
|||
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.146",
|
||||
"version": "0.1.147",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.146",
|
||||
"version": "0.1.147",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.146",
|
||||
"version": "0.1.147",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -6203,12 +6203,12 @@ small {
|
|||
font: bold 12px/1 sans-serif;
|
||||
}
|
||||
|
||||
.game-shell.playing-back .activity.floating-panel {
|
||||
.game-shell.playing-back:not(.full-replay) .activity.floating-panel {
|
||||
bottom: 260px;
|
||||
height: min(470px, calc(100% - 280px));
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.game-shell.playing-back .activity.floating-panel {
|
||||
.game-shell.playing-back:not(.full-replay) .activity.floating-panel {
|
||||
bottom: 285px;
|
||||
height: max(120px, calc(100% - 405px));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue