当前位置: 首页>>代码示例>>Python>>正文


Python Interface.printMsg方法代码示例

本文整理汇总了Python中interface.Interface.printMsg方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.printMsg方法的具体用法?Python Interface.printMsg怎么用?Python Interface.printMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在interface.Interface的用法示例。


在下文中一共展示了Interface.printMsg方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: computerRoll

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import printMsg [as 别名]
    def computerRoll(self, diceQueue, myBoard):
        Interface.printMsg("The Computer is rolling...")
        time.sleep(1)
        if diceQueue:
            diceResults = diceQueue[0][0] + diceQueue[0][1]
            diceQueue.pop(0)
        else:
            if self.willRollSingleDie(myBoard):
                diceResults = self.rollSingleDie()
            else:
                diceResults = self.rollDice()

        message = "The Computer rolled " + repr(diceResults)
        Interface.printMsg(message)
        return diceResults
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:17,代码来源:computer.py

示例2: humanRoll

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import printMsg [as 别名]
    def humanRoll(self, diceQueue, myBoard):
        Interface.printMsg("You are rolling...")
        time.sleep(1)
        if diceQueue:
            diceResults = diceQueue[0][0] + diceQueue[0][1]
            diceQueue.pop(0)
        else:
            if self.canRollSingleDie(myBoard) and Interface.validateBoolean(
                            "Would you like to roll one die? (y/n): "):
                diceResults = self.rollSingleDie()
            else:
                diceResults = self.rollDice()

        message = "You rolled " + repr(diceResults)
        Interface.printMsg(message)
        return diceResults
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:18,代码来源:human.py

示例3: applyHandicap

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import printMsg [as 别名]
 def applyHandicap(self, handicapSquare):
     if self.returnList[0] and self.humanIsFirstPlayer:
         Interface.printMsg("The Computer gets a handicap.")
         self.board.computerBoard[handicapSquare-1] = "*"
     if self.returnList[0] and not self.humanIsFirstPlayer:
         Interface.printMsg("You get a handicap.")
         self.board.humanBoard[handicapSquare-1] = "*"
     if not self.returnList[0] and not self.humanIsFirstPlayer:
         Interface.printMsg("You get a handicap.")
         self.board.humanBoard[handicapSquare-1] = "*"
     if not self.returnList[0] and self.humanIsFirstPlayer:
         Interface.printMsg("The Computer gets a handicap.")
         self.board.computerBoard[handicapSquare-1] = "*"
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:15,代码来源:tournament.py

示例4: playTurn

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import printMsg [as 别名]
    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)
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:43,代码来源:human.py

示例5: playTurn

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import printMsg [as 别名]
    def playTurn(self, board, diceQueue, turnCount, returnList):
        board.displayBoard()
        diceResults = self.computerRoll(diceQueue, board.computerBoard)
        coverMenu = self.generateCoverMenu(board.computerBoard, diceResults)    
        uncoverMenu = self.generateUncoverMenu(board.humanBoard, diceResults)

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

        # Returns false if human is next
        if not self.canMove(coverMenu, uncoverMenu):
            Interface.printMsg("There are no more moves.")
            return False

        willCover = self.willCover(board.computerBoard, board.humanBoard, coverMenu, 
                                    uncoverMenu, turnCount)
        choice = self.chooseBestOption(board.computerBoard, board.humanBoard, 
                                            coverMenu, uncoverMenu, willCover)
        self.executeChoice(board.computerBoard, board.humanBoard, 
                                            coverMenu, uncoverMenu, choice, willCover)
        mergedMenu = coverMenu + uncoverMenu

        self.logicString = (self.getChoiceString(mergedMenu[choice]) + 
                                        self.logicString)

        prefix = "The Computer chose to "

        if willCover:
            prefix += "cover "
        else:
            prefix += "uncover "

        self.printLogic(prefix)
        self.logicString = ""

        # Returns true if the computer has won the round
        if self.checkForWin(board.computerBoard, board.humanBoard, turnCount):
            return True
        else:
            return self.playTurn(board, diceQueue, turnCount, returnList)
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:42,代码来源:computer.py

示例6: saveSequence

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import printMsg [as 别名]
    def saveSequence(self):
        willSave = Interface.validateBoolean("Would you like to save and quit? (y/n): ")

        if not willSave:
            return

        saveFile = open("savedData.txt", 'w')

        Interface.printMsg("Saving data...")
        time.sleep(1)

        saveFile.write("Computer:\n")
        saveFile.write("\tSquares: " + self.getBoardString(self.board.computerBoard) + "\n")
        saveFile.write("\tScore: " + repr(self.computer.score) + "\n")
        saveFile.write("\n")
        saveFile.write("Human:\n")
        saveFile.write("\tSquares: " + self.getBoardString(self.board.humanBoard) + "\n")
        saveFile.write("\tScore: " + repr(self.human.score) + "\n")
        saveFile.write("\n")     
        firstString = "First Turn: "
        if self.humanIsFirstPlayer:
            firstString += "Human\n"
        else:
            firstString += "Computer\n"

        nextString = "Next Turn: "
        if self.humanIsNext:
            nextString += "Human\n"
        else:
            nextString += "Computer\n"

        saveFile.write(firstString)
        saveFile.write(nextString)
        saveFile.write("\n")
        saveFile.write("Dice: ")

        Interface.printMsg("Game saved.")

        self.terminate()
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:41,代码来源:cround.py

示例7: winSequence

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import printMsg [as 别名]
    def winSequence(self):
        if self.humanWon:
            Interface.printMsg("You won the round!")
            if len(self.board.humanBoard) == self.board.humanBoard.count("*"):
                score = self.computeScoreCover(self.board.computerBoard)
                self.human.score += score
                Interface.printMsg("You have been awarded " + repr(score) + " points!")
            else:
                score = self.computeScoreUncover(self.board.humanBoard)
                self.human.score += score
                Interface.printMsg("You have been awarded " + repr(score) + " points!")

        else:
            Interface.printMsg("The Computer won the round!")
            if len(self.board.computerBoard) == self.board.computerBoard.count("*"):
                score = self.computeScoreCover(self.board.humanBoard)
                self.computer.score += score
                Interface.printMsg("The Computer has been awarded " 
                                + repr(score) + " points!")
            else:
                score = self.computeScoreUncover(self.board.computerBoard)
                self.computer.score += score
                Interface.printMsg("The Computer has been awarded " + repr(score)
                                                 + " points!")

        self.winningScore = score
        self.returnList[0] = self.humanWon
        self.returnList[1] = self.winningScore
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:30,代码来源:cround.py

示例8: chooseFirstPlayer

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import printMsg [as 别名]
    def chooseFirstPlayer(self):
        if self.diceQueue:
            Interface.printMsg("You are rolling...")
            humanRoll = self.diceQueue[0][0] + self.diceQueue[0][1]
            self.diceQueue.pop(0)
            Interface.printMsg("You rolled " + repr(humanRoll))
            Interface.printMsg("The Computer is rolling...")
            computerRoll = self.diceQueue[0][0] + self.diceQueue[0][1]
            Interface.printMsg("The Computer rolled " + repr(computerRoll))
            self.diceQueue.pop(0)
        else:
            Interface.printMsg("You are rolling...")
            humanRoll = self.human.rollDice()
            Interface.printMsg("You rolled " + repr(humanRoll))
            Interface.printMsg("The Computer is rolling...")
            computerRoll = self.computer.rollDice()
            Interface.printMsg("The Computer rolled " + repr(computerRoll))

        if humanRoll > computerRoll:
            Interface.printMsg("You go first!")
            self.humanIsFirstPlayer = 1
            self.humanIsNext = 1
        elif humanRoll < computerRoll:
            Interface.printMsg("The Computer goes first!")
            self.humanIsFirstPlayer = 0
            self.humanIsNext = 0
        else:
            Interface.printMsg("It was a tie!")
            self.chooseFirstPlayer()
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:31,代码来源:tournament.py

示例9: printLogic

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import printMsg [as 别名]
 def printLogic(self, prefix):
     fullString = prefix + self.logicString
     Interface.printMsg(fullString)
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:5,代码来源:player.py


注:本文中的interface.Interface.printMsg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。