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