def readBlinds(self,hand):
     preflop = BettingRound()
     actions = []
     playerSet = set( hand.players.keys() )
     
     while True:
         try:
             pid = self.alternative(playerSet)
         except scanner.BadAlternative:
             break
         self.alternative( [ ': posts small blind ', ': posts big blind ', ': posts the ante '])
         act = Action()
         act.action = Action.Post
         act.bet = self.number()
         actions.append( [pid, act] )
         self.alternative([ '\n', ' and is all-in\n' ])
  
     hand.addBetRound(preflop,actions)
예제 #2
0
    def readBlinds(self, hand):
        preflop = BettingRound()
        actions = []
        playerSet = set(hand.players.keys())

        while True:
            try:
                pid = self.alternative(playerSet)
            except scanner.BadAlternative:
                break
            self.alternative([
                ': posts small blind ', ': posts big blind ',
                ': posts the ante '
            ])
            act = Action()
            act.action = Action.Post
            act.bet = self.number()
            actions.append([pid, act])
            self.alternative(['\n', ' and is all-in\n'])

        hand.addBetRound(preflop, actions)
 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
예제 #5
0
    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 + '"!!')
예제 #6
0
 def collectMoney(self, amount):
     act = Action()
     act.action = Action.Collect
     act.amount = amount
     return act