Add briscola: classic two-player and briscola a quattro
CI / Build and push docker image (push) Successful in 1m45s
CI / Build and push docker image (push) Successful in 1m45s
New tavolo-briscola distribution implementing briscola on the platform: - pure rules (state.py, engine.py): 3-card deals, a face-up trump that is the last card drawn, trump-first trick resolution (A > 3 > K > H > J > 7 > 6 > 5 > 4 > 2), 120 points per deal, 60-60 patta re-deals, a configurable target score (default 61), deal-end acknowledgements and turn auto-play; - BriscolaEngine (briscola, 2 players) and BriscolaQuattroEngine (briscola_a_quattro, 4 players in fixed partnerships) adapters; - registered in tavolo-app, packaged in the Docker image, documented. Platform fixes surfaced by a two-player lobby: - the websocket state and snapshot payloads now carry seats_open (they were only in the REST lobby payload), so lobbies with player counts other than four render correctly; seats_open is clamped at zero; - the web client logs unparseable server messages instead of silently dropping them. Web client: briscola table for both variants (stock, face-up trump, trick, last-trick banner), deal summary modal and game-over overlay. Tests: tavolo-briscola rules/adapter suites, app integration tests (lobby, websocket play, turn timeout, deal-end acks, persistence), a platform seats_open test and frontend model parsing tests.
This commit is contained in:
+30
-12
@@ -6,11 +6,16 @@ use sycamore::prelude::*;
|
||||
use wasm_bindgen_futures::spawn_local;
|
||||
|
||||
use crate::api;
|
||||
use crate::components::briscola::{deal_rows, deal_summary_modal};
|
||||
use crate::components::card::{card_back, card_img};
|
||||
use crate::components::copy::CopyButton;
|
||||
use crate::components::summary::{hand_summary_modal, summary_rows};
|
||||
use crate::components::toast::toast;
|
||||
use crate::model::{card_label, hand_sort_key, GameView, MoveView, PlayerView, Scores, ServerMessage};
|
||||
use crate::model::{
|
||||
card_label, hand_sort_key, is_briscola, GameView, MoveView, PlayerView, Scores,
|
||||
ServerMessage,
|
||||
};
|
||||
use crate::pages::briscola::briscola_table;
|
||||
use crate::ws::{self, GameSocket};
|
||||
|
||||
fn send_play(socket: Signal<Option<GameSocket>>, card: String, capture: Option<Vec<String>>) {
|
||||
@@ -20,7 +25,7 @@ fn send_play(socket: Signal<Option<GameSocket>>, card: String, capture: Option<V
|
||||
}
|
||||
|
||||
/// The absolute, shareable URL of this game's page, for the clipboard.
|
||||
fn watch_link(id: &str) -> String {
|
||||
pub(crate) fn watch_link(id: &str) -> String {
|
||||
let origin = web_sys::window()
|
||||
.and_then(|w| w.location().origin().ok())
|
||||
.unwrap_or_default();
|
||||
@@ -387,6 +392,10 @@ pub fn GamePage(id: String) -> View {
|
||||
}
|
||||
}
|
||||
Some(g) if g.phase == "lobby" => view! { LobbyView(game=g) },
|
||||
// Briscola has its own table view for both variants.
|
||||
Some(g) if is_briscola(&g.game_type) => {
|
||||
briscola_table(g, on_hand_card, now)
|
||||
}
|
||||
// The live table is scopone-specific; other games get a
|
||||
// fallback until they ship their own play view.
|
||||
Some(g) if g.game_type == "scopone_scientifico" => {
|
||||
@@ -401,6 +410,9 @@ pub fn GamePage(id: String) -> View {
|
||||
Some(g) if g.phase == "hand_end" && g.game_type == "scopone_scientifico" => {
|
||||
hand_summary_modal(g, socket, now)
|
||||
}
|
||||
Some(g) if g.phase == "hand_end" && is_briscola(&g.game_type) => {
|
||||
deal_summary_modal(g, socket, now)
|
||||
}
|
||||
_ => view! {},
|
||||
})
|
||||
(move || game_over_view(over.get_clone(), game.get_clone()))
|
||||
@@ -715,11 +727,11 @@ fn capture_picker(
|
||||
}
|
||||
}
|
||||
|
||||
/// End-of-match overlay (scopone's team score; other games render
|
||||
/// nothing until they ship their own play view).
|
||||
/// End-of-match overlay: the final hand/deal breakdown and the winner.
|
||||
fn game_over_view(over: Option<(Scores, Option<String>)>, game: Option<GameView>) -> View {
|
||||
let briscola = game.as_ref().is_some_and(|g| is_briscola(&g.game_type));
|
||||
if let Some(g) = &game {
|
||||
if g.game_type != "scopone_scientifico" {
|
||||
if g.game_type != "scopone_scientifico" && !briscola {
|
||||
return view! {};
|
||||
}
|
||||
}
|
||||
@@ -735,13 +747,19 @@ fn game_over_view(over: Option<(Scores, Option<String>)>, game: Option<GameView>
|
||||
let line = format!("Team {winner} wins {} – {}", scores.a, scores.b);
|
||||
// Spectators have no match history to look at.
|
||||
let spectator = game.as_ref().is_some_and(|g| g.spectator);
|
||||
// Explain the final hand's scoring before the result.
|
||||
let final_summary = game
|
||||
.and_then(|g| g.last_hand)
|
||||
.map(|s| {
|
||||
let rows = summary_rows(s);
|
||||
view! { (rows) }
|
||||
});
|
||||
// Explain the final hand's (scopone) or deal's (briscola)
|
||||
// scoring before the result.
|
||||
let final_summary: View = if briscola {
|
||||
match game.as_ref().and_then(|g| g.last_deal.clone()) {
|
||||
Some(deal) => deal_rows(&deal),
|
||||
None => view! {},
|
||||
}
|
||||
} else {
|
||||
match game.as_ref().and_then(|g| g.last_hand.clone()) {
|
||||
Some(hand) => summary_rows(hand),
|
||||
None => view! {},
|
||||
}
|
||||
};
|
||||
let my_matches = (!spectator).then(|| view! {
|
||||
a(class="btn btn-outline-light", href="/history") { "My matches" }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user