Exemplo n.º 1
0
    def startRound(self):
        playing = True
        while playing:
            for i in range(len(self.__players)):
                running = True
                while running:
                    player = self.__players[i]
                    alive = True
                    self.printAllPlayerScores()
                    print("Current Player: " + player.getName() +
                          "\nYour score at this turn: " + str(player.getCurrentPoints()) + "\n")
                    if self.__round == 0:
                        print(player.getName()+" your first dice at this turn will be automatically rolled!")
                        print("\nready?\n")
                        input("press enter to continue... ")
                        alive = self.rollTheDice(player)
                        if alive:
                            running = True
                            self.__round += 1
                        else:
                            running = False
                            self.__round = 0
                    else:
                        choiceMade = False
                        while not choiceMade:
                            choice = input(
                                player.getName() + " choose your next decision: 'r' to roll the dice  "
                                "'p': pass the turn and save your score:\n")
                            if choice == 'r':
                                alive = self.rollTheDice(player)
                                choiceMade = True
                                if alive:
                                    running = True
                                    self.__round += 1
                                else:
                                    running = False
                                    self.__round = 0
                            elif choice == 'p':
                                player.addCurrentPointstoSavedPoints()
                                if int(i+2) > len(self.__players):
                                    print("Pass the dice over to " + self.__players[0].getName())
                                else:
                                    print("Pass the dice over to " + self.__players[i+1].getName())

                                self.__round = 0
                                choiceMade = True
                                running = False
                                break
                    if player.getSavedPoints() >= self.__maxPoints:
                        playing = False
                        print(player.getName() + " won the game with a score of " + str(player.getCurrentPoints() + player.getSavedPoints()))
                        return
Exemplo n.º 2
0
Arquivo: main.py Projeto: halexus/Uno
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()
Exemplo n.º 3
0
Arquivo: main.py Projeto: halexus/Uno
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()
Exemplo n.º 4
0
	def writeInfo(self):
		fileList = ["qbroster.json","rbroster.json","wrroster.json","teroster.json","kickerroster.json","teamroster.json"]
		print len(fileList), " FILE LIST LEN ",len(self.dictList), "DICT LIST LENGTH "
		for i in range(0,len(self.dictList)):#dictionary in self.dictList:
			var = sorted(self.dictList[i].values(),key=lambda player:player.getFV(),reverse=True)
			with open(fileList[i],"w") as outfile:
				outfile.write("{")
				var = var[0:2]
				notFirstEntry = False
				for player in var:
					if notFirstEntry:
						outfile.write(",")
					else:
						notFirstEntry = True

					if self.dictList[i] is self.Teams:
						outfile.write("\""+player.getTeam()+"\":{")
						print "wee"
					else:
						outfile.write("\""+player.getName()+"\":{")
						print "noo"

					outfile.write("\"Stats\":")
					json.dump(player.getStatsDict(),outfile,indent=4)
					outfile.write(",\"Record\":")
					json.dump(player.getRecordDict(),outfile,indent=4)
					outfile.write("}")
				outfile.write("}")
		'''
Exemplo n.º 5
0
def takePlayerTurn(player):
    print(" ")
    print(player.getName(),", it is your turn")
    print("Your Letters are:",player.printLetters())
    word = input('Enter a word to play (or press enter to pass): ')

    check = player.checkWord(word)
    if check:
        print('Great Job!')
    else:
        print('Try again!')
Exemplo n.º 6
0
    def turn(self):
        cards_played = []
        for player in self.players:
            cards_played.append((player.getName(), player.playCard()))

        def getKey(item):
            return item[1]

        cards_played = sorted(cards_played, key=getKey)

        for players_card in cards_played:
            stacks = self.dealer.updateStacks(players_card)
            choice = self.players[players_card[0]].pickStack(stacks)
            self.dealer.removeStack(choice, players_card)
Exemplo n.º 7
0
def main():
    print("""Welcome! Time to play! Try to use all of your letters.
The first player that uses all of their letters wins!""")
    print('Great, Lets play!')
    players = getPlayers()

    while True:
        for player in players:

            current_letters = player.printLetters()
            if len(player.getLetters()) == 0:
                print(player.getName() + ' Won!')
                exit()
            print(player.getName() + ' it is your turn')
            print('Your current letters are ' + current_letters)

            while True:
                word = input('Enter a word. ')
                if word == '':
                    player.drawLetter()
                    break
                elif player.checkWord(word):
                    break
Exemplo n.º 8
0
def main():

        menu = formatMenu()
        for i in range(len(menu)):
            print(menu[i])

        startGame()

        while gameNotOver(g_player_name):
            for player in g_player_name:
                takePlayerTurn(player)

        for player in g_player_name:
            if len(player.getLetters()) == 0:
                print(player.getName(),",Congradulations. You Win")
Exemplo n.º 9
0
def gameLoop(player, letters):
	name = player.getName()
	print ('\n' + str(name) + ', it is your turn')
	print ('Your letters are: ' + letters )
	string = getUserString('Enter a word to play or press enter to pass: '******'Good Job\n')
		return True
	else:
		print ('Check your letters and try again')
		return False
Exemplo n.º 10
0
 def printHand(self, player):
     print(player.getName() + "'s hand is:")
     player.printHand()
Exemplo n.º 11
0
 def getAllPlayerNames(self):
     nameList = []
     for player in self.playerList:
         nameList.append(player.getName())
     return nameList