summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-08 03:36:26 +0100
committersalmonik <salmonik@tuta.io>2026-11-08 03:36:26 +0100
commitc6c8ddb7e4117628549afdb382b0d46f830f242d (patch)
treecd59ac8bf690c942bce3b226f5777d01fde4896b /gui
parentweb: restore the balance on a refresh into history (diff)
downloadzagan-bet-c6c8ddb7e4117628549afdb382b0d46f830f242d.tar.gz
zagan-bet-c6c8ddb7e4117628549afdb382b0d46f830f242d.zip
crash: show and verify the revealed seed in the TUI and GUI
The crash board gained a fairness line: the short commit while the round runs, then the short seed marked verified when sha256(seed) and the recomputed crash point both match. The terminal board grew from six to seven lines and the GUI sidebar shows the same values.
Diffstat (limited to 'gui')
-rw-r--r--gui/src/crash.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/gui/src/crash.rs b/gui/src/crash.rs
index 08113a8..a73c3bd 100644
--- a/gui/src/crash.rs
+++ b/gui/src/crash.rs
@@ -2,9 +2,18 @@
2 2
3use eframe::egui::{Align2, Color32, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, pos2, vec2}; 3use eframe::egui::{Align2, Color32, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, pos2, vec2};
4use zagan_bet::client::view::{Command, CrashView}; 4use zagan_bet::client::view::{Command, CrashView};
5use zagan_bet::crash::{crash_point_from_seed, seed_from_hex, verify_seed};
5 6
6use crate::{theme, widgets}; 7use crate::{theme, widgets};
7 8
9fn short_hash(hash: &str) -> String {
10 hash.char_indices()
11 .nth(12)
12 .map(|(index, _)| &hash[..index])
13 .unwrap_or(hash)
14 .to_string()
15}
16
8/// One sample of the running curve. 17/// One sample of the running curve.
9struct Sample { 18struct Sample {
10 seconds: f32, 19 seconds: f32,
@@ -136,6 +145,31 @@ fn sidebar(ui: &mut Ui, view: &CrashView, fx: &mut Fx) -> Option<Command> {
136 theme::GOLD, 145 theme::GOLD,
137 ); 146 );
138 147
148 if let Some(commit) = &view.commit {
149 widgets::row(ui, "Commit", &short_hash(commit), theme::TEXT_FAINT);
150 }
151 if let Some(seed) = &view.seed {
152 let commit_ok = view
153 .commit
154 .as_deref()
155 .map(|commit| verify_seed(seed, commit))
156 .unwrap_or(false);
157 let point_ok = seed_from_hex(seed)
158 .map(|bytes| {
159 view.crash_point
160 .map(|point| {
161 (crash_point_from_seed(&bytes) - point).abs() < 1e-9
162 })
163 .unwrap_or(false)
164 })
165 .unwrap_or(false);
166 if commit_ok && point_ok {
167 widgets::row(ui, "Seed ✓", &short_hash(seed), theme::WIN);
168 } else {
169 widgets::row(ui, "Seed ✗", &short_hash(seed), theme::LOSS);
170 }
171 }
172
139 ui.add_space(theme::SPACE_3); 173 ui.add_space(theme::SPACE_3);
140 status(ui, view); 174 status(ui, view);
141 175