Пример #1
0
    def deal(self):
        """
        DESCRIPTION
            Draw cards
        """
        players = [self.pe, self.pn, self.pw, self.ps]
        for i in xrange(25):
            for player in players:
                player.drawCard(self.deck.popCard())
                print "Length of player " + str(player) + "'s current hands:" + str(len(player.hand))
                if self.rule.canDeclareTrump(player.getHand()):
                    cdlist = player.declareTrump(self.declarer, self.trumpRank, self.trumpSuit)
                    while cdlist != False and (not self.rule.isTrumpAllowed(cdlist)):
                        cdlist = player.declareTrump(self.declarer, self.trumpRank, self.trumpSuit)

                    if cdlist != False:
                        self.trumpSuit = cdlist[0].getSuit()
                        self.declarer = player

        self.deck.bottom = self.declarer.replaceBottom(self.deck.getBottom())
        print "Cards in new bottom:"
        for item in self.deck.bottom:
            print item
        print "Cards in each player's hand:"
        for player in players:
            print str(player)
            for item in player.getHand():
                print item
        print "Cards in declarer's hand:"
        for item in self.declarer.getHand():
            print item
        self.rule.setTrumpSuit(self.trumpSuit)
Пример #2
0
def showNoOfCardsInHand(players, idCurrentPlayer):
    for player in players:
        if player.getId() == idCurrentPlayer:
            continue
        cardsInHand = player.getHand().noOfCardsInHand()
        print('%s has %d cards' % (player.getName(), cardsInHand), end='; ')
    print()
Пример #3
0
def showNoOfCardsInHand(players, idCurrentPlayer):
    for player in players:
        if player.getId() == idCurrentPlayer:
            continue
        cardsInHand = player.getHand().noOfCardsInHand()
        print('%s has %d cards' % (player.getName(), cardsInHand), end='; ')
    print()
Пример #4
0
    def hit(self, ctx):
        o = ""
        if self.state == "PLAYING":
            if self.players[self.turn].name == ctx.message.author.id:
                player = self.players[self.turn]
                card = self.deck.deal()
                player.addCard(card)
                o += "<@{}> hits and receives a {}.\nYour hand is now {} for {}".format(
                    player.name, card, player.getHand(), player.getBJCount())
                if player.status == "BUST":
                    o += " - Oh, no!  <@{}> has busted!".format(player.name)
                #else:
                #o += " - Dealer has {}".format(self.dealer.getDealerHand())
                if self.players[self.turn].status != "OK":
                    self.turn += 1
            else:
                o += "Not your turn yet..."
                o += "It's <@{}>'s turn...".format(player.name)
        else:
            o += "I can't do that yet..."

        return o
Пример #5
0
 def showPlayersHands(self):
     o = "Here are the hands:"
     for player in self.players:
         o += "\n<@{}> has {} for {}".format(player.name, player.getHand(),
                                             player.getBJCount())
     return o