Use player names in two-player briscola

Classic briscola has no partnerships: its "teams" are just the two
players, but the UI labelled them Team A/Team B.

- add is_individual_game() and GameView::player_name_for_team() to the
  model;
- the briscola table HUD reads "Alice 0 — 0 Bob (target 61)" and the
  seat panels drop the Team badge for two-player games;
- the deal summary and game-over screen name the sides and the winner;
- the waiting room and join preview hide the Team badge.

briscola a quattro and scopone keep their team labels, and the match
history table is unchanged.
This commit is contained in:
2026-10-06 17:37:55 +08:00
parent 6222e38da3
commit b821274f0b
5 changed files with 121 additions and 27 deletions
+23 -7
View File
@@ -7,9 +7,23 @@
use sycamore::prelude::*;
use crate::components::card::{card_back, card_img};
use crate::model::{DealSummary, GameView};
use crate::model::{is_individual_game, DealSummary, GameView};
use crate::ws::GameSocket;
/// Names of the two sides: the players' names for games without
/// partnerships (classic two-player briscola), "Team A"/"Team B"
/// otherwise.
fn side_names(game: &GameView) -> (String, String) {
if is_individual_game(&game.game_type) {
(
game.player_name_for_team("A"),
game.player_name_for_team("B"),
)
} else {
("Team A".to_string(), "Team B".to_string())
}
}
/// One explanatory row: icon, title, plain-language sentence, points chip.
fn summary_row(
icon: View,
@@ -31,9 +45,10 @@ fn summary_row(
}
/// The scoring rows of one completed deal (also used by the final screen).
pub fn deal_rows(summary: &DealSummary) -> View {
pub fn deal_rows(game: &GameView, summary: &DealSummary) -> View {
let a = summary.points.a;
let b = summary.points.b;
let (name_a, name_b) = side_names(game);
let cls = if summary.patta {
"score-row tie"
} else if a > b {
@@ -54,7 +69,7 @@ pub fn deal_rows(summary: &DealSummary) -> View {
let points_row = summary_row(
card_img("01D".to_string(), "score-mini"),
"Deal points",
format!("Team A {a} · Team B {b}"),
format!("{name_a} {a} · {name_b} {b}"),
cls,
chip,
);
@@ -62,7 +77,7 @@ pub fn deal_rows(summary: &DealSummary) -> View {
summary_row(
card_back("score-mini"),
"Cards captured",
format!("Team A {} · Team B {}", c.a, c.b),
format!("{name_a} {} · {name_b} {}", c.a, c.b),
"score-row",
format!("{} · {}", c.a, c.b),
)
@@ -87,10 +102,11 @@ fn totals(game: &GameView, summary: &DealSummary) -> View {
} else {
(summary.points.a, summary.points.b)
};
let (name_a, name_b) = side_names(game);
view! {
div(class="totals") {
div(class="total-row team-a") {
span(class="total-label") { "Team A" }
span(class="total-label") { (name_a) }
div(class="progress") {
div(class="progress-fill", style=format!("width: {pct_a}%")) {}
}
@@ -100,7 +116,7 @@ fn totals(game: &GameView, summary: &DealSummary) -> View {
}
}
div(class="total-row team-b") {
span(class="total-label") { "Team B" }
span(class="total-label") { (name_b) }
div(class="progress") {
div(class="progress-fill", style=format!("width: {pct_b}%")) {}
}
@@ -151,7 +167,7 @@ pub fn deal_summary_modal(
});
let title = format!("Deal {} — results", summary.deal);
let rows = deal_rows(&summary);
let rows = deal_rows(&game, &summary);
let totals_view = totals(&game, &summary);
let action = if game.spectator {