diff options
Diffstat (limited to 'src/bin/client')
| -rw-r--r-- | src/bin/client/repl.rs | 31 |
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 | ||
| 443 | fn 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 | |||
| 439 | fn map_key(key: crossterm::event::KeyEvent) -> Option<Key> { | 468 | fn 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 { |
