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