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


Python Interface.validateRange方法代码示例

本文整理汇总了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)
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:43,代码来源:human.py

示例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
开发者ID:nightCapLounge,项目名称:Canoga-Python,代码行数:7,代码来源:tournament.py


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