def __str__(self):
     s = 'BattleSkillDiary\n'
     s += ' Skill: Timestamp\n'
     for (skillId, details) in self._BattleSkillDiary__timers.items():
         skillName = WeaponGlobals.getSkillName(skillId)
         state = ('Idle', 'Charging')[details[0]]
         dt = details[1]
         timeStamp = details[2]
         remaining = self.getTimeRemaining(skillId)
         s += ' %s (%s): %s, dt=%f, t=%f, remaining=%f (s)\n' % (skillName, skillId, state, dt, timeStamp, remaining)
     
     for (skillId, details) in self._BattleSkillDiary__hits.items():
         skillName = WeaponGlobals.getSkillName(skillId)
         hits = details[0]
         remaining = self.getTimeRemaining(skillId)
         s += ' %s (%s): %s, hits=%f, remaining=%f (s)\n' % (skillName, skillId, hits, remaining)
     
     return s
Exemple #2
0
 def update(self, repId = None, fromUser = 0):
     inv = localAvatar.getInventory()
     if not inv:
         self.notify.warning('SkillPage unable to find inventory')
         return None
     
     if self.tabBar == None:
         return None
     
     if self.demo:
         return None
     
     if fromUser:
         self.lastUserSelectedTab = repId
     
     if repId == None:
         if localAvatar.getGameState() == 'Fishing':
             if self.lastUserSelectedTab:
                 repId = self.lastUserSelectedTab
             else:
                 repId = InventoryType.CannonRep
         elif localAvatar.cannon:
             repId = InventoryType.CannonRep
         elif localAvatar.gameFSM.state == 'ShipPilot':
             repId = InventoryType.SailingRep
         elif localAvatar.currentWeaponId and localAvatar.isWeaponDrawn:
             repId = WeaponGlobals.getRepId(localAvatar.currentWeaponId)
         elif localAvatar.currentWeaponId and not (localAvatar.isWeaponDrawn) and self.lastUserSelectedTab:
             repId = self.lastUserSelectedTab
         else:
             repId = InventoryType.CannonRep
     
     self.setRep(repId)
     self.tabBar.selectTab(str(repId))
     self.repMeter.setCategory(repId)
     self.repMeter.update(inv.getReputation(repId))
     unSpentId = self.getUnspent()
     amt = inv.getStackQuantity(unSpentId)
     if unSpentId in self.localMods:
         amt = self.localMods[unSpentId]
     
     self.unspent['text'] = PLocalizer.SkillPageUnspentPoints % amt
     if amt > 0:
         self.unspent['text_fg'] = (0.80000000000000004, 1, 0.80000000000000004, 1)
     else:
         self.unspent['text_fg'] = (1, 1, 1, 1)
     comboSkills = RadialMenu.ComboSkills(repId, 1)
     totalComboSkills = RadialMenu.ComboSkills(repId, 0)
     activeSkills = RadialMenu.ActiveSkills(repId, 1)
     totalActiveSkills = RadialMenu.ActiveSkills(repId, 0)
     passiveSkills = RadialMenu.PassiveSkills(repId, 1)
     totalPassiveSkills = RadialMenu.PassiveSkills(repId, 0)
     self.linkedSkillIds = { }
     linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId)
     if linkedSkills:
         for skillId in linkedSkills:
             realSkillId = WeaponGlobals.getLinkedSkillId(skillId)
             self.linkedSkillIds[realSkillId] = skillId
         
     
     for excludedSkillId in self.EXCLUDED_SKILLS:
         for skillId in activeSkills:
             if excludedSkillId == skillId:
                 activeSkills.remove(skillId)
                 totalActiveSkills.remove(skillId)
                 continue
         
     
     for spot in self.skillFrames.keys():
         if spot not in totalComboSkills:
             self.skillFrames[spot].hide()
             continue
     
     count = 0
     for skill in totalComboSkills:
         skillPts = inv.getStackQuantity(skill)
         if skill in self.localMods:
             skillPts = self.localMods[skill]
         
         if not skill in comboSkills:
             pass
         showIcon = skillPts > 0
         freeLock = False
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 freeLock = True
             
         
         if self.linkedSkillIds.has_key(skill):
             if self.skillFrames.has_key(skill):
                 self.skillFrames[skill].hide()
             
             skill = self.linkedSkillIds[skill]
         
         self.createFrame(skill, skillPts, amt, freeLock, showIcon)
         x = 0.20000000000000001 + 0.17499999999999999 * count
         y = 1.1100000000000001
         self.skillFrames[skill].setPos(x, 0, y)
         if showIcon and skillPts > 1:
             self.makeBoostDisplay(skill, skillPts - 1)
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 self.skillFrames[skill].skillButton['extraArgs'] = [
                     'Restricted_Skill_' + WeaponGlobals.getSkillName(skill),
                     5]
             
         
         count += 1
     
     count = 0
     for skill in totalActiveSkills:
         skillPts = inv.getStackQuantity(skill)
         if skill in self.localMods:
             skillPts = self.localMods[skill]
         
         (xMod, yMod) = self.ringOffset(count)
         xMod *= 0.90000000000000002
         yMod *= 0.90000000000000002
         if not skill in activeSkills:
             pass
         showIcon = skillPts > 0
         freeLock = False
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 freeLock = True
             
         
         if self.linkedSkillIds.has_key(skill):
             if self.skillFrames.has_key(skill):
                 self.skillFrames[skill].hide()
             
             skill = self.linkedSkillIds[skill]
         
         self.createFrame(skill, skillPts, amt, freeLock, showIcon)
         x = xMod + 0.53000000000000003
         y = yMod + 0.61499999999999999
         self.skillFrames[skill].setPos(x, 0, y)
         if showIcon and skillPts > 1:
             self.makeBoostDisplay(skill, skillPts - 1)
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 self.skillFrames[skill].skillButton['extraArgs'] = [
                     'Restricted_Skill_' + WeaponGlobals.getSkillName(skill),
                     5]
             
         
         ammo = self.getAmmo(skill)
         if ammo != None and showIcon:
             self.skillFrames[skill].showQuantity = True
             self.skillFrames[skill].updateQuantity(ammo)
         
         count += 1
     
     count = 0
     for skill in totalPassiveSkills:
         skillPts = inv.getStackQuantity(skill)
         if skill in self.localMods:
             skillPts = self.localMods[skill]
         
         if not skill in passiveSkills:
             pass
         showIcon = skillPts > 0
         freeLock = False
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 freeLock = True
             
         
         if self.linkedSkillIds.has_key(skill):
             if self.skillFrames.has_key(skill):
                 self.skillFrames[skill].hide()
             
             skill = self.linkedSkillIds[skill]
         
         self.createFrame(skill, skillPts, amt, freeLock, showIcon)
         x = 0.20000000000000001 + 0.17499999999999999 * count
         y = 0.14999999999999999
         self.skillFrames[skill].setPos(x, 0, y)
         if showIcon and skillPts > 1:
             self.makeBoostDisplay(skill, skillPts - 1)
         
         if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
             if not WeaponGlobals.canFreeUse(skill):
                 self.skillFrames[skill].skillButton['command'] = base.localAvatar.guiMgr.showNonPayer
                 self.skillFrames[skill].skillButton['extraArgs'] = [
                     'Restricted_Skill_' + WeaponGlobals.getSkillName(skill),
                     5]
             
         
         count += 1
     
     self.dataChanged = False
    def update(self, repId=None, fromUser=0):
        inv = localAvatar.getInventory()
        if not inv:
            self.notify.warning('SkillPage unable to find inventory')
            return
        if self.tabBar == None:
            return
        if self.demo:
            return
        if fromUser:
            self.lastUserSelectedTab = repId
        if repId == None:
            if localAvatar.getGameState() == 'Fishing':
                if self.lastUserSelectedTab:
                    repId = self.lastUserSelectedTab
                else:
                    repId = InventoryType.CannonRep
            elif localAvatar.cannon:
                repId = InventoryType.CannonRep
            elif localAvatar.gameFSM.state == 'ShipPilot':
                repId = InventoryType.SailingRep
            elif localAvatar.currentWeaponId and localAvatar.isWeaponDrawn:
                repId = WeaponGlobals.getRepId(localAvatar.currentWeaponId)
            elif localAvatar.currentWeaponId and not localAvatar.isWeaponDrawn and self.lastUserSelectedTab:
                repId = self.lastUserSelectedTab
            else:
                repId = InventoryType.CannonRep
        self.setRep(repId)
        self.tabBar.selectTab(str(repId))
        self.repMeter.setCategory(repId)
        self.repMeter.update(inv.getReputation(repId))
        unSpentId = self.getUnspent()
        amt = inv.getStackQuantity(unSpentId)
        if unSpentId in self.localMods:
            amt = self.localMods[unSpentId]
        self.unspent['text'] = PLocalizer.SkillPageUnspentPoints % amt
        if amt > 0:
            self.unspent['text_fg'] = (0.8, 1, 0.8, 1)
        else:
            self.unspent['text_fg'] = (1, 1, 1, 1)
        comboSkills = RadialMenu.ComboSkills(repId, 1)
        totalComboSkills = RadialMenu.ComboSkills(repId, 0)
        activeSkills = RadialMenu.ActiveSkills(repId, 1)
        totalActiveSkills = RadialMenu.ActiveSkills(repId, 0)
        passiveSkills = RadialMenu.PassiveSkills(repId, 1)
        totalPassiveSkills = RadialMenu.PassiveSkills(repId, 0)
        self.linkedSkillIds = {}
        linkedSkills = ItemGlobals.getLinkedSkills(localAvatar.currentWeaponId)
        if linkedSkills:
            for skillId in linkedSkills:
                realSkillId = WeaponGlobals.getLinkedSkillId(skillId)
                self.linkedSkillIds[realSkillId] = skillId

        for excludedSkillId in self.EXCLUDED_SKILLS:
            for skillId in activeSkills:
                if excludedSkillId == skillId:
                    activeSkills.remove(skillId)
                    totalActiveSkills.remove(skillId)

        for spot in self.skillFrames.keys():
            if spot not in totalComboSkills:
                self.skillFrames[spot].hide()

        count = 0
        for skill in totalComboSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            showIcon = skill in comboSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = 0.2 + 0.175 * count
            y = 1.11
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            count += 1

        count = 0
        for skill in totalActiveSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            xMod, yMod = self.ringOffset(count)
            xMod *= 0.9
            yMod *= 0.9
            showIcon = skill in activeSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = xMod + 0.53
            y = yMod + 0.615
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            ammo = self.getAmmo(skill)
            if ammo != None and showIcon:
                self.skillFrames[skill].showQuantity = True
                self.skillFrames[skill].updateQuantity(ammo)
            count += 1

        count = 0
        for skill in totalPassiveSkills:
            skillPts = inv.getStackQuantity(skill)
            if skill in self.localMods:
                skillPts = self.localMods[skill]
            showIcon = skill in passiveSkills or skillPts > 0
            freeLock = False
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    freeLock = True
            if self.linkedSkillIds.has_key(skill):
                if self.skillFrames.has_key(skill):
                    self.skillFrames[skill].hide()
                skill = self.linkedSkillIds[skill]
            self.createFrame(skill, skillPts, amt, freeLock, showIcon)
            x = 0.2 + 0.175 * count
            y = 0.15
            self.skillFrames[skill].setPos(x, 0, y)
            if showIcon and skillPts > 1:
                self.makeBoostDisplay(skill, skillPts - 1)
            if not Freebooter.getPaidStatus(base.localAvatar.getDoId()):
                if not WeaponGlobals.canFreeUse(skill):
                    self.skillFrames[skill].skillButton[
                        'command'] = base.localAvatar.guiMgr.showNonPayer
                    self.skillFrames[skill].skillButton['extraArgs'] = [
                        'Restricted_Skill_' +
                        WeaponGlobals.getSkillName(skill), 5
                    ]
            count += 1

        self.dataChanged = False
        return