From 8df84ba2281d406d07902634adcd2cefad1913b6 Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Sun, 27 Sep 2026 23:43:06 +0200 Subject: [PATCH] Add a 3D web viewer with Rust-backed actions and BGS protocol integration --- server/src/game_api_wrapper.rs | 30 + server/src/lib.rs | 3 +- server/src/web_view.rs | 210 ++++ web-client/.gitignore | 2 + web-client/.prettierrc.json | 8 + web-client/README.md | 60 + web-client/built-viewer.html | 29 + web-client/classic.html | 69 + web-client/index.html | 101 ++ web-client/package-lock.json | 1643 ++++++++++++++++++++++++ web-client/package.json | 29 + web-client/scripts/build-bridge.sh | 7 + web-client/scripts/preview-api.ts | 144 +++ web-client/src/App.svelte | 607 +++++++++ web-client/src/ResearchTree.svelte | 200 +++ web-client/src/board.ts | 463 +++++++ web-client/src/controller.ts | 179 +++ web-client/src/engine.test.ts | 242 ++++ web-client/src/local-frame.ts | 13 + web-client/src/local-host.ts | 132 ++ web-client/src/model.ts | 120 ++ web-client/src/research.css | 385 ++++++ web-client/src/research.ts | 128 ++ web-client/src/style.css | 1868 ++++++++++++++++++++++++++++ web-client/src/types.ts | 176 +++ web-client/src/viewer.ts | 46 + web-client/tsconfig.json | 18 + web-client/viewer.html | 12 + web-client/vite.config.ts | 12 + 29 files changed, 6935 insertions(+), 1 deletion(-) create mode 100644 server/src/web_view.rs create mode 100644 web-client/.gitignore create mode 100644 web-client/.prettierrc.json create mode 100644 web-client/README.md create mode 100644 web-client/built-viewer.html create mode 100644 web-client/classic.html create mode 100644 web-client/index.html create mode 100644 web-client/package-lock.json create mode 100644 web-client/package.json create mode 100644 web-client/scripts/build-bridge.sh create mode 100644 web-client/scripts/preview-api.ts create mode 100644 web-client/src/App.svelte create mode 100644 web-client/src/ResearchTree.svelte create mode 100644 web-client/src/board.ts create mode 100644 web-client/src/controller.ts create mode 100644 web-client/src/engine.test.ts create mode 100644 web-client/src/local-frame.ts create mode 100644 web-client/src/local-host.ts create mode 100644 web-client/src/model.ts create mode 100644 web-client/src/research.css create mode 100644 web-client/src/research.ts create mode 100644 web-client/src/style.css create mode 100644 web-client/src/types.ts create mode 100644 web-client/src/viewer.ts create mode 100644 web-client/tsconfig.json create mode 100644 web-client/viewer.html create mode 100644 web-client/vite.config.ts diff --git a/server/src/game_api_wrapper.rs b/server/src/game_api_wrapper.rs index 1621905d..f9c31905 100644 --- a/server/src/game_api_wrapper.rs +++ b/server/src/game_api_wrapper.rs @@ -185,3 +185,33 @@ impl Messages { Self { messages, data } } } + +#[wasm_bindgen(js_name = "webView")] +pub fn web_view(data: String, player: Option) -> Result { + serde_json::to_string(&crate::web_view::view(&get_game(data), player)) + .map_err(|e| JsValue::from_str(&e.to_string())) +} + +#[wasm_bindgen(js_name = "webCollectPreview")] +pub fn web_collect_preview( + data: String, + player: usize, + city: String, + selections: String, +) -> Result { + let selections = + serde_json::from_str(&selections).map_err(|e| JsValue::from_str(&e.to_string()))?; + let city = serde_json::from_value(serde_json::Value::String(city)) + .map_err(|e| JsValue::from_str(&e.to_string()))?; + let result = crate::web_view::collect_preview(&get_game(data), player, city, selections) + .map_err(|e| JsValue::from_str(&e))?; + serde_json::to_string(&result).map_err(|e| JsValue::from_str(&e.to_string())) +} + +#[wasm_bindgen(js_name = "tryMove")] +pub fn try_move(data: String, action: String, player: usize) -> Result { + let action = serde_json::from_str(&action).map_err(|e| JsValue::from_str(&e.to_string()))?; + crate::action::try_execute_action(get_game(data), action, player) + .map(from_game) + .map_err(|e| JsValue::from_str(&e)) +} diff --git a/server/src/lib.rs b/server/src/lib.rs index 60b57da9..892b9697 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -13,7 +13,6 @@ extern crate core; pub mod ability_initializer; pub mod action; -pub mod analysis; pub mod action_card; mod action_cost; pub mod advance; @@ -25,6 +24,7 @@ pub mod ai_actions; pub mod ai_collect; #[cfg(not(target_arch = "wasm32"))] pub mod ai_missions; +pub mod analysis; pub mod barbarians; pub mod cache; pub mod card; @@ -75,4 +75,5 @@ mod undo; pub mod unit; pub mod utils; pub mod victory_points; +pub mod web_view; pub mod wonder; diff --git a/server/src/web_view.rs b/server/src/web_view.rs new file mode 100644 index 00000000..0cbd5a3b --- /dev/null +++ b/server/src/web_view.rs @@ -0,0 +1,210 @@ +use crate::action::Action; +use crate::advance::AdvanceAction; +use crate::card::HandCard; +use crate::collect::{ + Collect, PositionCollection, collect_event_origin, get_total_collection, + possible_resource_collections, +}; +use crate::consts::OBJECTIVE_VICTORY_POINTS; +use crate::content::persistent_events::{ + EventResponse, PersistentEventRequest, PersistentEventType, +}; +use crate::game::{Game, GameState}; +use crate::objective_card::ObjectiveType; +use crate::player::CostTrigger; +use crate::playing_actions::{PlayingAction, PlayingActionType}; +use crate::position::Position; +use serde_json::{Value, json}; + +pub fn view(game: &Game, seat: Option) -> Value { + let seat = seat.filter(|i| *i < game.players.len() && game.player(*i).is_human()); + let active = game.active_player(); + let playing = game.state == GameState::Playing && game.events.is_empty(); + let objective_phase = game.events.last().is_some_and(|event| { + matches!(event.event_type, PersistentEventType::SelectObjectives(_)) + && matches!( + game.current_event_handler().map(|h| &h.request), + Some(PersistentEventRequest::SelectHandCards(_)) + ) + }); + let supported_phase = playing || objective_phase; + let can_play = seat == Some(active) && playing; + let players = game.players.iter().filter(|p| p.is_human()).map(|p| json!({ + "index": p.index, "name": game.player_name(p.index), "civilization": p.civilization.name, + "score": p.victory_points(game), + "cities": p.cities.iter().map(|c| json!({"position": c.position, "size": c.size(), "capacity": c.mood_modified_size(p), "mood": c.mood_state, "activations": c.activations})).collect::>() + })).collect::>(); + let Some(seat) = seat else { + return json!({"activePlayer": active, "canPlay": false, "supportedPhase": supported_phase, "players": players, "cities": [], "advances": [], "objectiveCards": [], "objectiveDecision": null, "canUndo": false, "canEndTurn": false}); + }; + let p = game.player(seat); + // Hidden cards use ID zero in the player-filtered state; never resolve them. + let objective_cards = p + .objective_cards + .iter() + .filter(|id| **id != 0) + .map(|id| { + let card = game.cache.get_objective_card(*id); + json!({"id": card.id, "objectives": card.objectives.iter().map(|objective| json!({ + "name": objective.name, + "description": objective.description, + "timing": match objective.get_type() { + ObjectiveType::Instant => "Instant", + ObjectiveType::StatusPhase => "Status phase", + } + })).collect::>()}) + }) + .collect::>(); + let collect_type = PlayingActionType::Collect; + let collect_reason = collect_type.is_available(game, seat).err(); + let origin = collect_event_origin(&collect_type, p); + let cities = p.cities.iter().map(|city| { + let info = possible_resource_collections(game, city.position, seat, &origin, CostTrigger::NoModifiers); + let mut choices = info.choices.iter().flat_map(|(position, piles)| piles.iter().map(move |pile| json!({"position":position,"pile":pile}))).collect::>(); + choices.sort_by_key(Value::to_string); + let reason = if !can_play { Some("Wait for your turn".to_string()) } else if !city.can_activate() { Some("This city has already been activated while angry".to_string()) } else { collect_reason.clone() }; + json!({"position":city.position,"size":city.size(),"capacity":info.max_selection,"maxPerTile":info.max_per_tile,"maxRange2":info.max_range2_tiles,"mood":city.mood_state,"activations":city.activations,"reason":reason,"choices":choices}) + }).collect::>(); + let mut advances = game.cache.get_advances().iter().map(|(advance, info)| { + let cost = p.advance_cost(*advance, game, CostTrigger::NoModifiers).cost; + let payment = cost.first_valid_payment(&p.resources); + let owned = p.has_advance(*advance); + let reason = if owned { Some("Already researched".to_string()) } + else if !can_play { Some("Wait for your turn".to_string()) } + else if let Err(reason) = PlayingActionType::Advance.is_available(game, seat) { Some(reason) } + else if let Some(required) = info.required.filter(|a| !p.has_advance(*a)) { Some(format!("Requires {}", required.name(game))) } + else if !p.can_advance_free(*advance, game) { Some("Conflicts with your current advances".to_string()) } + else if payment.is_none() { Some("Not enough resources".to_string()) } else { None }; + let action = if reason.is_none() { payment.clone().map(|payment| Action::Playing(PlayingAction::Advance(AdvanceAction::new(*advance, payment)))) } else { None }; + let group = game.cache.get_advance_groups().iter().enumerate().find_map(|(group_index, group)| { + group.advances.iter().position(|a| a.advance == *advance).map(|index| (group.name.clone(), group_index * 10 + index)) + }); + json!({"id":advance,"name":info.name,"description":info.description,"owned":owned,"reason":reason,"payment":payment.unwrap_or_else(|| cost.default_payment()),"action":action, + "group":group.as_ref().map(|g| &g.0),"order":group.as_ref().map(|g| g.1),"required":info.required, + "bonus":info.bonus.as_ref().map(|bonus| bonus.resources()),"unlocks":info.unlocked_building.map(|building| building.to_string())}) + }).collect::>(); + advances.sort_by_key(|a| a["name"].as_str().unwrap_or_default().to_string()); + json!({"activePlayer":active,"canPlay":can_play,"supportedPhase":supported_phase,"players":players,"cities":cities,"advances":advances,"objectiveCards":objective_cards,"objectiveDecision":objective_decision(game, seat),"canUndo":seat == active && game.can_undo(),"canEndTurn":can_play && PlayingActionType::EndTurn.is_available(game, seat).is_ok()}) +} + +fn objective_decision(game: &Game, seat: usize) -> Option { + let event = game.events.last()?; + if seat != event.player.index { + return None; + } + let PersistentEventType::SelectObjectives(info) = &event.event_type else { + return None; + }; + let name = info.shown_objective.as_ref()?; + let handler = game.current_event_handler()?; + let PersistentEventRequest::SelectHandCards(request) = &handler.request else { + return None; + }; + if handler.response.is_some() || !request.needed.contains(&1) { + return None; + } + let cards = request.choices.iter().filter_map(|card| { + let HandCard::ObjectiveCard(id) = card else { return None; }; + if *id == 0 || !game.player(seat).objective_cards.contains(id) { return None; } + let info = game.cache.get_objective_card(*id); + Some(json!({"id":id,"name":info.name(),"action":Action::Response(EventResponse::SelectHandCards(vec![card.clone()]))})) + }).collect::>(); + let skip = request + .needed + .contains(&0) + .then(|| Action::Response(EventResponse::SelectHandCards(vec![]))); + Some( + json!({"name":name,"description":game.cache.get_objective(name).description,"points":OBJECTIVE_VICTORY_POINTS,"cards":cards,"skip":skip}), + ) +} + +pub fn collect_preview( + game: &Game, + seat: usize, + city: Position, + selections: Vec, +) -> Result { + if seat >= game.players.len() || !game.player(seat).is_human() || seat != game.active_player() { + return Err("Wait for your turn".to_string()); + } + PlayingActionType::Collect.is_available(game, seat)?; + let p = game.player(seat); + let city_data = p.try_get_city(city).ok_or("Choose one of your cities")?; + if !city_data.can_activate() { + return Err("This city cannot be activated again this turn".to_string()); + } + if selections.iter().any(|c| c.times == 0) { + return Err("Choose at least one resource".to_string()); + } + let origin = collect_event_origin(&PlayingActionType::Collect, p); + let total = get_total_collection( + game, + seat, + &origin, + city, + &selections, + CostTrigger::NoModifiers, + )? + .total; + let mut after = p.resources.clone() + total.clone(); + let waste = after.apply_resource_limit(&p.resource_limit); + let action = Action::Playing(PlayingAction::Collect(Collect::new( + city, + selections, + PlayingActionType::Collect, + ))); + Ok( + json!({"action":action,"total":total,"waste":waste,"after":after,"moodWillDecrease":city_data.is_activated()}), + ) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{game::GameOptions, game_api, resource_pile::ResourcePile}; + fn game() -> Game { + game_api::init(2, "web-view-test".into(), GameOptions::default()) + } + #[test] + fn spectators_and_waiting_players_have_no_actions() { + let game = game(); + assert_eq!(view(&game, None)["canPlay"], false); + assert_eq!(view(&game, Some(99))["cities"], json!([])); + let waiting = view(&game, Some(1 - game.active_player())); + assert_eq!(waiting["canPlay"], false); + assert!( + waiting["advances"] + .as_array() + .unwrap() + .iter() + .all(|a| a["action"].is_null()) + ); + } + #[test] + fn collect_preview_uses_rules_and_does_not_mutate_state() { + let game = game(); + let before = serde_json::to_string(&game.cloned_data()).unwrap(); + let seat = game.active_player(); + let city = game.player(seat).cities[0].position; + let preview = collect_preview( + &game, + seat, + city, + vec![PositionCollection::new(city, ResourcePile::food(1))], + ) + .unwrap(); + let action: Action = serde_json::from_value(preview["action"].clone()).unwrap(); + assert!(crate::action::try_execute_action(game.clone(), action, seat).is_ok()); + assert_eq!(before, serde_json::to_string(&game.cloned_data()).unwrap()); + assert!(collect_preview(&game, 1 - seat, city, vec![]).is_err()); + assert!( + collect_preview( + &game, + seat, + city, + vec![PositionCollection::new(city, ResourcePile::gold(7))] + ) + .is_err() + ); + } +} diff --git a/web-client/.gitignore b/web-client/.gitignore new file mode 100644 index 00000000..4599ef6b --- /dev/null +++ b/web-client/.gitignore @@ -0,0 +1,2 @@ +.engine/ +public/engine/ diff --git a/web-client/.prettierrc.json b/web-client/.prettierrc.json new file mode 100644 index 00000000..f3b28867 --- /dev/null +++ b/web-client/.prettierrc.json @@ -0,0 +1,8 @@ +{ + "plugins": ["prettier-plugin-svelte"], + "printWidth": 110, + "useTabs": false, + "tabWidth": 2, + "singleQuote": true, + "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] +} diff --git a/web-client/README.md b/web-client/README.md new file mode 100644 index 00000000..d4bc613f --- /dev/null +++ b/web-client/README.md @@ -0,0 +1,60 @@ +# Clash of Cultures — web viewer + +First playable slice of a Svelte/TypeScript interface with a Three.js board. The Rust engine remains the rule authority. The existing Macroquad client is unchanged. + +## Run locally + +Requirements: Node 24+, Rust with `wasm32-unknown-unknown`, and `wasm-bindgen-cli` matching Cargo.lock (currently 0.2.100). + +```sh +cd web-client +npm ci +npm run build:bridge +npm run dev +``` + +Open http://127.0.0.1:8643. The preview binds to loopback and saves its disposable game under `.engine/preview-state.json`. **New game** resets that game and its local chat. Hotseat follows the active player; the player selector also supports fixed seats and spectators. + +No production games, catalog records, or chat rooms are modified. Remaining actions and phases will be implemented in this interface. + +## Implemented slice + +- Procedural 3D terrain, cities, settlers, tile selection, orbit/zoom, and a top-down view. +- Named resources, storage limits, player scores, action count, city mood, and a short field guide. +- Private objective hand with both alternative conditions and their completion timing, read from the Rust definitions. When the engine offers an eligible objective, the player can claim points or keep the card directly in the action panel. +- Collect resources: Rust supplies legal tiles, resource alternatives, capacity, total gain, waste, and an activation warning. Confirming submits the original Rust action format. +- Research: a searchable tree with pictograms, short effect summaries, prerequisite branches, costs, bonuses, and unlocked buildings. Rust supplies the graph, full rules, payments, and action payloads; selecting an advance opens its full rule text before confirmation. +- End turn and undo, with state and journal reconciliation. +- BGS registration/lifecycle, player/spectator handling, theme, avatars, and the shared chat controller/panel. Chat sends, failed-send drafts, updates/deletions, mentions, read reports, editing and translation handlers are supplied by the protocol package; the host decides which features are enabled. +- Journal entries use action and resource pictograms. Setup is summarized as player, civilization, and original starting tile. Text equivalents are published with `replaceLog` so undo cannot leave stale entries. +- Full-width board with floating action controls and dismissible journal/chat panels. The layout stays within the viewport on desktop and mobile; panels scroll internally. City/action controls are keyboard accessible, and the board renders only when changed. + +The preview host uses a real iframe and `postMessage` to exchange BGS events. Its chat is local test data, not a connection to a live BGS room. Production BGS integration still needs a staging playtest. + +## Build and verify + +```sh +npm run check +npm test +npm run build +# From repository root: +cargo test -p server --lib web_view +``` + +After building, `http://127.0.0.1:8643/?built` loads the production IIFE bundle inside the preview host. + +Upload the contents of `dist/` together, preserving `engine/` alongside `viewer.js`. The viewer resolves its WASM bridge relative to its own script URL. It exports `window.clash3d.launch(selector)` and uses string state/move payloads, matching the existing engine. Configure `topLevelVariable: "clash3d"`, `fullScreen: true`, `chat: true`, and `replayable: false`. No extra runtime scripts or stylesheets are needed. Fonts currently load from Google Fonts; system fonts remain available if blocked. + +## Next slices + +The new controls do not yet cover movement/exploration, construction, recruitment, action cards, cultural influence, happiness actions, combat, civilization selection, or status/event choices other than objective claims. City buildings beyond the center and unit types beyond settlers still need distinct models. Full replay and analysis controls are not advertised. The interface text is currently English; existing game translations need to be wired into the new presentation layer. Audio and advanced accessibility preferences need a separate pass. + +Before making this the default viewer: complete action/phase coverage, verify against an actual BGS staging game (including reconnects, moderation, translation, and read-state persistence), and test larger multiplayer boards on mobile hardware. + +## Architecture + +`server/src/web_view.rs` exposes read-only rule queries; `game_api_wrapper.rs` exports them to WASM. Queries consume the same player-filtered state BGS sends to the viewer. They neither mutate the game nor send moves. The server always validates actual moves. + +`src/controller.ts` coordinates state, choices, and the BGS commands. `src/App.svelte` owns the HTML interface. `src/board.ts` owns and disposes the Three.js scene. `src/viewer.ts` is the production entry. `src/local-host.ts` and `scripts/preview-api.ts` are development-only. + +The protocol dependency is AGPL-3.0-only. The existing engine and classic viewer retain their respective licensing. diff --git a/web-client/built-viewer.html b/web-client/built-viewer.html new file mode 100644 index 00000000..1ca9ebd7 --- /dev/null +++ b/web-client/built-viewer.html @@ -0,0 +1,29 @@ + + + + + + Clash 3D · production bundle + + +
+ + + + diff --git a/web-client/classic.html b/web-client/classic.html new file mode 100644 index 00000000..41522665 --- /dev/null +++ b/web-client/classic.html @@ -0,0 +1,69 @@ + + + + + + Clash · Classic controls + + + +
+ ← Return to 3D viewClassic controls · same local game +
+ +
+ + + + + diff --git a/web-client/index.html b/web-client/index.html new file mode 100644 index 00000000..0a7f84e1 --- /dev/null +++ b/web-client/index.html @@ -0,0 +1,101 @@ + + + + + + Clash of Cultures + + + +
+ Design previewConnecting to local game… +
+ + + + + diff --git a/web-client/package-lock.json b/web-client/package-lock.json new file mode 100644 index 00000000..04ff925e --- /dev/null +++ b/web-client/package-lock.json @@ -0,0 +1,1643 @@ +{ + "name": "@boardgamers/clash-web-client", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@boardgamers/clash-web-client", + "version": "0.1.0", + "dependencies": { + "@boardgamers/protocol": "0.6.1", + "lucide-svelte": "^0.468.0", + "svelte": "^5.0.0", + "three": "^0.180.0" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^6.0.0", + "@types/node": "^24.0.0", + "@types/three": "^0.180.0", + "prettier": "^3.9.9", + "prettier-plugin-svelte": "^4.1.1", + "svelte-check": "^4.0.0", + "typescript": "^5.9.0", + "vite": "^7.0.0" + } + }, + "node_modules/@boardgamers/protocol": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/@boardgamers/protocol/-/protocol-0.6.1.tgz", + "integrity": "sha512-/SdqqYrRUNizjGqQygR4kxTZqCOqWfj190Uj/YHI8i0pD4eNXGofZJd2QhkB63n0iSRHMvJJRJReadof151wBg==", + "license": "AGPL-3.0-only", + "dependencies": { + "zod": "^4.3.6" + } + }, + "node_modules/@dimforge/rapier3d-compat": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz", + "integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.63.5.tgz", + "integrity": "sha512-J25QJU+B78T4FhhBsNpLJyVWOi31mwtpcMwywHmOKH65Q9IWGA81gPj+dnwlhU8wktVriYE+tFAaQgrnJRzAZg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.63.5.tgz", + "integrity": "sha512-LDopB3zuZM5Ux9TT2luNEBJW/tYbGU2g1d+VpKk6I+gSKDb+/7sYE6M225gRQt4RbMX6MSwMsVR/phdjVUgRLg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.63.5.tgz", + "integrity": "sha512-wlJEERGfeuHeBavCL2qVnNacOK43NDoZM4sjkeRPymd04OAE9T1zBqDJgmZ+CIsPTYKwdzpUC8vmOw84dwY4Tg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.63.5.tgz", + "integrity": "sha512-4nJJGg5jbo2wwPP4JP+LfEBA3bvP8rU9CLuhp7jWvq9sxEyhjQFTFdrqi+/dHEin/pd8jpT0vcehIpnZtmEdcQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.63.5.tgz", + "integrity": "sha512-DrZbyCDF1hneuO6jRbvZ2D7+PIBM6yIwYnJpg2vIk58T+wuFpiaGZrfUr59lDWw45bg+IrpTGLPiNi/Fk4w3Cg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.63.5.tgz", + "integrity": "sha512-gqfUVMJMB3mehqywxp6hTBFfgtMQykZY19+cfiaYP0toIJLb/1DZRJHVkQQGP13W4TAwfZDWeg1qBcheTRioXQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.63.5.tgz", + "integrity": "sha512-CFmhpvAwzSaWMlN3VN7UtmoTihlZNzoP0juQib5TQRnYUyDV8dXeWOp29sobWAT6gXl/hQgAClLlEiYozQG3OQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.63.5.tgz", + "integrity": "sha512-Uc9H8eXCOayV6JLTH5bXKMId6qbhNHa818/BgYjm4jrlq3vZquC9cqyvHBw17xy5Mnj5f+I3gFK5JcEf3hSqrw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.63.5.tgz", + "integrity": "sha512-VcPr/szv/1BFw112Kt//fxulXt/JPqzzidU84iW68L2DdjnOO8QFUv2zTSYBEPHD6movBD4z+bbr5y60GYM7Jw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.63.5.tgz", + "integrity": "sha512-BnxtJ5/91BrIHYIkGrmjz/lbMhqEHt1dPFqIxIFR+jPn0xVc/oUSCtIT089zfp5ufwGDlYz2UC+Fe1SRBpYFbQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.63.5.tgz", + "integrity": "sha512-LrYcHZwF+fAMNKHYTOQ5osWM4AZF7YF6D+XtsjDyEvljtt11twc+zHVXBLNEjxVSUnKYsOhvVz4Z213eW02COQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.63.5.tgz", + "integrity": "sha512-nj7QKQePAAUpCpJHtg0pR0W/b92A9NO17JS3BAQmHDn/yhmkir2p8llrKY9TOhleKIaSzy1JhxS3T9FVld6coA==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.63.5.tgz", + "integrity": "sha512-5ylkX6dWMeBKge9nTU+Rxfb+ZfaCIJ9lRqIFaK0eAMcWp7OJbYnLveLgXmm0VrvuLKb8qIK+mHyH0qu88RM+iA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.63.5.tgz", + "integrity": "sha512-oHK4ZHYFDKjZviK34I+NwgfbGxgI7ztrNxj2hPTSSNFgeq1a/lEd7dHV2fdGAuTH4Iym3RHJg+vAbWaWG4B7Zg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.63.5.tgz", + "integrity": "sha512-UcetmHZ6XOXuUByiKZyQmb55ZPr0LABr3Ec/HB9wKZn6CEAFWZkE+hsJErJ9hbPBC7nI0dKuELx7CoV6IM7TMg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.63.5.tgz", + "integrity": "sha512-C5CmDPQBtvjVo8cgQsBs+w6WB0JLkiixhgi6hVLV11hERWdn/p0XcPU2OUcZzac9BPOFq7SbaHFa8r3SWEysCQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.63.5.tgz", + "integrity": "sha512-lHVQHJFKsuuxLMi3MQO9XVL8Tje3JR82CzB+QDKC5NWBcsIWuwsn9uIM5e3lBhI+fF1/s63qnyYqsg65+8rV/w==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.63.5.tgz", + "integrity": "sha512-3W9bTFcQNJn71cSJVM9RKIiZOy8DO/XLDii8Uv/Pm6WKqDRj7JV3ZfuXIEfyuy5LXpIzAbB/1M4Ukp9GKNa7nA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.63.5.tgz", + "integrity": "sha512-VDC7rRJlee/scpki96GZ27Omf6yU87s1YXwVTpjE5841faVlDYYT565rgfmoR1U0sqL7z5ivQSDjcsF6VRXyBA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.63.5.tgz", + "integrity": "sha512-z86Ok2p4pTdv5xqCKZsTooO7yBEiaJR/HzU3Wx8RmWsPoLppnMKROhJusQob8B3IE1ghC343kUW9rC2r+Wf3ig==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.63.5.tgz", + "integrity": "sha512-IzQmj+xXwQFGhMAMKMQVXkMwMZN3TqkJgAE0nSsqvVwWWciP4AIPMmWRqOQ2GfX7TUDZr+xqGFcBS36CRPGw0g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.63.5.tgz", + "integrity": "sha512-F6qpTaPc9bwBH85kjy0/BLmLSW1uv7AoOXCoRIkg2arlgCYlWYcAbiMkvZuAcaWk9TpCRG//okznLAqLGshkMw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.63.5.tgz", + "integrity": "sha512-igoDsTFhhwECBeGbUuLeIk7t8Y1apa+cs6mDWpx2EZ0ch7oEQgzHbFUXN9euoHekCAQzXdXApAGkV6jznS7tWw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.63.5.tgz", + "integrity": "sha512-U3teMeMbXFmaM5D+OTJpsOXd+wV/qftIeYF9kBKL4v73641qyJmoXFtA28DQLsnmlyayEsTe72xpLHrArq6vHw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.63.5.tgz", + "integrity": "sha512-ypfC34F3RKXvCXBglGqGMsUSMKlgwd1HX9AOAlx9RoZZ6GaI42YHVeKpzg3JG+wpBUJYTG+NNZhqbDWL8tBZkw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@sveltejs/acorn-typescript": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.13.tgz", + "integrity": "sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ==", + "license": "MIT", + "peerDependencies": { + "acorn": "^8.9.0" + } + }, + "node_modules/@sveltejs/load-config": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@sveltejs/load-config/-/load-config-0.2.3.tgz", + "integrity": "sha512-VT3qmUb8pRV2QrZjd8iAmtg8lf4W0TIjZbvXtz5MKei/q96teWZgGJyyidJzOjzZzvdq616eSRVeMYIQChUTAQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 18.0.0" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte": { + "version": "6.2.4", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-6.2.4.tgz", + "integrity": "sha512-ou/d51QSdTyN26D7h6dSpusAKaZkAiGM55/AKYi+9AGZw7q85hElbjK3kEyzXHhLSnRISHOYzVge6x0jRZ7DXA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sveltejs/vite-plugin-svelte-inspector": "^5.0.0", + "deepmerge": "^4.3.1", + "magic-string": "^0.30.21", + "obug": "^2.1.0", + "vitefu": "^1.1.1" + }, + "engines": { + "node": "^20.19 || ^22.12 || >=24" + }, + "peerDependencies": { + "svelte": "^5.0.0", + "vite": "^6.3.0 || ^7.0.0" + } + }, + "node_modules/@sveltejs/vite-plugin-svelte-inspector": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-5.0.2.tgz", + "integrity": "sha512-TZzRTcEtZffICSAoZGkPSl6Etsj2torOVrx6Uw0KpXxrec9Gg6jFWQ60Q3+LmNGfZSxHRCZL7vXVZIWmuV50Ig==", + "dev": true, + "license": "MIT", + "dependencies": { + "obug": "^2.1.0" + }, + "engines": { + "node": "^20.19 || ^22.12 || >=24" + }, + "peerDependencies": { + "@sveltejs/vite-plugin-svelte": "^6.0.0-next.0", + "svelte": "^5.0.0", + "vite": "^6.3.0 || ^7.0.0" + } + }, + "node_modules/@tweenjs/tween.js": { + "version": "23.1.3", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", + "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "24.19.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.19.0.tgz", + "integrity": "sha512-zY+5tKxXdhGh1PYI0ac+7juvEu4OI6vWtVVoj5i2m42jxAY1U+zHGt6QCyOFwykdP62sM3MJ9stoYYUw5aCWew==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": ">=7.24.0 <7.24.7" + } + }, + "node_modules/@types/stats.js": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz", + "integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/three": { + "version": "0.180.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.180.0.tgz", + "integrity": "sha512-ykFtgCqNnY0IPvDro7h+9ZeLY+qjgUWv+qEvUt84grhenO60Hqd4hScHE7VTB9nOQ/3QM8lkbNE+4vKjEpUxKg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@dimforge/rapier3d-compat": "~0.12.0", + "@tweenjs/tween.js": "~23.1.3", + "@types/stats.js": "*", + "@types/webxr": "*", + "@webgpu/types": "*", + "fflate": "~0.8.2", + "meshoptimizer": "~0.22.0" + } + }, + "node_modules/@types/webxr": { + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz", + "integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@webgpu/types": { + "version": "0.1.74", + "resolved": "https://registry.npmjs.org/@webgpu/types/-/types-0.1.74.tgz", + "integrity": "sha512-lgiI4hbuLcI9unnm2cL/tvCaQU45dp0xcLWJh5uB/9MBGvIA4F8XIk7nSiBeg+K4xWGYwgZKn80LmERI5CxoTA==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/acorn": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz", + "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==", + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/aria-query": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz", + "integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==", + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/axobject-query": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", + "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==", + "license": "Apache-2.0", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/devalue": { + "version": "5.9.4", + "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.4.tgz", + "integrity": "sha512-sPAT4pztbu6586/hrhOnMKS17IJrvg12mXiSPSS3W5qDeN2RGgvZ0diZCm31dBbnevfVmujNO3IM2wrS4Y2Rhg==", + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/esm-env": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz", + "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==", + "license": "MIT" + }, + "node_modules/esrap": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.4.0.tgz", + "integrity": "sha512-CQPcneEHw/czj32uwQC52nYnax8H4SXt25FCM+LIwGZ49cMIxpOj3bP8wmzcI+Z0HIy5KkClaPhRLfCySzwHPA==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "peerDependencies": { + "@typescript-eslint/types": "^8.2.0" + }, + "peerDependenciesMeta": { + "@typescript-eslint/types": { + "optional": true + } + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "dev": true, + "license": "MIT" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/is-reference": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz", + "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==", + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.6" + } + }, + "node_modules/locate-character": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz", + "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==", + "license": "MIT" + }, + "node_modules/lucide-svelte": { + "version": "0.468.0", + "resolved": "https://registry.npmjs.org/lucide-svelte/-/lucide-svelte-0.468.0.tgz", + "integrity": "sha512-n0ecAFtCY5LEeL+PJ1Xj4n3c2gzj8tMpak0KMGnvoSJEjCsCnRB0mekBtJZAo7beyynW9Qj5Um1KfMBAeTNplw==", + "deprecated": "Package deprecated. Please use @lucide/svelte instead.", + "license": "ISC", + "peerDependencies": { + "svelte": "^3 || ^4 || ^5.0.0-next.42" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/meshoptimizer": { + "version": "0.22.0", + "resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-0.22.0.tgz", + "integrity": "sha512-IebiK79sqIy+E4EgOr+CAw+Ke8hAspXKzBd0JdgEmPHiAwmvEj2S4h1rfvo+o/BnfEYd/jAOg5IeeIjzlzSnDg==", + "dev": true, + "license": "MIT" + }, + "node_modules/mri": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", + "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/nanoid": { + "version": "3.3.19", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz", + "integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/obug": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.2.1.tgz", + "integrity": "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.28", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz", + "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.18", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/prettier": { + "version": "3.9.9", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.9.tgz", + "integrity": "sha512-Z/CJHIkdujO/OtN7nXUii0Rf3VT5SRuhjBA82Xvu2XhBUgX3nhP67T0LHceBdQLex7OOFGTox+Q5Yg8Jk2Qivg==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-svelte": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-4.1.1.tgz", + "integrity": "sha512-wXvbXMjSvb4C9ENWTHXyd+ihakKCsJ6rJhLP6/8HFNj4GkZr48jqL9PoKsl2sk7SyCZRTnJ7O2TTowUpOxP/KA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "prettier": "^3.0.0", + "svelte": "^5.0.0" + } + }, + "node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/rollup": { + "version": "4.63.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.5.tgz", + "integrity": "sha512-KRWwmNLlPw5M7HcdYfm15oBv9n9LPtjzpzCIxS/phwqvPyxHSoKX6Y2YU3pxSPfy0CLquVgsx/j/hBi6OvH1Nw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.63.5", + "@rollup/rollup-android-arm64": "4.63.5", + "@rollup/rollup-darwin-arm64": "4.63.5", + "@rollup/rollup-darwin-x64": "4.63.5", + "@rollup/rollup-freebsd-arm64": "4.63.5", + "@rollup/rollup-freebsd-x64": "4.63.5", + "@rollup/rollup-linux-arm-gnueabihf": "4.63.5", + "@rollup/rollup-linux-arm-musleabihf": "4.63.5", + "@rollup/rollup-linux-arm64-gnu": "4.63.5", + "@rollup/rollup-linux-arm64-musl": "4.63.5", + "@rollup/rollup-linux-loong64-gnu": "4.63.5", + "@rollup/rollup-linux-loong64-musl": "4.63.5", + "@rollup/rollup-linux-ppc64-gnu": "4.63.5", + "@rollup/rollup-linux-ppc64-musl": "4.63.5", + "@rollup/rollup-linux-riscv64-gnu": "4.63.5", + "@rollup/rollup-linux-riscv64-musl": "4.63.5", + "@rollup/rollup-linux-s390x-gnu": "4.63.5", + "@rollup/rollup-linux-x64-gnu": "4.63.5", + "@rollup/rollup-linux-x64-musl": "4.63.5", + "@rollup/rollup-openbsd-x64": "4.63.5", + "@rollup/rollup-openharmony-arm64": "4.63.5", + "@rollup/rollup-win32-arm64-msvc": "4.63.5", + "@rollup/rollup-win32-ia32-msvc": "4.63.5", + "@rollup/rollup-win32-x64-gnu": "4.63.5", + "@rollup/rollup-win32-x64-msvc": "4.63.5", + "fsevents": "~2.3.2" + } + }, + "node_modules/sade": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz", + "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "mri": "^1.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/svelte": { + "version": "5.57.1", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.57.1.tgz", + "integrity": "sha512-Uqj49lWKB+iSSnneuwiYYJ7MZgkB+eXr0LXBhv4uDuAkXqnWmq65Sxflfvp0Lc6MdKjMUxGaeOKWJqz5SNiVIA==", + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "@jridgewell/sourcemap-codec": "^1.6.0", + "@sveltejs/acorn-typescript": "^1.0.13", + "@types/estree": "^1.0.9", + "acorn": "^8.18.0", + "aria-query": "5.3.1", + "axobject-query": "^4.1.0", + "clsx": "^2.1.1", + "devalue": "^5.9.2", + "esm-env": "^1.2.1", + "esrap": "^2.3.6", + "is-reference": "^3.0.3", + "locate-character": "^3.0.0", + "magic-string": "^0.30.11", + "zimmerframe": "^1.1.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/svelte-check": { + "version": "4.7.6", + "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.7.6.tgz", + "integrity": "sha512-t2scM//ZuVbSY/T2w6FSBw1v9s2NEmh/g+sy1lqtosW5ylBV5AF4wFb1Ts9Kf3MbfPDUDJDZ9L436YT0SPTdvw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.25", + "@sveltejs/load-config": "^0.2.3", + "chokidar": "^4.0.1", + "fdir": "^6.2.0", + "picocolors": "^1.0.0", + "sade": "^1.7.4" + }, + "bin": { + "svelte-check": "bin/svelte-check" + }, + "engines": { + "node": ">= 18.0.0" + }, + "peerDependencies": { + "svelte": "^4.0.0 || ^5.0.0-next.0", + "typescript": "^5.0.0 || ^6.0.0" + } + }, + "node_modules/three": { + "version": "0.180.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.180.0.tgz", + "integrity": "sha512-o+qycAMZrh+TsE01GqWUxUIKR1AL0S8pq7zDkYOQw8GqfX8b8VoCKYUoHbhiX5j+7hr8XsuHDVU6+gkQJQKg9w==", + "license": "MIT" + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "7.24.6", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz", + "integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==", + "dev": true, + "license": "MIT" + }, + "node_modules/vite": { + "version": "7.3.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.6.tgz", + "integrity": "sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.27.0 || ^0.28.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitefu": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.3.tgz", + "integrity": "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==", + "dev": true, + "license": "MIT", + "workspaces": [ + "tests/deps/*", + "tests/projects/*", + "tests/projects/workspace/packages/*" + ], + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "vite": { + "optional": true + } + } + }, + "node_modules/zimmerframe": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.5.tgz", + "integrity": "sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA==", + "license": "MIT" + }, + "node_modules/zod": { + "version": "4.6.5", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", + "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/web-client/package.json b/web-client/package.json new file mode 100644 index 00000000..d7bf1e27 --- /dev/null +++ b/web-client/package.json @@ -0,0 +1,29 @@ +{ + "name": "@boardgamers/clash-web-client", + "version": "0.1.0", + "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", + "build:bridge": "bash scripts/build-bridge.sh" + }, + "dependencies": { + "@boardgamers/protocol": "0.6.1", + "lucide-svelte": "^0.468.0", + "svelte": "^5.0.0", + "three": "^0.180.0" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^6.0.0", + "@types/node": "^24.0.0", + "@types/three": "^0.180.0", + "prettier": "^3.9.9", + "prettier-plugin-svelte": "^4.1.1", + "svelte-check": "^4.0.0", + "typescript": "^5.9.0", + "vite": "^7.0.0" + } +} diff --git a/web-client/scripts/build-bridge.sh b/web-client/scripts/build-bridge.sh new file mode 100644 index 00000000..68f46688 --- /dev/null +++ b/web-client/scripts/build-bridge.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "$0")/../.." +cargo build -p server --lib --target wasm32-unknown-unknown --release +wasm-bindgen target/wasm32-unknown-unknown/release/server.wasm --target web --out-dir web-client/public/engine +wasm-bindgen target/wasm32-unknown-unknown/release/server.wasm --target nodejs --out-dir web-client/.engine +printf '{"type":"commonjs"}\n' > web-client/.engine/package.json diff --git a/web-client/scripts/preview-api.ts b/web-client/scripts/preview-api.ts new file mode 100644 index 00000000..23924edb --- /dev/null +++ b/web-client/scripts/preview-api.ts @@ -0,0 +1,144 @@ +import { createRequire } from 'node:module'; +import { readFileSync, writeFileSync, existsSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import type { Plugin } from 'vite'; +const require = createRequire(import.meta.url); +export function previewApi(): Plugin { + return { + name: 'clash-local-preview', + configureServer(server) { + const engine = require(fileURLToPath(new URL('../.engine/server.js', import.meta.url))); + const save = fileURLToPath(new URL('../.engine/preview-state.json', import.meta.url)); + let state: string; + let revision = 0; + let messages: any[] = []; + let readAt: Record = {}; + const persist = () => writeFileSync(save, JSON.stringify({ state, revision, messages, readAt })); + const reset = async () => { + state = await engine.init( + 2, + [], + { undo: 'SamePlayer', civilization: 'Random' }, + 'clash-preview-20260927', + {}, + ); + for (let i = 0; i < 2; i++) + state = engine.setPlayerMetaData(state, i, { name: ['Leif', 'Aurelia'][i] }); + revision++; + messages = []; + readAt = {}; + persist(); + }; + const ready = (async () => { + if (existsSync(save)) { + const saved = JSON.parse(readFileSync(save, 'utf8')); + state = saved.state; + revision = saved.revision; + messages = saved.messages; + readAt = saved.readAt ?? {}; + engine.webView(state, engine.currentPlayer(state)); + } else await reset(); + })(); + server.middlewares.use(async (req, res, next) => { + const url = new URL(req.url ?? '/', 'http://127.0.0.1:8643'); + if (url.pathname.startsWith('/bundle/')) { + const asset = url.pathname.slice(8); + if (!['viewer.js', 'engine/server.js', 'engine/server_bg.wasm'].includes(asset)) { + res.statusCode = 404; + res.end(); + return; + } + try { + res.setHeader('content-type', asset.endsWith('.wasm') ? 'application/wasm' : 'text/javascript'); + res.end(readFileSync(fileURLToPath(new URL('../dist/' + asset, import.meta.url)))); + } catch { + res.statusCode = 404; + res.end('Build the viewer first'); + } + return; + } + if (!url.pathname.startsWith('/api/') && !url.pathname.startsWith('/legacy/')) return next(); + try { + if (url.pathname.startsWith('/legacy/')) { + const base = + 'https://s3.fr-par.scw.cloud/bgs-assets/games/clash/1/viewer/locales-b2602be75e79cd1b/'; + const response = await fetch(new URL(url.pathname.slice(8), base)); + res.writeHead(response.status, { + 'content-type': response.headers.get('content-type') ?? 'application/octet-stream', + }); + res.end(Buffer.from(await response.arrayBuffer())); + return; + } + await ready; + res.setHeader('content-type', 'application/json'); + res.setHeader('cache-control', 'no-store'); + let body: any = {}; + if (req.method === 'POST') { + if (req.headers.origin && req.headers.origin !== `http://${req.headers.host}`) { + res.writeHead(403).end('{}'); + return; + } + let text = ''; + for await (const chunk of req) { + text += chunk; + if (text.length > 100000) throw Error('Request too large'); + } + body = JSON.parse(text || '{}'); + } + if (url.pathname === '/api/reset' && req.method === 'POST') await reset(); + if (url.pathname === '/api/move' && req.method === 'POST') { + if (body.revision !== revision) throw Error('The game changed. Please choose your action again.'); + if (!Number.isInteger(body.seat) || body.seat !== engine.currentPlayer(state)) + throw Error('It is not your turn.'); + state = engine.tryMove( + state, + typeof body.move === 'string' ? body.move : JSON.stringify(body.move), + body.seat, + ); + revision++; + persist(); + } + if (url.pathname === '/api/chat' && req.method === 'POST') { + if (body.seat !== 0 && body.seat !== 1) + throw Error('Spectators cannot send messages in this preview.'); + if (typeof body.text !== 'string' || !body.text.trim() || body.text.length > 5000) + throw Error('Enter a message under 5000 characters.'); + const createdAt = new Date().toISOString(); + messages.push({ + _id: crypto.randomUUID().replaceAll('-', '').slice(0, 24), + text: body.text.trim(), + author: ['Leif', 'Aurelia'][body.seat], + authorId: `preview-${body.seat}`, + playerIndex: body.seat, + createdAt, + type: 'text', + }); + persist(); + } + if (url.pathname === '/api/read' && req.method === 'POST') { + if (body.seat !== 0 && body.seat !== 1) throw Error('Unknown player'); + const message = messages.find((m) => m._id === body.messageId); + if (message) readAt[body.seat] = Math.max(readAt[body.seat] ?? 0, Date.parse(message.createdAt)); + persist(); + } + const active = engine.currentPlayer(state); + const requested = url.searchParams.get('seat'); + const seat = + requested === 'spectator' ? undefined : requested === '0' ? 0 : requested === '1' ? 1 : active; + res.end( + JSON.stringify({ + state: engine.stripSecret(state, seat), + seat, + revision, + messages, + lastReadAt: readAt[String(seat)] ?? 0, + }), + ); + } catch (error) { + res.statusCode = 400; + res.end(JSON.stringify({ error: String(error) })); + } + }); + }, + }; +} diff --git a/web-client/src/App.svelte b/web-client/src/App.svelte new file mode 100644 index 00000000..4f736999 --- /dev/null +++ b/web-client/src/App.svelte @@ -0,0 +1,607 @@ + + +
+
+ +
+ THE AGES{#each [1, 2, 3, 4, 5, 6] as age}{['I', 'II', 'III', 'IV', 'V', 'VI'][age - 1]}{/each} +
+ +
+
+
+ {$session.seat === undefined ? 'THE TABLE' : 'YOUR CIVILIZATION'}{identity?.civilization ?? 'Spectator'} +
+ {#each resources as resource}{@const Icon = icons[resource]} +
+ {resourceNames[resource]}{current + ? (current.resources?.[resource] ?? 0) + : '—'}{#if current?.resource_limit?.[resource] !== undefined} + / {current.resource_limit[resource]}{/if} +
{/each} +
+ {#if ($session.game?.round ?? 1) > 3} + AGE ENDStatus + {:else} + ROUND{$session.game?.round ?? 1} / 3 + {/if} +
+
+
+
+
+
+
+ {#each $session.view?.players ?? [] as player}{/each} +
+ {#if !$session.game}
+ +

Loading game…

+
{/if} + {#if boardError}{/if} + {#if $session.focus && $session.focus !== $session.city && typeof focusTerrain === 'string'}
+ TILE {$session.focus}{focusTerrain === 'Unexplored' + ? 'Unexplored' + : focusTerrain === 'Fertile' + ? 'Fertile land' + : focusTerrain} +

+ {focusTerrain === 'Unexplored' + ? 'Move a unit here to reveal the terrain.' + : focusTerrain === 'Forest' + ? 'Collect wood here from a nearby city.' + : focusTerrain === 'Mountain' + ? 'Collect ore here from a nearby city.' + : focusTerrain === 'Fertile' + ? 'Collect food here from a nearby city.' + : focusTerrain === 'Water' + ? 'Coastal waters. Fishing unlocks food collection.' + : 'Barren terrain. Some advances unlock new ways to use it.'} +

+
{/if} +
+ +
+ {#if $session.mode === 'collect'}
+ Choose up to {city?.capacity} highlighted tiles{$session.selection.length} / {city?.capacity} +
{/if} +
+
YOUR CITIES
+ {#each $session.view?.cities ?? [] as c}{/each} +
+
+
+
+ {actionTitle}{#if !objectiveDecision && ($session.game?.round ?? 1) <= 3}{totalActions} {totalActions === 1 ? 'action' : 'actions'} left{/if} +
+ +
+ + {#if objectiveDecision || ($session.game && !$session.view?.supportedPhase && $session.seat === $session.view?.activePlayer) || $session.mode === 'collect' || confirmEnd || $session.error} +
+ {#if !objectiveDecision && $session.view?.supportedPhase}{/if} + {#if objectiveDecision} +

{objectiveDecision.name}

+

{objectiveDecision.description}

+ {#each objectiveDecision.cards as card (card.id)} +
+ Card: {card.name.replaceAll('/', ' / ')} + +
+ {/each} +

Claiming discards the card, including its other objective.

+ {#if objectiveDecision.skip} + + {/if} + {:else if !$session.view?.supportedPhase && $session.game} +

Decision not available yet

+

The controls for this phase are still being built.

+ {:else if $session.mode === 'collect'} +

Collect resources

+

+ Your {city?.mood.toLowerCase()} city can gather from up to {city?.capacity} tiles. Choose + on the map or below. +

+
+ {#each city?.choices ?? [] as choice}{@const resource = Object.keys( + choice.pile, + )[0] as Resource}{@const Icon = icons[resource] ?? Wheat}{@const selected = + $session.selection.some( + (c) => + c.position === choice.position && JSON.stringify(c.pile) === JSON.stringify(choice.pile), + )}{/each} +
+ {#if $session.preview}
+ You will collect{pileText($session.preview.total)}{#if Object.values($session.preview.waste).some((n) => n)}Storage is full: {pileText($session.preview.waste)} will be lost.{/if}{#if $session.preview.moodWillDecrease}Activating this city again lowers its mood.{/if} +
{/if} + Costs 1 action · Activates your city + {:else if confirmEnd} +

End turn?

+

You have {totalActions} unused {totalActions === 1 ? 'action' : 'actions'}.

+
+ +
+ {/if} + {#if $session.error}{/if} +
+ {/if} + +
+ {#if $session.mode === 'research'}{/if} + {#if $session.toast}
{$session.toast}
{/if} + {#if $session.objectivesOpen && $session.seat !== undefined} + { + if (e.target === e.currentTarget) closeObjectives(); + }} + onkeydown={(e) => { + if (e.key === 'Escape') closeObjectives(); + }} + > + +

Objectives

+

{identity?.civilization} · Private hand

+ {#each $session.view?.objectiveCards ?? [] as card (card.id)} +
o.name).join(' / ')}`} + > + {#each card.objectives as objective, index} + {#if index > 0}
or
{/if} +
+
+

{objective.name}

+ {objective.timing} +
+

{objective.description}

+
+ {/each} +
+ {:else} +

No objective cards in your hand.

+ {/each} + {#if $session.view?.objectiveCards?.length} +

+ Complete one objective per card for 2 points. When eligible, choose whether to claim it or keep the + card. Status phase objectives are checked at the end of an age. +

+ {/if} +
+ {/if} + {#if $session.help} { + if (e.target === e.currentTarget) closeHelp(); + }} + onkeydown={(e) => { + if (e.key === 'Escape') closeHelp(); + }} + > + +

How to play

+

Score the most points over six ages.

+
+
+ +

Scoring

+

+ Each city piece is worth 1 point. Advances add ½ point each. Completed objectives and wonders can + add more. +

+
+
+ +

Actions

+

+ Each turn gives you three actions. Collect resources, research, grow cities, recruit, move, + improve happiness, or influence another culture. +

+
+
+ +

Resources

+

+ Select your capital, then Collect resources. Fertile land gives food, forests give wood, and + mountains give ore. +

+
+
+ +

City mood and storage

+

+ A happy city collects from more tiles. Activating a city again in the same turn lowers its mood. + Storage limits can make excess resources go to waste. +

+
+
+
{/if} +
diff --git a/web-client/src/ResearchTree.svelte b/web-client/src/ResearchTree.svelte new file mode 100644 index 00000000..7e479c5f --- /dev/null +++ b/web-client/src/ResearchTree.svelte @@ -0,0 +1,200 @@ + + + { + if (e.target === e.currentTarget) close(); + }} + onkeydown={(e) => { + if (e.key === 'Escape') close(); + }} +> +
+
+

Research

+

Each advance scores ½ point. Branches unlock from their first advance.

+
+ + +
+ +
+ {#each visibleGroups as group}{@const GroupIcon = groupIcons[group] ?? BookOpen} +
+

{group}

+ {#each advances.filter((a) => a.group === group) as advance, index}{@const presentation = + researchPresentation(advance)}{@const Icon = presentation.icon}{@const parent = advances.find( + (a) => a.id === advance.required, + )} +
0} + class:owned={advance.owned} + class:available={!!advance.action} + class:selected={selected?.id === advance.id} + class:search-muted={!!query.trim() && !matches(advance)} + > + {#if index === 0 && parent}{/if} + +
+ {/each} +
+ {:else}

No advances match “{query}”.

{/each} +
+ {#if selected} +
+
+

{selected.name}

+

{selected.description}

+ {#if selected.bonus && Object.values(selected.bonus).some(Boolean)}Research bonus: {pileText(selected.bonus)}{/if}{#if selected.reason && !selected.owned}{selected.reason}{/if} + {#if $session.error}{/if} +
+ + +
+ {:else}
+ ResearchedAvailable UnavailableSelect an advance for its full rules and confirmation. +
{/if} +
diff --git a/web-client/src/board.ts b/web-client/src/board.ts new file mode 100644 index 00000000..1f456b55 --- /dev/null +++ b/web-client/src/board.ts @@ -0,0 +1,463 @@ +import * as THREE from 'three'; +import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; +import type { Session, Terrain } from './types'; +import { playerColors } from './types'; +import { positionXY } from './model'; + +const terrainColor: Record = { + Forest: '#54755a', + Fertile: '#9aa36b', + Mountain: '#858c87', + Barren: '#b6a27c', + Water: '#438d95', + Unexplored: '#526f77', +}; +export class World { + private scene = new THREE.Scene(); + private camera = new THREE.PerspectiveCamera(36, 1, 0.1, 120); + private renderer: THREE.WebGLRenderer; + private controls: OrbitControls; + private board = new THREE.Group(); + private rings = new THREE.Group(); + private tiles = new Map(); + private raycaster = new THREE.Raycaster(); + private resize: ResizeObserver; + private frame = 0; + private dirty = true; + private lastSignature = ''; + private selectionSignature = ''; + private start = [0, 0]; + private disposed = false; + private topDown = false; + private materials = new Set(); + private geometries = new Set(); + private textures = new Set(); + private labelPositions: { position: string; at: THREE.Vector3; node: HTMLButtonElement }[] = []; + private labelHost: HTMLDivElement; + private center = new THREE.Vector3(4.5, 0, 8); + private material(color: string, roughness = 1) { + const mat = new THREE.MeshStandardMaterial({ color, roughness, flatShading: true }); + this.materials.add(mat); + return mat; + } + private mesh(geo: THREE.BufferGeometry, mat: THREE.Material | THREE.Material[]) { + this.geometries.add(geo); + const obj = new THREE.Mesh(geo, mat); + obj.castShadow = true; + obj.receiveShadow = true; + return obj; + } + constructor( + private host: HTMLElement, + private pick: (position: string) => void, + ) { + this.scene.background = new THREE.Color('#b1c7c0'); + this.scene.fog = new THREE.Fog('#b1c7c0', 55, 105); + this.renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false }); + this.renderer.setPixelRatio(Math.min(devicePixelRatio, 1.8)); + this.renderer.shadowMap.enabled = true; + this.renderer.shadowMap.type = THREE.PCFSoftShadowMap; + this.renderer.outputColorSpace = THREE.SRGBColorSpace; + this.renderer.toneMapping = THREE.ACESFilmicToneMapping; + this.renderer.toneMappingExposure = 1.05; + this.renderer.domElement.setAttribute( + 'aria-label', + '3D civilization map. Select a city or terrain tile. Drag to orbit; scroll to zoom.', + ); + this.renderer.domElement.setAttribute('role', 'img'); + this.renderer.domElement.tabIndex = 0; + host.append(this.renderer.domElement); + this.labelHost = document.createElement('div'); + this.labelHost.className = 'world-labels'; + host.append(this.labelHost); + this.scene.add(new THREE.HemisphereLight('#fff4d8', '#386775', 2.2)); + const sun = new THREE.DirectionalLight('#ffe0a7', 3.2); + sun.position.set(-9, 18, 8); + sun.castShadow = true; + sun.shadow.mapSize.set(2048, 2048); + sun.shadow.camera.left = -18; + sun.shadow.camera.right = 18; + sun.shadow.camera.top = 18; + sun.shadow.camera.bottom = -18; + sun.shadow.normalBias = 0.045; + this.scene.add(sun); + const water = this.mesh(new THREE.PlaneGeometry(150, 150), this.material('#679a9d', 0.4)); + water.rotation.x = -Math.PI / 2; + water.position.y = -0.56; + water.receiveShadow = true; + this.scene.add(water); + const glintMat = this.material('#a1c1b8'); + for (let i = 0; i < 130; i++) { + const x = Math.sin(i * 99.31) * 22 + 4.5, + z = Math.cos(i * 47.79) * 22 + 8; + const glint = this.mesh(new THREE.PlaneGeometry(0.12 + (i % 5) * 0.06, 0.018), glintMat); + glint.rotation.x = -Math.PI / 2; + glint.position.set(x, -0.535, z); + this.scene.add(glint); + } + this.scene.add(this.board, this.rings); + this.camera.position.set(17, 22, 25); + this.controls = new OrbitControls(this.camera, this.renderer.domElement); + this.controls.target.copy(this.center); + this.controls.enableDamping = false; + this.controls.minDistance = 8; + this.controls.maxDistance = 55; + this.controls.maxPolarAngle = Math.PI * 0.43; + this.controls.minPolarAngle = 0.08; + this.controls.enablePan = true; + this.controls.update(); + this.controls.addEventListener('change', () => this.invalidate()); + this.renderer.domElement.addEventListener('pointerdown', this.down); + this.renderer.domElement.addEventListener('pointerup', this.up); + this.renderer.domElement.addEventListener('keydown', this.key); + this.resize = new ResizeObserver(() => { + const { width, height } = host.getBoundingClientRect(); + if (!width || !height) return; + this.renderer.setSize(width, height); + this.camera.aspect = width / height; + this.camera.updateProjectionMatrix(); + this.controls.enableZoom = true; + this.controls.enableRotate = true; + this.controls.touches.ONE = THREE.TOUCH.ROTATE; + this.renderer.domElement.style.touchAction = 'none'; + this.reset(); + }); + this.resize.observe(host); + } + private down = (e: PointerEvent) => { + this.start = [e.clientX, e.clientY]; + }; + private up = (e: PointerEvent) => { + if (Math.hypot(e.clientX - this.start[0], e.clientY - this.start[1]) > 5) return; + const rect = this.renderer.domElement.getBoundingClientRect(); + this.raycaster.setFromCamera( + new THREE.Vector2( + ((e.clientX - rect.left) / rect.width) * 2 - 1, + (-(e.clientY - rect.top) / rect.height) * 2 + 1, + ), + this.camera, + ); + const hit = this.raycaster.intersectObjects([...this.tiles.values()])[0]; + if (hit) this.pick(hit.object.userData.position); + }; + private key = (e: KeyboardEvent) => { + if (e.key === 'Home') this.reset(); + else if (e.key === '+' || e.key === '=') this.zoom(0.85); + else if (e.key === '-') this.zoom(1.15); + else if (e.key.startsWith('Arrow')) { + e.preventDefault(); + const offset = this.camera.position.clone().sub(this.controls.target); + offset.applyAxisAngle( + new THREE.Vector3(0, 1, 0), + e.key === 'ArrowLeft' ? 0.12 : e.key === 'ArrowRight' ? -0.12 : 0, + ); + this.camera.position.copy(this.controls.target).add(offset); + this.controls.update(); + this.invalidate(); + } + }; + private invalidate() { + if (this.disposed) return; + this.dirty = true; + if (this.frame) return; + this.frame = requestAnimationFrame(() => { + this.frame = 0; + if (!this.dirty) return; + this.dirty = false; + this.renderer.render(this.scene, this.camera); + const w = this.host.clientWidth, + h = this.host.clientHeight; + for (const label of this.labelPositions) { + const v = label.at.clone().project(this.camera); + label.node.style.transform = `translate(-50%, -50%) translate(${((v.x + 1) * w) / 2}px,${((-v.y + 1) * h) / 2}px)`; + label.node.style.display = v.z > 1 ? 'none' : ''; + } + }); + } + zoom(factor: number) { + const direction = this.camera.position.clone().sub(this.controls.target); + direction.multiplyScalar(factor).clampLength(8, 55); + this.camera.position.copy(this.controls.target).add(direction); + this.controls.update(); + this.invalidate(); + } + reset() { + this.controls.target.copy(this.center); + this.camera.position + .copy(this.center) + .add( + new THREE.Vector3( + this.topDown ? 0 : 12.5, + this.topDown ? 27 : 22, + this.topDown ? 0.01 : 17, + ).multiplyScalar( + Math.max(1, 0.92 / this.camera.aspect) * (this.camera.aspect > 1.4 ? 0.85 : 1), + ), + ); + this.controls.update(); + this.invalidate(); + } + private building(color: string) { + const group = new THREE.Group(); + const stone = this.material('#ead7ad'), + roof = this.material('#a86042'); + const base = this.mesh(new THREE.BoxGeometry(0.83, 0.12, 0.66), stone); + base.position.y = 0.06; + group.add(base); + const hall = this.mesh(new THREE.BoxGeometry(0.54, 0.3, 0.4), stone); + hall.position.set(0, 0.26, 0); + group.add(hall); + const ridge = this.mesh(new THREE.CylinderGeometry(0.42, 0.42, 0.66, 3), roof); + ridge.rotation.z = Math.PI / 2; + ridge.rotation.x = Math.PI / 2; + ridge.position.y = 0.51; + group.add(ridge); + for (const x of [-0.25, -0.08, 0.09, 0.26]) { + const column = this.mesh(new THREE.CylinderGeometry(0.033, 0.04, 0.32, 7), stone); + column.position.set(x, 0.28, 0.29); + group.add(column); + } + for (let i = 0; i < 3; i++) { + const step = this.mesh(new THREE.BoxGeometry(0.68 + i * 0.08, 0.04, 0.16), stone); + step.position.set(0, 0.12 - i * 0.025, 0.37 + i * 0.06); + group.add(step); + } + const pole = this.mesh(new THREE.CylinderGeometry(0.015, 0.02, 0.85, 6), this.material('#624d30')); + pole.position.set(0.47, 0.5, -0.2); + group.add(pole); + const flag = this.mesh(new THREE.BoxGeometry(0.28, 0.18, 0.018), this.material(color)); + flag.position.set(0.6, 0.84, -0.2); + group.add(flag); + return group; + } + private tree(x: number, z: number, scale: number, seed: number) { + const group = new THREE.Group(); + const trunk = this.mesh(new THREE.CylinderGeometry(0.035, 0.055, 0.4, 5), this.material('#6b6042')); + trunk.position.y = 0.2; + group.add(trunk); + const green = this.material(['#355849', '#456d4f', '#637950'][seed % 3]); + for (let k = 0; k < 3; k++) { + const cone = this.mesh(new THREE.ConeGeometry(0.22 - k * 0.035, 0.45, 6), green); + cone.position.y = 0.39 + k * 0.18; + group.add(cone); + } + group.position.set(x, 0.12, z); + group.scale.setScalar(scale); + return group; + } + private addTerrain(group: THREE.Group, kind: string, seed: number) { + if (kind === 'Forest') { + for (let i = 0; i < 9; i++) { + const angle = i * 2.4; + const radius = 0.18 + 0.1 * (i % 5); + group.add( + this.tree(Math.cos(angle) * radius, Math.sin(angle) * radius, 0.75 + (i % 3) * 0.17, i + seed), + ); + } + } + if (kind === 'Mountain') { + for (let i = 0; i < 3; i++) { + const height = [1.1, 0.8, 0.6][i]; + const rock = this.mesh( + new THREE.ConeGeometry(0.45, height, 5), + this.material(['#82867a', '#999c8c', '#767d77'][i]), + ); + rock.position.set((i - 1) * 0.32, height / 2 + 0.08, (i % 2) * 0.24 - 0.1); + rock.rotation.y = i; + group.add(rock); + const cap = this.mesh(new THREE.ConeGeometry(0.14, height * 0.28, 5), this.material('#eee9d7')); + cap.position.copy(rock.position); + cap.position.y = height * 0.87 + 0.08; + cap.rotation.y = i; + group.add(cap); + } + } + if (kind === 'Fertile') { + const fieldMat = this.material('#c6b968'); + for (let i = 0; i < 5; i++) { + const furrow = this.mesh(new THREE.BoxGeometry(0.06, 0.035, 0.7), fieldMat); + furrow.position.set(-0.35 + i * 0.14, 0.12, 0.03); + furrow.rotation.y = 0.25; + group.add(furrow); + } + group.add(this.tree(0.55, -0.25, 0.5, seed)); + } + if (kind === 'Barren') { + for (let i = 0; i < 7; i++) { + const rock = this.mesh( + new THREE.DodecahedronGeometry(0.09 + (i % 3) * 0.04, 0), + this.material('#c8b18b'), + ); + rock.position.set(Math.sin(i * 8) * 0.65, 0.13, Math.cos(i * 5) * 0.6); + rock.scale.y = 0.5; + group.add(rock); + } + } + if (kind === 'Unexplored') { + const mat = this.material('#90aba5'); + const circle = this.mesh(new THREE.TorusGeometry(0.22, 0.009, 4, 24), mat); + circle.rotation.x = -Math.PI / 2; + circle.position.y = 0.09; + group.add(circle); + for (let i = 0; i < 4; i++) { + const mark = this.mesh(new THREE.BoxGeometry(0.014, 0.012, 0.14), mat); + mark.position.set(Math.sin((i * Math.PI) / 2) * 0.26, 0.093, Math.cos((i * Math.PI) / 2) * 0.26); + mark.rotation.y = (i * Math.PI) / 2; + group.add(mark); + } + } + if (kind === 'Water') { + for (let i = 0; i < 4; i++) { + const line = this.mesh(new THREE.BoxGeometry(0.5 - i * 0.08, 0.018, 0.025), this.material('#96c9c1')); + line.position.set((i % 2) * 0.16, 0.07, (i - 2) * 0.19); + group.add(line); + } + } + } + private clearBoard() { + this.board.traverse((o) => { + if (o instanceof THREE.Mesh) { + o.geometry.dispose(); + this.geometries.delete(o.geometry); + const mats = Array.isArray(o.material) ? o.material : [o.material]; + mats.forEach((m) => { + m.dispose(); + this.materials.delete(m); + }); + } + }); + this.board.clear(); + this.tiles.clear(); + this.labelHost.replaceChildren(); + this.labelPositions = []; + } + update(s: Session) { + if (!s.game) return; + const signature = JSON.stringify([ + s.game.map.tiles, + s.game.players.map((p) => [p.cities, p.units]), + s.view?.players, + s.seat, + ]); + if (signature !== this.lastSignature) { + this.lastSignature = signature; + this.clearBoard(); + const coords = s.game.map.tiles.map(([p]) => positionXY(p)); + const minX = Math.min(...coords.map((c) => c[0])), + maxX = Math.max(...coords.map((c) => c[0])), + minZ = Math.min(...coords.map((c) => c[1])), + maxZ = Math.max(...coords.map((c) => c[1])); + this.center.set((minX + maxX) / 2, 0, (minZ + maxZ) / 2); + for (const [position, terrain] of s.game.map.tiles) { + const kind = typeof terrain === 'string' ? terrain : 'Barren'; + const [x, z] = positionXY(position); + const height = kind === 'Water' ? 0.13 : kind === 'Unexplored' ? 0.27 : 0.43; + const group = new THREE.Group(); + group.position.set(x, height / 2 - 0.12, z); + const top = this.material(terrainColor[kind]); + const side = this.material( + kind === 'Unexplored' ? '#4c7378' : kind === 'Water' ? '#4c8a91' : '#837655', + ); + const hex = this.mesh(new THREE.CylinderGeometry(0.976, 0.98, height, 6), [side, top, side]); + hex.rotation.y = Math.PI / 6; + hex.userData.position = position; + group.add(hex); + this.tiles.set(position, hex); + const terrainGroup = new THREE.Group(); + terrainGroup.position.y = height / 2; + this.addTerrain(terrainGroup, kind, position.charCodeAt(0)); + group.add(terrainGroup); + this.board.add(group); + } + for (const player of s.game.players) { + for (const [i, city] of (player.cities ?? []).entries()) { + const [x, z] = positionXY(city.position); + const cityModel = this.building(playerColors[player.id] ?? '#bfa986'); + cityModel.position.set(x, 0.38, z); + cityModel.rotation.y = 0.25; + this.board.add(cityModel); + const label = document.createElement('button'); + label.className = 'city-map-label'; + label.style.setProperty('--player-color', playerColors[player.id] ?? '#bfa986'); + label.textContent = `${player.civilization} · ${i === 0 ? 'Capital' : city.position}`; + label.setAttribute('aria-label', `Select ${player.civilization} city ${city.position}`); + label.onclick = () => this.pick(city.position); + this.labelHost.append(label); + this.labelPositions.push({ + position: city.position, + at: new THREE.Vector3(x, 1.85, z), + node: label, + }); + } + for (const unit of player.units ?? []) { + const [x, z] = positionXY(unit.position); + const pawn = new THREE.Group(); + const color = this.material(playerColors[player.id] ?? '#bfa986'); + const body = this.mesh(new THREE.ConeGeometry(0.085, 0.27, 7), color); + body.position.y = 0.19; + pawn.add(body); + const head = this.mesh(new THREE.SphereGeometry(0.062, 8, 6), this.material('#e4c7a1')); + head.position.y = 0.39; + pawn.add(head); + const base = this.mesh(new THREE.CylinderGeometry(0.14, 0.14, 0.04, 14), this.material('#e5d19e')); + pawn.add(base); + pawn.position.set(x - 0.58, 0.4, z + 0.25); + this.board.add(pawn); + } + } + if (this.selectionSignature === '') this.reset(); + } + const selected = s.mode === 'collect' ? s.selection.map((c) => c.position) : s.city ? [s.city] : []; + const available = + s.mode === 'collect' + ? (s.view?.cities.find((c) => c.position === s.city)?.choices.map((c) => c.position) ?? []) + : []; + const selectionSig = JSON.stringify([selected, available]); + if (selectionSig !== this.selectionSignature) { + this.selectionSignature = selectionSig; + this.rings.traverse((o) => { + if (o instanceof THREE.Mesh) { + o.geometry.dispose(); + this.geometries.delete(o.geometry); + (o.material as THREE.Material).dispose(); + this.materials.delete(o.material as THREE.Material); + } + }); + this.rings.clear(); + for (const pos of new Set([...selected, ...available])) { + const [x, z] = positionXY(pos); + const ring = this.mesh( + new THREE.TorusGeometry(0.99, selected.includes(pos) ? 0.035 : 0.018, 6, 6), + this.material(selected.includes(pos) ? '#ffe0a0' : '#e5cc92'), + ); + ring.rotation.x = -Math.PI / 2; + ring.rotation.z = Math.PI / 6; + ring.position.set(x, 0.35, z); + this.rings.add(ring); + } + } + this.labelPositions.forEach((label) => + label.node.classList.toggle('selected', label.position === s.city), + ); + if (s.topDown !== this.topDown) { + this.topDown = s.topDown; + this.reset(); + } + this.invalidate(); + } + destroy() { + this.disposed = true; + cancelAnimationFrame(this.frame); + this.resize.disconnect(); + this.controls.dispose(); + this.renderer.domElement.removeEventListener('pointerdown', this.down); + this.renderer.domElement.removeEventListener('pointerup', this.up); + this.renderer.domElement.removeEventListener('keydown', this.key); + for (const geometry of this.geometries) geometry.dispose(); + for (const material of this.materials) material.dispose(); + for (const texture of this.textures) texture.dispose(); + this.renderer.dispose(); + this.renderer.domElement.remove(); + this.labelHost.remove(); + } +} diff --git a/web-client/src/controller.ts b/web-client/src/controller.ts new file mode 100644 index 00000000..7523c8e9 --- /dev/null +++ b/web-client/src/controller.ts @@ -0,0 +1,179 @@ +import { get, writable } from 'svelte/store'; +import { ChatController } from '@boardgamers/protocol/chat'; +import type { ViewerCommands } from '@boardgamers/protocol/viewer'; +import type { Bridge, Choice, Game, Move, Session, View } from './types'; +import { journal } from './model'; +export class Controller { + readonly session = writable({ + game: null, + view: null, + city: null, + focus: null, + mode: 'overview', + selection: [], + preview: null, + error: '', + pending: false, + tab: 'journal', + activityOpen: false, + help: false, + objectivesOpen: false, + dark: false, + unread: 0, + avatars: [], + reducedMotion: false, + colorBlind: false, + locale: 'en', + selectedAdvance: null, + toast: '', + topDown: false, + }); + readonly chat = new ChatController(); + private raw = ''; + private engine: Bridge | null = null; + private timer: ReturnType | undefined; + private refreshTimer: ReturnType | undefined; + private destroyed = false; + private chatOff: () => void; + constructor( + readonly commands: ViewerCommands, + readonly assetBase: URL, + ) { + this.chat.setOpen(false); + this.chatOff = this.chat.subscribe(() => this.patch({ unread: this.chat.unread })); + } + patch(patch: Partial) { + this.session.update((s) => ({ ...s, ...patch })); + } + async load(raw: unknown) { + if (typeof raw !== 'string') throw new Error('Clash expects a serialized game state.'); + if (!this.engine) { + const engine = (await import( + /* @vite-ignore */ new URL('engine/server.js', this.assetBase).href + )) as Bridge; + await engine.default(); + this.engine = engine; + } + if (this.destroyed) return; + const old = get(this.session); + const game = JSON.parse(raw) as Game; + this.raw = raw; + const view = JSON.parse(this.engine.webView(raw, old.seat)) as View; + const city = view.cities.some((c) => c.position === old.city) + ? old.city + : (view.cities[0]?.position ?? null); + clearTimeout(this.refreshTimer); + this.patch({ + game, + view, + city, + focus: old.focus ?? city, + pending: false, + error: '', + selection: [], + preview: null, + mode: old.pending || view.objectiveDecision ? 'overview' : old.mode, + objectivesOpen: view.objectiveDecision ? false : old.objectivesOpen, + }); + this.commands.replaceLog(journal(game).map((entry) => entry.text)); + if (old.pending) this.notify('Game updated.'); + } + setPlayer(index?: number) { + this.patch({ + seat: index, + mode: 'overview', + selection: [], + preview: null, + selectedAdvance: null, + objectivesOpen: false, + }); + if (this.engine && this.raw) { + const view = JSON.parse(this.engine.webView(this.raw, index)) as View; + this.patch({ view, city: view.cities[0]?.position ?? null, focus: view.cities[0]?.position ?? null }); + } + } + selectCity(position: string) { + this.patch({ + city: position, + focus: position, + selection: [], + preview: null, + error: '', + mode: 'overview', + }); + } + selectTile(position: string) { + const s = get(this.session); + const city = s.view?.cities.find((c) => c.position === position); + if (s.mode === 'collect') { + const choice = s.view?.cities + .find((c) => c.position === s.city) + ?.choices.find((c) => c.position === position); + if (choice) this.toggleChoice(choice); + } else if (city) this.selectCity(position); + else this.patch({ focus: position }); + } + beginCollect() { + this.closeActivity(); + this.patch({ mode: 'collect', selection: [], preview: null, error: '', selectedAdvance: null }); + } + toggleChoice(choice: Choice) { + const s = get(this.session); + if (s.pending || !s.view?.canPlay || s.seat === undefined || !s.city || !this.engine) return; + const selected = s.selection.find( + (c) => c.position === choice.position && JSON.stringify(c.pile) === JSON.stringify(choice.pile), + ); + const city = s.view.cities.find((c) => c.position === s.city)!; + const selection = selected + ? s.selection.filter((c) => c !== selected) + : [...s.selection, { ...choice, times: 1 }]; + if (selection.length > city.capacity) { + this.patch({ error: `This city can collect from ${city.capacity} tiles. Remove a selection first.` }); + return; + } + try { + const preview = selection.length + ? JSON.parse(this.engine.webCollectPreview(this.raw, s.seat, s.city, JSON.stringify(selection))) + : null; + this.patch({ selection, preview, error: '' }); + } catch (error) { + this.patch({ error: String(error) }); + } + } + submit(move: Move) { + const s = get(this.session); + if (s.pending || s.seat === undefined || s.view?.activePlayer !== s.seat) return; + this.patch({ pending: true, error: '' }); + if (!this.commands.move(JSON.stringify(move))) { + this.patch({ pending: false, error: 'The action could not be sent. Please try again.' }); + return; + } + this.refreshTimer = setTimeout(() => { + this.commands.fetchState(); + this.patch({ error: 'Waiting for the game to confirm your action…' }); + }, 8000); + } + collect() { + const s = get(this.session); + if (s.preview) this.submit(s.preview.action); + } + setTab(tab: 'journal' | 'chat') { + this.chat.setOpen(tab === 'chat'); + this.patch({ tab, activityOpen: true, mode: 'overview' }); + } + closeActivity() { + this.chat.setOpen(false); + this.patch({ activityOpen: false }); + } + notify(toast: string) { + clearTimeout(this.timer); + this.patch({ toast }); + this.timer = setTimeout(() => this.patch({ toast: '' }), 4000); + } + destroy() { + this.destroyed = true; + clearTimeout(this.timer); + clearTimeout(this.refreshTimer); + this.chatOff(); + } +} diff --git a/web-client/src/engine.test.ts b/web-client/src/engine.test.ts new file mode 100644 index 00000000..a9504cea --- /dev/null +++ b/web-client/src/engine.test.ts @@ -0,0 +1,242 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { createRequire } from 'node:module'; +import { createViewer } from '@boardgamers/protocol/viewer'; +import { ChatController } from '@boardgamers/protocol/chat'; +import { journal, positionXY } from './model.ts'; +import type { View, Game } from './types.ts'; +const require = createRequire(import.meta.url); +const engine = require('../.engine/server.js'); +async function initial() { + return engine.init(2, [], { undo: 'SamePlayer', civilization: 'Random' }, 'clash-preview-20260927', {}); +} + +test('opening collection, research, undo, and handoff use the Rust engine', async () => { + let state = await initial(); + const seat = engine.currentPlayer(state); + const publicState = engine.stripSecret(state, seat); + const view: View = JSON.parse(engine.webView(publicState, seat)); + const city = view.cities[0]; + const choices = city.choices.filter((c) => c.pile.wood || c.pile.ore).map((c) => ({ ...c, times: 1 })); + const preview = JSON.parse( + engine.webCollectPreview(publicState, seat, city.position, JSON.stringify(choices)), + ); + state = engine.tryMove(state, JSON.stringify(preview.action), seat); + let game: Game = JSON.parse(state); + assert.equal(game.actions_left, 2); + assert.equal(game.players[seat].resources?.wood, 1); + assert.equal(game.players[seat].resources?.ore, 1); + const afterCollection = state; + const research = JSON.parse(engine.webView(engine.stripSecret(state, seat), seat)).advances.find( + (a: any) => a.id === 'Storage', + ); + assert.ok(research.action); + state = engine.tryMove(state, JSON.stringify(research.action), seat); + game = JSON.parse(state); + assert.equal(game.actions_left, 1); + assert.equal(game.players[seat].resource_limit?.food, 7); + state = engine.tryMove(state, '"Undo"', seat); + game = JSON.parse(state); + assert.equal(game.actions_left, 2); + assert.equal(game.players[seat].resource_limit?.food, 2); + assert.deepEqual(journal(game), journal(JSON.parse(afterCollection))); + state = engine.tryMove(state, JSON.stringify({ Playing: 'EndTurn' }), seat); + assert.notEqual(engine.currentPlayer(state), seat); +}); + +test('viewer queries respect spectator and opponent seats and reject illegal choices', async () => { + const state = await initial(); + const seat = engine.currentPlayer(state); + const visible = engine.stripSecret(state, seat); + for (const index of [undefined, 99, 1 - seat]) { + const view: View = JSON.parse(engine.webView(visible, index)); + assert.equal(view.canPlay, false); + assert.equal(view.canUndo, false); + assert.ok(view.advances.every((a) => a.action === null)); + } + const view: View = JSON.parse(engine.webView(visible, seat)); + const city = view.cities[0]; + assert.throws(() => engine.webCollectPreview(visible, 1 - seat, city.position, '[]')); + assert.throws(() => + engine.webCollectPreview( + visible, + seat, + city.position, + JSON.stringify([{ position: city.position, pile: { gold: 7 }, times: 1 }]), + ), + ); + const full = JSON.parse(state); + const limited = JSON.parse(visible); + assert.ok(full.players[1 - seat].action_cards.some((id: number) => id !== 0)); + assert.ok(limited.players[1 - seat].action_cards.every((id: number) => id === 0)); +}); + +test('objective cards show both conditions only from the player-visible hand', async () => { + const state = await initial(); + const seat = engine.currentPlayer(state); + const visible = engine.stripSecret(state, seat); + const view: View = JSON.parse(engine.webView(visible, seat)); + const hand = JSON.parse(visible).players[seat].objective_cards; + assert.deepEqual( + view.objectiveCards.map((card) => card.id), + hand, + ); + assert.ok(view.objectiveCards.length > 0); + for (const card of view.objectiveCards) { + assert.equal(card.objectives.length, 2); + for (const objective of card.objectives) { + assert.ok(objective.name.length > 0); + assert.ok(objective.description.length > 0); + assert.ok(['Instant', 'Status phase'].includes(objective.timing)); + } + } + assert.deepEqual( + view.objectiveCards[0].objectives.map((o) => o.name), + ['Legacy', 'Ivory Tower'], + ); + for (const index of [undefined, 99, 1 - seat]) { + assert.deepEqual(JSON.parse(engine.webView(visible, index)).objectiveCards, []); + } + const spectatorState = engine.stripSecret(state, undefined); + assert.deepEqual(JSON.parse(engine.webView(spectatorState, seat)).objectiveCards, []); +}); + +test('an eligible status objective can be claimed or kept, with correct points and privacy', async () => { + const setup = JSON.parse(await initial()); + const seat = setup.current_player_index; + // A city with an Obelisk makes the existing Legacy objective eligible. + setup.players[seat].cities[0].city_pieces = { obelisk: seat }; + let state = JSON.stringify(setup); + for (let turn = 0; turn < 6; turn++) { + assert.equal(JSON.parse(state).events?.length ?? 0, 0); + state = engine.tryMove(state, JSON.stringify({ Playing: 'EndTurn' }), engine.currentPlayer(state)); + } + const visible = engine.stripSecret(state, seat); + const view: View = JSON.parse(engine.webView(visible, seat)); + const decision = view.objectiveDecision!; + assert.ok(decision); + assert.equal(view.supportedPhase, true); + assert.equal(view.canPlay, false); + assert.equal(decision.name, 'Legacy'); + assert.equal(decision.points, 2); + assert.equal(decision.cards.length, 1); + assert.equal(decision.cards[0].id, 36); + for (const index of [undefined, 1 - seat]) { + const limited = engine.stripSecret(state, index); + assert.equal(JSON.parse(engine.webView(limited, index)).objectiveDecision, null); + // Switching a seat never reveals card choices from already-filtered data. + assert.equal(JSON.parse(engine.webView(limited, seat)).objectiveDecision, null); + } + const claimed = engine.tryMove(state, JSON.stringify(decision.cards[0].action), seat); + const claimedPlayer = JSON.parse(claimed).players[seat]; + assert.ok(!claimedPlayer.objective_cards?.includes(36)); + assert.ok(claimedPlayer.completed_objectives.some((o: any) => o.card === 36 && o.name === 'Legacy')); + const after: View = JSON.parse(engine.webView(engine.stripSecret(claimed, seat), seat)); + assert.equal( + after.players.find((p) => p.index === seat)!.score, + view.players.find((p) => p.index === seat)!.score + 2, + ); + assert.equal(after.objectiveDecision, null); + assert.ok(journal(JSON.parse(claimed)).some((entry) => entry.text.includes('Legacy'))); + assert.ok(decision.skip); + const kept = engine.tryMove(state, JSON.stringify(decision.skip), seat); + assert.ok(JSON.parse(kept).players[seat].objective_cards.includes(36)); + const keptView: View = JSON.parse(engine.webView(engine.stripSecret(kept, seat), seat)); + assert.equal(keptView.objectiveDecision, null); + assert.equal( + keptView.players.find((p) => p.index === seat)!.score, + view.players.find((p) => p.index === seat)!.score, + ); +}); + +test('research graph has valid prerequisites and setup summaries retain historical locations', async () => { + const state = await initial(); + const seat = engine.currentPlayer(state); + const game: Game = JSON.parse(engine.stripSecret(state, seat)); + const view: View = JSON.parse(engine.webView(JSON.stringify(game), seat)); + assert.equal(new Set(view.advances.map((a) => a.group)).size, 12); + for (const advance of view.advances) { + if (advance.required) assert.ok(view.advances.some((a) => a.id === advance.required)); + assert.ok(Number.isInteger(advance.order)); + } + const storage = view.advances.find((a) => a.id === 'Storage')!; + assert.equal(storage.required, 'Farming'); + assert.equal(storage.group, 'Agriculture'); + assert.deepEqual(storage.bonus, { mood_tokens: 1 }); + assert.equal(view.advances.find((a) => a.id === 'Voting')!.required, 'Philosophy'); + const before = journal(game).filter((entry) => entry.kind === 'setup'); + assert.equal(before.length, 2); + assert.ok( + before.every( + (entry) => entry.setup?.position && !entry.text.includes('Gain') && !entry.text.includes('card'), + ), + ); + game.players.forEach((player) => { + player.cities = []; + }); + assert.deepEqual( + journal(game).filter((entry) => entry.kind === 'setup'), + before, + ); +}); + +test('BGS lifecycle, chat acknowledgements, journal, and cleanup', async () => { + const chat = new ChatController({ readDelayMs: 0 }); + let renders = 0; + let ready = 0; + let lines: string[] = []; + const client = createViewer({ + chat, + onPlayer() {}, + onState(state) { + renders++; + client.replaceLog(journal(JSON.parse(state)).map((l) => l.text)); + }, + }); + client.emitter.on('ready', () => ready++); + client.emitter.on('replaceLog', (payload) => { + lines = payload; + }); + client.emitter.emit('player', { index: 1 }); + client.emitter.emit('state', engine.stripSecret(await initial(), 1)); + await new Promise((resolve) => setTimeout(resolve, 30)); + assert.equal(renders, 1); + assert.equal(ready, 1); + assert.ok(lines.length > 0); + assert.equal(client.diagnostics(['chat']).compatible, true); + client.emitter.emit('chat:state', { canSend: true, readState: { userId: 'me', lastReadAt: 0 } }); + client.emitter.on('chat:send', (payload) => { + assert.equal(payload.text, 'hello'); + client.emitter.emit('chat:result', { requestId: payload.requestId!, ok: false, error: 'Try again' }); + }); + chat.setDraft('hello'); + chat.submit(); + assert.equal(chat.snapshot.draft, 'hello'); + assert.equal(chat.snapshot.error, 'Try again'); + client.emitter.emit('chat:appended', [ + { + _id: '0123456789abcdef01234567', + author: 'Aurelia', + authorId: 'other', + playerIndex: 0, + text: 'Welcome', + createdAt: new Date().toISOString(), + type: 'text', + }, + ]); + assert.equal(chat.unread, 1); + client.emitter.emit('chat:updated', [ + { _id: '0123456789abcdef01234567', text: 'Welcome back', type: 'text' }, + ]); + assert.equal(chat.snapshot.messages[0].text, 'Welcome back'); + client.emitter.emit('chat:deleted', ['0123456789abcdef01234567']); + assert.equal(chat.snapshot.messages.length, 0); + client.destroy(); + assert.equal(client.emitter.emit('state', '{}'), false); +}); + +test('offset hex coordinates preserve the odd-column layout', () => { + assert.deepEqual(positionXY('A1'), [0, 0]); + assert.deepEqual(positionXY('B1'), [1.5, Math.sqrt(3) / 2]); + assert.equal(positionXY('D7')[1] - positionXY('D2')[1], 5 * Math.sqrt(3)); +}); diff --git a/web-client/src/local-frame.ts b/web-client/src/local-frame.ts new file mode 100644 index 00000000..800ed81c --- /dev/null +++ b/web-client/src/local-frame.ts @@ -0,0 +1,13 @@ +import { viewer } from './viewer'; +import { uplinkSchemas } from '@boardgamers/protocol'; +const transport = viewer.launch('#app'); +for (const event of Object.keys(uplinkSchemas)) { + transport.on(event as any, (payload: unknown) => + parent.postMessage({ source: 'clash-viewer', event, payload }, location.origin), + ); +} +addEventListener('message', (event) => { + if (event.source === parent && event.origin === location.origin && event.data?.source === 'clash-host') + transport.receive(event.data.event, event.data.payload); +}); +parent.postMessage({ source: 'clash-viewer', event: 'mounted' }, location.origin); diff --git a/web-client/src/local-host.ts b/web-client/src/local-host.ts new file mode 100644 index 00000000..12e93fde --- /dev/null +++ b/web-client/src/local-host.ts @@ -0,0 +1,132 @@ +const frame = document.querySelector('iframe')!; +if (new URLSearchParams(location.search).has('built')) frame.src = '/built-viewer.html'; +const seatSelect = document.querySelector('#seat')!; +let revision = -1; +let seat: number | undefined; +let ready = false; +let dark = false; +let lastMessages = ''; +let fetching = false; +let queued = false; +let journal: string[] = []; +const send = (event: string, payload?: unknown) => + frame.contentWindow?.postMessage({ source: 'clash-host', event, payload }, location.origin); +function showError(message: string) { + document.querySelector('#host-error')!.textContent = message; +} +async function refresh(force = false) { + if (fetching) { + queued = true; + return; + } + fetching = true; + try { + const response = await fetch(`/api/state?seat=${seatSelect.value}`); + const data = await response.json(); + if (!response.ok) throw Error(data.error); + if (force || data.revision !== revision || data.seat !== seat) { + revision = data.revision; + seat = data.seat; + send('player', { index: seat }); + send('state', data.state); + } + send('chat:state', { + canSend: seat !== undefined, + reason: seat === undefined ? 'not-a-player' : undefined, + mentions: [ + { id: '0', name: 'Leif', playerIndex: 0 }, + { id: '1', name: 'Aurelia', playerIndex: 1 }, + ], + readState: { userId: `preview-${seat}`, lastReadAt: data.lastReadAt ?? 0 }, + }); + const serialized = JSON.stringify(data.messages); + if (lastMessages !== serialized) { + send('chat:messages', data.messages); + lastMessages = serialized; + } + document.querySelector('#status')!.textContent = + `Local game · Revision ${revision} · BGS protocol connected`; + } catch (error) { + showError(String(error)); + } finally { + fetching = false; + if (queued) { + queued = false; + void refresh(true); + } + } +} +async function post(path: string, body: unknown) { + const response = await fetch(path, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify(body), + }); + const data = await response.json(); + if (!response.ok) throw Error(data.error); + return data; +} +addEventListener('message', async (event) => { + if ( + event.source !== frame.contentWindow || + event.origin !== location.origin || + event.data?.source !== 'clash-viewer' + ) + return; + const { event: kind, payload } = event.data; + if (kind === 'mounted') { + ready = true; + send('preferences', { locale: 'en' }); + send('theme', { dark }); + await refresh(true); + } + if (kind === 'fetchState') await refresh(true); + if (kind === 'move') { + try { + showError(''); + await post('/api/move', { move: payload, seat, revision }); + } catch (error) { + showError(String(error)); + } + await refresh(true); + } + if (kind === 'replaceLog') journal = payload; + if (kind === 'chat:read') { + try { + await post('/api/read', { messageId: payload.messageId, seat }); + } catch (error) { + showError(String(error)); + } + } + if (kind === 'chat:send') { + try { + await post('/api/chat', { text: payload.text, seat }); + send('chat:result', { requestId: payload.requestId, ok: true }); + await refresh(); + } catch (error) { + send('chat:result', { requestId: payload.requestId, ok: false, error: String(error) }); + } + } + if (kind === 'boardgame:clicked') + window.open('https://boardgamers.space/boardgame/clash', '_blank', 'noopener'); + if (kind === 'player:clicked') + document.querySelector('#status')!.textContent = + `Player ${payload.index + 1} · ${payload.index === 0 ? 'Leif' : 'Aurelia'}`; +}); +seatSelect.onchange = () => { + lastMessages = ''; + void refresh(true); +}; +document.querySelector('#reset')!.addEventListener('click', async () => { + await post('/api/reset', {}); + lastMessages = ''; + showError(''); + await refresh(true); +}); +document.querySelector('#theme')!.addEventListener('click', () => { + dark = !dark; + send('theme', { dark }); +}); +setInterval(() => { + if (ready) void refresh(); +}, 2000); diff --git a/web-client/src/model.ts b/web-client/src/model.ts new file mode 100644 index 00000000..d2203463 --- /dev/null +++ b/web-client/src/model.ts @@ -0,0 +1,120 @@ +import type { Game, JournalEntry, LoggedAction, Pile, Resource } from './types.ts'; +import { resourceNames } from './types.ts'; +export function pileText(pile: Pile): string { + return ( + Object.entries(pile) + .filter(([, n]) => n) + .map(([key, n]) => `${n} ${resourceNames[key as Resource].toLowerCase()}`) + .join(' + ') || 'No resources' + ); +} +export function journal(game: Game): JournalEntry[] { + return (game.log ?? []).flatMap((age, a) => + age.rounds.flatMap((round, r) => + round.turns.flatMap((turn, t) => + (turn.actions ?? []).flatMap((action, c) => { + if (turn.turn_type === 'Setup' || action.action === 'Setup') { + return setupJournal(game, action).map((setup, i) => ({ + id: `${a}-${r}-${t}-${c}-${i}`, + age: age.age, + round: round.round, + kind: 'setup' as const, + setup, + text: `${setup.player} plays as ${setup.civilization}${setup.position ? ` · starts at ${setup.position}` : ''}`, + })); + } + return (action.log ?? []).map((text, i) => ({ + id: `${a}-${r}-${t}-${c}-${i}`, + age: age.age, + round: round.round, + kind: journalKind(action), + text, + })); + }), + ), + ), + ); +} +function setupJournal(game: Game, action: LoggedAction): NonNullable[] { + const players = [...new Set((action.items ?? []).map((item) => item.player))]; + if (players.length) { + return players.flatMap((id) => { + const player = game.players.find((p) => p.id === id); + if (!player) return []; + // Read the original location from history, even if the city has since moved or been lost. + const position = action.items?.find( + (item) => + item.player === id && + item.Structure?.structure === 'CityCenter' && + item.Structure.balance === 'Gain', + )?.Structure?.position; + return [{ player: player.name ?? `Player ${id + 1}`, civilization: player.civilization, position }]; + }); + } + // Older saved logs may contain only their rendered text. + return (action.log ?? []).flatMap((text) => { + const match = text.match(/^(.+?): Setup: Play as ([^,]+)/); + if (!match) return []; + return [ + { player: match[1], civilization: match[2], position: text.match(/\bGain city ([A-Z]+\d+)\b/)?.[1] }, + ]; + }); +} +function journalKind(action: LoggedAction): JournalEntry['kind'] { + if (action.combat_stats) return 'combat'; + if ( + action.items?.some( + (item) => + item.HandCard?.to && typeof item.HandCard.to === 'object' && 'CompleteObjective' in item.HandCard.to, + ) + ) + return 'objective'; + if (!action.action || typeof action.action === 'string') return 'event'; + if ('Movement' in action.action) return 'move'; + const playing = action.action.Playing; + const name = + typeof playing === 'string' + ? playing + : playing && typeof playing === 'object' + ? Object.keys(playing)[0] + : ''; + const kinds: Record = { + Collect: 'collect', + Advance: 'research', + EndTurn: 'end-turn', + Construct: 'build', + FoundCity: 'build', + Recruit: 'recruit', + ActionCard: 'card', + WonderCard: 'card', + }; + return kinds[name] ?? 'event'; +} +export function journalParts(text: string): { text: string; resource?: Resource }[] { + const names: Record = { + food: 'food', + wood: 'wood', + ore: 'ore', + ideas: 'ideas', + gold: 'gold', + 'mood token': 'mood_tokens', + 'mood tokens': 'mood_tokens', + 'culture token': 'culture_tokens', + 'culture tokens': 'culture_tokens', + }; + const pattern = /\b\d+(?:\.\d+)? (food|wood|ore|ideas|gold|mood tokens?|culture tokens?)\b/g; + const parts: { text: string; resource?: Resource }[] = []; + let offset = 0; + for (const match of text.matchAll(pattern)) { + if (match.index > offset) parts.push({ text: text.slice(offset, match.index) }); + parts.push({ text: match[0], resource: names[match[1]] }); + offset = match.index + match[0].length; + } + if (offset < text.length) parts.push({ text: text.slice(offset) }); + return parts; +} +export function positionXY(position: string): [number, number] { + const q = position.charCodeAt(0) - 65; + const row = Number(position.slice(1)) - 1; + return [q * 1.5, (row + (q % 2) * 0.5) * Math.sqrt(3)]; +} diff --git a/web-client/src/research.css b/web-client/src/research.css new file mode 100644 index 00000000..b8f8019d --- /dev/null +++ b/web-client/src/research.css @@ -0,0 +1,385 @@ +.research-dialog { + width: calc(100% - 36px); + max-width: 1400px; + height: calc(100dvh - 36px); + max-height: 900px; + padding: 0; + border: 1px solid var(--line); + border-radius: 12px; + background: var(--paper); + color: var(--ink); + box-shadow: 0 18px 100px #163c3c66; + display: flex; + flex-direction: column; + overflow: hidden; +} +.research-dialog::backdrop { + background: #153a345b; + backdrop-filter: blur(3px); +} +.research-header { + display: flex; + align-items: center; + gap: 22px; + padding: 20px 25px 15px; + flex-shrink: 0; +} +.research-dialog h2 { + font-size: 34px; +} +.research-header p { + font-size: 12px; + color: var(--muted); + margin-top: 5px; +} +.research-header > .icon-button { + margin-left: auto; +} +.research-search { + display: flex; + align-items: center; + gap: 8px; + margin-left: auto; + border: 1px solid var(--line); + border-radius: 5px; + padding: 9px 11px; + color: var(--muted); + min-width: 245px; +} +.research-search input { + width: 100%; + background: none; + border: 0; + outline: none; + font-size: 12px; + color: var(--ink); +} +.research-search:focus-within { + outline: 2px solid #b58a45; +} +.research-filters { + display: flex; + flex-wrap: wrap; + gap: 5px; + padding: 0 25px 16px; + flex-shrink: 0; + border-bottom: 1px solid var(--line); +} +.research-filters button { + display: flex; + align-items: center; + gap: 6px; + padding: 7px 9px; + font-size: 11px; + border: 1px solid transparent; + border-radius: 5px; +} +.research-filters button:hover { + background: var(--paper2); +} +.research-filters button.active { + color: #f7f3e8; + background: #355948; +} +.research-tree { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); + gap: 28px 24px; + padding: 22px 25px 30px; + overflow: auto; + flex: 1; + min-height: 0; + align-content: start; +} +.research-branch { + min-width: 0; +} +.research-branch > h3 { + display: flex; + align-items: center; + gap: 9px; + font-family: inherit; + font-size: 12px; + font-weight: 600; + margin-bottom: 13px; +} +.research-node { + position: relative; + margin-bottom: 12px; + border: 1px solid var(--line); + border-radius: 7px; + background: var(--paper); + scroll-margin: 16px; +} +.research-node.child { + margin-left: 17px; +} +.research-node.child::before { + content: ''; + position: absolute; + left: -12px; + top: -14px; + bottom: -12px; + width: 1px; + background: #b6bba6; +} +.research-node.child::after { + content: ''; + position: absolute; + left: -12px; + top: 22px; + width: 11px; + height: 1px; + background: #b6bba6; +} +.research-node.child:last-child::before { + bottom: calc(100% - 23px); +} +.research-node.owned { + border-color: #a0b493; + background: #e9eedf; +} +.research-node.available { + border-color: #c2a46e; + box-shadow: 0 1px 4px #86652c12; +} +.research-node.selected { + outline: 2px solid #a67e3d; + outline-offset: 2px; +} +.research-node.search-muted { + opacity: 0.45; +} +.research-pick { + width: 100%; + text-align: left; + padding: 12px; + display: flex; + flex-direction: column; + gap: 9px; + border-radius: 7px; +} +.research-pick:hover { + background: #bba77912; +} +.research-node-title { + display: flex; + align-items: center; + gap: 9px; + width: 100%; +} +.advance-pictogram { + width: 32px; + height: 32px; + background: var(--paper2); + color: #8d7447; + border-radius: 5px; + display: grid; + place-items: center; + flex-shrink: 0; +} +.research-node-title strong { + font-size: 13px; + font-weight: 600; + line-height: 1.3; +} +.research-node-title > svg { + margin-left: auto; + color: #697958; + flex-shrink: 0; +} +.research-summary { + font-size: 12px; + line-height: 1.55; + color: var(--ink); +} +.research-effects { + display: flex; + flex-wrap: wrap; + gap: 5px 9px; + color: #6c794e; +} +.research-effects:empty { + display: none; +} +.research-effects > span, +.research-node-cost > span { + display: inline-flex; + gap: 4px; + align-items: center; + font-size: 10px; +} +.research-effects svg, +.research-node-cost svg { + flex-shrink: 0; +} +.research-node-cost { + border-top: 1px solid var(--line); + padding-top: 8px; + display: flex; + flex-wrap: wrap; + gap: 5px 9px; + width: 100%; +} +.research-node-cost .research-availability { + margin-left: auto; + color: var(--muted); + text-align: right; +} +.available .research-availability { + color: #456c3f; +} +.researched-label { + color: #4b7045; +} +.research-prerequisite { + display: flex; + gap: 5px; + align-items: center; + font-size: 10px; + padding: 8px 12px; + border-bottom: 1px solid var(--line); + width: 100%; + background: var(--paper2); + border-radius: 7px 7px 0 0; +} +.research-legend { + display: flex; + flex-wrap: wrap; + gap: 10px 22px; + align-items: center; + padding: 13px 25px; + border-top: 1px solid var(--line); + font-size: 11px; + color: var(--muted); + flex-shrink: 0; +} +.research-legend > span { + display: flex; + align-items: center; + gap: 5px; +} +.research-legend > span:last-child { + margin-left: auto; +} +.available-key::before { + content: ''; + width: 9px; + height: 9px; + border: 1px solid #b18c4d; + border-radius: 3px; +} +.research-detail { + display: flex; + align-items: center; + gap: 18px; + border-top: 1px solid var(--line); + padding: 16px 25px; + background: var(--paper2); + max-height: 38%; + overflow: auto; + flex-shrink: 0; +} +.research-detail > div { + flex: 1; +} +.research-detail h3 { + font-size: 25px; + margin-bottom: 5px; +} +.research-detail p { + font-size: 12px; + line-height: 1.6; +} +.research-detail small { + display: block; + font-size: 11px; + margin-top: 7px; + color: var(--muted); +} +.research-detail .primary { + flex-direction: column; + gap: 5px; + min-width: 210px; +} +.research-detail .primary span { + font-size: 10px; + font-weight: 400; +} +.research-empty { + font-size: 14px; + padding: 20px; + color: var(--muted); +} +.dark .research-node.owned { + background: #344531; +} +.dark .research-effects, +.dark .researched-label, +.dark .available .research-availability { + color: #bbd09b; +} +@media (max-width: 760px) { + .research-dialog { + width: calc(100% - 16px); + height: calc(100dvh - 16px); + max-height: none; + } + .research-header { + padding: 15px; + gap: 8px; + flex-wrap: wrap; + } + .research-dialog h2 { + font-size: 29px; + } + .research-header > div { + flex: 1; + } + .research-header p { + font-size: 11px; + max-width: 250px; + } + .research-search { + order: 3; + width: 100%; + margin: 4px 0 0; + } + .research-filters { + flex-wrap: nowrap; + overflow-x: auto; + padding: 0 15px 12px; + } + .research-filters button { + white-space: nowrap; + } + .research-tree { + grid-template-columns: 1fr; + padding: 16px; + gap: 25px; + } + .research-summary { + font-size: 13px; + } + .research-detail { + padding: 12px 15px; + flex-wrap: wrap; + gap: 9px; + max-height: 42%; + } + .research-detail > div { + min-width: calc(100% - 45px); + } + .research-detail .primary { + order: 3; + width: 100%; + } + .research-legend { + padding: 10px 15px; + font-size: 10px; + gap: 8px 12px; + } + .research-legend > span:last-child { + display: none; + } +} diff --git a/web-client/src/research.ts b/web-client/src/research.ts new file mode 100644 index 00000000..b06521aa --- /dev/null +++ b/web-client/src/research.ts @@ -0,0 +1,128 @@ +import { + Wheat, + Warehouse, + Droplets, + Beef, + Pickaxe, + Hammer, + HeartPulse, + Route, + Fish, + Ship, + Shield, + Map, + BookOpen, + School, + GraduationCap, + Brain, + Swords, + Castle, + Anvil, + Users, + Sun, + Flame, + Church, + Landmark, + Handshake, + Coins, + Palette, + Dumbbell, + Drama, + Calculator, + Telescope, + Vote, + Scale, + Heart, + Store, + Flag, + Crown, + Shovel, + Scroll, + ShieldCheck, + Sparkles, + Zap, +} from 'lucide-svelte'; +import type { AdvanceView } from './types'; + +// Short reading aids; the engine's complete rule text remains available on selection. +const advances = { + Farming: [Wheat, 'Collect food from grassland and wood from forests.'], + Storage: [Warehouse, 'Food storage increases from 2 to 7.'], + Irrigation: [Droplets, 'Collect food from barren land. Ignore famine.'], + Husbandry: [Beef, 'Collect from one land tile 2 spaces away; two with Roads. Once per turn.'], + Mining: [Pickaxe, 'Collect ore from mountains.'], + Engineering: [Hammer, 'Draw a wonder card. Build wonders in happy cities.'], + Sanitation: [HeartPulse, 'Recruit 1 settler for 1 mood. Ignore pestilence and epidemics.'], + Roads: [ + Route, + 'From/to cities, pay 1 food + 1 ore for +1 land range and ignore terrain. No exploring or boarding ships.', + ], + Fishing: [Fish, 'Collect food from one sea tile.'], + Navigation: [Ship, 'Move ships around the map edge to the next sea tile.'], + WarShips: [Shield, 'Ignore the first hit in round 1 when attacking by ship or disembarking.'], + Cartography: [Map, 'Ship movement earns 1 idea; using Navigation also earns 1 culture.'], + Writing: [BookOpen, 'Draw an action card and an objective card.'], + PublicEducation: [School, 'Gain 1 idea when collecting in an Academy city. Once per turn.'], + FreeEducation: [ + GraduationCap, + 'After buying an advance with gold or ideas, trade 1 extra idea for 1 mood.', + ], + Philosophy: [Brain, 'Gain 1 idea now, and 1 for each Science advance.'], + Tactics: [Swords, 'Move army units and use the tactics on action cards.'], + Siegecraft: [Castle, 'Cancel a Fortress’s extra die for 2 wood, or its hit protection for 2 ore.'], + SteelWeapons: [Anvil, 'Pay 1 ore for +2 combat strength in land battles; +1 versus Steel Weapons.'], + Draft: [Users, 'Recruit an infantry unit with 1 mood instead of resources.'], + Myths: [Sun, 'Spend mood to prevent event-driven city mood loss, except Pirates.'], + Rituals: [Flame, 'Use resources instead of mood when increasing happiness.'], + Priesthood: [Church, 'One Science advance per turn costs no resources. Still uses an action.'], + StateReligion: [Landmark, 'Build a Temple without paying food. Once per turn.'], + Bartering: [Handshake, 'Discard an action card for 1 gold or culture. Free, once per turn.'], + TradeRoutes: [Route, 'Settlers and ships near non-angry enemy cities earn up to 4 food per turn.'], + Taxes: [Coins, 'Spend an action and 1 mood for food, wood or ore equal to your city count. Once per turn.'], + Currency: [Coins, 'Take gold instead of food from Trade Routes and Taxes.'], + Arts: [Palette, 'Spend 1 culture for a free influence attempt. Once per turn.'], + Sports: [Dumbbell, 'Spend an action and 1–2 culture to raise a city’s mood 1–2 steps.'], + Monuments: [Landmark, 'Draw a wonder card. Wonder cities cannot be culturally influenced.'], + Theaters: [Drama, 'Swap 1 mood and 1 culture either way. Free, once per turn.'], + Math: [Calculator, 'Engineering and Roads cost no food.'], + Astronomy: [Telescope, 'Navigation and Cartography cost no food.'], + Medicine: [HeartPulse, 'Recover one resource spent after recruiting.'], + Metallurgy: [Anvil, 'Improve Steel Weapons. When collecting 2+ ore, replace 1 ore with gold.'], + Voting: [Vote, 'Spend 1 mood to take a free Increase Happiness action.'], + SeparationOfPower: [Scale, 'Culture tokens cannot boost influence attempts against your happy cities.'], + CivilLiberties: [Heart, 'Gain 3 mood for an action. Draft now costs 2 mood per infantry.'], + FreeEconomy: [Store, 'Spend 1 mood to collect without an action. Your only collection that turn.'], + Nationalism: [Flag, 'Recruit an army or ship unit to gain 1 mood or culture.'], + Totalitarianism: [Shield, 'Culture tokens cannot boost influence against cities with armies.'], + AbsolutePower: [Crown, 'Buy an extra action for 2 mood. Once per turn.'], + ForcedLabor: [Shovel, 'Spend 1 mood to treat angry cities as neutral this turn. Free, once per turn.'], + Dogma: [Scroll, 'New Temples grant a free Theocracy advance. Idea storage drops to 2.'], + Devotion: [ShieldCheck, 'Culture tokens cannot boost influence against your Temple cities.'], + Conversion: [Sparkles, '+1 to influence rolls. Successful attempts earn 1 culture.'], + Fanaticism: [Zap, '+2 in the first battle round at a Temple city. Gain infantry if you lose.'], +} as const; + +export const groupIcons: Record = { + Agriculture: Wheat, + Construction: Hammer, + Seafaring: Ship, + Education: GraduationCap, + Warfare: Swords, + Spirituality: Sun, + Economy: Coins, + Culture: Palette, + Science: Telescope, + Democracy: Vote, + Autocracy: Crown, + Theocracy: Church, +}; +export function researchPresentation(advance: AdvanceView) { + const entry = advances[advance.id as keyof typeof advances]; + return { + icon: entry?.[0] ?? groupIcons[advance.group] ?? BookOpen, + summary: + advance.id === 'Philosophy' && advance.description.includes('3 ideas') + ? advance.description + : (entry?.[1] ?? advance.description), + }; +} diff --git a/web-client/src/style.css b/web-client/src/style.css new file mode 100644 index 00000000..0991ceaa --- /dev/null +++ b/web-client/src/style.css @@ -0,0 +1,1868 @@ +@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;450;500;550;600;650;700&family=Libre+Caslon+Display&display=swap'); +@import './research.css'; +:root { + font-family: 'DM Sans', sans-serif; + color: #343c32; + font-synthesis: none; +} +* { + box-sizing: border-box; +} +body { + margin: 0; +} +button, +input, +textarea { + font: inherit; +} +button { + cursor: pointer; + color: inherit; +} +button:disabled { + cursor: not-allowed; + opacity: 0.46; +} +button:focus-visible, +a:focus-visible { + outline: 3px solid #bb8745; + outline-offset: 4px; +} +button { + transition: + background 0.17s, + box-shadow 0.17s, + transform 0.17s; +} +button:not(:disabled):active { + transform: translateY(1px); +} +button svg { + flex-shrink: 0; +} +button { + border: 0; + background: none; +} +h1, +h2, +h3, +p { + margin: 0; +} +button strong { + font-weight: 600; +} +h1, +h2, +h3 { + font-family: 'Libre Caslon Display', Georgia, serif; + font-weight: 400; +} +small { + font-size: 11px; +} +[hidden] { + display: none !important; +} +.game-shell { + --paper: #f7f3e8; + --paper2: #efe9da; + --ink: #333d34; + --muted: #7e8272; + --line: #dedacc; + --green: #2c5145; + --gold: #b58a45; + background: var(--paper); + color: var(--ink); + width: 100%; + min-height: 100dvh; + display: flex; + flex-direction: column; +} +.masthead { + height: 85px; + padding: 0 28px; + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1px solid var(--line); + gap: 20px; + background: var(--paper); + z-index: 5; +} +.brand { + display: flex; + align-items: center; + gap: 12px; + padding: 0; + text-align: left; +} +.brand-name { + font-family: 'Libre Caslon Display', Georgia, serif; + font-size: 28px; + line-height: 1; +} +.brand-name i { + font-size: 21px; +} +.age-track { + display: flex; + gap: 19px; + align-items: center; + margin-left: auto; + margin-right: auto; +} +.age-track > span:first-child { + font-size: 8px; + letter-spacing: 2px; + margin-right: 3px; + color: #858371; +} +.age-track > span:not(:first-child) { + font: + 14px Georgia, + serif; + color: #a8a596; + width: 25px; + height: 29px; + display: grid; + place-items: center; + position: relative; +} +.age-track > span.current { + background: #38574a; + color: #fff7dc; + border-radius: 50%; + box-shadow: 0 0 0 4px #e6e5d8; +} +.age-track > span.past { + color: #557464; +} +.age-track > span:not(:last-child):not(:first-child):after { + content: ''; + position: absolute; + left: 32px; + width: 8px; + height: 1px; + background: #c9c7b6; +} +.header-actions { + display: flex; + align-items: center; + gap: 14px; +} +.text-button { + display: flex; + align-items: center; + gap: 9px; + font-size: 11px; + font-weight: 500; +} +.icon-button { + display: grid; + place-items: center; + width: 32px; + height: 32px; + border-radius: 5px; +} +.icon-button:hover { + background: var(--paper2); +} +.resource-bar { + height: 83px; + display: grid; + grid-template-columns: 160px repeat(7, minmax(76px, 1fr)) 70px; + align-items: center; + border-bottom: 1px solid var(--line); + padding: 0 29px; + gap: 13px; + background: var(--paper); + z-index: 4; +} +.tiny-label { + font-size: 8px; + font-weight: 600; + letter-spacing: 1.6px; + color: #8b8977; +} +.civilization-tag { + display: flex; + flex-direction: column; + gap: 6px; + border-right: 1px solid var(--line); +} +.civilization-tag strong { + font: + 25px 'Libre Caslon Display', + Georgia, + serif; +} +.resource { + display: flex; + align-items: center; + justify-content: center; + gap: 10px; +} +.resource-icon { + width: 35px; + height: 38px; + display: grid; + place-items: center; + border-radius: 50%; + background: #f0e9d6; + color: #947849; +} +.resource-icon.wood, +.choice-icon.wood { + color: #4c7557; + background: #e5eadb; +} +.resource-icon.ore, +.choice-icon.ore { + color: #697983; + background: #e3e8e7; +} +.resource-icon.ideas { + color: #bc9f52; + background: #f1ead8; +} +.resource-icon.gold { + color: #bd9744; + background: #f1e8cd; +} +.resource-icon.mood_tokens { + color: #c49d55; + background: #f2e7cf; +} +.resource-icon.culture_tokens { + color: #94707b; + background: #eee4e3; +} +.resource small { + display: block; + font-size: 10px; + color: #888879; + margin-bottom: 2px; +} +.resource strong { + font-size: 21px; + font-weight: 500; + font-variant-numeric: tabular-nums; +} +.resource em { + font-size: 10px; + font-style: normal; + font-weight: 400; + color: #a3a292; +} +.round-label { + border-left: 1px solid var(--line); + padding-left: 21px; + display: flex; + flex-direction: column; + gap: 4px; +} +.round-label strong { + font-size: 20px; + font-weight: 500; +} +.round-label strong span { + font-size: 11px; + color: #a3a292; +} +.play-layout { + display: grid; + grid-template-columns: minmax(0, 1fr) 337px; + flex: 1; + min-height: 700px; + height: calc(100dvh - 168px); +} +.map-section { + position: relative; + min-width: 0; + overflow: hidden; + background: #adc5c0; + isolation: isolate; +} +.map-world { + position: absolute; + inset: 0 0 83px; +} +.map-world > canvas { + width: 100%; + height: 100%; + display: block; + touch-action: none; +} +.map-vignette { + position: absolute; + inset: 0 0 83px; + pointer-events: none; + background: + linear-gradient(180deg, #afc9c399, transparent 22%, transparent 76%, #759b9380), + linear-gradient(90deg, #b6ccc960, transparent 30%); + z-index: 1; +} +.player-list { + position: absolute; + top: 20px; + left: 25px; + display: flex; + flex-direction: column; + gap: 8px; + z-index: 3; + width: 170px; +} +.player-card { + position: relative; + display: flex; + align-items: center; + gap: 9px; + text-align: left; + border: 1px solid #ffffff38; + border-radius: 6px; + background: #f1f0e5c9; + backdrop-filter: blur(10px); + padding: 10px; + box-shadow: 0 3px 12px #3154470b; +} +.player-card.active { + background: #fbf8ebeb; + border-color: #bfa57599; +} +.player-card:hover { + background: #fffaf0; +} +.player-emblem { + display: grid; + place-items: center; + width: 32px; + height: 34px; + border-radius: 50%; + color: var(--player); + background: color-mix(in srgb, var(--player) 15%, #f7f4e8); + flex-shrink: 0; +} +.player-emblem img { + width: 32px; + height: 32px; + object-fit: cover; + border-radius: 50%; +} +.player-info { + flex: 1; + min-width: 0; +} +.player-info strong { + font: + 18px 'Libre Caslon Display', + Georgia, + serif; + display: block; +} +.player-info small { + font-size: 9px; + color: #858779; +} +.player-score { + font-size: 17px; + display: flex; + flex-direction: column; + align-items: center; + gap: 2px; + font-weight: 500; + color: #726b51; +} +.active-dot { + position: absolute; + right: -4px; + top: 50%; + width: 7px; + height: 7px; + background: #b39353; + border: 2px solid #f7f2e3; + border-radius: 50%; +} +.world-labels { + position: absolute; + inset: 0; + pointer-events: none; + z-index: 2; + overflow: hidden; +} +.city-map-label { + position: absolute; + left: 0; + top: 0; + pointer-events: auto; + white-space: nowrap; + border: 1px solid #f4efde80; + border-radius: 4px; + background: #f7f3e8e8; + color: #47564a; + font: + 500 10px 'DM Sans', + sans-serif; + padding: 7px 11px; + box-shadow: 0 3px 13px #28483d28; + border-bottom: 2px solid var(--player-color); +} +.city-map-label.selected { + background: #fff6df; + box-shadow: + 0 0 0 2px #b5925580, + 0 3px 13px #28483d28; +} +.map-controls { + position: absolute; + right: 20px; + bottom: 98px; + display: flex; + align-items: center; + padding: 4px; + background: #f7f3e8db; + backdrop-filter: blur(8px); + border: 1px solid #ffffff66; + border-radius: 6px; + box-shadow: 0 3px 16px #294c3812; + z-index: 3; +} +.map-controls button { + width: 31px; + height: 31px; + display: grid; + place-items: center; + border-radius: 4px; + color: #536b5c; +} +.map-controls button:hover, +.map-controls button[aria-pressed='true'] { + background: #e2e5d6; +} +.map-controls > span { + height: 17px; + width: 1px; + background: #d5d7c9; + margin: 0 4px; +} +.map-instruction { + position: absolute; + bottom: 190px; + left: 50%; + transform: translateX(-50%); + display: flex; + align-items: center; + gap: 10px; + white-space: nowrap; + background: #305347ed; + color: #f8f0db; + padding: 12px 15px; + border: 1px solid #e1d4a959; + border-radius: 6px; + box-shadow: 0 8px 25px #233d3529; + font-size: 11px; + z-index: 3; +} +.instruction-count { + padding-left: 12px; + border-left: 1px solid #ffffff30; + font-size: 10px; + color: #d9c998; +} +.city-dock { + position: absolute; + bottom: 0; + left: 0; + right: 0; + min-height: 83px; + background: #f2efe3e8; + backdrop-filter: blur(15px); + border-top: 1px solid #fff9e89c; + display: flex; + align-items: center; + gap: 15px; + padding: 13px 25px; + z-index: 3; + overflow-x: auto; + overflow-y: hidden; +} +.dock-intro { + display: flex; + align-items: center; + gap: 9px; + color: #948264; + margin-right: 4px; +} +.city-dock button { + display: flex; + gap: 10px; + align-items: center; + text-align: left; + padding: 7px 12px 7px 7px; + border: 1px solid transparent; + border-radius: 5px; + min-width: 208px; + background: #eae7d9; +} +.city-dock button.selected { + background: #fcf7e8; + border-color: #c9b488; +} +.city-thumb { + width: 40px; + height: 38px; + display: grid; + place-items: center; + background: #e6dfcb; + color: #928361; + border-radius: 3px; +} +.city-dock button strong { + font-size: 11px; + display: block; + font-weight: 500; +} +.city-dock button small { + display: block; + font-size: 9px; + color: #8b8b79; + margin-top: 4px; +} +.city-dock button small span { + padding: 0 3px; +} +.city-dock button > svg { + margin-left: auto; + color: #a7a18c; +} +.turn-banner { + height: 49px; + flex-shrink: 0; + border-bottom: 1px solid var(--line); + display: flex; + align-items: center; + padding: 0 22px; + gap: 8px; + background: #edeede; +} +.turn-light { + height: 6px; + width: 6px; + background: #527155; + border-radius: 50%; + box-shadow: 0 0 0 3px #59795f13; +} +.turn-banner strong { + font-size: 10px; + letter-spacing: 0.2px; + font-weight: 600; +} +.turn-banner small { + font-size: 9px; + color: #848775; + margin-left: 4px; +} +.action-panel { + padding: 25px 24px 17px; + overflow-y: auto; + max-height: 65%; + flex-shrink: 0; + scrollbar-width: thin; + scrollbar-color: #d2cbb8 transparent; +} +.action-panel h2 { + font-size: 28px; + line-height: 1.04; + letter-spacing: -0.5px; + margin-bottom: 14px; +} +.action-panel > p { + font-size: 11px; + line-height: 1.8; + color: #898878; +} +.action-panel b { + font-weight: 600; + color: #59634f; +} +.primary { + background: #355948; + color: #fff6df; + box-shadow: + inset 0 0 0 1px #ffffff12, + 0 2px 5px #273b2720; + min-height: 43px; + border: 1px solid #274a3b; + border-radius: 4px; + padding: 10px 15px; + font-weight: 500; + font-size: 11px; + display: flex; + align-items: center; + justify-content: center; + gap: 14px; +} +.primary:hover:not(:disabled) { + background: #416a53; + box-shadow: 0 3px 10px #273b2730; +} +.primary.wide { + justify-content: space-between; +} +.wide { + width: 100%; +} +.action-cost { + display: block; + text-align: center; + font-size: 8px; + letter-spacing: 0.1px; + color: #979480; + margin: 9px 0 19px; +} +.end-confirm { + padding: 12px; + background: var(--paper2); + border-radius: 4px; +} +.end-confirm p { + font-size: 11px; + margin-bottom: 8px; +} +.end-confirm button { + font-size: 10px; + padding: 7px; + margin-right: 3px; +} +.secondary { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 8px; + background: #eae6d7; + border: 1px solid #d9d2bf; + border-radius: 4px; + padding: 10px 15px; + font-size: 11px; +} +.collection-choices { + display: flex; + flex-direction: column; + gap: 7px; + margin: 18px 0; +} +.collection-choices button { + display: flex; + align-items: center; + gap: 11px; + border: 1px solid #ded8c5; + border-radius: 5px; + padding: 11px; + text-align: left; + background: #f3efdf; +} +.collection-choices button.selected { + border-color: #8e9d7e; + background: #e8ebda; + box-shadow: inset 0 0 0 1px #8e9d7e55; +} +.choice-icon { + width: 34px; + height: 35px; + border-radius: 50%; + background: #eae0bd; + color: #a48a4c; + display: grid; + place-items: center; +} +.collection-choices strong { + font-size: 12px; + display: block; + text-transform: capitalize; +} +.collection-choices small { + display: block; + font-size: 9px; + color: #91917f; + margin-top: 4px; +} +.choice-check { + margin-left: auto; + color: #a3a48d; + width: 19px; + height: 19px; + border: 1px solid #d4d3c0; + display: grid; + place-items: center; + border-radius: 50%; +} +.selected .choice-check { + background: #5d7d5d; + color: white; + border-color: #5d7d5d; +} +.collection-summary { + padding: 12px 0 18px; +} +.collection-summary > span { + font-size: 9px; + color: #908d77; +} +.collection-summary > strong { + display: block; + margin-top: 6px; + font-size: 13px; + color: #526951; + font-weight: 500; +} +.warning { + display: block; + color: #ab7939; + font-size: 10px; + line-height: 1.6; + margin-top: 9px; +} +.inline-error { + font-size: 11px !important; + color: #a64730 !important; + padding: 12px 0; + line-height: 1.5 !important; +} +.cost-pill { + display: inline-block; + font-size: 10px; + color: #8d794e; + padding: 5px 8px; + background: #e4dcc4; + border-radius: 3px; +} +.activity { + border-top: 1px solid var(--line); + display: flex; + flex: 1; + flex-direction: column; + min-height: 190px; + overflow: hidden; +} +.activity-tabs { + display: flex; + align-items: center; + gap: 22px; + height: 45px; + padding: 0 23px; + border-bottom: 1px solid var(--line); + flex-shrink: 0; +} +.activity-tabs button { + height: 45px; + display: flex; + align-items: center; + gap: 8px; + font-size: 11px; + color: #9a9884; + padding: 0; + position: relative; +} +.activity-tabs button.active { + color: #4b6651; +} +.activity-tabs button.active:after { + position: absolute; + content: ''; + bottom: 0; + left: 0; + right: 0; + height: 2px; + background: #6a805c; +} +.unread { + background: #58704d; + border-radius: 50%; + font-size: 8px; + padding: 3px 5px; + color: #fff; +} +.journal { + padding: 20px 23px; + overflow: auto; + scrollbar-width: thin; + scrollbar-color: #d2cbb8 transparent; + flex: 1; +} +.journal article { + padding-left: 24px; + border-left: 1px solid #ddd6c2; + position: relative; + padding-bottom: 23px; +} +.journal article:last-child { + padding-bottom: 2px; +} +.journal article > small { + font-size: 7px; + letter-spacing: 1.2px; + color: #a59879; +} +.journal article p { + font-size: 10px; + line-height: 1.8; + color: #8a8b77; + margin-top: 8px; +} +.journal-symbol { + width: 23px; + height: 23px; + position: absolute; + left: -12px; + top: 0; + background: var(--paper); + color: #927d4e; + border-radius: 50%; + display: grid; + place-items: center; +} +.journal-setup { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 5px; +} +.journal-setup strong { + color: var(--ink); + font-weight: 500; +} +.journal-position { + display: inline-flex; + align-items: center; + gap: 3px; + margin-left: auto; + color: var(--ink); + font-size: 11px; +} +.journal-resource { + display: inline-flex; + align-items: baseline; + gap: 3px; + white-space: nowrap; +} +.journal-resource svg { + align-self: center; + color: var(--green); +} +.dark .journal-resource svg { + color: #b5c5a0; +} +.sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border: 0; +} +.chat-panel { + min-height: 0; + flex: 1; + overflow: auto; + padding: 12px; + font-size: 11px; +} +.chat-panel details { + border: 0 !important; + background: transparent !important; + font-family: 'DM Sans', sans-serif !important; +} +.chat-panel summary { + display: none !important; +} +.chat-panel textarea { + font-size: 11px !important; + background: #fffdf5 !important; +} +.toast { + position: fixed; + bottom: 35px; + left: 50%; + transform: translateX(-50%); + padding: 12px 20px; + display: flex; + gap: 10px; + align-items: center; + background: #355948; + color: #fff4db; + border: 1px solid #839372; + border-radius: 6px; + font-size: 12px; + box-shadow: 0 5px 30px #0002; + z-index: 30; +} +.map-loading { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: center; + gap: 20px; + color: #426656; + z-index: 4; +} +.map-warning { + position: absolute; + left: 210px; + right: 20px; + top: 190px; + background: #fff1dc; + border: 1px solid #b79767; + border-radius: 6px; + padding: 20px; + font-size: 13px; + line-height: 1.6; + z-index: 5; +} +.field-guide { + position: fixed; + max-width: 730px; + width: calc(100% - 35px); + max-height: 90dvh; + overflow: auto; + border: 1px solid #bca574; + padding: 44px; + background: #f7f1e1; + color: #3c493b; + border-radius: 8px; + box-shadow: 0 15px 80px #172e3550; +} +.field-guide::backdrop { + background: #18392fa8; + backdrop-filter: blur(7px); +} +.close-guide { + position: absolute; + right: 15px; + top: 15px; +} +.field-guide h2 { + font-size: 52px; + line-height: 1.03; + margin-bottom: 17px; +} +.guide-intro { + font-size: 13px; + line-height: 1.8; + color: #82836d; + max-width: 530px; +} +.card-count { + min-width: 20px; + padding: 2px 5px; + border-radius: 4px; + background: var(--paper2); + font-size: 11px; + text-align: center; +} +.objectives-button { + white-space: nowrap; +} +.objectives-dialog { + max-width: 620px; + padding: 32px; + background: var(--paper); + color: var(--ink); +} +.objectives-dialog h2 { + font-size: 36px; + margin-bottom: 8px; +} +.objective-card { + margin-top: 22px; + border: 1px solid var(--line); + border-radius: 6px; + padding: 22px; + background: var(--paper2); +} +.objective-title { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 16px; +} +.objective-title h3 { + font-size: 27px; +} +.objective-title > span { + font-size: 11px; + color: var(--muted); + white-space: nowrap; +} +.objective-card p { + font-size: 14px; + line-height: 1.65; + margin-top: 10px; +} +.objective-divider { + display: flex; + align-items: center; + gap: 12px; + margin: 20px 0; + font-size: 11px; + color: var(--muted); +} +.objective-divider::before, +.objective-divider::after { + content: ''; + flex: 1; + height: 1px; + background: var(--line); +} +.objectives-note, +.objectives-empty { + font-size: 12px; + line-height: 1.7; + margin-top: 20px; + color: var(--muted); +} +.objective-claim { + margin: 20px 0 12px; +} +.objective-claim small { + display: block; + color: var(--muted); + margin-bottom: 8px; + line-height: 1.5; +} +.action-panel > .claim-note { + font-size: 12px; + margin: 12px 0; +} +.guide-grid { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 27px; + margin: 28px 0; +} +.guide-grid article > svg { + color: #a08954; + width: 22px; + margin-bottom: 7px; +} +.guide-grid h3 { + font-size: 24px; + margin-bottom: 7px; +} +.guide-grid p { + font-size: 11px; + line-height: 1.8; + color: #82836d; +} +.dark { + --paper: #272f2b; + --paper2: #353e33; + --ink: #e7e3d2; + --line: #444a3d; + --muted: #aeb298; +} +.dark .turn-banner { + background: #343e31; +} +.dark .action-panel > p, +.dark .journal article p { + color: #b0b09c; +} +.dark .primary { + background: #557655; +} +.dark .collection-choices button { + background: #3b4335; + color: #ebe4d1; + border-color: #5b6249; +} +.colorblind .active-dot { + border-radius: 0; +} +.colorblind .player-emblem { + border: 2px solid currentColor; +} +@media (min-width: 1550px) { + .play-layout { + grid-template-columns: minmax(0, 1fr) 380px; + } + .action-panel { + padding: 32px; + } + .action-panel h2 { + font-size: 28px; + } + .action-panel > p { + font-size: 13px; + } + .resource-bar { + height: 90px; + } + .play-layout { + height: calc(100dvh - 175px); + } + .primary { + font-size: 12px; + } + .journal article p { + font-size: 12px; + } + .activity-tabs { + padding: 0 30px; + } + .journal { + padding: 25px 30px; + } + .player-list { + left: 36px; + top: 20px; + } +} +@media (max-width: 1050px) { + .age-track { + gap: 10px; + } + .age-track > span:first-child { + display: none; + } + .age-track > span:after { + display: none; + } + .resource-bar { + padding: 0 16px; + gap: 8px; + grid-template-columns: 105px repeat(7, minmax(55px, 1fr)); + } + .round-label { + display: none; + } + .resource-icon { + width: 25px; + } + .resource { + gap: 5px; + } + .resource strong { + font-size: 18px; + } + .play-layout { + grid-template-columns: minmax(0, 1fr) 310px; + } + .player-list { + width: 140px; + left: 15px; + } + .player-card { + padding: 8px; + gap: 7px; + } + .player-info strong { + font-size: 16px; + } + .action-panel { + padding: 23px 21px; + } + .action-panel h2 { + font-size: 28px; + } + .city-dock { + padding: 12px; + gap: 8px; + } + .dock-intro .tiny-label { + display: none; + } + .masthead { + padding: 0 19px; + } + .brand-name { + font-size: 24px; + } + .header-actions { + gap: 10px; + } + .map-instruction { + font-size: 9px; + left: 55%; + } +} +@media (max-width: 760px) { + .masthead { + height: 66px; + padding: 0 16px; + gap: 10px; + } + .brand-name { + font-size: 21px; + } + .brand { + gap: 9px; + } + .age-track { + display: none; + } + .header-actions .text-button { + font-size: 0; + gap: 0; + } + .header-actions .text-button svg { + width: 21px; + height: 21px; + } + .header-actions { + gap: 8px; + } + .header-actions .objectives-button { + font-size: 11px; + gap: 5px; + } + .header-actions .objectives-button svg { + display: none; + } + .objective-card { + padding: 16px; + } + .objective-title { + flex-wrap: wrap; + gap: 5px; + } + .resource-bar { + height: 69px; + padding: 0 11px; + gap: 2px; + grid-template-columns: repeat(7, minmax(0, 1fr)); + } + .civilization-tag { + display: none; + } + .resource { + flex-direction: column; + gap: 0; + position: relative; + } + .resource-icon { + height: 20px; + width: 22px; + background: transparent !important; + } + .resource-icon svg { + width: 18px; + height: 18px; + } + .resource > span:last-child { + text-align: center; + } + .resource small { + font-size: 8px; + margin: 1px 0; + } + .resource strong { + font-size: 16px; + line-height: 1; + } + .resource em { + font-size: 8px; + } + .play-layout { + display: flex; + flex-direction: column; + height: auto; + min-height: 0; + } + .map-section { + height: 570px; + min-height: 0; + flex-shrink: 0; + } + .map-world { + inset: 0 0 75px; + } + .map-vignette { + bottom: 75px; + } + .player-list { + top: 20px; + left: 14px; + width: 120px; + gap: 5px; + } + .player-card { + padding: 6px; + gap: 6px; + } + .player-emblem { + width: 24px; + height: 27px; + } + .player-emblem svg { + width: 15px; + } + .player-info strong { + font-size: 15px; + } + .player-info small { + font-size: 8px; + } + .player-score { + font-size: 13px; + } + .player-score svg { + width: 8px; + } + .city-map-label { + font-size: 8px; + padding: 6px 8px; + } + .map-controls { + right: 12px; + bottom: 98px; + } + .map-controls button { + width: 28px; + height: 28px; + } + .city-dock { + height: 75px; + min-height: 75px; + padding: 11px 14px; + } + .city-dock button { + min-width: 185px; + padding: 5px 9px; + } + .city-thumb { + width: 32px; + height: 32px; + } + .city-dock button strong { + font-size: 10px; + } + .dock-intro { + display: none; + } + .map-instruction { + bottom: 157px; + left: 50%; + font-size: 9px; + padding: 10px 11px; + } + .action-panel { + max-height: none; + padding: 23px; + } + .action-panel h2 { + font-size: 28px; + } + .action-panel > p { + font-size: 12px; + } + .activity { + min-height: 260px; + max-height: 390px; + } + .journal article p { + font-size: 12px; + } + .primary { + font-size: 12px; + height: 45px; + } + .field-guide { + padding: 29px 23px; + } + .field-guide h2 { + font-size: 43px; + } + .guide-grid { + gap: 21px; + } + .guide-grid h3 { + font-size: 22px; + } + .guide-grid p { + font-size: 10px; + } + .map-warning { + left: 20px; + top: 260px; + } + .toast { + font-size: 11px; + white-space: nowrap; + } +} +@media (prefers-reduced-motion: reduce) { + * { + transition: none !important; + scroll-behavior: auto !important; + } +} +@media (min-width: 761px) { + .game-shell { + height: 100dvh; + min-height: 650px; + } + .masthead, + .resource-bar { + flex-shrink: 0; + } + .play-layout { + grid-template-columns: minmax(0, 1fr) 370px; + grid-template-rows: minmax(0, 1fr); + flex: 1 1 0; + min-height: 0; + } + .action-panel { + padding: 28px 26px 20px; + } + .action-panel > p { + font-size: 13px; + line-height: 1.7; + } + .action-panel h2 { + font-size: 28px; + } + .tiny-label { + font-size: 9px; + } + .primary { + font-size: 13px; + min-height: 46px; + } + .action-cost { + font-size: 10px; + } + .turn-banner strong { + font-size: 12px; + } + .turn-banner small { + font-size: 10px; + } + .activity-tabs button { + font-size: 13px; + } + .journal article p { + font-size: 12px; + line-height: 1.7; + } + .journal article > small { + font-size: 8px; + } + .resource small { + font-size: 11px; + } + .resource strong { + font-size: 23px; + } + .resource em { + font-size: 11px; + } + .text-button { + font-size: 12px; + } + .collection-choices strong { + font-size: 13px; + } + .collection-choices small { + font-size: 11px; + } + .collection-summary > span { + font-size: 11px; + } + .collection-summary > strong { + font-size: 14px; + } + .warning { + font-size: 12px; + } + .player-info small { + font-size: 10px; + } + .city-dock button strong { + font-size: 12px; + } + .city-dock button small { + font-size: 10px; + } + .city-map-label { + font-size: 11px; + } +} +@media (min-width: 761px) and (max-width: 1100px) { + .play-layout { + grid-template-columns: minmax(0, 1fr) 330px; + } + .action-panel { + padding: 23px; + } + .action-panel h2 { + font-size: 28px; + } + .resource small { + font-size: 10px; + } + .resource strong { + font-size: 20px; + } +} +.tile-inspector { + position: absolute; + left: 25px; + bottom: 215px; + width: 190px; + z-index: 3; + background: #f9f3e5eb; + border: 1px solid #c8bb9e; + border-radius: 6px; + padding: 16px; + box-shadow: 0 5px 25px #27483818; +} +.tile-inspector > button { + position: absolute; + right: 7px; + top: 7px; + padding: 3px; +} +.tile-inspector > strong { + display: block; + font: + 24px 'Libre Caslon Display', + Georgia, + serif; + margin: 7px 0; +} +.tile-inspector > p { + font-size: 11px; + color: #7a856d; + line-height: 1.6; +} +@media (max-width: 760px) { + .tile-inspector { + left: 15px; + bottom: 172px; + width: 170px; + padding: 13px; + } + .tile-inspector > p { + font-size: 10px; + } + .tile-inspector > strong { + font-size: 21px; + } +} +@media (min-width: 761px) and (max-height: 950px) { + .masthead { + height: 68px; + } + .resource-bar { + height: 70px; + } + .play-layout { + height: calc(100dvh - 138px); + min-height: 480px; + } + .action-panel { + max-height: calc(100% - 205px); + padding: 20px 24px; + flex-shrink: 1; + } + .activity { + min-height: 155px; + } + .action-panel h2 { + font-size: 28px; + } + .player-list { + top: 20px; + } + .player-card { + padding: 8px; + } + .map-controls { + bottom: 98px; + } + .city-dock { + height: 74px; + min-height: 74px; + padding: 9px 25px; + } + .map-world { + bottom: 74px; + } + .map-vignette { + bottom: 74px; + } + .map-instruction { + bottom: 170px; + } + .tile-inspector { + bottom: 180px; + } +} + +/* The board owns the viewport; tools open over it without changing its size. */ +.game-shell { + height: 100dvh; + min-height: 0; + overflow: hidden; +} +.masthead, +.resource-bar { + flex-shrink: 0; +} +.play-layout { + display: block; + position: relative; + flex: 1 1 0; + height: auto; + min-height: 0; + overflow: hidden; +} +.map-section { + height: 100%; + min-height: 0; +} +.map-world, +.map-vignette { + inset: 0; +} +.city-dock { + left: 20px; + bottom: 18px; + right: auto; + width: max-content; + max-width: calc(100% - 235px); + height: auto; + min-height: 0; + padding: 0; + border: 0; + gap: 8px; + background: transparent; + backdrop-filter: none; +} +.dock-intro { + display: none; +} +.city-dock button { + min-width: 190px; + box-shadow: 0 3px 18px #28483d20; +} +.map-controls { + right: 20px; + bottom: 18px; +} +.map-instruction { + left: 50%; + bottom: 100px; +} +.tile-inspector { + bottom: 100px; +} +.board-toolbar { + position: absolute; + right: 20px; + top: 20px; + z-index: 6; + border: 1px solid #d8d4c3cc; + border-radius: 8px; + background: var(--paper); + box-shadow: 0 4px 22px #27483a20; + width: 278px; +} +.board-toolbar .turn-banner { + height: 35px; + padding: 0 13px; + border-radius: 8px 8px 0 0; +} +.board-toolbar .turn-banner small { + margin-left: auto; + font-size: 10px; +} +.board-actions { + display: flex; + padding: 6px; + gap: 2px; +} +.board-actions button { + display: flex; + flex: 1; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 6px; + padding: 8px 4px; + border-radius: 5px; + font-size: 10px; + color: var(--green); +} +.board-actions button:hover:not(:disabled), +.board-actions button.active { + background: var(--paper2); +} +.dark .board-actions button { + color: var(--ink); +} +.table-tools { + position: absolute; + right: 20px; + bottom: 72px; + display: flex; + align-items: center; + gap: 5px; + padding: 5px; + border: 1px solid #d8d4c3cc; + border-radius: 6px; + background: var(--paper); + box-shadow: 0 3px 18px #27483a20; + z-index: 6; +} +.table-tools button { + display: flex; + align-items: center; + gap: 7px; + padding: 7px; + font-size: 11px; + border-radius: 4px; +} +.table-tools button.active, +.table-tools button:hover { + background: var(--paper2); +} +.floating-panel { + position: absolute; + z-index: 7; + right: 20px; + width: 354px; + background: var(--paper); + color: var(--ink); + border: 1px solid var(--line); + border-radius: 9px; + box-shadow: 0 10px 40px #203c3d30; +} +.action-panel.floating-panel { + top: 130px; + bottom: auto; + max-height: calc(100% - 150px); + padding: 22px; + overflow-y: auto; +} +.action-panel h2 { + font-size: 28px; + padding-right: 15px; +} +.close-action { + position: absolute; + right: 8px; + top: 8px; +} +.activity.floating-panel { + top: auto; + bottom: 126px; + height: min(470px, calc(100% - 150px)); + min-height: 0; + max-height: none; +} +.close-activity { + margin-left: auto; +} +.activity-tabs button.close-activity { + width: 26px; +} +.end-confirm { + display: flex; + gap: 8px; + background: none; + padding: 18px 0 0; +} +.end-confirm .primary { + font-size: 12px; +} +.end-confirm button { + margin: 0; +} +.map-warning { + top: 145px; +} +@media (max-width: 760px) { + .board-toolbar { + right: 12px; + top: 12px; + width: 208px; + max-width: calc(100% - 150px); + } + .board-toolbar .turn-banner { + height: 32px; + gap: 5px; + padding: 0 8px; + } + .board-toolbar .turn-banner strong { + font-size: 10px; + } + .board-toolbar .turn-banner small { + font-size: 9px; + } + .board-actions { + padding: 4px; + gap: 0; + } + .board-actions button { + font-size: 9px; + padding: 7px 2px; + } + .board-actions button svg { + width: 18px; + height: 18px; + } + .player-list { + left: 12px; + top: 12px; + width: 120px; + } + .city-dock { + bottom: 12px; + left: 12px; + max-width: calc(100% - 160px); + } + .city-dock button { + min-width: 172px; + } + .city-dock button .city-thumb { + width: 26px; + } + .map-controls { + bottom: 12px; + right: 12px; + } + .table-tools { + bottom: 63px; + right: 12px; + } + .table-tools button > span:not(.unread) { + display: none; + } + .floating-panel { + right: 12px; + left: 12px; + width: auto; + } + .action-panel.floating-panel { + top: 114px; + max-height: calc(100% - 132px); + padding: 22px; + } + .activity.floating-panel { + bottom: 113px; + height: calc(100% - 130px); + } + .map-instruction { + display: none; + } + .tile-inspector { + bottom: 90px; + } +} diff --git a/web-client/src/types.ts b/web-client/src/types.ts new file mode 100644 index 00000000..f41717bf --- /dev/null +++ b/web-client/src/types.ts @@ -0,0 +1,176 @@ +export type Pile = Partial< + Record<'food' | 'wood' | 'ore' | 'ideas' | 'gold' | 'mood_tokens' | 'culture_tokens', number> +>; +export type Resource = keyof Pile; +export type Move = string | Record; +export type Terrain = + 'Forest' | 'Fertile' | 'Mountain' | 'Barren' | 'Water' | 'Unexplored' | { Exhausted: string }; +export interface City { + position: string; + mood_state: string; + pieces?: Record; + activations?: number; +} +export interface Player { + id: number; + name?: string; + civilization: string; + resources?: Pile; + resource_limit?: Pile; + cities?: City[]; + units?: { position: string; unit_type: string; id: number }[]; + advances?: string[]; + action_cards?: number[]; + objective_cards?: number[]; +} +export interface Game { + state: unknown; + players: Player[]; + map: { tiles: [string, Terrain][] }; + current_player_index: number; + actions_left: number; + age: number; + round: number; + log?: { + age: number; + rounds: { round: number; turns: { turn_type: unknown; actions?: LoggedAction[] }[] }[]; + }[]; + log_index: number; +} +export interface LoggedAction { + action?: Move; + log?: string[]; + items?: { + player: number; + Structure?: { structure: unknown; balance: string; position: string }; + HandCard?: { to: unknown }; + }[]; + combat_stats?: unknown; +} +export interface Choice { + position: string; + pile: Pile; +} +export interface Selection extends Choice { + times: number; +} +export interface CityView { + position: string; + size: number; + capacity: number; + maxPerTile: number; + maxRange2: number; + mood: string; + activations: number; + reason: string | null; + choices: Choice[]; +} +export interface AdvanceView { + id: string; + name: string; + description: string; + owned: boolean; + reason: string | null; + payment: Pile; + action: Move | null; + group: string; + order: number; + required: string | null; + bonus: Pile | null; + unlocks: string | null; +} +export interface PlayerView { + index: number; + name: string; + civilization: string; + score: number; + cities: { position: string; size: number; capacity: number; mood: string; activations: number }[]; +} +export interface View { + activePlayer: number; + canPlay: boolean; + supportedPhase: boolean; + players: PlayerView[]; + cities: CityView[]; + advances: AdvanceView[]; + objectiveCards: { + id: number; + objectives: { name: string; description: string; timing: 'Instant' | 'Status phase' }[]; + }[]; + objectiveDecision: { + name: string; + description: string; + points: number; + cards: { id: number; name: string; action: Move }[]; + skip: Move | null; + } | null; + canUndo: boolean; + canEndTurn: boolean; +} +export interface CollectionPreview { + action: Move; + total: Pile; + waste: Pile; + after: Pile; + moodWillDecrease: boolean; +} +export interface Bridge { + default: (input?: unknown) => Promise; + webView: (state: string, seat?: number) => string; + webCollectPreview: (state: string, seat: number, city: string, choices: string) => string; +} +export interface JournalEntry { + id: string; + age: number; + round: number; + text: string; + kind: + | 'setup' + | 'collect' + | 'research' + | 'objective' + | 'end-turn' + | 'move' + | 'build' + | 'recruit' + | 'combat' + | 'card' + | 'event'; + setup?: { player: string; civilization: string; position?: string }; +} +export interface Session { + game: Game | null; + view: View | null; + seat?: number; + city: string | null; + focus: string | null; + mode: 'overview' | 'collect' | 'research'; + selection: Selection[]; + preview: CollectionPreview | null; + error: string; + pending: boolean; + tab: 'journal' | 'chat'; + activityOpen: boolean; + help: boolean; + objectivesOpen: boolean; + dark: boolean; + unread: number; + avatars: string[]; + reducedMotion: boolean; + colorBlind: boolean; + locale: string; + selectedAdvance: string | null; + toast: string; + topDown: boolean; +} +export const resourceNames: Record = { + food: 'Food', + wood: 'Wood', + ore: 'Ore', + ideas: 'Ideas', + gold: 'Gold', + mood_tokens: 'Mood', + culture_tokens: 'Culture', +}; +export const resources = Object.keys(resourceNames) as Resource[]; +export const playerColors = ['#5086af', '#b96c4c', '#6d9173', '#ae92b6']; diff --git a/web-client/src/viewer.ts b/web-client/src/viewer.ts new file mode 100644 index 00000000..bf3a2f71 --- /dev/null +++ b/web-client/src/viewer.ts @@ -0,0 +1,46 @@ +import { mount, unmount, tick } from 'svelte'; +import { registerViewer } from '@boardgamers/protocol/viewer'; +import App from './App.svelte'; +import { Controller } from './controller'; +import css from './style.css?inline'; +const source = document.currentScript?.getAttribute('src'); +const assetBase = new URL(source ? '.' : '/', source ? new URL(source, location.href) : location.href); +export const viewer = registerViewer('clash3d', ({ target, ...commands }) => { + const style = document.createElement('style'); + style.textContent = css; + document.head.append(style); + const controller = new Controller(commands, assetBase); + const app = mount(App, { target, props: { controller } }); + const motion = matchMedia('(prefers-reduced-motion: reduce)'); + controller.patch({ reducedMotion: motion.matches }); + return { + chat: controller.chat, + async onState(state) { + await controller.load(state); + await tick(); + }, + onPlayer({ index }) { + controller.setPlayer(index); + }, + onAvatars(avatars) { + controller.patch({ avatars }); + }, + onPreferences(prefs) { + controller.patch({ + locale: typeof prefs.locale === 'string' ? prefs.locale : 'en', + colorBlind: prefs.colorBlind === true, + }); + }, + onTheme({ dark }) { + controller.patch({ dark }); + }, + onError(error) { + controller.patch({ error: String(error), pending: false }); + }, + destroy() { + controller.destroy(); + void unmount(app); + style.remove(); + }, + }; +}); diff --git a/web-client/tsconfig.json b/web-client/tsconfig.json new file mode 100644 index 00000000..865d2a6e --- /dev/null +++ b/web-client/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "strict": true, + "allowJs": true, + "checkJs": false, + "resolveJsonModule": true, + "esModuleInterop": true, + "skipLibCheck": true, + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "types": ["vite/client", "node"], + "allowImportingTsExtensions": true, + "noEmit": true + }, + "include": ["src/**/*.ts", "src/**/*.svelte", "vite.config.ts"] +} diff --git a/web-client/viewer.html b/web-client/viewer.html new file mode 100644 index 00000000..1e79617f --- /dev/null +++ b/web-client/viewer.html @@ -0,0 +1,12 @@ + + + + + + Clash 3D viewer + + +
+ + + diff --git a/web-client/vite.config.ts b/web-client/vite.config.ts new file mode 100644 index 00000000..5df98e01 --- /dev/null +++ b/web-client/vite.config.ts @@ -0,0 +1,12 @@ +import { defineConfig } from 'vite'; +import { svelte } from '@sveltejs/vite-plugin-svelte'; +import { previewApi } from './scripts/preview-api'; +export default defineConfig({ + plugins: [svelte(), previewApi()], + build: { + lib: { entry: 'src/viewer.ts', name: 'Clash3DBundle', formats: ['iife'], fileName: () => 'viewer.js' }, + target: 'es2022', + emptyOutDir: true, + }, + server: { strictPort: true }, +});