Queue private tactics in the normal battle panel; release viewer 0.1.220 and engine 0.4.153
This commit is contained in:
parent
7af8257c42
commit
a6cd817a15
42 changed files with 957 additions and 62 deletions
|
|
@ -31,6 +31,99 @@ pub struct Offer {
|
|||
pub selected: Option<EventResponse>,
|
||||
}
|
||||
|
||||
// A plan belongs to this battle round, not to a transient event phase.
|
||||
fn tactics_key(game: &Game, combat: &crate::combat::Combat) -> String {
|
||||
format!(
|
||||
"{}:{}:{}:{}:{}:{}:{}/tactics",
|
||||
game.age,
|
||||
game.round,
|
||||
game.current_player_index,
|
||||
game.actions_left,
|
||||
combat.attacker(),
|
||||
combat.defender_position(),
|
||||
combat.stats.round
|
||||
)
|
||||
}
|
||||
|
||||
fn tactics_offer(game: &Game, player: usize) -> Option<Offer> {
|
||||
use crate::combat_listeners::{CombatEventPhase, CombatRoundStart};
|
||||
let event = game.events.iter().rev().find(|e| {
|
||||
matches!(
|
||||
e.event_type,
|
||||
PersistentEventType::CombatStart(_) | PersistentEventType::CombatRoundStart(_)
|
||||
)
|
||||
})?;
|
||||
let round = match &event.event_type {
|
||||
PersistentEventType::CombatStart(c) => CombatRoundStart::new(c.clone()),
|
||||
PersistentEventType::CombatRoundStart(r)
|
||||
if matches!(
|
||||
r.phase,
|
||||
CombatEventPhase::AllowTacticsCard
|
||||
| CombatEventPhase::Loyalty
|
||||
| CombatEventPhase::Default
|
||||
) =>
|
||||
{
|
||||
if r.phase == CombatEventPhase::Default
|
||||
&& (event.players_used.contains(&player) || event.player.index == player)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
r.clone()
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
let c = &round.combat;
|
||||
if !c.players().contains(&player)
|
||||
|| !game
|
||||
.player(player)
|
||||
.can_use_advance(crate::advance::Advance::Tactics)
|
||||
|| crate::combat::get_combat_strength(player, &round).deny_tactics_card
|
||||
|| (player == c.defender()
|
||||
&& c.first_round()
|
||||
&& c.modifiers
|
||||
.contains(&crate::combat::CombatModifier::TrojanHorse))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let mut options = vec![option("No tactics", EventResponse::SelectHandCards(vec![]))];
|
||||
for id in game
|
||||
.player(player)
|
||||
.action_cards
|
||||
.iter()
|
||||
.filter(|id| **id != 0)
|
||||
{
|
||||
let card = game.cache.get_action_card(*id);
|
||||
let Some(tactics) = &card.tactics_card else {
|
||||
continue;
|
||||
};
|
||||
// Scout's enemy-card requirement is deliberately provisional; never
|
||||
// inspect a hidden enemy commitment to build an early offer.
|
||||
if tactics.name == "Scout"
|
||||
|| crate::tactics_card::can_play_tactics_card(game, player, card, &round)
|
||||
{
|
||||
options.push(OptionChoice {
|
||||
label: tactics.name.clone(),
|
||||
description: tactics.description.clone(),
|
||||
response: EventResponse::SelectHandCards(vec![HandCard::ActionCard(*id)]),
|
||||
});
|
||||
}
|
||||
}
|
||||
if options.len() == 1 {
|
||||
return None;
|
||||
}
|
||||
let key = tactics_key(game, c);
|
||||
Some(Offer {
|
||||
selected: game
|
||||
.early_choices
|
||||
.iter()
|
||||
.find(|s| s.player == player && s.key == key)
|
||||
.map(|s| s.response.clone()),
|
||||
key,
|
||||
title: "Tactics".into(),
|
||||
options,
|
||||
})
|
||||
}
|
||||
|
||||
fn scope(game: &Game, index: usize) -> Option<String> {
|
||||
let name = match &game.events.get(index)?.event_type {
|
||||
PersistentEventType::StatusPhase(phase) => format!("status:{phase:?}"),
|
||||
|
|
@ -98,6 +191,28 @@ fn objective_offers(game: &Game, player: usize) -> Vec<Offer> {
|
|||
}
|
||||
|
||||
pub fn prune_objectives(game: &mut Game) {
|
||||
// Navigation and interrupted/skipped rounds must not leave a plan that can
|
||||
// attach to a later battle at the same location.
|
||||
let combat_keys: Vec<_> = game
|
||||
.events
|
||||
.iter()
|
||||
.filter_map(|event| match &event.event_type {
|
||||
PersistentEventType::CombatStart(c) => Some(tactics_key(game, c)),
|
||||
PersistentEventType::CombatRoundStart(r)
|
||||
if matches!(
|
||||
r.phase,
|
||||
crate::combat_listeners::CombatEventPhase::AllowTacticsCard
|
||||
| crate::combat_listeners::CombatEventPhase::Loyalty
|
||||
| crate::combat_listeners::CombatEventPhase::Default
|
||||
) =>
|
||||
{
|
||||
Some(tactics_key(game, &r.combat))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
game.early_choices
|
||||
.retain(|c| !c.key.ends_with("/tactics") || combat_keys.contains(&c.key));
|
||||
let invalid: Vec<_> = game
|
||||
.early_choices
|
||||
.iter()
|
||||
|
|
@ -194,6 +309,9 @@ pub fn offers(game: &Game, player: usize) -> Vec<Offer> {
|
|||
return vec![];
|
||||
}
|
||||
let mut result = current_offers(game, player);
|
||||
if let Some(offer) = tactics_offer(game, player) {
|
||||
result.push(offer);
|
||||
}
|
||||
if let Some(offer) = advance_offer(game, player) {
|
||||
result.push(offer);
|
||||
}
|
||||
|
|
@ -351,7 +469,9 @@ fn current_offers(game: &Game, player: usize) -> Vec<Offer> {
|
|||
}
|
||||
|
||||
pub fn can_save(game: &Game, player: usize, key: &str, response: Option<&EventResponse>) -> bool {
|
||||
(player != game.active_player() || (game.events.is_empty() && key.contains(":objective:")))
|
||||
(player != game.active_player()
|
||||
|| key.ends_with("/tactics")
|
||||
|| (game.events.is_empty() && key.contains(":objective:")))
|
||||
&& offers(game, player).iter().any(|offer| {
|
||||
offer.key == key
|
||||
&& response.is_none_or(|r| offer.options.iter().any(|o| &o.response == r))
|
||||
|
|
@ -386,6 +506,14 @@ pub fn save(
|
|||
}
|
||||
|
||||
pub fn expire_current_event(game: &mut Game) {
|
||||
if let Some(PersistentEventType::CombatRoundStart(r)) =
|
||||
game.events.last().map(|e| &e.event_type)
|
||||
{
|
||||
if r.phase == crate::combat_listeners::CombatEventPhase::Default {
|
||||
let key = tactics_key(game, &r.combat);
|
||||
game.early_choices.retain(|c| c.key != key);
|
||||
}
|
||||
}
|
||||
if game.events.last().is_some_and(|e| {
|
||||
matches!(
|
||||
e.event_type,
|
||||
|
|
@ -424,6 +552,31 @@ pub fn take_ready(game: &mut Game) -> Option<EventResponse> {
|
|||
let player = game.active_player();
|
||||
let event = game.events.last()?;
|
||||
let handler = event.player.handler.as_ref()?;
|
||||
if let PersistentEventType::CombatRoundStart(r) = &event.event_type {
|
||||
if r.phase != crate::combat_listeners::CombatEventPhase::Default
|
||||
|| handler.origin
|
||||
!= crate::events::EventOrigin::Advance(crate::advance::Advance::Tactics)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let key = tactics_key(game, &r.combat);
|
||||
let at = game
|
||||
.early_choices
|
||||
.iter()
|
||||
.position(|c| c.player == player && c.key == key)?;
|
||||
let valid = match (&handler.request, &game.early_choices[at].response) {
|
||||
(
|
||||
PersistentEventRequest::SelectHandCards(request),
|
||||
EventResponse::SelectHandCards(cards),
|
||||
) => {
|
||||
request.needed.contains(&(cards.len() as u8))
|
||||
&& cards.iter().all(|c| request.choices.contains(c))
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
let choice = game.early_choices.remove(at);
|
||||
return valid.then_some(choice.response);
|
||||
}
|
||||
let (index, suffix) = match &event.event_type {
|
||||
PersistentEventType::StatusPhase(StatusPhaseState::DetermineFirstPlayer(_)) => {
|
||||
(game.events.len() - 1, "first".into())
|
||||
|
|
|
|||
|
|
@ -147,6 +147,8 @@ pub fn civilizations(game: Game) -> Vec<String> {
|
|||
|
||||
#[must_use]
|
||||
pub fn strip_secret(mut game: Game, player_index: Option<usize>) -> Game {
|
||||
// Platform bookkeeping is not public evidence of a private commitment.
|
||||
game.early_choice_update = false;
|
||||
crate::calendar_knowledge::strip(&mut game, player_index);
|
||||
if game
|
||||
.action_plan
|
||||
|
|
|
|||
|
|
@ -342,11 +342,20 @@ pub fn view(game: &Game, seat: Option<usize>) -> Value {
|
|||
"shogunateDraft":p.has_special_advance(crate::special_advance::SpecialAdvance::Shogunate)&&p.can_use_advance(Advance::Draft)&&!p.event_info.contains_key("Shogunate Draft"),
|
||||
"canActivate":city.can_activate(), "activationMood":after_activation.mood_state,"activationCapacity":after_activation.mood_modified_size(p)})
|
||||
}).collect::<Vec<_>>();
|
||||
let early_offers = if seat != active || game.events.is_empty() {
|
||||
crate::early_choices::offers(game, seat)
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
let early_offers: Vec<_> = crate::early_choices::offers(game, seat)
|
||||
.into_iter()
|
||||
// Combat queues use the same waiting-player surface as other early choices.
|
||||
// Never offer tactics before this player's combat-start choices (notably
|
||||
// Steel Weapons) have finished. Keep engine queue authorization separate.
|
||||
.filter(|_| seat != active || game.events.is_empty())
|
||||
.filter(|o| {
|
||||
!o.key.ends_with("/tactics")
|
||||
|| !game.events.iter().any(|event| {
|
||||
matches!(event.event_type, PersistentEventType::CombatStart(_))
|
||||
&& !event.players_used.contains(&seat)
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let early_advance = early_offers.iter().find(|o| o.key.ends_with("/advance"));
|
||||
let early_advance_choices: Vec<_> = early_advance
|
||||
.into_iter()
|
||||
|
|
|
|||
|
|
@ -51,9 +51,15 @@ pub(super) fn describe(game: &Game) -> Value {
|
|||
activated.modifiers.push(modifier);
|
||||
let bonus =
|
||||
strength(game, &activated, player).extra_combat_value - s.extra_combat_value;
|
||||
inactive.push(format!(
|
||||
"Steel Weapons not activated: +{bonus} value if activated"
|
||||
));
|
||||
let pending = game.events.iter().any(|event| {
|
||||
matches!(event.event_type, PersistentEventType::CombatStart(_))
|
||||
&& !event.players_used.contains(&player)
|
||||
});
|
||||
inactive.push(if pending {
|
||||
format!("Steel Weapons pending: +{bonus} value if activated")
|
||||
} else {
|
||||
format!("Steel Weapons not activated: +{bonus} value if activated")
|
||||
});
|
||||
}
|
||||
if crate::content::civilizations::persia::caps_opponent_bonus(game, c, player) {
|
||||
s.extra_combat_value = s.extra_combat_value.min(2);
|
||||
|
|
|
|||
275
server/tests/tactics_queue_tests.rs
Normal file
275
server/tests/tactics_queue_tests.rs
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
use serde_json::{Value, json};
|
||||
use server::{
|
||||
board_history,
|
||||
cache::Cache,
|
||||
early_choices,
|
||||
game::{Game, GameContext},
|
||||
game_data::GameData,
|
||||
};
|
||||
|
||||
fn load(value: Value) -> Game {
|
||||
let data: GameData = serde_json::from_value(value).unwrap();
|
||||
let cache = Cache::new(&data.options);
|
||||
Game::from_data(data, cache, GameContext::Play)
|
||||
}
|
||||
fn data(game: &Game) -> Value {
|
||||
serde_json::to_value(game.cloned_data()).unwrap()
|
||||
}
|
||||
fn play(game: Game, player: usize, action: Value) -> Game {
|
||||
board_history::execute(game, serde_json::from_value(action).unwrap(), player).unwrap()
|
||||
}
|
||||
fn battle() -> Game {
|
||||
let mut v: Value =
|
||||
serde_json::from_str(include_str!("test_games/tactics_cards/peltasts.json")).unwrap();
|
||||
for p in [0, 1] {
|
||||
v["players"][p]["advances"]
|
||||
.as_array_mut()
|
||||
.unwrap()
|
||||
.push(json!("SteelWeapons"));
|
||||
}
|
||||
v["players"][0]["action_cards"] = json!([3, 6, 11]);
|
||||
v["players"][1]["action_cards"] = json!([4, 7, 23]);
|
||||
play(
|
||||
load(v),
|
||||
0,
|
||||
json!({"Movement":{"Move":{"units":[0,1,2],"destination":"C1","payment":{}}}}),
|
||||
)
|
||||
}
|
||||
fn key(g: &Game, p: usize) -> String {
|
||||
early_choices::offers(g, p)
|
||||
.into_iter()
|
||||
.find(|o| o.key.ends_with("/tactics"))
|
||||
.unwrap()
|
||||
.key
|
||||
}
|
||||
fn queue(g: Game, p: usize, card: Option<u8>) -> Game {
|
||||
let k = key(&g, p);
|
||||
let cards: Vec<Value> = card
|
||||
.into_iter()
|
||||
.map(|id| json!({"ActionCard":id}))
|
||||
.collect();
|
||||
play(
|
||||
g,
|
||||
p,
|
||||
json!({"QueueChoice":{"key":k,"response":{"SelectHandCards":cards}}}),
|
||||
)
|
||||
}
|
||||
fn steel(g: Game, p: usize) -> Game {
|
||||
play(g, p, json!({"Response":{"Payment":[{"ore":1}]}}))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn private_metadata_edits_leave_payment_hand_rng_history_and_timing_untouched() {
|
||||
let g = battle();
|
||||
let original = data(&g);
|
||||
let enemy = data(&server::game_api::strip_secret(g.clone(), Some(1)));
|
||||
let spectator = data(&server::game_api::strip_secret(g.clone(), None));
|
||||
let k = key(&g, 0);
|
||||
let mut g = queue(g, 0, Some(3));
|
||||
for card in [None, Some(6), Some(3)] {
|
||||
g = queue(g, 0, card);
|
||||
}
|
||||
assert_eq!(
|
||||
data(&server::game_api::strip_secret(g.clone(), Some(1))),
|
||||
enemy
|
||||
);
|
||||
assert_eq!(
|
||||
data(&server::game_api::strip_secret(g.clone(), None)),
|
||||
spectator
|
||||
);
|
||||
let mut edited = data(&g);
|
||||
edited.as_object_mut().unwrap().remove("early_choices");
|
||||
edited
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("early_choice_update");
|
||||
assert_eq!(edited, original);
|
||||
assert_eq!(g.active_player(), 0);
|
||||
g = play(g, 0, json!({"QueueChoice":{"key":k,"response":null}}));
|
||||
let mut cancelled = data(&g);
|
||||
cancelled
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("early_choice_update");
|
||||
assert_eq!(cancelled, original);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn consume_only_at_real_prompt_once_and_keep_card_facedown_until_other_choice() {
|
||||
let g = queue(battle(), 0, Some(3));
|
||||
let k = key(&g, 0);
|
||||
let g = steel(g, 0);
|
||||
assert!(g.player(0).action_cards.contains(&3));
|
||||
assert_eq!(g.early_choices.len(), 1);
|
||||
let g = steel(load(data(&g)), 1);
|
||||
assert_eq!(g.active_player(), 1);
|
||||
assert!(!g.player(0).action_cards.contains(&3));
|
||||
assert!(g.early_choices.is_empty());
|
||||
assert!(g.current_event_handler().is_some());
|
||||
let hidden = data(&server::game_api::strip_secret(g.clone(), Some(1)));
|
||||
assert_eq!(
|
||||
hidden["events"][0]["event_type"]["CombatRoundStart"]["attacker_strength"]["tactics_card"],
|
||||
json!(0)
|
||||
);
|
||||
assert!(!early_choices::can_save(&g, 0, &k, None));
|
||||
assert!(!early_choices::can_save(&g, 1, &k, None)); // live tactics is not a queued choice
|
||||
let done = play(
|
||||
g,
|
||||
1,
|
||||
json!({"Response":{"SelectHandCards":[{"ActionCard":4}]}}),
|
||||
);
|
||||
assert!(done.early_choices.is_empty());
|
||||
assert!(!done.player(1).action_cards.contains(&4));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn both_players_queue_and_automatic_execution_matches_ordinary_responses() {
|
||||
let g = battle();
|
||||
let queued = queue(queue(g.clone(), 0, Some(3)), 1, Some(4));
|
||||
let queued = steel(steel(queued, 0), 1);
|
||||
let normal = steel(steel(g, 0), 1);
|
||||
let normal = play(
|
||||
normal,
|
||||
0,
|
||||
json!({"Response":{"SelectHandCards":[{"ActionCard":3}]}}),
|
||||
);
|
||||
let normal = play(
|
||||
normal,
|
||||
1,
|
||||
json!({"Response":{"SelectHandCards":[{"ActionCard":4}]}}),
|
||||
);
|
||||
for field in [
|
||||
"players",
|
||||
"events",
|
||||
"rng",
|
||||
"dice_roll_log",
|
||||
"log",
|
||||
"time_increments",
|
||||
"action_cards_discarded",
|
||||
] {
|
||||
assert_eq!(data(&queued)[field], data(&normal)[field], "{field}");
|
||||
}
|
||||
assert!(queued.early_choices.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_card_and_scout_after_enemy_pass_fall_back_to_real_prompt() {
|
||||
let mut g = queue(battle(), 0, Some(3));
|
||||
g.players[0].action_cards.retain(|c| *c != 3);
|
||||
let g = steel(steel(g, 0), 1);
|
||||
assert_eq!(g.active_player(), 0);
|
||||
assert!(g.early_choices.is_empty());
|
||||
let g = queue(queue(battle(), 0, None), 1, Some(23));
|
||||
let g = steel(steel(g, 0), 1);
|
||||
assert_eq!(g.active_player(), 1);
|
||||
assert!(g.early_choices.is_empty());
|
||||
assert!(g.player(1).action_cards.contains(&23));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn skipped_tactics_ability_expires_instead_of_surviving_battle() {
|
||||
let mut g = queue(battle(), 1, Some(4));
|
||||
if let server::content::persistent_events::PersistentEventType::CombatStart(c) =
|
||||
&mut g.events[0].event_type
|
||||
{
|
||||
c.modifiers
|
||||
.push(server::combat::CombatModifier::TrojanHorse);
|
||||
}
|
||||
let g = queue(g, 0, None);
|
||||
let g = steel(steel(g, 0), 1);
|
||||
assert!(g.early_choices.is_empty());
|
||||
assert!(g.player(1).action_cards.contains(&4));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn undoing_battle_start_removes_plan_and_redo_does_not_resurrect_it() {
|
||||
let g = queue(battle(), 0, Some(3));
|
||||
let g = play(g, 0, json!("Undo"));
|
||||
assert!(g.early_choices.is_empty());
|
||||
let g = play(g, 0, json!("Redo"));
|
||||
assert!(g.early_choices.is_empty());
|
||||
assert!(g.player(0).action_cards.contains(&3));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hidden_hand_during_seat_switch_never_becomes_an_offer() {
|
||||
let g = server::game_api::strip_secret(battle(), Some(0));
|
||||
assert!(
|
||||
early_choices::offers(&g, 1)
|
||||
.iter()
|
||||
.all(|o| !o.key.ends_with("/tactics"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn martyr_queue_does_not_choose_sacrifices_or_other_effect_responses() {
|
||||
let mut g = battle();
|
||||
g.players[0].action_cards.push(24);
|
||||
let g = queue(queue(g, 0, Some(24)), 1, Some(4));
|
||||
let g = steel(steel(g, 0), 1);
|
||||
assert!(g.early_choices.is_empty());
|
||||
let handler = g.current_event_handler().unwrap();
|
||||
assert!(matches!(
|
||||
handler.request,
|
||||
server::content::persistent_events::PersistentEventRequest::SelectUnits(_)
|
||||
));
|
||||
assert_eq!(g.active_player(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn waiting_defender_can_queue_during_attackers_normal_tactics_prompt() {
|
||||
let g = steel(steel(battle(), 0), 1);
|
||||
assert_eq!(g.active_player(), 0);
|
||||
let k = key(&g, 1);
|
||||
let g = queue(g, 1, Some(4));
|
||||
assert_eq!(g.active_player(), 0);
|
||||
assert!(g.player(1).action_cards.contains(&4));
|
||||
let g = play(
|
||||
g,
|
||||
0,
|
||||
json!({"Response":{"SelectHandCards":[{"ActionCard":3}]}}),
|
||||
);
|
||||
assert!(g.early_choices.is_empty());
|
||||
assert!(!g.player(1).action_cards.contains(&4));
|
||||
assert!(!early_choices::can_save(&g, 1, &k, None));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn viewer_offers_tactics_only_after_own_steel_and_only_while_waiting() {
|
||||
let offered = |g: &Game, p| {
|
||||
server::web_view::view(g, Some(p))["earlyChoices"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.any(|o| o["key"].as_str().unwrap().ends_with("/tactics"))
|
||||
};
|
||||
let g = battle();
|
||||
assert!(!offered(&g, 0));
|
||||
assert!(!offered(&g, 1));
|
||||
let g = steel(g, 0);
|
||||
assert!(offered(&g, 0));
|
||||
assert!(!offered(&g, 1));
|
||||
let g = queue(g, 0, Some(3));
|
||||
let g = steel(g, 1);
|
||||
assert!(!offered(&g, 1)); // defender now has the ordinary live tactics request
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stale_round_and_finished_battle_plans_are_pruned() {
|
||||
let mut g = queue(battle(), 0, Some(3));
|
||||
let old_key = key(&g, 0);
|
||||
if let server::content::persistent_events::PersistentEventType::CombatStart(c) =
|
||||
&mut g.events[0].event_type
|
||||
{
|
||||
c.stats.round += 1;
|
||||
}
|
||||
assert_ne!(key(&g, 0), old_key);
|
||||
early_choices::prune_objectives(&mut g);
|
||||
assert!(g.early_choices.is_empty());
|
||||
assert!(!early_choices::can_save(&g, 0, &old_key, None));
|
||||
let mut g = queue(g, 0, Some(3));
|
||||
g.events.clear();
|
||||
early_choices::prune_objectives(&mut g);
|
||||
assert!(g.early_choices.is_empty());
|
||||
assert!(g.player(0).action_cards.contains(&3));
|
||||
}
|
||||
|
|
@ -1471,3 +1471,54 @@ Verified locally: 1,081 frontend tests, four gallery tests, 19 achievement check
|
|||
extraction, Svelte with zero errors/warnings, and production build. Ownership
|
||||
browser checks also verify every building kind and English/German hover names;
|
||||
existing tile-hover, structure-owner and split-WASM bundle checks pass.
|
||||
|
||||
# Viewer 0.1.220 / engine 0.4.153
|
||||
|
||||
Waiting combatants can privately queue a tactics card in the ordinary Tactics
|
||||
panel after their own combat-start decisions (including Steel Weapons) finish.
|
||||
The normal printed card names, battle rules and Combat Forces are reused, without
|
||||
an Abilities detour or extra opening step. Own Steel Weapons remains the live
|
||||
payment prompt first; unresolved opposing Steel Weapons is shown as pending,
|
||||
with its conditional bonus. Queue tactics saves or replaces the choice, Cancel
|
||||
removes it, and Skip queues no tactics. The redundant “Discards the selected
|
||||
card” footer is removed from both queued and live tactics; actual card effect
|
||||
rules and discard decisions are unchanged. Monte Carlo estimates remain on live
|
||||
choices, not provisional queued decisions.
|
||||
|
||||
Queues are battle-round scoped private metadata: they do not move cards, spend
|
||||
resources, advance time or append history. The normal tactics handler revalidates
|
||||
and consumes the saved choice exactly once, preserving face-down commitments,
|
||||
reveal order, effects and normal replay actions. Missing cards and late Scout
|
||||
ineligibility return to the ordinary prompt. Skipped abilities, completed rounds,
|
||||
and undo/redo cannot carry a plan into another battle. Opponents and spectators
|
||||
receive neither queued content nor its bookkeeping flag. The viewer adapter only
|
||||
accepts single authorized cards present in the owner's hand, never placeholder 0.
|
||||
|
||||
The disposable localhost match has a real-engine Steel/tactics fixture, readable
|
||||
native selectors in both themes, and persisted fixture restart across tabs. The
|
||||
rejected standalone simulated queue prototype and its unused EarlyChoices hooks
|
||||
are not included. No production moves, game repairs, achievement/gallery updates,
|
||||
Fossil refresh, or unrelated card/rules changes are part of this release.
|
||||
|
||||
Verification includes the complete Rust 1.94.1 workspace suite, 11 focused native
|
||||
queue tests, frontend and packed-engine queue/privacy/replay regressions, both
|
||||
17-locale catalogs and source extraction, Svelte, bridge and production builds.
|
||||
Built-viewer queue/edit/cancel/skip and live tactics checks run at 1400, 390 and
|
||||
320px, including absence of the removed footer. Existing Steel payment, combat
|
||||
forces, journal, playback and split-WASM browser regressions are also exercised.
|
||||
Achievement artwork is generated locally solely to exercise the two otherwise
|
||||
artifact-dependent validation tests; it is not republished. Existing Clippy
|
||||
warnings and expected rejected-move WASM diagnostics remain.
|
||||
|
||||
Publish only after matching main-branch CI passes, using the supported publisher
|
||||
with the tested 0.4.153 engine package. Independently compare every hosted viewer
|
||||
asset and the engine package against the frozen tested build; preserve all other
|
||||
BGS metadata, especially real-game gallery, achievements, and game-length
|
||||
labels/order with the Standard default.
|
||||
|
||||
Local result: 528 native tests passed (one existing ignored); 1,086 frontend
|
||||
tests, four gallery checks, 21 achievement checks with no artifact-dependent
|
||||
skips, and four localization-source tests passed. One full native rerun hit the
|
||||
pre-existing random-actions Tributes eligibility rejection; a subsequent complete
|
||||
workspace rerun passed without skipping or changing it. No Tributes rule changes
|
||||
are included. Svelte reports zero errors/warnings.
|
||||
|
|
|
|||
|
|
@ -46,9 +46,13 @@
|
|||
gap: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
/* The host bar stays dark in both viewer themes. Give native controls
|
||||
opaque colors so OS popup/field defaults cannot wash out the labels. */
|
||||
#preview-bar select,
|
||||
#preview-bar select option {
|
||||
color: #222;
|
||||
background: #eee;
|
||||
color-scheme: dark;
|
||||
color: #e4e8d9;
|
||||
background-color: #233d35;
|
||||
}
|
||||
#preview-bar #status {
|
||||
margin-left: auto;
|
||||
|
|
@ -94,7 +98,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="preview-bar">
|
||||
<strong>Design preview</strong
|
||||
<strong>Local engine match</strong
|
||||
><select id="seat" aria-label="Preview player">
|
||||
<option value="auto">Hotseat</option>
|
||||
<option value="0">Player 1</option>
|
||||
|
|
|
|||
4
web-client/package-lock.json
generated
4
web-client/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.219",
|
||||
"version": "0.1.220",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.219",
|
||||
"version": "0.1.220",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.11.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.219",
|
||||
"version": "0.1.220",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
"web-client/src/civilization-emblems.ts": "01b0cbf3fa77a8466532ccd73d63c1a3ddc9bbc79fc06ce7224b425322a9c9f0",
|
||||
"web-client/src/civilization-flags.ts": "cd176076bfe05b3059093b80c88596b7ae46b77898695c6c7406cbe1a3a0f78b",
|
||||
"server/src/content/civilizations.rs": "73602f3db506f3dc2dbc6de43d01179440fd3bb034c997ff209336faaef2a332",
|
||||
"web-client/package-lock.json": "23509d56dafcaa64bd51adec9d0889b07c73b73699e114e14984d06f3dfcc628",
|
||||
"web-client/package-lock.json": "6e1aa90692d42347f0e179bfdeb825efa2726405556ce9d3fa02779104309a4c",
|
||||
"web-client/node_modules/lucide-svelte/dist/Icon.svelte": "f7b49ab842c143fa680fa8bd9a54a9efdc48c2e2d49fa574bd5ccf8f6cfca5be",
|
||||
"web-client/node_modules/lucide-svelte/dist/defaultAttributes.js": "5b8981c6e3434ae6538716af9e0403554e7708c4087f18d060950a7bef00d96a",
|
||||
"web-client/node_modules/lucide-svelte/LICENSE": "668dcc52803480e0a026b31140a4cae668772663cd764e5991d252eef03f98db"
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
"missing": []
|
||||
},
|
||||
"optional": {
|
||||
"completed": 15,
|
||||
"total": 28,
|
||||
"percent": 54,
|
||||
"completed": 17,
|
||||
"total": 30,
|
||||
"percent": 57,
|
||||
"missing": [
|
||||
"presenceChanged",
|
||||
"phase",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-server",
|
||||
"version": "0.4.152",
|
||||
"version": "0.4.153",
|
||||
"description": "Clash of Cultures: Monumental edition engine for Boardgamers Space",
|
||||
"license": "MIT",
|
||||
"type": "commonjs",
|
||||
|
|
|
|||
61
web-client/scripts/local-host-smoke.mjs
Normal file
61
web-client/scripts/local-host-smoke.mjs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { chromium } from 'playwright';
|
||||
const base = process.env.CLASH_PREVIEW_URL ?? 'http://localhost:8679';
|
||||
assert.ok(['localhost', '127.0.0.1'].includes(new URL(base).hostname), 'local preview only');
|
||||
const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] });
|
||||
const state = async () => {
|
||||
const data = await (await fetch(`${base}/api/state?seat=0`)).json();
|
||||
assert.equal(data.activeScenario, 'tactics');
|
||||
return JSON.parse(data.state);
|
||||
};
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 1400, height: 900 } });
|
||||
await page.goto(base);
|
||||
await page.locator('#scenario option[value="tactics"]').waitFor({ state: 'attached' });
|
||||
await page.locator('#scenario').selectOption('tactics');
|
||||
const steel = page.frameLocator('iframe').getByRole('region', { name: 'Steel Weapons', exact: true });
|
||||
await steel.waitFor();
|
||||
const initial = await state();
|
||||
for (const theme of ['light', 'dark']) {
|
||||
if (theme === 'dark') await page.locator('#theme').click();
|
||||
for (const selector of ['#seat', '#scenario', '#seat option', '#scenario option']) {
|
||||
const styles = await page
|
||||
.locator(selector)
|
||||
.first()
|
||||
.evaluate((el) => {
|
||||
const s = getComputedStyle(el);
|
||||
return [s.color, s.backgroundColor, s.colorScheme, s.opacity];
|
||||
});
|
||||
assert.deepEqual(styles, ['rgb(228, 232, 217)', 'rgb(35, 61, 53)', 'dark', '1']);
|
||||
}
|
||||
await page.screenshot({ path: `/tmp/clash-local-host-${theme}.png` });
|
||||
}
|
||||
await steel.getByRole('button', { name: 'Gold', exact: false }).click();
|
||||
await steel.getByRole('button', { name: 'Confirm', exact: true }).click();
|
||||
await steel.waitFor({ state: 'hidden' });
|
||||
assert.equal((await state()).players[0].resources.gold, initial.players[0].resources.gold - 1);
|
||||
const game = page.frameLocator('iframe');
|
||||
const tactics = game.getByRole('region', { name: 'Tactics', exact: true });
|
||||
await tactics.getByRole('button', { name: 'Select Routing', exact: true }).click();
|
||||
await tactics.getByRole('button', { name: 'Queue tactics', exact: true }).click();
|
||||
await page.waitForTimeout(300);
|
||||
assert.equal((await state()).early_choices.length, 1);
|
||||
await page.locator('#restart-scenario').click();
|
||||
await steel.waitFor();
|
||||
const restarted = await state();
|
||||
for (const key of ['players', 'events', 'early_choices', 'actions_left'])
|
||||
assert.deepEqual(restarted[key], initial[key], key);
|
||||
assert.equal(restarted.early_choices?.length ?? 0, 0);
|
||||
const fresh = await browser.newPage();
|
||||
await fresh.goto(base);
|
||||
await fresh.waitForFunction(
|
||||
() =>
|
||||
document.querySelector('#scenario')?.value === 'tactics' &&
|
||||
!document.querySelector('#restart-scenario')?.disabled,
|
||||
);
|
||||
console.log(
|
||||
'Host select contrast in both themes; Steel fixture selection, payment/restart and fresh-tab restart passed.',
|
||||
);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
|
|
@ -14,10 +14,12 @@ export function previewApi(): Plugin {
|
|||
fileURLToPath(new URL('../.engine/preview-state.json', import.meta.url));
|
||||
let state: string;
|
||||
let revision = 0;
|
||||
let activeScenario: string | null = null;
|
||||
let messages: any[] = [];
|
||||
let readAt: Record<string, number> = {};
|
||||
const persist = () => writeFileSync(save, JSON.stringify({ state, revision, messages, readAt }));
|
||||
const persist = () => writeFileSync(save, JSON.stringify({ state, revision, messages, readAt, activeScenario }));
|
||||
const reset = async () => {
|
||||
activeScenario = null;
|
||||
state = await engine.init(2, [], { civilization: 'Random' }, 'clash-preview-20260927', {});
|
||||
for (let i = 0; i < 2; i++)
|
||||
state = engine.setPlayerMetaData(state, i, { name: ['Leif', 'Aurelia'][i] });
|
||||
|
|
@ -30,6 +32,7 @@ export function previewApi(): Plugin {
|
|||
if (existsSync(save)) {
|
||||
const saved = JSON.parse(readFileSync(save, 'utf8'));
|
||||
state = saved.state;
|
||||
activeScenario = saved.activeScenario ?? null;
|
||||
revision = saved.revision;
|
||||
messages = saved.messages;
|
||||
readAt = saved.readAt ?? {};
|
||||
|
|
@ -98,6 +101,7 @@ export function previewApi(): Plugin {
|
|||
if (req.method !== 'POST') { res.end(JSON.stringify(previewScenarios)); return; }
|
||||
const scenario = await createPreviewScenario(engine, body.id);
|
||||
state = scenario.state;
|
||||
activeScenario = body.id;
|
||||
revision++;
|
||||
messages = []; readAt = {};
|
||||
persist();
|
||||
|
|
@ -161,6 +165,7 @@ export function previewApi(): Plugin {
|
|||
settings: seat === undefined ? null : engine.playerSettings(state, seat),
|
||||
seat,
|
||||
revision,
|
||||
activeScenario,
|
||||
messages,
|
||||
lastReadAt: readAt[String(seat)] ?? 0,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { readFileSync } from 'node:fs';
|
||||
|
||||
export const previewScenarios = [
|
||||
{ id: 'tactics', label: 'Tactics · Steel Weapons', note: 'Local engine match. Queue tactics privately, then switch seats to resolve Steel Weapons and play the battle.' },
|
||||
{ id: 'advance', label: 'Free advance', note: 'Research lets you save an early choice.' },
|
||||
{ id: 'raze', label: 'Raze city', note: 'Cities lets you save an early choice.' },
|
||||
{ id: 'objectives-before', label: 'Objectives · during turn', note: 'Queue in Objectives now; conditions are checked again before scoring.' },
|
||||
|
|
@ -13,7 +14,7 @@ export const previewScenarios = [
|
|||
export async function createPreviewScenario(engine: any, id: string) {
|
||||
if (!previewScenarios.some(s => s.id === id)) throw Error('Unknown preview scenario');
|
||||
const names: Record<string, string> = {
|
||||
advance: 'status_phase/free_advance', raze: 'status_phase/raze_city_decline',
|
||||
tactics: 'tactics_cards/peltasts', advance: 'status_phase/free_advance', raze: 'status_phase/raze_city_decline',
|
||||
'objectives-before': 'objective_cards/status_phase/standing_army', objectives: 'objective_cards/status_phase/standing_army', person: 'incidents/pirates_spawn',
|
||||
government: 'status_phase/change_government', first: 'status_phase/change_government',
|
||||
};
|
||||
|
|
@ -28,12 +29,24 @@ export async function createPreviewScenario(engine: any, id: string) {
|
|||
game.action_cards_left = game.action_cards_left?.filter((card: number) => ![7, 9, 17].includes(card));
|
||||
}
|
||||
if (id === 'government' || id === 'first') { game.players[1].advances = [...game.players[0].advances]; game.players[0].resources.mood_tokens = 6; }
|
||||
if (id === 'tactics') {
|
||||
delete game.dice_roll_outcomes;
|
||||
delete game.dice_roll_log;
|
||||
for (const p of game.players.slice(0, 2)) {
|
||||
p.advances = [...new Set([...p.advances, 'Tactics', 'SteelWeapons'])];
|
||||
p.resources.ore = 4; p.resources.gold = 3;
|
||||
}
|
||||
game.players[0].action_cards = [3, 6, 11];
|
||||
game.players[1].action_cards = [4, 7, 23];
|
||||
game.action_cards_left = game.action_cards_left?.filter((card: number) => ![3, 6, 11, 4, 7, 23].includes(card));
|
||||
}
|
||||
let state = JSON.stringify(game);
|
||||
const apply = (action: unknown) => { state = engine.tryMove(state, JSON.stringify(action), engine.currentPlayer(state)); };
|
||||
if (id === 'tactics') apply({ Movement: { Move: { units: [0, 1, 2], destination: 'C1', payment: {} } } });
|
||||
if (id === 'advance' || id === 'objectives') apply({ Playing: 'EndTurn' });
|
||||
if (id === 'government' || id === 'first') apply({ Response: { SelectPositions: [] } });
|
||||
if (id === 'person') for (const response of [{ SelectAdvance: 'Storage' }, { SelectPositions: ['A2'] }, { SelectPositions: ['D1'] }, { Payment: [{ food: 1 }] }]) apply({ Response: response });
|
||||
const seat = id === 'objectives-before' ? 1 : 1 - engine.currentPlayer(state);
|
||||
const seat = id === 'tactics' ? 0 : id === 'objectives-before' ? 1 : 1 - engine.currentPlayer(state);
|
||||
// Check the fixture can be rendered from both seats before replacing the preview.
|
||||
for (const player of [0, 1]) engine.webView(engine.stripSecret(state, player), player);
|
||||
return { state, seat };
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ try {
|
|||
assert(await panel.evaluate((el) => el.scrollWidth <= el.clientWidth + 1));
|
||||
if (width < 760) {
|
||||
const bounds = await panel.boundingBox();
|
||||
assert(bounds.height <= 400 && bounds.height < height * 0.6);
|
||||
assert(bounds.y >= 100 && bounds.y + bounds.height <= height - 55);
|
||||
assert(bounds.height < height - 76);
|
||||
assert(bounds.y >= 60 && bounds.y + bounds.height <= height - 55);
|
||||
assert((await play.boundingBox()).width < 170);
|
||||
}
|
||||
await play.scrollIntoViewIfNeeded();
|
||||
|
|
|
|||
93
web-client/scripts/tactics-queue-smoke.mjs
Normal file
93
web-client/scripts/tactics-queue-smoke.mjs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { chromium } from 'playwright';
|
||||
const base = process.env.CLASH_PREVIEW_URL ?? 'http://localhost:8679';
|
||||
const browser = await chromium.launch({
|
||||
headless: true,
|
||||
args: ['--no-sandbox', '--use-gl=angle', '--use-angle=swiftshader'],
|
||||
});
|
||||
assert.ok(['localhost', '127.0.0.1'].includes(new URL(base).hostname), 'local preview only');
|
||||
const state = async (seat) => await (await fetch(`${base}/api/state?seat=${seat}`)).json();
|
||||
try {
|
||||
for (const [width, height] of [
|
||||
[1400, 900],
|
||||
[390, 740],
|
||||
[320, 640],
|
||||
]) {
|
||||
await fetch(`${base}/api/scenarios`, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ id: 'tactics' }),
|
||||
});
|
||||
const page = await browser.newPage({ viewport: { width, height } });
|
||||
const errors = [];
|
||||
page.on('pageerror', (e) => errors.push(e.message));
|
||||
await page.goto(`${base}/?built`);
|
||||
await page.locator('#seat').selectOption('0');
|
||||
const game = page.frameLocator('iframe');
|
||||
const panel = game.getByRole('region', { name: 'Steel Weapons', exact: true });
|
||||
await panel.waitFor();
|
||||
assert.equal(await panel.locator('.tactics-queue').count(), 0);
|
||||
assert.equal(await game.getByRole('region', { name: 'Choose ahead', exact: true }).count(), 0);
|
||||
await page.screenshot({ path: `/tmp/clash-tactics-steel-${width}.png` });
|
||||
await panel.getByRole('button', { name: 'Gold', exact: false }).click();
|
||||
const before = JSON.parse((await state(0)).state);
|
||||
await panel.getByRole('button', { name: 'Confirm', exact: true }).click();
|
||||
await panel.waitFor({ state: 'hidden' });
|
||||
const paid = JSON.parse((await state(0)).state);
|
||||
assert.equal(paid.players[0].resources.gold, before.players[0].resources.gold - 1);
|
||||
assert.equal(paid.players[0].resources.ore, before.players[0].resources.ore);
|
||||
const commit = async (name) => {
|
||||
const response = page.waitForResponse(
|
||||
(r) => r.url().endsWith('/api/move') && r.request().method() === 'POST',
|
||||
);
|
||||
await choices.getByRole('button', { name, exact: true }).click();
|
||||
assert.equal((await response).status(), 200);
|
||||
};
|
||||
const choices = game.getByRole('region', { name: 'Tactics', exact: true });
|
||||
await choices.waitFor();
|
||||
assert.equal(await game.getByRole('region', { name: 'Choose ahead', exact: true }).count(), 0);
|
||||
assert(await choices.evaluate((el) => el.scrollWidth <= el.clientWidth + 1));
|
||||
await page.screenshot({ path: `/tmp/clash-tactics-queue-${width}.png` });
|
||||
await choices.getByRole('button', { name: 'Select Routing', exact: true }).click();
|
||||
assert.doesNotMatch(await choices.innerText(), /Discards the selected card/);
|
||||
await commit('Queue tactics');
|
||||
await choices.getByText('Queued', { exact: true }).waitFor();
|
||||
const queued = JSON.parse((await state(0)).state);
|
||||
for (const field of ['players', 'events', 'log', 'log_index', 'board_history', 'time_increments'])
|
||||
assert.deepEqual(queued[field], paid[field], field);
|
||||
assert.equal(queued.early_choices.length, 1);
|
||||
assert.equal(JSON.parse((await state(1)).state).early_choices, undefined);
|
||||
await choices.getByRole('button', { name: 'Select High Morale', exact: true }).click();
|
||||
assert.doesNotMatch(await choices.innerText(), /Discards the selected card/);
|
||||
await commit('Queue tactics');
|
||||
await commit('Cancel queued choice');
|
||||
await choices.getByText('Queued', { exact: true }).waitFor({ state: 'hidden' });
|
||||
await commit('Skip');
|
||||
await choices.getByText('Queued', { exact: true }).waitFor();
|
||||
assert.deepEqual(JSON.parse((await state(0)).state).early_choices[0].response, { SelectHandCards: [] });
|
||||
await choices.getByRole('button', { name: 'Select Routing', exact: true }).click();
|
||||
assert.doesNotMatch(await choices.innerText(), /Discards the selected card/);
|
||||
await commit('Queue tactics');
|
||||
await choices.getByText('Queued', { exact: true }).waitFor();
|
||||
await page.locator('#seat').selectOption('1');
|
||||
await panel.waitFor({ timeout: 10000 }).catch(async (e) => {
|
||||
console.log(await page.frames()[1].locator('body').innerText(), errors);
|
||||
throw e;
|
||||
});
|
||||
await panel.getByRole('button', { name: 'Confirm', exact: true }).click();
|
||||
const tactics = game.getByRole('region', { name: 'Tactics', exact: true });
|
||||
await tactics.waitFor();
|
||||
await tactics.getByRole('button', { name: 'Select Peltasts', exact: true }).click();
|
||||
assert.doesNotMatch(await tactics.innerText(), /Discards the selected card/);
|
||||
assert.equal(await tactics.getByRole('button', { name: 'Play tactics', exact: true }).count(), 1);
|
||||
assert.equal(await tactics.locator('.tactics-queue').count(), 0, 'current prompt is not a queued choice');
|
||||
await page.screenshot({ path: `/tmp/clash-tactics-live-${width}.png` });
|
||||
assert.deepEqual(errors, []);
|
||||
await page.close();
|
||||
console.log(
|
||||
`Steel first, automatic normal tactics queue/edit/cancel, privacy and ordinary live prompt: ${width}px passed`,
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
|
|
@ -102,6 +102,7 @@
|
|||
import CollectionCapacity from './CollectionCapacity.svelte';
|
||||
import ContextualCards from './ContextualCards.svelte';
|
||||
import DecisionPanel from './DecisionPanel.svelte';
|
||||
import { queuedTacticsDecision } from './queued-tactics';
|
||||
import EarlyChoices from './EarlyChoices.svelte';
|
||||
import EarlyChoiceBadge from './EarlyChoiceBadge.svelte';
|
||||
import CombatJournal from './CombatJournal.svelte';
|
||||
|
|
@ -136,12 +137,14 @@
|
|||
const planningQueue = $derived(!!queueControls?.pending && queueControls.seat === 0);
|
||||
let earlyPanel = $state<'cities' | 'abilities' | 'first' | null>(null);
|
||||
const earlyOffers = $derived(!$session.playback ? $session.view?.earlyChoices ?? [] : []);
|
||||
const tacticsQueue = $derived(!$session.view?.decision ? earlyOffers.find(o => o.key.endsWith('/tactics')) : undefined);
|
||||
const queuedTactics = $derived(queuedTacticsDecision($session.view, tacticsQueue));
|
||||
const earlyAdvance = $derived(earlyOffers.find(o => o.key.endsWith('/advance')));
|
||||
const earlyFirst = $derived(earlyOffers.filter(o => o.key.endsWith(':first')));
|
||||
const earlyCities = $derived(earlyOffers.filter(o => o.key.endsWith('/raze')));
|
||||
const earlyObjectives = $derived(earlyOffers.filter(o => o.key.includes(':objective:')));
|
||||
const earlyPeople = $derived(earlyOffers.filter(o => o.key.endsWith('/offer')));
|
||||
const earlyAbilities = $derived(earlyOffers.filter(o => !o.key.endsWith('/advance') && !o.key.endsWith('/raze') && !o.key.includes(':objective:') && !o.key.endsWith('/offer') && !o.key.endsWith('/government') && !o.key.endsWith(':first')));
|
||||
const earlyAbilities = $derived(earlyOffers.filter(o => !o.key.endsWith('/tactics') && !o.key.endsWith('/advance') && !o.key.endsWith('/raze') && !o.key.includes(':objective:') && !o.key.endsWith('/offer') && !o.key.endsWith('/government') && !o.key.endsWith(':first')));
|
||||
const panelOffers = $derived(earlyPanel === 'cities' ? earlyCities : earlyPanel === 'abilities' ? earlyAbilities : earlyPanel === 'first' ? earlyFirst : []);
|
||||
function openEarly(panel: 'cities' | 'abilities' | 'first') {
|
||||
earlyPanel = earlyPanel === panel ? null : panel;
|
||||
|
|
@ -1895,6 +1898,9 @@
|
|||
{controller}
|
||||
decision={$session.view.decision}
|
||||
onHighlight={(position) => world?.highlightCoordinate(position)}
|
||||
/>{/key}{:else if queuedTactics && tacticsQueue}{#key `${$session.seat}:${tacticsQueue.key}`}<DecisionPanel
|
||||
{controller} decision={queuedTactics} queue={tacticsQueue}
|
||||
onHighlight={(position) => world?.highlightCoordinate(position)}
|
||||
/>{/key}{/if}
|
||||
{#if $session.abilitiesOpen && $session.mode === 'overview' && !$session.view?.decision && !choiceDecision && !objectiveDecision}<AbilitiesPanel
|
||||
{controller}
|
||||
|
|
|
|||
|
|
@ -100,4 +100,10 @@
|
|||
color: var(--muted);
|
||||
font-style: italic;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.combat-forces { padding: 6px; margin: 6px 0; }
|
||||
.combat-table { margin: 3px 0; }
|
||||
.combat-table th, .combat-table td { padding: 4px 3px; font-size: 10px; }
|
||||
.detail { font-size: 10px; line-height: 1.25; }
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
import { onDestroy } from 'svelte';
|
||||
import { untrack } from 'svelte';
|
||||
import { Check, Sparkles, Layers, BookOpen, ChevronRight, ArrowLeft, X, Zap, Wheat } from 'lucide-svelte';
|
||||
import type { TacticsQueue } from './queued-tactics';
|
||||
import type { Controller } from './controller';
|
||||
import type { Decision, Move, Pile, UnitKind } from './types';
|
||||
import { unitInfo } from './city';
|
||||
|
|
@ -33,13 +34,18 @@
|
|||
controller,
|
||||
decision,
|
||||
onHighlight,
|
||||
}: { controller: Controller; decision: Decision; onHighlight: (position: string | null) => void } =
|
||||
queue,
|
||||
}: { controller: Controller; decision: Decision; queue?: TacticsQueue; onHighlight: (position: string | null) => void } =
|
||||
$props();
|
||||
const session = $derived(controller.session);
|
||||
const announcedCard = $derived(pendingActionCard($session.view, decision));
|
||||
let announcedRulesOpen = $state(false);
|
||||
const panelId = $props.id();
|
||||
const selected = $derived($session.decisionSelection);
|
||||
let queuedSelection = $state<number[]>(untrack(() => {
|
||||
const cards = (queue?.selected as {SelectHandCards?: unknown[]} | null)?.SelectHandCards ?? [];
|
||||
return decision.options.flatMap((o, i) => cards.some(c => JSON.stringify(c) === JSON.stringify(o.value)) ? [i] : []);
|
||||
}));
|
||||
const selected = $derived(queue ? queuedSelection : $session.decisionSelection);
|
||||
const opponentTactics = $derived(opponentTacticsLabel(decision));
|
||||
const resourceChoice = $derived(decision.reward && decision.name === 'Select a resource to gain');
|
||||
const title = $derived(resourceChoice ? 'Gain resources' : printedCardName(decision.name));
|
||||
|
|
@ -133,6 +139,7 @@
|
|||
payments = payments.map((p, j) => (i === j ? payment : p));
|
||||
}
|
||||
const preview = $derived.by(() => {
|
||||
if (queue) return { action: {QueueChoice: {key: queue.key, response: {SelectHandCards: selected.map(i => decision.options[i].value)}}} as Move, error: '' };
|
||||
try {
|
||||
return {
|
||||
...controller.query<{ action: Move }>({
|
||||
|
|
@ -168,7 +175,8 @@
|
|||
return [...groups.values()].sort((a,b)=>a.order-b.order);
|
||||
});
|
||||
function toggle(i: number) {
|
||||
controller.selectDecisionOption(i);
|
||||
if (queue) queuedSelection = selected.includes(i) ? [] : [i];
|
||||
else controller.selectDecisionOption(i);
|
||||
}
|
||||
onDestroy(() => onHighlight(null));
|
||||
</script>
|
||||
|
|
@ -503,7 +511,7 @@
|
|||
Always keep cities in future ages
|
||||
</label>
|
||||
{/if}
|
||||
{#if (decision.tacticsSelection || decision.name === 'Siegecraft') && preview.action}
|
||||
{#if !queue && (decision.tacticsSelection || decision.name === 'Siegecraft') && preview.action}
|
||||
<CombatEstimate {controller} action={preview.action} />
|
||||
{/if}
|
||||
<div class="decision-footer" class:objective-exchange-footer={decision.objectiveExchange} class:map-decision-footer={mapChoice}>
|
||||
|
|
@ -523,11 +531,15 @@
|
|||
onclick={() => preview.action && selected.length === 2 && controller.submit(preview.action)}
|
||||
>Exchange objectives<Check size={16} /></button>
|
||||
{:else if decision.tacticsSelection}
|
||||
{#if selected.length}<small class="tactics-discard">Discards the selected card</small>{/if}
|
||||
<button
|
||||
class="secondary"
|
||||
disabled={$session.pending}
|
||||
onclick={() => {
|
||||
if (queue) {
|
||||
queuedSelection = [];
|
||||
controller.submit({QueueChoice: {key: queue.key, response: {SelectHandCards: []}}});
|
||||
return;
|
||||
}
|
||||
const response = controller.query<{ action: Move }>({
|
||||
kind: 'decision',
|
||||
values: [],
|
||||
|
|
@ -540,7 +552,7 @@
|
|||
class="primary"
|
||||
disabled={!preview.action || $session.pending}
|
||||
onclick={() => preview.action && controller.submit(preview.action)}
|
||||
>Play tactics<Check size={16} /></button
|
||||
>{queue ? 'Queue tactics' : 'Play tactics'}<Check size={16} /></button
|
||||
>{/if}
|
||||
{:else}
|
||||
{#if decision.options.length && !mapChoice && !firstPlayerChoice}<div class="decision-count">
|
||||
|
|
@ -561,7 +573,7 @@
|
|||
title={preview.error || 'Confirm selection'}
|
||||
onclick={() => preview.action && controller.submit(preview.action)}
|
||||
>
|
||||
{selected.length === 0 && !decision.fields.length && decision.min === 0 ? 'Skip' : tribalStopChoice ? 'Continue' : 'Confirm'}{#if tribalStopChoice && selected.length}<ResourceAmount pile={{ food: 1 }} compact />{/if}<Check
|
||||
{selected.length === 0 && !decision.fields.length && decision.min === 0 ? 'Skip' : queue ? 'Queue tactics' : tribalStopChoice ? 'Continue' : 'Confirm'}{#if tribalStopChoice && selected.length}<ResourceAmount pile={{ food: 1 }} compact />{/if}<Check
|
||||
size={16}
|
||||
/>
|
||||
</button>
|
||||
|
|
@ -571,6 +583,7 @@
|
|||
</p>{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if queue?.selected}<div class="choice-row"><span role="status">Queued</span><button disabled={$session.pending} onclick={() => { queuedSelection = []; controller.submit({QueueChoice: {key: queue!.key, response: null}}); }}>Cancel queued choice</button></div>{/if}
|
||||
{#if $session.error}<p class="inline-error" role="alert">{$session.error}</p>{/if}
|
||||
</section>
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,12 @@ async function refresh(force = false) {
|
|||
const response = await fetch(`/api/state?seat=${seatSelect.value}`);
|
||||
const data = await response.json();
|
||||
if (!response.ok) throw Error(data.error);
|
||||
// The persisted local engine, not a tab's session, owns the active fixture.
|
||||
const activeScenario = scenarios.find(s => s.id === data.activeScenario);
|
||||
scenarioSelect.value = activeScenario?.id ?? '';
|
||||
restartScenario.disabled = !activeScenario;
|
||||
scenarioNote.textContent = activeScenario?.note ?? '';
|
||||
scenarioNote.style.display = activeScenario ? 'block' : 'none';
|
||||
if (force || data.revision !== revision || data.seat !== seat) {
|
||||
revision = data.revision;
|
||||
seat = data.seat;
|
||||
|
|
@ -202,9 +208,7 @@ let scenarios: {id: string; label: string; note: string}[] = [];
|
|||
fetch('/api/scenarios').then(r => r.json()).then(data => {
|
||||
scenarios = data;
|
||||
for (const item of scenarios) scenarioSelect.add(new Option(item.label, item.id));
|
||||
const remembered = sessionStorage.getItem('clash-preview-scenario');
|
||||
const scenario = scenarios.find(s => s.id === remembered);
|
||||
if (scenario) { scenarioSelect.value = scenario.id; restartScenario.disabled = false; scenarioNote.textContent = scenario.note; scenarioNote.style.display = 'block'; }
|
||||
void refresh(true);
|
||||
});
|
||||
async function loadScenario() {
|
||||
if (!scenarioSelect.value) return;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Sæt taktik i kø",
|
||||
"Queued": "I kø",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Stålvåben afventer: +{p0} værdi hvis aktiveret",
|
||||
"No tactics": "Ingen taktik",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Vælg en anden spiller. I kan ikke angribe hinanden, medmindre angriberen betaler forsvareren 2 kulturpoletter. Kassér dette kort, hvis en af spillerne angriber den anden. Du kan kassere kortet som en almindelig handling.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Vælg en anden spiller. I kan ikke angribe hinanden, medmindre angriberen betaler forsvareren 2 kulturpoletter. Kassér dette kort, hvis en af spillerne angriber den anden. Du kan kassere kortet som en almindelig handling.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Straks efter at have bygget spillets første vidunder, eller i statusfasen hvis du var den eneste spiller, der byggede vidundere i sidste runde.",
|
||||
|
|
@ -1021,7 +1025,6 @@
|
|||
"Discard {p0} at {p1}": "Kassér {p0} ved {p1}",
|
||||
"Discard {p0} for recruitment": "Kassér {p0} til rekruttering",
|
||||
"Discarded card rules": "Regler for det kasserede kort",
|
||||
"Discards the selected card": "Kasserer det valgte kort",
|
||||
"Disembark": "Gå i land",
|
||||
"Disembark the Settler to found a city": "Sæt Nybyggeren i land for at grundlægge en by",
|
||||
"Disembark units": "Gå i land med enheder",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Taktik vormerken",
|
||||
"Queued": "Vorgemerkt",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Stahlwaffen ausstehend: +{p0} Wert bei Aktivierung",
|
||||
"No tactics": "Keine Taktik",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Wähle einen anderen Spieler. Ihr könnt euch nicht gegenseitig angreifen, es sei denn, der Angreifer zahlt dem Verteidiger 2 Kulturmarker. Lege diese Karte ab, falls ein Spieler den anderen angreift. Du darfst die Karte als reguläre Aktion ablegen.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Wähle einen anderen Spieler. Ihr könnt euch nicht gegenseitig angreifen, es sei denn, der Angreifer zahlt dem Verteidiger 2 Kulturmarker. Lege diese Karte ab, falls ein Spieler den anderen angreift. Du darfst die Karte als reguläre Aktion ablegen.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Sofort nach dem Bau des ersten Weltwunders im Spiel oder in der Statusphase, wenn nur du in der letzten Runde Weltwunder gebaut hast.",
|
||||
|
|
@ -1021,7 +1025,6 @@
|
|||
"Discard {p0} at {p1}": "{p0} bei {p1} abwerfen",
|
||||
"Discard {p0} for recruitment": "{p0} für Rekrutierung abwerfen",
|
||||
"Discarded card rules": "Regeln der abgeworfenen Karte",
|
||||
"Discards the selected card": "Wirft die gewählte Karte ab",
|
||||
"Disembark": "Anlanden",
|
||||
"Disembark the Settler to found a city": "Lass den Siedler an Land gehen, um eine Stadt zu gründen",
|
||||
"Disembark units": "Einheiten ausschiffen",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Προγραμμάτισε τακτική",
|
||||
"Queued": "Προγραμματίστηκε",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Εκκρεμούν ατσάλινα όπλα: +{p0} αξία αν ενεργοποιηθούν",
|
||||
"No tactics": "Χωρίς τακτική",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Επίλεξε άλλον παίκτη. Δεν μπορείτε να επιτεθείτε ο ένας στον άλλον, εκτός αν ο επιτιθέμενος πληρώσει στον αμυνόμενο 2 μάρκες πολιτισμού. Απόρριψε αυτή την κάρτα αν κάποιος παίκτης επιτεθεί στον άλλον. Μπορείς να απορρίψεις την κάρτα ως κανονική ενέργεια.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Επίλεξε άλλον παίκτη. Δεν μπορείτε να επιτεθείτε ο ένας στον άλλον, εκτός αν ο επιτιθέμενος πληρώσει στον αμυνόμενο 2 μάρκες πολιτισμού. Απόρριψε αυτή την κάρτα αν κάποιος παίκτης επιτεθεί στον άλλον. Μπορείς να απορρίψεις την κάρτα ως κανονική ενέργεια.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Αμέσως μετά την κατασκευή του πρώτου Θαύματος στο παιχνίδι, ή στη Φάση Κατάστασης αν ήσουν ο μόνος παίκτης που κατασκεύασε Θαύματα στον τελευταίο γύρο.",
|
||||
|
|
@ -1031,7 +1035,6 @@
|
|||
"Discard {p0} at {p1}": "Απόρριψη {p0} στο {p1}",
|
||||
"Discard {p0} for recruitment": "Απόρριψη {p0} για στρατολόγηση",
|
||||
"Discarded card rules": "Κανόνες απορριφθείσας κάρτας",
|
||||
"Discards the selected card": "Απορρίπτει την επιλεγμένη κάρτα",
|
||||
"Disembark": "Αποβίβαση",
|
||||
"Disembark the Settler to found a city": "Αποβίβασε τον Άποικο για να ιδρύσεις πόλη",
|
||||
"Disembark units": "Αποβίβαση μονάδων",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Queue tactics",
|
||||
"Queued": "Queued",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Steel Weapons pending: +{p0} value if activated",
|
||||
"No tactics": "No tactics",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.",
|
||||
|
|
@ -1500,7 +1504,6 @@
|
|||
"Discard an action card to cancel another player's non-combat action card when their units or cities are within 2 spaces of your cities or armies. The cancelled card is discarded; its costs are not paid.": "Discard an action card to cancel another player's non-combat action card when their units or cities are within 2 spaces of your cities or armies. The cancelled card is discarded; its costs are not paid.",
|
||||
"Discard Pile": "Discard Pile",
|
||||
"Discarded card rules": "Discarded card rules",
|
||||
"Discards the selected card": "Discards the selected card",
|
||||
"discount cannot rebate culture": "discount cannot rebate culture",
|
||||
"discount cannot rebate mood": "discount cannot rebate mood",
|
||||
"discount must be used": "discount must be used",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "تاکتیک را در صف بگذار",
|
||||
"Queued": "در صف",
|
||||
"Steel Weapons pending: +{p0} value if activated": "سلاحهای فولادی در انتظار: +{p0} قدرت در صورت فعالسازی",
|
||||
"No tactics": "بدون تاکتیک",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "بازیکن دیگری انتخاب کنید. مگر با پرداخت ۲ نشان فرهنگ از مهاجم به مدافع، به هم حمله نمیکنید. اگر یکی حمله کرد، این کارت را دور بیندازید. میتوانید با اقدام عادی هم کارت را دور بیندازید.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} بازیکن دیگری انتخاب کنید. مگر با پرداخت ۲ نشان فرهنگ از مهاجم به مدافع، به هم حمله نمیکنید. اگر یکی حمله کرد، این کارت را دور بیندازید. میتوانید با اقدام عادی هم کارت را دور بیندازید.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "بلافاصله پس از ساخت نخستین شگفتی بازی، یا در مرحله وضعیت اگر تنها بازیکنی بودید که در دور گذشته شگفتی ساخته است.",
|
||||
|
|
@ -1031,7 +1035,6 @@
|
|||
"Discard {p0} at {p1}": "حذف {p0} در {p1}",
|
||||
"Discard {p0} for recruitment": "حذف {p0} برای جذب نیرو",
|
||||
"Discarded card rules": "قوانین کارت دورریختهشده",
|
||||
"Discards the selected card": "کارت انتخابشده را دور میاندازد",
|
||||
"Disembark": "پیاده شدن",
|
||||
"Disembark the Settler to found a city": "برای بنای شهر، مهاجر را از کشتی پیاده کنید",
|
||||
"Disembark units": "پیادهکردن واحدها",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Préparer la tactique",
|
||||
"Queued": "En attente",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Armes en acier en attente : +{p0} en valeur si activées",
|
||||
"No tactics": "Aucune tactique",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Choisir un autre joueur. Vous ne pouvez pas vous attaquer, sauf si l’attaquant paie 2 jetons de culture au défenseur. Défaussez cette carte si l'un des joueurs attaque l'autre. Vous pouvez défausser la carte comme action normale.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Choisir un autre joueur. Vous ne pouvez pas vous attaquer, sauf si l’attaquant paie 2 jetons de culture au défenseur. Défaussez cette carte si l'un des joueurs attaque l'autre. Vous pouvez défausser la carte comme action normale.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Immédiatement après avoir construit la première Merveille de la partie, ou en phase de statut si vous êtes le seul joueur à avoir construit des Merveilles lors de la dernière manche.",
|
||||
|
|
@ -1021,7 +1025,6 @@
|
|||
"Discard {p0} at {p1}": "Défausser {p0} à {p1}",
|
||||
"Discard {p0} for recruitment": "Défausser {p0} pour le recrutement",
|
||||
"Discarded card rules": "Règles de la carte défaussée",
|
||||
"Discards the selected card": "Défausse la carte sélectionnée",
|
||||
"Disembark": "Débarquer",
|
||||
"Disembark the Settler to found a city": "Débarquez le Colon pour fonder une ville",
|
||||
"Disembark units": "Débarquer des unités",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "रणनीति कतार में रखें",
|
||||
"Queued": "कतार में",
|
||||
"Steel Weapons pending: +{p0} value if activated": "इस्पात हथियार लंबित: सक्रिय होने पर +{p0} मूल्य",
|
||||
"No tactics": "कोई रणनीति नहीं",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "दूसरा खिलाड़ी चुनें। आप एक-दूसरे पर हमला नहीं कर सकते, जब तक कि हमलावर रक्षक को 2 संस्कृति टोकन का भुगतान न करे। यदि कोई भी खिलाड़ी दूसरे पर हमला करता है तो यह कार्ड त्याग दें। आप नियमित क्रिया के रूप में कार्ड त्याग सकते हैं।",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} दूसरा खिलाड़ी चुनें। आप एक-दूसरे पर हमला नहीं कर सकते, जब तक कि हमलावर रक्षक को 2 संस्कृति टोकन का भुगतान न करे। यदि कोई भी खिलाड़ी दूसरे पर हमला करता है तो यह कार्ड त्याग दें। आप नियमित क्रिया के रूप में कार्ड त्याग सकते हैं।",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "खेल का पहला अजूबा बनाने के तुरंत बाद, या स्थिति चरण में यदि पिछले दौर में केवल आपने अजूबे बनाए थे।",
|
||||
|
|
@ -956,7 +960,6 @@
|
|||
"Discard {p0} at {p1}": "{p1} पर {p0} त्यागें",
|
||||
"Discard {p0} for recruitment": "भर्ती के लिए {p0} त्यागें",
|
||||
"Discarded card rules": "त्यागे गए कार्ड के नियम",
|
||||
"Discards the selected card": "चुने हुए कार्ड को त्यागता है",
|
||||
"Disembark": "उतरें",
|
||||
"Disembark the Settler to found a city": "नगर बसाने के लिए बसने वाले को जहाज़ से उतारें",
|
||||
"Disembark units": "इकाइयाँ उतारें",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Prepara tattica",
|
||||
"Queued": "In attesa",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Armi d’acciaio in attesa: +{p0} al valore se attivate",
|
||||
"No tactics": "Nessuna tattica",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Scegli un altro giocatore. Non potete attaccarvi a vicenda, a meno che l'attaccante non paghi 2 segnalini cultura al difensore. Scarta questa carta se uno dei due giocatori attacca l'altro. Puoi scartare la carta come azione regolare.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Scegli un altro giocatore. Non potete attaccarvi a vicenda, a meno che l'attaccante non paghi 2 segnalini cultura al difensore. Scarta questa carta se uno dei due giocatori attacca l'altro. Puoi scartare la carta come azione regolare.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Subito dopo aver costruito la prima Meraviglia della partita, oppure nella fase di stato se sei stato l'unico giocatore a costruire Meraviglie nell'ultimo round.",
|
||||
|
|
@ -1021,7 +1025,6 @@
|
|||
"Discard {p0} at {p1}": "Scarta {p0} a {p1}",
|
||||
"Discard {p0} for recruitment": "Scarta {p0} per il reclutamento",
|
||||
"Discarded card rules": "Regole della carta scartata",
|
||||
"Discards the selected card": "Scarta la carta selezionata",
|
||||
"Disembark": "Sbarca",
|
||||
"Disembark the Settler to found a city": "Sbarca il Colono per fondare una città",
|
||||
"Disembark units": "Sbarca le unità",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "전술 예약",
|
||||
"Queued": "예약됨",
|
||||
"Steel Weapons pending: +{p0} value if activated": "강철 무기 대기 중: 활성화 시 전투력 +{p0}",
|
||||
"No tactics": "전술 없음",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "다른 플레이어를 선택하세요. 공격자가 방어자에게 문화 토큰 2개를 지불하지 않으면 서로 공격할 수 없습니다. 어느 플레이어가 다른 플레이어를 공격하면 이 카드를 버립니다. 일반 행동으로 카드를 버릴 수 있습니다.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} 다른 플레이어를 선택하세요. 공격자가 방어자에게 문화 토큰 2개를 지불하지 않으면 서로 공격할 수 없습니다. 어느 플레이어가 다른 플레이어를 공격하면 이 카드를 버립니다. 일반 행동으로 카드를 버릴 수 있습니다.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "게임의 첫 불가사의를 건설한 직후, 또는 지난 라운드에 불가사의를 건설한 유일한 플레이어라면 상태 단계에 달성합니다.",
|
||||
|
|
@ -956,7 +960,6 @@
|
|||
"Discard {p0} at {p1}": "{p1}에서 {p0} 제거",
|
||||
"Discard {p0} for recruitment": "모집을 위해 {p0} 제거",
|
||||
"Discarded card rules": "버린 카드 규칙",
|
||||
"Discards the selected card": "선택한 카드를 버립니다",
|
||||
"Disembark": "하선",
|
||||
"Disembark the Settler to found a city": "도시를 세우려면 개척자를 하선시키세요",
|
||||
"Disembark units": "유닛 하선",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Tactiek klaarzetten",
|
||||
"Queued": "Klaargezet",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Stalen wapens in afwachting: +{p0} waarde indien geactiveerd",
|
||||
"No tactics": "Geen tactiek",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Kies een andere speler. Jullie kunnen elkaar niet aanvallen, tenzij de aanvaller de verdediger 2 cultuurfiches betaalt. Leg deze kaart af als een van beide spelers de ander aanvalt. Je mag de kaart afleggen als een gewone actie.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Kies een andere speler. Jullie kunnen elkaar niet aanvallen, tenzij de aanvaller de verdediger 2 cultuurfiches betaalt. Leg deze kaart af als een van beide spelers de ander aanvalt. Je mag de kaart afleggen als een gewone actie.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Direct na het bouwen van het eerste wereldwonder in het spel, of in de statusfase als jij de enige speler was die in de laatste ronde wereldwonderen bouwde.",
|
||||
|
|
@ -1021,7 +1025,6 @@
|
|||
"Discard {p0} at {p1}": "{p0} op {p1} afleggen",
|
||||
"Discard {p0} for recruitment": "{p0} afleggen voor rekrutering",
|
||||
"Discarded card rules": "Regels van de afgelegde kaart",
|
||||
"Discards the selected card": "Legt de geselecteerde kaart af",
|
||||
"Disembark": "Ontschepen",
|
||||
"Disembark the Settler to found a city": "Laat de Kolonist aan land gaan om een stad te stichten",
|
||||
"Disembark units": "Eenheden ontschepen",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Zaplanuj taktykę",
|
||||
"Queued": "Zaplanowano",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Broń stalowa oczekuje: +{p0} wartości po aktywacji",
|
||||
"No tactics": "Bez taktyki",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Wybierz innego gracza. Nie możecie się atakować, chyba że atakujący zapłaci obrońcy 2 żetony kultury. Odrzuć tę kartę, jeśli którykolwiek gracz zaatakuje drugiego. Możesz odrzucić kartę jako zwykłą akcję.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Wybierz innego gracza. Nie możecie się atakować, chyba że atakujący zapłaci obrońcy 2 żetony kultury. Odrzuć tę kartę, jeśli którykolwiek gracz zaatakuje drugiego. Możesz odrzucić kartę jako zwykłą akcję.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Natychmiast po zbudowaniu pierwszego cudu w grze lub w fazie statusu, jeśli tylko ty zbudowałeś cuda w ostatniej rundzie.",
|
||||
|
|
@ -1031,7 +1035,6 @@
|
|||
"Discard {p0} at {p1}": "Odrzuć {p0} na {p1}",
|
||||
"Discard {p0} for recruitment": "Odrzuć {p0} do rekrutacji",
|
||||
"Discarded card rules": "Zasady odrzuconej karty",
|
||||
"Discards the selected card": "Odrzuca wybraną kartę",
|
||||
"Disembark": "Zejdź na ląd",
|
||||
"Disembark the Settler to found a city": "Wyładuj Osadnika, aby założyć miasto",
|
||||
"Disembark units": "Wyokrętuj jednostki",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Preparar tática",
|
||||
"Queued": "Na fila",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Armas de aço pendentes: +{p0} de valor se ativadas",
|
||||
"No tactics": "Sem tática",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Escolha outro jogador. Vocês não podem atacar um ao outro, a menos que o atacante pague 2 fichas de cultura ao defensor. Descarte esta carta se qualquer jogador atacar o outro. Você pode descartar a carta como uma ação regular.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Escolha outro jogador. Vocês não podem atacar um ao outro, a menos que o atacante pague 2 fichas de cultura ao defensor. Descarte esta carta se qualquer jogador atacar o outro. Você pode descartar a carta como uma ação regular.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Imediatamente após construir a primeira Maravilha da partida, ou na fase de status se você foi o único jogador a construir Maravilhas na última rodada.",
|
||||
|
|
@ -1031,7 +1035,6 @@
|
|||
"Discard {p0} at {p1}": "Descartar {p0} em {p1}",
|
||||
"Discard {p0} for recruitment": "Descartar {p0} para recrutar",
|
||||
"Discarded card rules": "Regras da carta descartada",
|
||||
"Discards the selected card": "Descarta a carta selecionada",
|
||||
"Disembark": "Desembarcar",
|
||||
"Disembark the Settler to found a city": "Desembarque o Colono para fundar uma cidade",
|
||||
"Disembark units": "Desembarcar unidades",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Pregătește tactica",
|
||||
"Queued": "În așteptare",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Arme de oțel în așteptare: +{p0} valoare dacă sunt activate",
|
||||
"No tactics": "Fără tactică",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Alege alt jucător. Nu vă puteți ataca reciproc, decât dacă atacatorul plătește apărătorului 2 jetoane de cultură. Aruncă această carte dacă oricare jucător îl atacă pe celălalt. Poți arunca cartea ca acțiune obișnuită.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Alege alt jucător. Nu vă puteți ataca reciproc, decât dacă atacatorul plătește apărătorului 2 jetoane de cultură. Aruncă această carte dacă oricare jucător îl atacă pe celălalt. Poți arunca cartea ca acțiune obișnuită.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Imediat după construirea primei Minuni din joc sau în faza de statut dacă ai fost singurul jucător care a construit Minuni în ultima rundă.",
|
||||
|
|
@ -1031,7 +1035,6 @@
|
|||
"Discard {p0} at {p1}": "Elimină {p0} la {p1}",
|
||||
"Discard {p0} for recruitment": "Elimină {p0} pentru recrutare",
|
||||
"Discarded card rules": "Regulile cărții decartate",
|
||||
"Discards the selected card": "Decartează cartea aleasă",
|
||||
"Disembark": "Debarcă",
|
||||
"Disembark the Settler to found a city": "Debarcă Colonistul pentru a întemeia un oraș",
|
||||
"Disembark units": "Debarcă unități",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Запланировать тактику",
|
||||
"Queued": "Запланировано",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Стальное оружие ожидает решения: +{p0} к силе при активации",
|
||||
"No tactics": "Без тактики",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Выберите другого игрока. Вы не можете атаковать друг друга, если атакующий не заплатит защитнику 2 жетона культуры. Сбросьте эту карту, если один из игроков атакует другого. Вы можете сбросить карту как обычное действие.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Выберите другого игрока. Вы не можете атаковать друг друга, если атакующий не заплатит защитнику 2 жетона культуры. Сбросьте эту карту, если один из игроков атакует другого. Вы можете сбросить карту как обычное действие.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Сразу после постройки первого чуда в игре или в фазе статуса, если только вы строили чудеса в последнем раунде.",
|
||||
|
|
@ -1031,7 +1035,6 @@
|
|||
"Discard {p0} at {p1}": "Убрать {p0} в {p1}",
|
||||
"Discard {p0} for recruitment": "Убрать {p0} для найма",
|
||||
"Discarded card rules": "Правила сброшенной карты",
|
||||
"Discards the selected card": "Сбрасывает выбранную карту",
|
||||
"Disembark": "Высадиться",
|
||||
"Disembark the Settler to found a city": "Высадите Поселенца, чтобы основать город",
|
||||
"Disembark units": "Высадить отряды",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "Xếp chiến thuật vào hàng đợi",
|
||||
"Queued": "Đã xếp hàng",
|
||||
"Steel Weapons pending: +{p0} value if activated": "Vũ khí thép đang chờ: +{p0} giá trị nếu kích hoạt",
|
||||
"No tactics": "Không dùng chiến thuật",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "Chọn người chơi khác. Các bạn không thể tấn công nhau, trừ khi người tấn công trả cho người phòng thủ 2 token văn hóa. Loại bỏ thẻ này nếu một trong hai người chơi tấn công người kia. Bạn có thể loại bỏ thẻ như một hành động thường.",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} Chọn người chơi khác. Các bạn không thể tấn công nhau, trừ khi người tấn công trả cho người phòng thủ 2 token văn hóa. Loại bỏ thẻ này nếu một trong hai người chơi tấn công người kia. Bạn có thể loại bỏ thẻ như một hành động thường.",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "Ngay sau khi xây Kỳ quan đầu tiên của ván chơi, hoặc trong giai đoạn trạng thái nếu bạn là người duy nhất xây Kỳ quan trong vòng vừa qua.",
|
||||
|
|
@ -956,7 +960,6 @@
|
|||
"Discard {p0} at {p1}": "Loại bỏ {p0} tại {p1}",
|
||||
"Discard {p0} for recruitment": "Loại bỏ {p0} để tuyển quân",
|
||||
"Discarded card rules": "Luật lá bài đã bỏ",
|
||||
"Discards the selected card": "Bỏ lá bài đã chọn",
|
||||
"Disembark": "Lên bờ",
|
||||
"Disembark the Settler to found a city": "Cho Người định cư lên bờ để lập thành phố",
|
||||
"Disembark units": "Cho quân lên bờ",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "预选战术",
|
||||
"Queued": "已预选",
|
||||
"Steel Weapons pending: +{p0} value if activated": "钢制武器待决定:激活后战斗值+{p0}",
|
||||
"No tactics": "不使用战术",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "选择另一位玩家。除非攻击方向防守方支付2枚文化标记,否则你们不能互相攻击。任一玩家攻击另一方时弃置此卡。你也可以用一次常规行动弃置此卡。",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} 选择另一位玩家。除非攻击方向防守方支付2枚文化标记,否则你们不能互相攻击。任一玩家攻击另一方时弃置此卡。你也可以用一次常规行动弃置此卡。",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "建造本局首座奇迹后立即完成;或在状态阶段完成,条件是上一轮只有你建造过奇迹。",
|
||||
|
|
@ -1500,7 +1504,6 @@
|
|||
"Discard an action card to cancel another player's non-combat action card when their units or cities are within 2 spaces of your cities or armies. The cancelled card is discarded; its costs are not paid.": "当其他玩家的单位或城市距你的城市或军队两格内时,可弃置一张行动卡,取消该玩家的一张非战斗行动卡。被取消卡牌弃置,无需支付其费用。",
|
||||
"Discard Pile": "弃牌堆",
|
||||
"Discarded card rules": "已弃置卡牌规则",
|
||||
"Discards the selected card": "弃置所选卡牌",
|
||||
"discount cannot rebate culture": "折扣不能返还文化",
|
||||
"discount cannot rebate mood": "折扣不能返还心情",
|
||||
"discount must be used": "必须使用折扣",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"Queue tactics": "預選戰術",
|
||||
"Queued": "已預選",
|
||||
"Steel Weapons pending: +{p0} value if activated": "鋼製武器待決定:啟用後戰鬥值+{p0}",
|
||||
"No tactics": "不使用戰術",
|
||||
"Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "選擇另一位玩家。除非攻擊方向防守方支付2個文化標記,否則你們不能互相攻擊。若任一方攻擊另一方,棄掉此卡。你可以將棄掉此卡作為一個常規行動。",
|
||||
"{p0} Choose another player. You cannot attack each other, unless the attacker pays the defender 2 culture tokens. Discard this card if either player attacks the other. You may discard the card as a regular action.": "{p0} 選擇另一位玩家。除非攻擊方向防守方支付2個文化標記,否則你們不能互相攻擊。若任一方攻擊另一方,棄掉此卡。你可以將棄掉此卡作為一個常規行動。",
|
||||
"Immediately after constructing the first Wonder in the game, or during the Status Phase if you were the only player to construct Wonders in the last round.": "建造本局首座奇觀後立即完成;或在狀態階段完成,條件是上一輪只有你建造過奇觀。",
|
||||
|
|
@ -956,7 +960,6 @@
|
|||
"Discard {p0} at {p1}": "在 {p1} 移除 {p0}",
|
||||
"Discard {p0} for recruitment": "為招募移除 {p0}",
|
||||
"Discarded card rules": "棄置卡牌規則",
|
||||
"Discards the selected card": "棄置所選卡牌",
|
||||
"Disembark": "登陸",
|
||||
"Disembark the Settler to found a city": "讓移民登陸後才能建立城市",
|
||||
"Disembark units": "登陸單位",
|
||||
|
|
|
|||
42
web-client/src/queued-tactics.test.ts
Normal file
42
web-client/src/queued-tactics.test.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { queuedTacticsDecision, type TacticsQueue } from './queued-tactics.ts';
|
||||
import type { ActionCard, View } from './types.ts';
|
||||
const card = (id: number): ActionCard => ({
|
||||
id,
|
||||
name: 'Civil side',
|
||||
description: 'Civil rules',
|
||||
free: false,
|
||||
cost: {},
|
||||
tactics: { name: 'Routing', description: 'Battle rules' },
|
||||
reason: null,
|
||||
action: null,
|
||||
});
|
||||
const view = { actionCards: [card(3), card(0)] } as View;
|
||||
const offer: TacticsQueue = {
|
||||
key: 'battle/tactics',
|
||||
title: 'Tactics',
|
||||
selected: null,
|
||||
options: [
|
||||
[],
|
||||
[{ ActionCard: 3 }],
|
||||
[{ ActionCard: 4 }],
|
||||
[{ ActionCard: 0 }],
|
||||
[{ ActionCard: 3 }, { ActionCard: 4 }],
|
||||
].map((cards) => ({ label: 'offer', description: '', response: { SelectHandCards: cards } })),
|
||||
};
|
||||
test('queued tactics uses only single authorized cards in the owner hand, never hidden placeholders', () => {
|
||||
const decision = queuedTacticsDecision(view, offer)!;
|
||||
assert.equal(decision.tacticsSelection, true);
|
||||
assert.equal(decision.min, 0);
|
||||
assert.equal(decision.max, 1);
|
||||
assert.equal(decision.options.length, 1);
|
||||
assert.deepEqual(decision.options[0].value, { ActionCard: 3 });
|
||||
assert.equal(decision.options[0].card?.kind, 'action');
|
||||
assert.deepEqual(
|
||||
decision.options[0].card?.kind === 'action' && decision.options[0].card.tactics,
|
||||
card(3).tactics,
|
||||
);
|
||||
assert.equal(queuedTacticsDecision(null, offer), null);
|
||||
assert.equal(queuedTacticsDecision(view, undefined), null);
|
||||
});
|
||||
40
web-client/src/queued-tactics.ts
Normal file
40
web-client/src/queued-tactics.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import type { Decision, View } from './types';
|
||||
|
||||
export type TacticsQueue = NonNullable<View['earlyChoices']>[number];
|
||||
|
||||
/** Adapt only owner-authorized offer IDs to the normal hand-card decision UI. */
|
||||
export function queuedTacticsDecision(view: View | null, offer: TacticsQueue | undefined): Decision | null {
|
||||
if (!view || !offer) return null;
|
||||
return {
|
||||
reward: false,
|
||||
endOfAge: false,
|
||||
name: 'Tactics',
|
||||
description: '',
|
||||
min: 0,
|
||||
max: 1,
|
||||
fields: [],
|
||||
tacticsSelection: true,
|
||||
options: offer.options.flatMap((option) => {
|
||||
const cards = (option.response as { SelectHandCards?: { ActionCard?: number }[] }).SelectHandCards;
|
||||
const id = cards?.[0]?.ActionCard;
|
||||
if (!id || cards?.length !== 1) return [];
|
||||
const card = view.actionCards?.find((card) => card.id === id);
|
||||
return card?.tactics
|
||||
? [
|
||||
{
|
||||
value: { ActionCard: id },
|
||||
name: card.name,
|
||||
description: card.description,
|
||||
position: null,
|
||||
card: {
|
||||
kind: 'action' as const,
|
||||
name: card.name,
|
||||
description: card.description,
|
||||
tactics: card.tactics,
|
||||
},
|
||||
},
|
||||
]
|
||||
: [];
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
|
@ -5173,11 +5173,6 @@ small {
|
|||
bottom: -12px;
|
||||
padding: 8px 0 12px;
|
||||
}
|
||||
.tactics-discard {
|
||||
flex: 1 0 100%;
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
.game-shell .tactics-decision .decision-footer button {
|
||||
width: auto;
|
||||
min-width: 72px;
|
||||
|
|
@ -5193,7 +5188,8 @@ small {
|
|||
right: 8px;
|
||||
bottom: calc(56px + var(--mobile-bottom));
|
||||
width: auto;
|
||||
max-height: min(54%, 400px);
|
||||
/* Battle forces and the first card must fit without an extra opening step. */
|
||||
max-height: calc(100% - 76px - var(--mobile-bottom));
|
||||
}
|
||||
.game-shell .tactics-decision .decision-footer button {
|
||||
min-height: 40px;
|
||||
|
|
@ -5300,9 +5296,6 @@ small {
|
|||
.game-shell .decision-footer .inline-error {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
.game-shell .tactics-discard {
|
||||
flex: 1 1 110px;
|
||||
}
|
||||
}
|
||||
.map-exploration-label {
|
||||
position: absolute;
|
||||
|
|
|
|||
68
web-client/src/tactics-queue-engine.test.ts
Normal file
68
web-client/src/tactics-queue-engine.test.ts
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
const engine = createRequire(import.meta.url)(process.env.CLASH_TEST_ENGINE ?? '../.engine/server.js');
|
||||
const apply = (raw: string, action: unknown, player = engine.currentPlayer(raw)) =>
|
||||
engine.tryMove(raw, JSON.stringify(action), player);
|
||||
const view = (raw: string, player: number) =>
|
||||
JSON.parse(engine.webView(engine.stripSecret(raw, player), player));
|
||||
const actions = (raw: string) =>
|
||||
JSON.parse(raw).log.flatMap((a: any) =>
|
||||
a.rounds.flatMap((r: any) => r.turns.flatMap((t: any) => t.actions ?? [])),
|
||||
);
|
||||
async function battle() {
|
||||
const g = JSON.parse(
|
||||
readFileSync(
|
||||
new URL('../../server/tests/test_games/tactics_cards/peltasts.json', import.meta.url),
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
g.players = [
|
||||
...g.players.slice(0, 2),
|
||||
...JSON.parse(await engine.init(2, [], {}, 'tactics-queue', {})).players.slice(2),
|
||||
];
|
||||
for (const p of g.players.slice(0, 2)) {
|
||||
p.advances.push('SteelWeapons');
|
||||
p.resources.ore = 4;
|
||||
}
|
||||
g.players[0].action_cards = [3, 6, 11];
|
||||
g.players[1].action_cards = [4, 7, 23];
|
||||
return apply(
|
||||
JSON.stringify(g),
|
||||
{ Movement: { Move: { units: [0, 1, 2], destination: 'C1', payment: {} } } },
|
||||
0,
|
||||
);
|
||||
}
|
||||
test('actual packed engine queues privately after Steel; consumes once as a normal response and replays', async () => {
|
||||
let raw = await battle();
|
||||
assert(!view(raw, 0).earlyChoices.some((o: any) => o.key.endsWith('/tactics')));
|
||||
raw = apply(raw, { Response: { Payment: [{ ore: 1 }] } });
|
||||
const before = raw;
|
||||
const offer = view(raw, 0).earlyChoices.find((o: any) => o.key.endsWith('/tactics'));
|
||||
assert(offer);
|
||||
const command = JSON.stringify({
|
||||
QueueChoice: { key: offer.key, response: { SelectHandCards: [{ ActionCard: 3 }] } },
|
||||
});
|
||||
assert(engine.canMoveOutOfTurn(raw, command, 0));
|
||||
raw = engine.tryMove(raw, command, 0);
|
||||
assert(engine.isLiveUpdate(raw));
|
||||
for (const seat of [1, undefined])
|
||||
assert.deepEqual(JSON.parse(engine.stripSecret(raw, seat)), JSON.parse(engine.stripSecret(before, seat)));
|
||||
for (const field of ['players', 'events', 'rng', 'log', 'board_history', 'time_increments'])
|
||||
assert.deepEqual(JSON.parse(raw)[field], JSON.parse(before)[field], field);
|
||||
raw = apply(raw, { Response: { Payment: [{ ore: 1 }] } });
|
||||
assert.equal(engine.currentPlayer(raw), 1);
|
||||
assert.equal(JSON.parse(raw).early_choices, undefined);
|
||||
assert(!JSON.parse(raw).players[0].action_cards.includes(3));
|
||||
assert.equal(view(raw, 1).decision.opponentTactics, 'played');
|
||||
raw = apply(raw, { Response: { SelectHandCards: [{ ActionCard: 4 }] } });
|
||||
const added = actions(raw)
|
||||
.slice(actions(before).length)
|
||||
.map((a: any) => a.action);
|
||||
assert.equal(added.filter((a: any) => a.Response?.SelectHandCards?.[0]?.ActionCard === 3).length, 1);
|
||||
let replay = before;
|
||||
for (const action of added) if (action !== 'StartTurn') replay = apply(replay, action);
|
||||
for (const field of ['players', 'events', 'rng', 'time_increments'])
|
||||
assert.deepEqual(JSON.parse(replay)[field], JSON.parse(raw)[field], field);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue