示例#1
0
 def update(self, cmdrRating=0, unit=None, **kwargs):
     self.rating = cmdrRating
     if unit:
         creatorDBID = unit.getCreatorDBID()
         if self.creator.dbID != creatorDBID:
             isChanged = True
             data = unit.getCreator()
             if data:
                 self.creator = PlayerUnitInfo(creatorDBID, self.cfdUnitID,
                                               unit, **data)
             else:
                 self.creator = None
         self.flags = UnitFlags(unit.getFlags())
         freeSlots = unit.getFreeSlots()
         playersSlots = unit.getPlayerSlots()
         self.playersCount = len(playersSlots)
         self.commandSize = len(playersSlots) + len(freeSlots)
         self.isRosterSet = unit.isRosterSet(
             ignored=CREATOR_ROSTER_SLOT_INDEXES)
         self.description = passCensor(unit.getComment())
     else:
         self.creator = None
         self.playersCount = 0
         self.commandSize = 0
         self.flags = UnitFlags(0)
         self.isRosterSet = False
         self.description = None
     return
示例#2
0
 def __init__(self, cfdUnitID, unitMgrID=0, cmdrRating=0, peripheryID=0, unit=None, **kwargs):
     super(UnitsListItem, self).__init__()
     playersCount = 0
     commandSize = 0
     flags = 0
     isRosterSet = False
     creator = None
     description = None
     extra = None
     if unit:
         creator = unit.getCreator()
         if creator is not None:
             creator = PlayerUnitInfo(unit.getCreatorDBID(), cfdUnitID, unit, **creator)
         freeSlots = unit.getFreeSlots()
         playersSlots = unit.getPlayerSlots()
         flags = unit.getFlags()
         playersCount = len(playersSlots)
         commandSize = len(playersSlots) + len(freeSlots)
         isRosterSet = unit.isRosterSet(ignored=CREATOR_ROSTER_SLOT_INDEXES)
         description = passCensor(unit.getComment())
         extra = unit.getExtra()
     self.cfdUnitID = cfdUnitID
     self.unitMgrID = unitMgrID
     self.creator = creator
     self.rating = cmdrRating
     self.peripheryID = peripheryID
     self.playersCount = playersCount
     self.commandSize = commandSize
     self.flags = UnitFlags(flags)
     self.isRosterSet = isRosterSet
     self.description = description
     self.extra = extra
     return