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


Python Rules.getPlayersAlive方法代码示例

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


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

示例1: __init__

# 需要导入模块: from rules import Rules [as 别名]
# 或者: from rules.Rules import getPlayersAlive [as 别名]

#.........这里部分代码省略.........
        if self.getTroops(fromCountry) < howMany+1:
            return False
        if self.rules.moveUnits(fromCountry, toCountry, howMany):
            self.turnStage = 'fortify'
            self.fortifiesLeft -=1
            self.updateTurn()
            return True
        else:
            return False

    def player_skip(self, player):
        if self.whosTurn != player:
            return False
        else:
            if self.turnStage == 'reinforce':
                if self.reinforcementsToPlace[self.whosTurn] <= 0:
                    self.updateTurn()
                else:
                    return False
            elif self.turnStage == 'attacks':
                self.turnStage = 'fortify'
                self.showAttackResult = False
                self.updateTurn()
                return True
            elif self.turnStage == 'fortify':
                self.fortifiesLeft = 0
                self.updateTurn()
                return True
            else:
                return False

    def player_getLastAttack(self,player):
        if self.whosTurn != player:
            return False
        else:
            return self.lastAttack

    def getReinforcements(self,player):
        """Returns the number of reinforcements the player has yet to place"""
        return self.reinforcementsToPlace[player]

    def getCoordinates(self, country):
        return self.coordinates[country]

    def getAdjacentAttacks(self, country):
        possibleAttacks = []
        player = self.getOwner(country)
        for adjCountry in self.getAdjacentCountries(country):
            if self.getOwner(adjCountry) != player:
                possibleAttacks.append(adjCountry)
        return possibleAttacks

    def getAdjacentCountries(self,country):
        return self.rules.getAdjacentCountries(country)

    def isTouching(self, country1, country2):
        return self.rules.isTouching(country1, country2)

    def isOwned(self, country, player):
        return self.rules.isOwned(country, player)

    def setSelection(self, list):
        self.selectionList = list[:]

    def getSelection(self):
        return self.selectionList[:]

    def clearSelection(self):
        self.selectionList = []

    def allOwned(countryList, player):
        return self.rules.isOwned(country, player)

    def isCountry(self,country):
        return country in self.countries

    def getOwner(self, country):
        return self.rules.getOwner(country)

    def getTroops(self, country):
        return self.rules.getTroops(country)

    def getFortifies(self):
        return self.fortifies

    @property
    def countries(self):
        return self.rules.board.getCountries()

    @property
    def players(self):
        return self.rules.players

    @property
    def playersAlive(self):
        return self.rules.getPlayersAlive()

    @property
    def states(self):
        return self.rules.board.getCountryStates()
开发者ID:thomasballinger,项目名称:Utok,代码行数:104,代码来源:game.py


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