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, /// `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, }; Ok(Extras { board_double: board_double(root)?, rit_offered, tournament: tournament(root)?, want_evs }) }