summaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-28 23:19:52 +0100
committersalmonik <salmonik@tuta.io>2026-10-28 23:19:52 +0100
commit2915d826f744612e0d975282f5bddf13270b9f3f (patch)
treea2864bfaef91070ac3b4e13b8b731e539a757cc8 /src/bin
parentv1.0.0: replace slots with 5x3 reels and five paylines (diff)
downloadzagan-bet-2915d826f744612e0d975282f5bddf13270b9f3f.tar.gz
zagan-bet-2915d826f744612e0d975282f5bddf13270b9f3f.zip
v1.1.0: highlight winning symbols on the slots board
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/client/repl.rs31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/bin/client/repl.rs b/src/bin/client/repl.rs
index 033fb1a..58cb541 100644
--- a/src/bin/client/repl.rs
+++ b/src/bin/client/repl.rs
@@ -240,8 +240,12 @@ impl ClientState {
240 .map(|line| { 240 .map(|line| {
241 if line.starts_with("===") { 241 if line.starts_with("===") {
242 line.as_str().bold().cyan().to_string() 242 line.as_str().bold().cyan().to_string()
243 } else if line.contains("JACKPOT") || line.contains("Two of a kind") { 243 } else if line.contains('{') {
244 style_winning_cells(line)
245 } else if line.contains("WIN!") || line.starts_with("Won ") {
244 line.as_str().bold().green().to_string() 246 line.as_str().bold().green().to_string()
247 } else if line.starts_with("Winning lines:") {
248 line.as_str().yellow().to_string()
245 } else if line.starts_with("ERROR:") { 249 } else if line.starts_with("ERROR:") {
246 line.as_str().red().to_string() 250 line.as_str().red().to_string()
247 } else { 251 } else {
@@ -436,6 +440,31 @@ impl ClientState {
436 } 440 }
437} 441}
438 442
443fn style_winning_cells(line: &str) -> String {
444 let chars: Vec<char> = line.chars().collect();
445 let mut out = String::new();
446 let mut index = 0;
447
448 while index < chars.len() {
449 if chars[index] == '{' {
450 let start = index;
451 while index < chars.len() && chars[index] != '}' {
452 index += 1;
453 }
454 if index < chars.len() {
455 index += 1;
456 }
457 let cell: String = chars[start..index].iter().collect();
458 out.push_str(&cell.as_str().bold().yellow().to_string());
459 } else {
460 out.push(chars[index]);
461 index += 1;
462 }
463 }
464
465 out
466}
467
439fn map_key(key: crossterm::event::KeyEvent) -> Option<Key> { 468fn map_key(key: crossterm::event::KeyEvent) -> Option<Key> {
440 if key.modifiers.contains(KeyModifiers::CONTROL) { 469 if key.modifiers.contains(KeyModifiers::CONTROL) {
441 match key.code { 470 match key.code {