當前位置: 首頁>>代碼示例>>Python>>正文


Python Rules.getOwner方法代碼示例

本文整理匯總了Python中rules.Rules.getOwner方法的典型用法代碼示例。如果您正苦於以下問題:Python Rules.getOwner方法的具體用法?Python Rules.getOwner怎麽用?Python Rules.getOwner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rules.Rules的用法示例。


在下文中一共展示了Rules.getOwner方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from rules import Rules [as 別名]
# 或者: from rules.Rules import getOwner [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.getOwner方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。