本文整理汇总了Python中interface.Interface.validateRange方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.validateRange方法的具体用法?Python Interface.validateRange怎么用?Python Interface.validateRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.Interface
的用法示例。
在下文中一共展示了Interface.validateRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: playTurn
# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import validateRange [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)
示例2: getNumSquares
# 需要导入模块: from interface import Interface [as 别名]
# 或者: from interface.Interface import validateRange [as 别名]
def getNumSquares(self):
squares = Interface.validateRange(
"How many squares would you like to use? (9, 10, or 11): ",
9, 11)
return squares