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


Python Rules.isTouching方法代碼示例

本文整理匯總了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
開發者ID:thomasballinger,項目名稱:Utok,代碼行數:70,代碼來源:game.py


注:本文中的rules.Rules.isTouching方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。