本文整理汇总了Python中rules.Rules.isTouching方法的典型用法代码示例。如果您正苦于以下问题:Python Rules.isTouching方法的具体用法?Python Rules.isTouching怎么用?Python Rules.isTouching使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rules.Rules
的用法示例。
在下文中一共展示了Rules.isTouching方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from rules import Rules [as 别名]
# 或者: from rules.Rules import isTouching [as 别名]
#.........这里部分代码省略.........
self.updateTurn()
return True
else:
return False
def player_attack(self,fromCountry,toCountry,howMany,player):
if self.whosTurn != player:
#raise Exception, 'player error'
return False
if self.turnStage != 'attacks':
#raise Exception, 'its not in the attack stage'
return False
if type(fromCountry)!=type('string') and type(fromCountry) != type(u'string'):
#raise Exception, 'from country is not a string'
return False
if type(toCountry)!=type('string') and type(fromCountry) != type(u'string'):
#raise Exception, 'to country is not a string'
return False
if type(player)!=type('string') and type(player) != type(u'string'):
#raise Exception, 'player is not a string'
return False
if type(howMany)!=type(1):
#raise Exception, 'how many is not a number'
return False
if not fromCountry in self.countries:
#raise Exception, 'from country is not a country'
return False
if not toCountry in self.countries:
#raise Exception, 'to country is not a country'
return False
if not player in self.players:
#raise Exception, 'player is not in this game'
return False
if not self.isTouching(fromCountry, toCountry):
#raise Exception, 'those countries do not touch'
return False
if not self.isOwned(fromCountry, player):
#raise Exception, 'attacker does not own from country'
return False
if self.isOwned(toCountry, player):
#raise Exception, 'attacker owns destination country'
return False
if self.getTroops(fromCountry) < howMany+1:
#raise Exception, 'not enough troops in fromCountry'
return False
if howMany < 1:
#raise Exception, 'attacking with less than one troop'
return False
output = self.rules.attack(fromCountry,toCountry,howMany)
if not output:
raise Exception, 'rules.attack failed'
return False
else:
self.lastAttack = output
self.updateTurn()
self.showAttackResult = True
self.justMadeFreeMove = False
return output
def player_freeMove(self,fromCountry,toCountry,howMany,player):
if type(player)!=type('string') and type(player) != type(u'string'):
return False
if self.whosTurn != player:
return False
if self.turnStage != 'attacks':
return False