예제 #1
0
    def playTurn(self, board, diceQueue, turnCount, returnList):
        board.displayBoard()
        diceResults = self.humanRoll(diceQueue, board.humanBoard)
        coverMenu = self.generateCoverMenu(board.humanBoard, diceResults)
        uncoverMenu = self.generateUncoverMenu(board.computerBoard, diceResults)

        if returnList[2] != 0:
            self.removeHandicap(returnList, uncoverMenu)

        if not self.canMove(coverMenu, uncoverMenu):
            Interface.printMsg("There are no more moves.")
            return False

        self.displayMenu(coverMenu, uncoverMenu)
        choice = Interface.validateRange("Please choose an option: ", 1, 
                                        (len(coverMenu)+len(uncoverMenu)+1))
        choice -= 1

        while(choice == (len(coverMenu)+len(uncoverMenu))):
            self.logicString =  ""
            self.getHelp(board.humanBoard, board.computerBoard, 
                                coverMenu, uncoverMenu, turnCount)
            self.displayMenu(coverMenu, uncoverMenu)
            choice = Interface.validateRange("Please choose an option: ", 1, 
                                        (len(coverMenu)+len(uncoverMenu)+1))
            choice -= 1


        if choice < len(coverMenu):
            willCover = True
        else:
            willCover = False

        self.executeChoice(board.humanBoard, board.computerBoard, 
                                        coverMenu, uncoverMenu, choice, willCover)


        if self.checkForWin(board.humanBoard, board.computerBoard, turnCount):
            return True
        else:
            return self.playTurn(board, diceQueue, turnCount, returnList)
예제 #2
0
 def getNumSquares(self):
     squares = Interface.validateRange(
         "How many squares would you like to use? (9, 10, or 11): ",
              9, 11)
     return squares