-
- {label}
- {double_tag}
- {ways_tag}
- {pts_str}
-
- {
- let move_lines: Vec<_> = moves.iter()
- .map(|&(m1, m2)| {
- let text = format_move_pair(m1, m2);
- view! {
{text}
}
- })
- .collect();
- view! {
-
- {move_lines}
-
- }
+/// Split `dice_jans` into (viewer_jans, opponent_jans).
+/// Entries where the active player scores (total >= 0) go to the active player.
+/// Entries where the active player loses (total < 0) go to the opponent, with signs flipped.
+fn split_jans(
+ dice_jans: &[JanEntry],
+ viewer_is_active: bool,
+) -> (Vec
, Vec) {
+ let mut mine = Vec::new();
+ let mut theirs = Vec::new();
+ for e in dice_jans {
+ if viewer_is_active {
+ if e.total >= 0 {
+ mine.push(e.clone());
+ } else {
+ theirs.push(JanEntry { total: -e.total, points_per: -e.points_per, ..e.clone() });
}
-
+ } else {
+ if e.total >= 0 {
+ theirs.push(e.clone());
+ } else {
+ mine.push(JanEntry { total: -e.total, points_per: -e.points_per, ..e.clone() });
+ }
+ }
}
+ (mine, theirs)
}
#[component]
@@ -174,6 +119,13 @@ pub fn GameScreen(state: GameUiState) -> impl IntoView {
let show_roll = is_my_turn && vs.turn_stage == SerTurnStage::RollDice;
let show_hold_go = is_my_turn && vs.turn_stage == SerTurnStage::HoldOrGoChoice;
+ // ── Jan split: viewer_jans / opponent_jans ─────────────────────────────────
+ let (my_jans, opp_jans) = split_jans(&vs.dice_jans, is_my_turn);
+
+ // ── Scores: index = mp_player_id ──────────────────────────────────────────
+ let my_score = vs.scores[player_id as usize].clone();
+ let opp_score = vs.scores[1 - player_id as usize].clone();
+
view! {
// ── Top bar ──────────────────────────────────────────────────────
@@ -182,10 +134,11 @@ pub fn GameScreen(state: GameUiState) -> impl IntoView {
"Quit"
+ }>Quit
-
@@ -207,15 +160,6 @@ pub fn GameScreen(state: GameUiState) -> impl IntoView {
})}
- // ── Jan panel ────────────────────────────────────────────────────
- {(!vs.dice_jans.is_empty()).then(|| {
- let expanded: RwSignal