Example #1
0
def wp(table, p1, dk):
    clist = cpair(dk, 2)
    # best five for player
    temp = p1.getcards()
    temp2 = table.getcards()
    for i in range(len(temp)):
        temp2.append(temp[i])
    best = checker.extract(temp2, 5)

    # compete to possible opponent cards
    cnt = 0
    # number of draw
    nod = 0
    for i in range(len(clist)):
        temp = clist[i]
        temp2 = table.getcards()
        for j in range(len(temp)):
            temp2.append(temp[j])
        oppbest = checker.extract(temp2, 5)
        fight = checker.compete([best, oppbest])
        if fight == 0:
            cnt += 1
        elif fight == 1:
            nod += 1
    return [cnt, nod, len(clist) - cnt - nod]
Example #2
0
def wp(table,p1,dk):
    clist = cpair(dk,2)
    # best five for player
    temp = p1.getcards()
    temp2 = table.getcards()
    for i in range(len(temp)):
        temp2.append(temp[i])
    best = checker.extract(temp2,5)

    # compete to possible opponent cards
    cnt = 0
    # number of draw
    nod = 0
    for i in range(len(clist)):
        temp = clist[i]
        temp2 = table.getcards()
        for j in range(len(temp)):
            temp2.append(temp[j])
        oppbest = checker.extract(temp2,5)
        fight = checker.compete([best,oppbest])
        if fight==0:
            cnt+=1
        elif fight==1:
            nod+=1
    return [cnt,nod,len(clist)-cnt-nod]
Example #3
0
def holdem(n):
    # define deck
    dk = deck.deck(1)
    dk.setdeck()

    # define table
    p = [deck.player("table", 0)]
    for i in range(n):
        p.append(deck.player(str(i + 1), 100))

    # deal 2 cards to each
    for i in range(1, len(p)):
        p[i].take(dk.deal())
        p[i].take(dk.deal())

    # bet
    ##

    # deal 2 cards to table
    p[0].take(dk.deal())
    p[0].take(dk.deal())

    # show table cards
    print "table cards"
    p[0].showcards()

    # bet
    ##

    # deal 3 more cards to table
    p[0].take(dk.deal())
    p[0].take(dk.deal())
    p[0].take(dk.deal())

    # show table cards
    print "table cards"
    p[0].showcards()
    print ""
    # bet
    ##

    # check
    # get best cards of each
    best = []
    for i in range(1, len(p)):
        if p[i].status == 1:
            continue
        temp = p[0].getcards()
        for j in range(len(temp)):
            p[i].take(temp[j])
        best.append([checker.extract(p[i].getcards(), 5), i])
    # check the winner
    win = [0]
    for i in range(1, len(best)):
        fight = checker.compete([best[win[0]][0], best[i][0]])
        if fight == 2:
            win = [i]
        elif fight == 1:
            win.append(i)
    # show result
    for i in range(len(best)):
        p[best[i][1]].showcards()
        print p[best[i][1]].name + ": " + score[checker.order(best[i][0])]
        for j in range(len(best[i][0])):
            print best[i][0][j]
        print ""
    print "The winner is "
    for i in range(len(win)):
        print p[best[win[i]][1]].name
Example #4
0
def holdem(n):
    # define deck
    dk = deck.deck(1)
    dk.setdeck()

    # define table
    p = [deck.player('table', 0)]
    for i in range(n):
        p.append(deck.player(str(i + 1), 100))

    # deal 2 cards to each
    for i in range(1, len(p)):
        p[i].take(dk.deal())
        p[i].take(dk.deal())

    # bet
    ##

    # deal 2 cards to table
    p[0].take(dk.deal())
    p[0].take(dk.deal())

    # show table cards
    print 'table cards'
    p[0].showcards()

    # bet
    ##

    # deal 3 more cards to table
    p[0].take(dk.deal())
    p[0].take(dk.deal())
    p[0].take(dk.deal())

    # show table cards
    print 'table cards'
    p[0].showcards()
    print ''
    # bet
    ##

    # check
    # get best cards of each
    best = []
    for i in range(1, len(p)):
        if p[i].status == 1:
            continue
        temp = p[0].getcards()
        for j in range(len(temp)):
            p[i].take(temp[j])
        best.append([checker.extract(p[i].getcards(), 5), i])
    # check the winner
    win = [0]
    for i in range(1, len(best)):
        fight = checker.compete([best[win[0]][0], best[i][0]])
        if fight == 2:
            win = [i]
        elif fight == 1:
            win.append(i)
    # show result
    for i in range(len(best)):
        p[best[i][1]].showcards()
        print p[best[i][1]].name + ': ' + score[checker.order(best[i][0])]
        for j in range(len(best[i][0])):
            print best[i][0][j]
        print ''
    print 'The winner is '
    for i in range(len(win)):
        print p[best[win[i]][1]].name