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


Python Interface.validateBoolean方法代码示例

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


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

示例1: humanRoll

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import validateBoolean [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

示例2: saveSequence

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import validateBoolean [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

示例3: askToPlayAgain

# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import validateBoolean [as 别名]
    def askToPlayAgain(self):
        willPlay = Interface.validateBoolean("Would you like to play another round? (y/n): ")

        if willPlay:
            return True
        self.terminate()
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:8,代码来源:tournament.py


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