本文整理匯總了Python中rules.Rules.moveUnits方法的典型用法代碼示例。如果您正苦於以下問題:Python Rules.moveUnits方法的具體用法?Python Rules.moveUnits怎麽用?Python Rules.moveUnits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rules.Rules
的用法示例。
在下文中一共展示了Rules.moveUnits方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from rules import Rules [as 別名]
# 或者: from rules.Rules import moveUnits [as 別名]
#.........這裏部分代碼省略.........
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
if type(fromCountry)!=type('string') and type(fromCountry) != type(u'string'):
return False
if type(toCountry)!=type('string') and type(toCountry) != type(u'string'):
return False
if type(howMany)!=type(1):
return False
if not self.lastAttack['captured']:
return False
if fromCountry != self.lastAttack['from']:
return False
if toCountry != self.lastAttack['to']:
return False
if not player in self.players:
return False
if not self.isTouching(fromCountry, toCountry):
return False
if not self.isOwned(fromCountry, player):
return False
if not self.isOwned(toCountry, player):
return False
if self.getTroops(fromCountry) < howMany+1:
return False
if self.rules.moveUnits(fromCountry, toCountry, howMany):
self.updateTurn()
self.showAttackResult = False
self.justMadeFreeMove = True
return True
else:
raise Exception, 'rules failed'
return False
def player_fortify(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 != 'fortify' and self.turnStage != 'attack':
return False
if self.fortifiesLeft <1:
return False
if type(fromCountry)!=type('string') and type(fromCountry) != type(u'string'):
return False
if type(toCountry)!=type('string') and type(toCountry) != type(u'string'):
return False
if type(howMany)!=type(1):
return False
if not self.isTouching(fromCountry, toCountry):
return False
if not self.isOwned(fromCountry, player):
return False
if not self.isOwned(toCountry, player):
return False
if self.getTroops(fromCountry) < howMany+1:
return False
if self.rules.moveUnits(fromCountry, toCountry, howMany):