def readAction(self): act = Action() txt = self.alternative( ['folds', 'calls', 'checks', 'bets', 'raises', 'shows', 'mucks']) if txt == 'folds' or txt == 'checks': self.text(' ') if txt == 'folds': act.action = Action.Fold if self.peek(1) == '[': act.cards = self.readCards() else: act.action = Action.Check return act elif txt == 'calls' or txt == 'bets': self.text(' ') if txt == 'calls': act.action = Action.Call else: act.action = Action.Bet act.amount = Money(self.number()) # we might be all in here try: self.text(' and is all-in') except scanner.BadAlternative: pass return act elif txt == 'raises': self.text(' ') self.number() self.text(' to ') act.action = Action.Raise act.amount = Money(self.number()) # we might be all in here try: self.text(' and is all-in') except scanner.BadAlternative: pass return act elif txt == 'shows': self.text(' ') act.action = Action.Show act.cards = self.readCards() hand = self.lookaheadTill('\n') self.text(hand) return act elif txt == 'mucks': self.text(' hand ') act.action = Action.Muck return act raise handparser.HandParsingException( None, self.line_num, self.char_num, 'Unexpected action : "' + txt + '"!!')
def readAction(self): act = Action() txt = self.alternative(['folds', 'calls', 'checks', 'bets', 'raises', 'shows', 'mucks']) if txt == 'folds' or txt == 'checks': self.text(' ') if txt == 'folds': act.action = Action.Fold if self.peek(1) == '[': act.cards = self.readCards() else: act.action = Action.Check return act elif txt == 'calls' or txt == 'bets': self.text(' ') if txt == 'calls': act.action = Action.Call else: act.action = Action.Bet act.amount = Money( self.number() ) # we might be all in here try: self.text(' and is all-in') except scanner.BadAlternative: pass return act elif txt == 'raises': self.text(' ') self.number() self.text(' to ') act.action = Action.Raise act.amount = Money( self.number() ) # we might be all in here try: self.text(' and is all-in') except scanner.BadAlternative: pass return act elif txt == 'shows': self.text(' ') act.action = Action.Show act.cards = self.readCards() hand = self.lookaheadTill('\n') self.text( hand ) return act elif txt == 'mucks': self.text(' hand ') act.action = Action.Muck return act raise handparser.HandParsingException( None, self.line_num, self.char_num, 'Unexpected action : "'+txt+'"!!')
def collectMoney(self,amount): act = Action() act.action = Action.Collect act.amount = amount return act
def collectMoney(self, amount): act = Action() act.action = Action.Collect act.amount = amount return act