NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

standingData.py (4526B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\standings\standingData.py
      2 import inventorycommon.const as invconst
      3 from carbonui.util.color import Color
      4 from eve.client.script.ui.shared.standings import standingUIConst
      5 from eve.client.script.ui.station.agents.agentDialogueUtil import GetAgentNameAndLevel
      6 from eve.common.script.util import standingUtil
      7 from eve.common.script.util.standingUtil import GetStandingBonusSkillTypeID, GetFactionIDFromOwnerID
      8 STANDINGS_SKILLS = (invconst.typeDiplomacy, invconst.typeConnections, invconst.typeCriminalConnections)
      9 
     10 class StandingData(object):
     11 
     12     def __init__(self, ownerID1, ownerID2, standing1to2 = None, standing2to1 = None, standingIncrease = None):
     13         self.ownerID1 = ownerID1
     14         self.ownerID2 = ownerID2
     15         self.standing1to2 = standing1to2
     16         self.standing2to1 = standing2to1
     17         self.standingIncrease = standingIncrease
     18         if standing1to2 is None and standing2to1 is None:
     19             raise ValueError('No standings set')
     20 
     21     def GetOwnerID1(self):
     22         return self.ownerID1
     23 
     24     def GetOwnerID2(self):
     25         return self.ownerID2
     26 
     27     def GetStanding2To1(self):
     28         return self._GetStandingWithBonus(self.ownerID2, self.ownerID1, self.standing2to1)
     29 
     30     def GetStanding1To2(self):
     31         return self._GetStandingWithBonus(self.ownerID1, self.ownerID2, self.standing1to2)
     32 
     33     def GetStandingIncrease(self):
     34         if self.standingIncrease > 0.01:
     35             return min(self.standingIncrease, 10.0)
     36         return 0.0
     37 
     38     def GetOwner1Name(self):
     39         return self._GetOwnerName(self.ownerID1)
     40 
     41     def GetOwner2Name(self):
     42         return self._GetOwnerName(self.ownerID2)
     43 
     44     def GetSkillTypeID1To2(self):
     45         factionID = GetFactionIDFromOwnerID(self.ownerID1)
     46         return GetStandingBonusSkillTypeID(factionID, self.standing1to2)
     47 
     48     def GetSkillTypeID2To1(self):
     49         factionID = GetFactionIDFromOwnerID(self.ownerID2)
     50         return GetStandingBonusSkillTypeID(factionID, self.standing2to1)
     51 
     52     def _GetOwnerName(self, ownerID):
     53         agentsSvc = sm.GetService('agents')
     54         if agentsSvc.IsAgent(ownerID):
     55             agent = agentsSvc.GetAgentByID(ownerID)
     56             return GetAgentNameAndLevel(ownerID, agent.level)
     57         else:
     58             return cfg.eveowners.Get(ownerID).ownerName
     59 
     60     def GetOwner1TypeID(self):
     61         return cfg.eveowners.Get(self.ownerID1).typeID
     62 
     63     def GetOwner2TypeID(self):
     64         return cfg.eveowners.Get(self.ownerID2).typeID
     65 
     66     def _GetStandingWithBonus(self, fromID, toID, standing):
     67         if toID == session.charid:
     68             _, bonus = standingUtil.GetStandingBonus(standing, fromID, self.GetStandingsSkills())
     69         else:
     70             bonus = 0.0
     71         return standingUtil.ApplyBonusToStanding(bonus, standing)
     72 
     73     def GetStandingBonus2To1(self):
     74         bonus = round(self.GetStanding2To1() - self.standing2to1, 2)
     75         bonus = bonus if bonus > 0.0 else 0.0
     76         return bonus
     77 
     78     def GetStandingBonus1To2(self):
     79         bonus = round(self.GetStanding1To2() - self.standing1to2, 2)
     80         bonus = bonus if bonus > 0.0 else 0.0
     81         return bonus
     82 
     83     @staticmethod
     84     def GetStandingsSkills():
     85         skills = {}
     86         skillSvc = sm.GetService('skills')
     87         for skillTypeID in STANDINGS_SKILLS:
     88             skill = skillSvc.GetSkill(skillTypeID)
     89             if skill is not None:
     90                 skills[skillTypeID] = skill
     91 
     92         return skills
     93 
     94     def GetStanding1To2Formatted(self):
     95         return self._GetStandingFormatted(self.GetStanding1To2())
     96 
     97     def GetStanding2To1Formatted(self):
     98         return self._GetStandingFormatted(self.GetStanding2To1())
     99 
    100     @staticmethod
    101     def _GetStandingFormatted(standing):
    102         if standing >= 9.995:
    103             standing = 10.0
    104         return round(standing, 2)
    105 
    106     @staticmethod
    107     def GetStandingColor(standing):
    108         if standing < -2.0:
    109             color = standingUIConst.COLOR_BAD
    110         elif standing < 2.0:
    111             color = standingUIConst.COLOR_NEUTRAL
    112         else:
    113             color = standingUIConst.COLOR_GOOD
    114         return Color.RGBtoHex(*color)
    115 
    116     def IsRightToLeft(self):
    117         return self.standing2to1 is not None and self.standing1to2 is None
    118 
    119     def IsTwoWay(self):
    120         return self.standing1to2 is not None and self.standing2to1 is not None
    121 
    122     def GetHint1To2(self):
    123         return self.GetStanding1To2Formatted()
    124 
    125     def GetHint2To1(self):
    126         return self.GetStanding2To1Formatted()