def findToonAttack(toons, attacks, track): foundAttacks = [] for t in toons: if t in attacks: attack = attacks[t] local_track = attack[TOON_TRACK_COL] if track != NPCSOS and attack[TOON_TRACK_COL] == NPCSOS: local_track = NPCToons.getNPCTrack(attack[TOON_TGT_COL]) if local_track == track: if local_track == FIRE: canFire = 1 for attackCheck in foundAttacks: if attackCheck[TOON_TGT_COL] == attack[TOON_TGT_COL]: canFire = 0 if canFire: foundAttacks.append(attack) else: foundAttacks.append(attack) def compFunc(a, b): if a[TOON_LVL_COL] > b[TOON_LVL_COL]: return 1 elif a[TOON_LVL_COL] < b[TOON_LVL_COL]: return -1 return 0 foundAttacks.sort(compFunc) return foundAttacks
def findToonAttack(toons, attacks, track): foundAttacks = [] for t in toons: if attacks.has_key(t): attack = attacks[t] local_track = attack[TOON_TRACK_COL] if track != NPCSOS and attack[TOON_TRACK_COL] == NPCSOS: local_track = NPCToons.getNPCTrack(attack[TOON_TGT_COL]) if local_track == track: if local_track == FIRE: canFire = 1 for attackCheck in foundAttacks: if attackCheck[TOON_TGT_COL] == attack[TOON_TGT_COL]: canFire = 0 if canFire: foundAttacks.append(attack) else: foundAttacks.append(attack) def compFunc(a, b): if a[TOON_LVL_COL] > b[TOON_LVL_COL]: return 1 elif a[TOON_LVL_COL] < b[TOON_LVL_COL]: return -1 return 0 foundAttacks.sort(compFunc) return foundAttacks
def findToonAttack(toons, attacks, track): """ findToonAttack(toons, attacks, track) Return all attacks of the specified track sorted by increasing level """ foundAttacks = [] for t in toons: if (attacks.has_key(t)): attack = attacks[t] local_track = attack[TOON_TRACK_COL] # If it's an NPC, convert to the appropriate track if (track != NPCSOS and attack[TOON_TRACK_COL] == NPCSOS): local_track = NPCToons.getNPCTrack(attack[TOON_TGT_COL]) if (local_track == track): if local_track == FIRE: canFire = 1 for attackCheck in foundAttacks: if attackCheck[TOON_TGT_COL] == attack[TOON_TGT_COL]: canFire = 0 else: pass if canFire: assert(t == attack[TOON_ID_COL]) foundAttacks.append(attack) else: assert(t == attack[TOON_ID_COL]) foundAttacks.append(attack) def compFunc(a, b): if (a[TOON_LVL_COL] > b[TOON_LVL_COL]): return 1 elif (a[TOON_LVL_COL] < b[TOON_LVL_COL]): return -1 return 0 foundAttacks.sort(compFunc) return foundAttacks
def findToonAttack(toons, attacks, track): foundAttacks = [] for t in toons: if t in attacks: attack = attacks[t] local_track = attack[TOON_TRACK_COL] if track != NPCSOS and attack[TOON_TRACK_COL] == NPCSOS: local_track = NPCToons.getNPCTrack(attack[TOON_TGT_COL]) if local_track == track: if local_track == FIRE: canFire = 1 for attackCheck in foundAttacks: if attackCheck[TOON_TGT_COL] == attack[TOON_TGT_COL]: canFire = 0 if canFire: foundAttacks.append(attack) else: foundAttacks.append(attack) def compFunc(a, b): if a[TOON_LVL_COL] > b[TOON_LVL_COL]: return 1 elif a[TOON_LVL_COL] < b[TOON_LVL_COL]: return -1 return 0 def sortOnThird(gagLevel): # PY3 return gagLevel[TOON_LVL_COL] #foundAttacks.sort(compFunc) foundAttacks.sort(key=sortOnThird) # PY3 # NJF # IMPORTANT return foundAttacks
def __updateNPCFriendsPanel(self): self.NPCFriends = {} for friend, count in base.localAvatar.NPCFriendsDict.items(): track = NPCToons.getNPCTrack(friend) if track == ToontownBattleGlobals.LURE_TRACK and self.canLure == 0 or track == ToontownBattleGlobals.TRAP_TRACK and self.canTrap == 0: self.NPCFriends[friend] = 0 else: self.NPCFriends[friend] = count self.NPCFriendPanel.update(self.NPCFriends, fCallable=1)
def __updateNPCFriendsPanel(self): # Make a dict of the NPC Toons that are callable at this time self.NPCFriends = {} # Determine if any should be disabled because their # attacks won't work (e.g. all the cogs are already lured) for friend, count in list(base.localAvatar.NPCFriendsDict.items()): track = NPCToons.getNPCTrack(friend) if ((track == ToontownBattleGlobals.LURE_TRACK and self.canLure == 0) or (track == ToontownBattleGlobals.TRAP_TRACK and self.canTrap == 0)): self.NPCFriends[friend] = 0 else: self.NPCFriends[friend] = count self.NPCFriendPanel.update(self.NPCFriends, fCallable=1)