本文整理汇总了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
示例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()
示例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()