def onUnitUpdate(self, unitMgrID, packedUnit, packedOps): LOG_DEBUG('onUnitUpdate: unitMgrID=%s, packedUnit=%r, packedOps=%r' % (unitMgrID, packedUnit, packedOps)) if not unitMgrID: unitIdx = 0 else: unitIdx = 1 if self.id != unitMgrID: prevMgrID = self.id prevUnitIdx = self.unitIdx self.id = unitMgrID self.unitIdx = unitIdx self.battleID = None self._clearUnits() if not self.id and prevMgrID: self.onUnitLeft(prevMgrID, prevUnitIdx) if packedUnit: unit = ClientUnit(packedUnit=packedUnit) if unitIdx in self.units: self.units[unitIdx].destroy() self.units[unitIdx] = unit if 'battleID' in unit._extras: self.battleID = unit._extras['battleID'] self.onUnitJoined(self.id, self.unitIdx) if packedOps: unit = self.units.get(unitIdx) if unit: unit.unpackOps(packedOps) unit.onUnitUpdated() return
def getSortieUnit(self, unitMgrID, peripheryID): sortieKey = (unitMgrID, peripheryID) unit = None if not self.isEmpty() and sortieKey in self._sortieUnits: unit = ClientUnit() unit.unpack(self._sortieUnits[sortieKey]) return unit
def onUnitUpdate(self, unitMgrID, packedUnit, packedOps): LOG_DEBUG('onUnitUpdate: unitMgrID=%s, packedUnit=%r, packedOps=%r' % (unitMgrID, packedUnit, packedOps)) if not unitMgrID: unitIdx = 0 else: unitIdx = 1 if self.id != unitMgrID: prevMgrID = self.id prevUnitIdx = self.unitIdx self.id = unitMgrID self.unitIdx = unitIdx self.battleID = None self._clearUnits() if not self.id and prevMgrID: self.onUnitLeft(prevMgrID, prevUnitIdx) if packedUnit: unit = ClientUnit(packedUnit=packedUnit) if unitIdx in self.units: self.units[unitIdx].destroy() self.units[unitIdx] = unit if 'battleID' in unit._extras: self.battleID = unit._extras['battleID'] self.onUnitJoined(self.id, self.unitIdx) if packedOps: unit = self.units.get(unitIdx) if unit: unit.lock() unit.unpackOps(packedOps) unit.unlock() unit.onUnitUpdated() return
def onUnitUpdate(self, unitMgrID, unitIdx, packedUnit, packedOps): LOG_DAN('onUnitUpdate: unitMgrID=%s, unitIdx=%s, packedUnit=%r, packedOps=%r' % (unitMgrID, unitIdx, packedUnit, packedOps)) if self.id != unitMgrID: prevMgrID = self.id prevUnitIdx = self.unitIdx self.id = unitMgrID self.unitIdx = unitIdx self._clearUnits() if not self.id and prevMgrID: self.onUnitLeft(prevMgrID, prevUnitIdx) if packedUnit: unit = ClientUnit(packedUnit=packedUnit) if unitIdx in self.units: self.units[unitIdx].destroy() self.units[unitIdx] = unit self.onUnitJoined(self.id, self.unitIdx) if packedOps: unit = self.units.get(unitIdx) if unit: unit.unpackOps(packedOps) unit.onUnitUpdated()
def onResultsSet(self, pickledBrowserResultsList): browserResultsList = cPickle.loads(pickledBrowserResultsList) LOG_DEBUG('unitBrowser.onResultsSet: %s' % browserResultsList) self.results.clear() for row in browserResultsList: try: cfdUnitID, unitMgrID, cmdrRating, peripheryID, strUnitPack = row unit = ClientUnit(packedUnit=strUnitPack) self.results[cfdUnitID] = dict(unitMgrID=unitMgrID, cmdrRating=cmdrRating, peripheryID=peripheryID, unit=unit) except: LOG_CURRENT_EXCEPTION() LOG_DEBUG('unitBrowser results=%r' % self.results) self.onResultsReceived(self.results)
def onResultsUpdate(self, pickledBrowserUpdatesDict): browserUpdatesDict = cPickle.loads(pickledBrowserUpdatesDict) LOG_DEBUG('unitBrowser.onResultsUpdate: %s' % browserUpdatesDict) res = {} for cfdUnitID, (cmdrRating, strUnitPack) in browserUpdatesDict.iteritems(): try: if strUnitPack is None: self.results.pop(cfdUnitID, None) res[cfdUnitID] = None else: unit = ClientUnit(packedUnit=strUnitPack) if cfdUnitID in self.results: self.results[cfdUnitID]['unit'] = unit self.results[cfdUnitID]['cmdrRating'] = cmdrRating res[cfdUnitID] = self.results[cfdUnitID] except: LOG_CURRENT_EXCEPTION() self.onResultsUpdated(res) return
def getFortBattleUnit(self, battleID): unit = None if not self.isEmpty() and battleID in self.battleUnits: unit = ClientUnit() unit.unpack(self.battleUnits[battleID]) return unit
def onUnitUpdate(self, unitMgrID, packedUnit, packedOps): LOG_DEBUG('onUnitUpdate: unitMgrID=%s, packedUnit=%r, packedOps=%r' % (unitMgrID, packedUnit, packedOps)) if self.id != unitMgrID: prevMgrID = self.id self.id = unitMgrID self.battleID = None self._clearUnit() if not self.id and prevMgrID: self.onUnitLeft(prevMgrID) if packedUnit: unit = ClientUnit(packedUnit=packedUnit) self._clearUnit() self.__unit = unit if 'battleID' in unit._extras: self.battleID = unit._extras['battleID'] self.onUnitJoined(self.id, unit.getPrebattleType()) if packedOps: unit = self.__unit if unit is not None: unit.lock() unit.unpackOps(packedOps) unit.unlock() unit.onUnitUpdated() return