104 lines
2.9 KiB
Rust
104 lines
2.9 KiB
Rust
//! Was an einem Tisch gespielt wird - wie lesen/formate.py (Format.swift). Nicht der Modus (Uebung/Cash).
|
|
|
|
use serde_json::Value;
|
|
|
|
use crate::nachsichtig::Feld;
|
|
|
|
/// Die Reihenfolge der Varianten ist die der Swift-`allCases` (die Vorgabe der Fuellfolge).
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
pub enum SpielFormat {
|
|
Cash,
|
|
CashPlo,
|
|
Aof,
|
|
Bombpot,
|
|
Turnier,
|
|
Kpoker,
|
|
Vip,
|
|
Freeroll,
|
|
}
|
|
|
|
impl SpielFormat {
|
|
pub const ALLE: [SpielFormat; 8] = [
|
|
SpielFormat::Cash,
|
|
SpielFormat::CashPlo,
|
|
SpielFormat::Aof,
|
|
SpielFormat::Bombpot,
|
|
SpielFormat::Turnier,
|
|
SpielFormat::Kpoker,
|
|
SpielFormat::Vip,
|
|
SpielFormat::Freeroll,
|
|
];
|
|
|
|
pub fn roh(&self) -> &'static str {
|
|
match self {
|
|
SpielFormat::Cash => "cash",
|
|
SpielFormat::CashPlo => "cash_plo",
|
|
SpielFormat::Aof => "aof",
|
|
SpielFormat::Bombpot => "bombpot",
|
|
SpielFormat::Turnier => "turnier",
|
|
SpielFormat::Kpoker => "kpoker",
|
|
SpielFormat::Vip => "vip",
|
|
SpielFormat::Freeroll => "freeroll",
|
|
}
|
|
}
|
|
|
|
pub fn aus_roh(s: &str) -> Option<SpielFormat> {
|
|
Self::ALLE.into_iter().find(|f| f.roh() == s)
|
|
}
|
|
|
|
pub fn name(&self) -> &'static str {
|
|
match self {
|
|
SpielFormat::Cash => "Cash NLH",
|
|
SpielFormat::CashPlo => "Cash PLO",
|
|
SpielFormat::Aof => "All-In or Fold",
|
|
SpielFormat::Bombpot => "Bomb Pot",
|
|
SpielFormat::Turnier => "Turnier",
|
|
SpielFormat::Kpoker => "K-Poker",
|
|
SpielFormat::Vip => "VIP Arena",
|
|
SpielFormat::Freeroll => "Freerolls",
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Eine Zeile des Vergleichs je Format (wachstum.je_format): bb/100 mit 95-%-Spanne.
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub struct FormatZeile {
|
|
pub format: String,
|
|
pub name: String,
|
|
pub haende: i64,
|
|
pub netto_bb: Option<f64>,
|
|
pub bb100: Option<f64>,
|
|
pub unten: Option<f64>,
|
|
pub oben: Option<f64>,
|
|
}
|
|
|
|
impl FormatZeile {
|
|
pub fn aus(v: &Value) -> Option<Self> {
|
|
let f = Feld::aus(v)?;
|
|
let format = f.text("format").unwrap_or_else(|| "unbekannt".into());
|
|
Some(FormatZeile {
|
|
name: f.text("name").unwrap_or_else(|| format.clone()),
|
|
format,
|
|
haende: f.ganz("haende").unwrap_or(0),
|
|
netto_bb: f.zahl("netto_bb"),
|
|
bb100: f.zahl("bb100"),
|
|
unten: f.zahl("unten"),
|
|
oben: f.zahl("oben"),
|
|
})
|
|
}
|
|
}
|
|
|
|
/// Welches Format vorn liegt - nur wenn die Spannen es tragen (betrieb/statistik.bestes_format).
|
|
#[derive(Clone, Debug, PartialEq)]
|
|
pub struct FormatUrteil {
|
|
pub format: Option<String>,
|
|
pub grund: String,
|
|
}
|
|
|
|
impl FormatUrteil {
|
|
pub fn aus(v: &Value) -> Option<Self> {
|
|
let f = Feld::aus(v)?;
|
|
Some(FormatUrteil { format: f.text("format"), grund: f.text("grund").unwrap_or_default() })
|
|
}
|
|
}
|