use super::decode_board::board_double; use super::decode_tournament::tournament; use crate::card::Card; use crate::fault::Fault; use crate::icm::lage::Turnierlage; use crate::json::field::optional; use crate::json::scalar::flag; use crate::json::Value; /// Optional request fields that do not belong to the `Spot`: they change how the /// decision is formed or what is answered besides it. #[derive(Clone, Debug, Default, PartialEq)] pub struct Extras { /// `boardDouble`: second board of a double-board hand. pub board_double: Option>, /// `ritOffered`: the table offers to run it twice; absent or `null` means no. pub rit_offered: bool, /// `tournament`: the situation to price the decision in money; absent means cash. pub tournament: Option, /// `_turnier`: a tournament table, priced (`tournament`) or not (chip-EV fallback). pub turniertisch: bool, /// `wantEvs`: answer the EV of each priced line as `evs`; absent or `null` means no. pub want_evs: bool, } /// Read after the `Spot` checks, so faults of contract fields keep their precedence. pub fn extras(root: &Value) -> Result { let rit_offered = match optional(root, "", "ritOffered")? { Some(value) => flag(value, "ritOffered")?, None => false, }; let want_evs = match optional(root, "", "wantEvs")? { Some(value) => flag(value, "wantEvs")?, None => false, }; let tournament = tournament(root)?; let turniertisch = tournament.is_some() || optional(root, "", "_turnier")?.is_some(); Ok(Extras { board_double: board_double(root)?, rit_offered, tournament, turniertisch, want_evs }) }