Files
pokerfreak/src/wire/decode_board.rs
T
mmintelandClaude Opus 5.5 7a5357523b Doppel-Board und Run it twice als optionale Felder
- boardDouble (Form wie board): je Board entschieden, die bessere Bewertung
  (höhere Equity) gewinnt; Näherung offen dokumentiert (Topf geteilt, exakt
  wäre der Mittelwert). Ungleiche Länge, doppelte Karte -> ABSTAIN
- ritOffered -> rit (ACCEPT/DECLINE/ABSTAIN) und ritReason: annehmen über dem
  Bruchpunkt, ohne offenen Call fairer Anteil, ohne Equity ABSTAIN
- keine bestehenden Felder oder Typen geändert; Zusatzfelder werden nach der
  Spot-Prüfung gelesen
- Tests: benannte Referenzwerte, ein Board verbessert/das andere nicht,
  pipeline_extras_neutral zeigt bitgleiche Antworten ohne die Felder (779)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 17:30:01 +01:00

35 lines
1.2 KiB
Rust

use super::decode_card::cards;
use crate::card::Card;
use crate::fault::Fault;
use crate::json::field::{join, optional};
use crate::json::Value;
const STREETS: [&str; 3] = ["FLOP", "TURN", "RIVER"];
/// A board object `{"FLOP": null|[cards], "TURN": …, "RIVER": …}` under `key`; absent
/// (or `null`) means `None`. Cards are concatenated in deal order regardless of key order.
fn board_at(root: &Value, key: &str) -> Result<Option<Vec<Card>>, Fault> {
let Some(object) = optional(root, "", key)? else {
return Ok(None);
};
let per_street = STREETS
.iter()
.map(|name| match optional(object, key, name)? {
Some(list) => cards(list, &join(key, name)),
None => Ok(Vec::new()),
})
.collect::<Result<Vec<_>, Fault>>()?;
Ok(Some(per_street.concat()))
}
/// `board`; absent means no cards.
pub fn board(root: &Value) -> Result<Vec<Card>, Fault> {
Ok(board_at(root, "board")?.unwrap_or_default())
}
/// Extension field `boardDouble`: a second board in the shape of `board`; absent or
/// `null` means a single board.
pub fn board_double(root: &Value) -> Result<Option<Vec<Card>>, Fault> {
board_at(root, "boardDouble")
}