Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Author:Isaac
- #Date: Mar 22 2018
- #Purpose: to get 2 cards
- #inputs:
- #outputs:
- #----------------------------
- import random
- class TwoCard():
- def __init__(self,a=2,b=2):
- self.cardOne = a
- self.cardTwo = b
- #Author:Isaac
- #Date: Mar 22 2018
- #Purpose: to get a random number between
- #inputs:
- #outputs:
- #----------------------------
- def getCard():
- return random.randint(2,14)
- #Author:Isaac
- #Date: Mar 22 2018
- #Purpose: to get an actual hand
- #inputs:
- #outputs:
- #----------------------------
- def getHand():
- playerHand = TwoCard()
- playerHand.cardOne = getCard()
- playerHand.cardTwo = getCard()
- return playerHand
- #Author:Isaac
- #Date: Mar 22 2018
- #Purpose: to check if it is a pair, consecutive, or a non consecutive
- #inputs:
- #outputs:
- #----------------------------
- def handType():
- firstCard = playerHand.cardOne
- secondCard = playerHand.cardTwo
- if firstCard < secondCard:
- huge = secondCard
- little = firstCard
- if firstCard == secondCard:
- whatType = 7
- elif (firstCard - secondCard) == -1:
- whatType = 8
- elif (firstCard - secondCard) == 1:
- whatType = 9
- elif firstCard != secondCard:
- whatType = 10
- return whatType
- #Author:Isaac
- #Date: Mar 22 2018
- #Purpose: to check the spread of the hand
- #inputs:
- #outputs:
- #----------------------------
- def spread():
- firstCard = playerHand.cardOne
- secondCard = playerHand.cardTwo
- if firstCard <= secondCard:
- cardSpread = secondCard - firstCard
- cardSpread = cardSpread - 1
- else:
- cardSpread = firstCard - secondCard
- cardSpread = cardSpread - 1
- return cardSpread
- #Author:Isaac
- #Date: Mar 22 2018
- #Purpose: to give the player the payout
- #inputs:
- #outputs:
- #----------------------------
- def payout():
- payoutTimes = spread()
- if payoutTimes == 1:
- payoutMulti = 5
- elif payoutTimes == 2:
- payoutMulti = 4
- elif payoutTimes == 3:
- payoutMulti = 2
- else:
- payoutMulti = 1
- return payoutMulti
- #Author:Isaac
- #Date: Mar 22 2018
- #Purpose: to give the player the payout
- #inputs:
- #outputs:
- #----------------------------
- def between():
- spreadOut = spread()
- if spreadOut >= 1:
- betweenSpace = 1
- else:
- betweenSpace = 2
- return betweenSpace
- #MAIN=============================================
- go = "y"
- playerHand = getHand()
- whatType = handType()
- cardSpread = spread()
- payoutTimes = payout()
- betweenSpace = between()
- while go == "y":
- purse = 100
- betAmount = int(input("Please input a bet amount between 1 and 100: "))
- if betAmount > 0:
- print("Your first card is ",playerHand.cardOne)
- print("Your second card is ",playerHand.cardTwo)
- if whatType == 7:
- thirdCard = getCard()
- print("Your third card",thirdCard)
- if thirdCard == playerHand.cardOne:
- purse = (purse + betAmount*11)
- else:
- print("It is a tie")
- elif whatType == 8 or whatType == 9:
- print("it is a tie")
- elif whatType == 10:
- betAdd = int(input("Do you want to make an additional bet? if so please make a bet between 0 and" + str(purse) +": "))
- betAmount = betAmount + betAdd
- thirdCard = getCard()
- print("Your third card",thirdCard)
- if thirdCard > playerHand.cardOne and thirdCard < playerHand.cardOne:
- print("You win!!")
- purse = purse + betAmount * payoutTimes
- print("your new balance ",purse)
- else:
- purse = purse - betAmount
- print(purse)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement