Exemplo n.º 1
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
 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)
Exemplo n.º 3
0
 def __cmp__(self, other):
     if self is other:
         return 1
     res = nationCompareByIndex(self.nationID, other.nationID)
     if res:
         return res
     return 0
Exemplo n.º 4
0
 def __cmp__(self, other):
     if self is other:
         return 1
     res = nationCompareByIndex(self.nationID, other.nationID)
     if res:
         return res
     return 0
Exemplo n.º 5
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
Exemplo n.º 6
0
 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
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
0
 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
Exemplo n.º 11
0
 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
Exemplo n.º 12
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
Exemplo n.º 13
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
Exemplo n.º 14
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
Exemplo n.º 15
0
_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:
Exemplo n.º 16
0
 def __sortFunc(cls, i1, i2):
     res = i1.level - i2.level
     if res:
         return res
     return nationCompareByIndex(i1.nation, i2.nation)
Exemplo n.º 17
0
 def __sortFunc(cls, i1, i2):
     res = i1.level - i2.level
     if res:
         return res
     return nationCompareByIndex(i1.nation, i2.nation)
Exemplo n.º 18
0
def __vehiclesListSort(i1, i2):
    res = i1['level'] - i2['level']
    if res:
        return res
    return nationCompareByIndex(i1['nation'], i2['nation'])
Exemplo n.º 19
0
    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,
Exemplo n.º 20
0
def __vehiclesListSort(i1, i2):
    res = i1['level'] - i2['level']
    if res:
        return res
    return nationCompareByIndex(i1['nation'], i2['nation'])
Exemplo n.º 21
0
 def comparator(x, y):
     xNationID, _ = vehicles.parseVehicleCompactDescr(x['compDescr'])
     yNationID, _ = vehicles.parseVehicleCompactDescr(y['compDescr'])
     return nationCompareByIndex(xNationID, yNationID)
Exemplo n.º 22
0
_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: