def tankmenSortFunc(first, second): if first is None or second is None: return 1 res = nationCompareByIndex(first.nation, second.nation) if res: return res elif first.isInTank and not second.isInTank: return -1 elif not first.isInTank and second.isInTank: return 1 if first.isInTank and second.isInTank: tman1vehicle, tman2vehicle = (None, None) for vcl in vcls: if vcl.inventoryId == first.vehicleID: tman1vehicle = vcl if vcl.inventoryId == second.vehicleID: tman2vehicle = vcl if tman1vehicle is not None and tman2vehicle is not None: break if tman1vehicle is not None and tman2vehicle is not None: res = tman1vehicle.__cmp__(tman2vehicle) if res: return res if TANKMEN_ROLES_ORDER[first.descriptor.role] < TANKMEN_ROLES_ORDER[second.descriptor.role]: return -1 if TANKMEN_ROLES_ORDER[first.descriptor.role] > TANKMEN_ROLES_ORDER[second.descriptor.role]: return 1 if first.lastname < second.lastname: return -1 elif first.lastname > second.lastname: return 1 else: return 1
def __cmp__(self, other): res = super(NationSpecificAchievement, self).__cmp__(other) if res: return res if isinstance(other, NationSpecificAchievement): if self._nationID != -1 and other._nationID != -1: return nationCompareByIndex(self._nationID, other._nationID)
def __cmp__(self, other): if self is other: return 1 res = nationCompareByIndex(self.nationID, other.nationID) if res: return res return 0
def __call__(self, first, second): if first is None or second is None: return 1 res = nationCompareByIndex(first.nationID, second.nationID) if res: return res if first.isInTank and not second.isInTank: return -1 if not first.isInTank and second.isInTank: return 1 if first.isInTank and second.isInTank: if self._vehicleGetter is not None: tman1vehicle = self._vehicleGetter(first.vehicleInvID) tman2vehicle = self._vehicleGetter(second.vehicleInvID) if tman1vehicle is not None and tman2vehicle is not None: res = tman1vehicle.__cmp__(tman2vehicle) if res: return res TANKMEN_ROLES_ORDER = Tankman.TANKMEN_ROLES_ORDER if TANKMEN_ROLES_ORDER[ first.descriptor.role] < TANKMEN_ROLES_ORDER[ second.descriptor.role]: return -1 if TANKMEN_ROLES_ORDER[ first.descriptor.role] > TANKMEN_ROLES_ORDER[ second.descriptor.role]: return 1 return cmp(first.lastUserName, second.lastUserName) or 1
def __call__(self, first, second): if first is None or second is None: return 1 else: res = nationCompareByIndex(first.nationID, second.nationID) if res: return res if first.isInTank and not second.isInTank: return -1 if not first.isInTank and second.isInTank: return 1 if first.isInTank and second.isInTank: if self._vehicleGetter is not None: tman1vehicle = self._vehicleGetter(first.vehicleInvID) tman2vehicle = self._vehicleGetter(second.vehicleInvID) if tman1vehicle is not None and tman2vehicle is not None: res = tman1vehicle.__cmp__(tman2vehicle) if res: return res TANKMEN_ROLES_ORDER = Tankman.TANKMEN_ROLES_ORDER if TANKMEN_ROLES_ORDER[first.descriptor.role] < TANKMEN_ROLES_ORDER[second.descriptor.role]: return -1 if TANKMEN_ROLES_ORDER[first.descriptor.role] > TANKMEN_ROLES_ORDER[second.descriptor.role]: return 1 return cmp(first.lastUserName, second.lastUserName) or 1
def __cmp__(self, other): res = super(NationSpecificAchievement, self).__cmp__(other) if res: return res if isinstance(other, NationSpecificAchievement): if self._nationID != -1 and other._nationID != -1: return nationCompareByIndex(self._nationID, other._nationID) return 0
def __cmp__(self, other): if isinstance(other, MechEngineerAchievement): if self.nationID == -1: return -1 elif other.nationID == -1: return 1 else: return nationCompareByIndex(self.nationID, other.nationID) return super(MechEngineerAchievement, self).__cmp__(other)
def __cmp__(self, other): """ Compares items by nation and types. """ if self is other: return 1 res = nationCompareByIndex(self.nationID, other.nationID) if res: return res return 0
def __cmp__(self, other): if other is None: return -1 res = nationCompareByIndex(self.nationID, other.nationID) if res: return res if self.isInTank and not other.isInTank: return -1 if not self.isInTank and other.isInTank: return 1 if self.isInTank and other.isInTank: if self.vehicleInvID != other.vehicleInvID: return -1 res = self.TANKMEN_ROLES_ORDER[self.descriptor.role] - self.TANKMEN_ROLES_ORDER[other.descriptor.role] if res: return res if self.lastUserName < other.lastUserName: return -1 if self.lastUserName > other.lastUserName: return 1 return 0
def __cmp__(self, other): if other is None: return -1 res = nationCompareByIndex(self.nationID, other.nationID) if res: return res elif self.isInTank and not other.isInTank: return -1 elif not self.isInTank and other.isInTank: return 1 if self.isInTank and other.isInTank: if self.vehicleInvID != other.vehicleInvID: return -1 res = self.TANKMEN_ROLES_ORDER[self.descriptor.role] - self.TANKMEN_ROLES_ORDER[other.descriptor.role] if res: return res if self.lastUserName < other.lastUserName: return -1 elif self.lastUserName > other.lastUserName: return 1 else: return 0
def tankmenSortFunc(first, second): if first is None or second is None: return 1 res = nationCompareByIndex(first.nation, second.nation) if res: return res elif first.isInTank and not second.isInTank: return -1 elif not first.isInTank and second.isInTank: return 1 if first.isInTank and second.isInTank: tman1vehicle, tman2vehicle = (None, None) for vcl in vcls: if vcl.inventoryId == first.vehicleID: tman1vehicle = vcl if vcl.inventoryId == second.vehicleID: tman2vehicle = vcl if tman1vehicle is not None and tman2vehicle is not None: break if tman1vehicle is not None and tman2vehicle is not None: res = tman1vehicle.__cmp__(tman2vehicle) if res: return res if TANKMEN_ROLES_ORDER[ first.descriptor.role] < TANKMEN_ROLES_ORDER[ second.descriptor.role]: return -1 if TANKMEN_ROLES_ORDER[ first.descriptor.role] > TANKMEN_ROLES_ORDER[ second.descriptor.role]: return 1 if first.lastname < second.lastname: return -1 elif first.lastname > second.lastname: return 1 else: return 1
_g_navInfo = None def getNavInfo(): global _g_navInfo if _g_navInfo is None: _g_navInfo = _NavigationInfo() return _g_navInfo def clearNavInfo(): global _g_navInfo _g_navInfo = None return _SORTINGS = {'nation': lambda (veh1, _), (veh2, __): nationCompareByIndex(veh1.nationID, veh2.nationID), 'type': lambda (veh1, _), (veh2, __): veh1._sortByType(veh2), 'level': lambda (veh1, _), (veh2, __): veh1.level - veh2.level, 'vName': lambda (veh1, _), (veh2, __): cmp(veh1.userName, veh2.userName), 'notAvailable': lambda (_, vData1), (__, vData2): cmp(vData1[0], vData2[0]), 'discount': lambda (_, vData1), (__, vData2): cmp(vData1[1], vData2[1])} def sortVehTable(tableID, btnID, direction, nation = None, vehType = None, level = None, cbSelected = None, isAction = None): result = [] vehData = getVehiclesData(tableID) if vehData is None: return result else: vehList, props = vehData updateVehiclesDataProps(tableID, nationIdx=nation, vehTypeIdx=vehType, levelIdx=level, selectedBtn=btnID, sortDirect=direction, checkbox=cbSelected) for v, data in vehList:
def __sortFunc(cls, i1, i2): res = i1.level - i2.level if res: return res return nationCompareByIndex(i1.nation, i2.nation)
def __vehiclesListSort(i1, i2): res = i1['level'] - i2['level'] if res: return res return nationCompareByIndex(i1['nation'], i2['nation'])
global _g_navInfo if _g_navInfo is None: _g_navInfo = _NavigationInfo() return _g_navInfo def clearNavInfo(): global _g_navInfo _g_navInfo = None return _SORTINGS = { 'nation': lambda (veh1, _), (veh2, __): nationCompareByIndex(veh1.nationID, veh2.nationID), 'type': lambda (veh1, _), (veh2, __): compareByVehTableTypeName(veh2.type, veh1.type), 'level': lambda (veh1, _), (veh2, __): veh1.level - veh2.level, 'vName': lambda (veh1, _), (veh2, __): cmp(veh1.userName, veh2.userName), 'notAvailable': lambda (_, vData1), (__, vData2): cmp(vData1[0], vData2[0]), 'discount': lambda (_, vData1), (__, vData2): cmp(vData1[1], vData2[1]) } def sortVehTable(tableID,
def comparator(x, y): xNationID, _ = vehicles.parseVehicleCompactDescr(x['compDescr']) yNationID, _ = vehicles.parseVehicleCompactDescr(y['compDescr']) return nationCompareByIndex(xNationID, yNationID)
_g_navInfo = None def getNavInfo(): global _g_navInfo if _g_navInfo is None: _g_navInfo = _NavigationInfo() return _g_navInfo def clearNavInfo(): global _g_navInfo _g_navInfo = None return _SORTINGS = {'nation': lambda (veh1, _), (veh2, __): nationCompareByIndex(veh1.nationID, veh2.nationID), 'type': lambda (veh1, _), (veh2, __): compareByVehTableTypeName(veh2.type, veh1.type), 'level': lambda (veh1, _), (veh2, __): veh1.level - veh2.level, 'vName': lambda (veh1, _), (veh2, __): cmp(veh1.userName, veh2.userName), 'notAvailable': lambda (_, vData1), (__, vData2): cmp(vData1[0], vData2[0]), 'discount': lambda (_, vData1), (__, vData2): cmp(vData1[1], vData2[1])} def sortVehTable(tableID, btnID, direction, nation = None, vehType = None, level = None, cbSelected = None, isAction = None): result = [] vehData = getVehiclesData(tableID) if vehData is None: return result else: vehList, props = vehData updateVehiclesDataProps(tableID, nationIdx=nation, vehTypeIdx=vehType, levelIdx=level, selectedBtn=btnID, sortDirect=direction, checkbox=cbSelected) for v, data in vehList: