def __doNPCSOS(sos): npcId = sos['npcId'] track, level, hp = NPCToons.getNPCTrackLevelHp(npcId) if track != None: return NPCSOSfn_dict[track](sos, level, hp) else: return __cogsMiss(sos, 0, 0) return
def __doNPCSOS(sos): npcId = sos['npcId'] track, level, hp = NPCToons.getNPCTrackLevelHp(npcId) if track != None: return NPCSOSfn_dict[track](sos, level, hp) else: return __cogsMiss(sos, 0, 0) return
def __genToonAttackDicts(self, toons, suits, toonAttacks): for ta in toonAttacks: targetGone = 0 track = ta[TOON_TRACK_COL] if track != NO_ATTACK: adict = {} toonIndex = ta[TOON_ID_COL] toonId = toons[toonIndex] toon = self.battle.findToon(toonId) if toon == None: continue level = ta[TOON_LVL_COL] adict['toon'] = toon adict['track'] = track adict['level'] = level hps = ta[TOON_HP_COL] kbbonuses = ta[TOON_KBBONUS_COL] if track == NPCSOS: adict['npcId'] = ta[TOON_TGT_COL] toonId = ta[TOON_TGT_COL] track, npc_level, npc_hp = NPCToons.getNPCTrackLevelHp(adict['npcId']) if track == None: track = NPCSOS adict['track'] = track adict['level'] = npc_level elif track == PETSOS: petId = ta[TOON_TGT_COL] adict['toonId'] = toonId adict['petId'] = petId if track == SOS: targetId = ta[TOON_TGT_COL] if targetId == base.localAvatar.doId: target = base.localAvatar adict['targetType'] = 'callee' elif toon == base.localAvatar: target = base.cr.identifyAvatar(targetId) adict['targetType'] = 'caller' else: target = None adict['targetType'] = 'observer' adict['target'] = target elif track == NPCSOS or track == NPC_COGS_MISS or track == NPC_TOONS_HIT or track == NPC_RESTOCK_GAGS or track == PETSOS: adict['special'] = 1 toonHandles = [] for t in toons: if t != -1: target = self.battle.findToon(t) if target == None: continue if track == NPC_TOONS_HIT and t == toonId: continue toonHandles.append(target) adict['toons'] = toonHandles suitHandles = [] for s in suits: if s != -1: target = self.battle.findSuit(s) if target == None: continue suitHandles.append(target) adict['suits'] = suitHandles if track == PETSOS: del adict['special'] targets = [] for t in toons: if t != -1: target = self.battle.findToon(t) if target == None: continue tdict = {} tdict['toon'] = target tdict['hp'] = hps[toons.index(t)] self.notify.debug('PETSOS: toon: %d healed for hp: %d' % (target.doId, hps[toons.index(t)])) targets.append(tdict) if len(targets) > 0: adict['target'] = targets elif track == HEAL: if levelAffectsGroup(HEAL, level): targets = [] for t in toons: if t != toonId and t != -1: target = self.battle.findToon(t) if target == None: continue tdict = {} tdict['toon'] = target tdict['hp'] = hps[toons.index(t)] self.notify.debug('HEAL: toon: %d healed for hp: %d' % (target.doId, hps[toons.index(t)])) targets.append(tdict) if len(targets) > 0: adict['target'] = targets else: targetGone = 1 else: targetIndex = ta[TOON_TGT_COL] if targetIndex < 0: targetGone = 1 else: targetId = toons[targetIndex] target = self.battle.findToon(targetId) if target != None: tdict = {} tdict['toon'] = target tdict['hp'] = hps[targetIndex] adict['target'] = tdict else: targetGone = 1 elif attackAffectsGroup(track, level, ta[TOON_TRACK_COL]): targets = [] for s in suits: if s != -1: target = self.battle.findSuit(s) if ta[TOON_TRACK_COL] == NPCSOS: if track == LURE and self.battle.isSuitLured(target) == 1: continue elif track == TRAP and (self.battle.isSuitLured(target) == 1 or target.battleTrap != NO_TRAP): continue targetIndex = suits.index(s) sdict = {} sdict['suit'] = target sdict['hp'] = hps[targetIndex] if ta[TOON_TRACK_COL] == NPCSOS and track == DROP and hps[targetIndex] == 0: continue sdict['kbbonus'] = kbbonuses[targetIndex] sdict['died'] = ta[SUIT_DIED_COL] & 1 << targetIndex sdict['revived'] = ta[SUIT_REVIVE_COL] & 1 << targetIndex if sdict['died'] != 0: pass sdict['leftSuits'] = [] sdict['rightSuits'] = [] targets.append(sdict) adict['target'] = targets else: targetIndex = ta[TOON_TGT_COL] if targetIndex < 0: targetGone = 1 else: targetId = suits[targetIndex] target = self.battle.findSuit(targetId) sdict = {} sdict['suit'] = target if self.battle.activeSuits.count(target) == 0: targetGone = 1 suitIndex = 0 else: suitIndex = self.battle.activeSuits.index(target) leftSuits = [] for si in xrange(0, suitIndex): asuit = self.battle.activeSuits[si] if self.battle.isSuitLured(asuit) == 0: leftSuits.append(asuit) lenSuits = len(self.battle.activeSuits) rightSuits = [] if lenSuits > suitIndex + 1: for si in xrange(suitIndex + 1, lenSuits): asuit = self.battle.activeSuits[si] if self.battle.isSuitLured(asuit) == 0: rightSuits.append(asuit) sdict['leftSuits'] = leftSuits sdict['rightSuits'] = rightSuits sdict['hp'] = hps[targetIndex] sdict['kbbonus'] = kbbonuses[targetIndex] sdict['died'] = ta[SUIT_DIED_COL] & 1 << targetIndex sdict['revived'] = ta[SUIT_REVIVE_COL] & 1 << targetIndex if sdict['revived'] != 0: pass if sdict['died'] != 0: pass if track == DROP or track == TRAP: adict['target'] = [sdict] else: adict['target'] = sdict adict['hpbonus'] = ta[TOON_HPBONUS_COL] adict['sidestep'] = ta[TOON_ACCBONUS_COL] if 'npcId' in adict: adict['sidestep'] = 0 adict['battle'] = self.battle adict['playByPlayText'] = self.playByPlayText if targetGone == 0: self.toonAttackDicts.append(adict) else: self.notify.warning('genToonAttackDicts() - target gone!') def compFunc(a, b): alevel = a['level'] blevel = b['level'] if alevel > blevel: return 1 elif alevel < blevel: return -1 return 0 self.toonAttackDicts.sort(compFunc) return