fn bet(
        &mut self,
        player: usize,
        max_bet: Money,
        min_betsize: Money,
        pot: Money,
    ) -> Result<Money, Error> {
        match self.callback.callback(Message::RequestAction {
            player,
            bets: self
                .players
                .iter()
                .map(|p| if p.folded() { None } else { Some(p.bet) })
                .collect(),
            pot,
        }) {
            Ok(Response::Action(PlayerAction::Fold)) => {
                self.players[player].fold();
                Ok(ZERO_MONEY)
            }
            Ok(Response::Action(PlayerAction::Call)) => {
                self.players[player].call(max_bet);
                Ok(ZERO_MONEY)
            }
            Ok(Response::Action(PlayerAction::Raise(raise))) => {
                if raise < min_betsize || self.players[player].raise(max_bet + raise).is_err() {
                    Err(Error {
                        player,
                        error: ErrorMessage::BetNotAllowed,
                    })
                } else {
                    Ok(raise)
                }
            }
            Ok(_) => Err(Error {
                player,
                error: ErrorMessage::InvalidResponse,
            }),
            Err(e) => Err(e),
        }
    }
/// Request a player's action, verify this action is allowed within the
/// rule set of the current game type, and update pot & table bets.
Request a player's action, verify this action is allowed within the
rule set of the current game type, and update pot & table bets.
Request a player ' s action verify this action is allowed within the rule set of the current game type and update pot & table bets .
fn bet(
        &mut self,
        player: usize,
        max_bet: Money,
        min_betsize: Money,
        pot: Money,
    ) -> Result<Money, Error> {
        match self.callback.callback(Message::RequestAction {
            player,
            bets: self
                .players
                .iter()
                .map(|p| if p.folded() { None } else { Some(p.bet) })
                .collect(),
            pot,
        }) {
            Ok(Response::Action(PlayerAction::Fold)) => {
                self.players[player].fold();
                Ok(ZERO_MONEY)
            }
            Ok(Response::Action(PlayerAction::Call)) => {
                self.players[player].call(max_bet);
                Ok(ZERO_MONEY)
            }
            Ok(Response::Action(PlayerAction::Raise(raise))) => {
                if raise < min_betsize || self.players[player].raise(max_bet + raise).is_err() {
                    Err(Error {
                        player,
                        error: ErrorMessage::BetNotAllowed,
                    })
                } else {
                    Ok(raise)
                }
            }
            Ok(_) => Err(Error {
                player,
                error: ErrorMessage::InvalidResponse,
            }),
            Err(e) => Err(e),
        }
    }
fn bet ( & mut self , player : usize , max_bet : Money , min_betsize : Money , pot : Money , ) -> Result < Money , Error > { match self . callback . callback ( Message :: RequestAction { player , bets : self . players . iter ( ) . map ( | p | if p . folded ( ) { None } else { Some ( p . bet ) } ) . collect ( ) , pot , } ) { Ok ( Response :: Action ( PlayerAction :: Fold ) ) => { self . players [ player ] . fold ( ) ; Ok ( ZERO_MONEY ) } Ok ( Response :: Action ( PlayerAction :: Call ) ) => { self . players [ player ] . call ( max_bet ) ; Ok ( ZERO_MONEY ) } Ok ( Response :: Action ( PlayerAction :: Raise ( raise ) ) ) => { if raise < min_betsize || self . players [ player ] . raise ( max_bet + raise ) . is_err ( ) { Err ( Error { player , error : ErrorMessage :: BetNotAllowed , } ) } else { Ok ( raise ) } } Ok ( _ ) => Err ( Error { player , error : ErrorMessage :: InvalidResponse , } ) , Err ( e ) => Err ( e ) , } }
Request a player's action, verify this action is allowed within the
rule set of the current game type, and update pot & table bets.
Request a player ' s action verify this action is allowed within the rule set of the current game type and update pot & table bets .
&mut self
player
usize
max_bet
Money
min_betsize
Money
pot
Money
&mut self
player
usize
max_bet
Money
min_betsize
Money
pot
Money