Compare commits
2 commits
3539bcda0f
...
0b65bdbf88
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b65bdbf88 | |||
| 05e09fba95 |
3 changed files with 8 additions and 19 deletions
|
|
@ -18,6 +18,7 @@ pub fn GameScreen(state: GameUiState) -> impl IntoView {
|
||||||
let i18n = use_i18n();
|
let i18n = use_i18n();
|
||||||
|
|
||||||
let vs = state.view_state.clone();
|
let vs = state.view_state.clone();
|
||||||
|
let message = format!("{}", vs.message);
|
||||||
let player_id = state.player_id;
|
let player_id = state.player_id;
|
||||||
let is_my_turn = vs.active_mp_player == Some(player_id);
|
let is_my_turn = vs.active_mp_player == Some(player_id);
|
||||||
let is_move_stage = is_my_turn
|
let is_move_stage = is_my_turn
|
||||||
|
|
@ -351,6 +352,9 @@ pub fn GameScreen(state: GameUiState) -> impl IntoView {
|
||||||
|
|
||||||
// ── Player score (below board) ────────────────────────────────────
|
// ── Player score (below board) ────────────────────────────────────
|
||||||
<PlayerScorePanel score=my_score is_you=true />
|
<PlayerScorePanel score=my_score is_you=true />
|
||||||
|
<div>
|
||||||
|
{format!("{message}")}
|
||||||
|
</div>
|
||||||
|
|
||||||
// ── Game-over overlay ─────────────────────────────────────────────
|
// ── Game-over overlay ─────────────────────────────────────────────
|
||||||
{stage_is_ended.then(|| {
|
{stage_is_ended.then(|| {
|
||||||
|
|
|
||||||
|
|
@ -167,8 +167,7 @@ impl BackEndArchitecture<PlayerAction, GameDelta, ViewState> for TrictracBackend
|
||||||
moves: (m1, m2),
|
moves: (m1, m2),
|
||||||
};
|
};
|
||||||
if self.game.validate(&event) {
|
if self.game.validate(&event) {
|
||||||
let message = format!("Event {:?} validated on {:?}", event, self.game);
|
self.game.debug_message = format!("Event {:?} validated", event);
|
||||||
console_log(message);
|
|
||||||
let _ = self.game.consume(&event);
|
let _ = self.game.consume(&event);
|
||||||
self.drive_automatic_stages();
|
self.drive_automatic_stages();
|
||||||
}
|
}
|
||||||
|
|
@ -332,20 +331,3 @@ mod tests {
|
||||||
.any(|c| matches!(c, BackendCommand::TerminateRoom)));
|
.any(|c| matches!(c, BackendCommand::TerminateRoom)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Public API: WASM delegates to `inner`, other targets are no-ops ───────────
|
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
mod inner {
|
|
||||||
use web_sys::console;
|
|
||||||
|
|
||||||
pub fn console_log(message: String) {
|
|
||||||
console::log_1(&message.into());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
|
||||||
pub use inner::console_log;
|
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
|
||||||
pub fn console_log(message: String) {}
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ pub struct ViewState {
|
||||||
pub dice_jans: Vec<JanEntry>,
|
pub dice_jans: Vec<JanEntry>,
|
||||||
/// Last two checker moves played; default when no move has occurred yet.
|
/// Last two checker moves played; default when no move has occurred yet.
|
||||||
pub dice_moves: (CheckerMove, CheckerMove),
|
pub dice_moves: (CheckerMove, CheckerMove),
|
||||||
|
pub message: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One scoring event from a dice roll.
|
/// One scoring event from a dice roll.
|
||||||
|
|
@ -86,6 +87,7 @@ impl ViewState {
|
||||||
dice: (0, 0),
|
dice: (0, 0),
|
||||||
dice_jans: Vec::new(),
|
dice_jans: Vec::new(),
|
||||||
dice_moves: (CheckerMove::default(), CheckerMove::default()),
|
dice_moves: (CheckerMove::default(), CheckerMove::default()),
|
||||||
|
message: "".into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,6 +186,7 @@ impl ViewState {
|
||||||
dice: (gs.dice.values.0, gs.dice.values.1),
|
dice: (gs.dice.values.0, gs.dice.values.1),
|
||||||
dice_jans,
|
dice_jans,
|
||||||
dice_moves: gs.dice_moves,
|
dice_moves: gs.dice_moves,
|
||||||
|
message: gs.get_debug_message(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue