def __vehiclesComparator(self, item, other):
     res = 0
     iKiller = item.get('killerID', 0)
     cd = item.get('typeCompDescr')
     if cd is not None:
         iType = vehicles_core.getVehicleType(cd)
         iLevel = iType.level if iType else -1
         iWeight = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(set(VEHICLE_CLASS_TAGS.intersection(iType.tags)).pop(), 10) if iType else 10
     else:
         iLevel = -1
         iWeight = 10
     oKiller = other.get('killerID', 0)
     cd = other.get('typeCompDescr')
     if cd is not None:
         oType = vehicles_core.getVehicleType(other.get('typeCompDescr', None))
         oLevel = oType.level if oType else -1
         oWeight = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(set(VEHICLE_CLASS_TAGS.intersection(oType.tags)).pop(), 10) if oType else 10
     else:
         oLevel = -1
         oWeight = 10
     if iKiller == 0 and oKiller == 0 or iKiller != 0 and oKiller != 0:
         res = cmp(oLevel, iLevel) or cmp(iWeight, oWeight) or cmp(item.get('vehicleName', ''), other.get('vehicleName', ''))
     elif not iKiller:
         res = -1
     else:
         res = 1
     return res
示例#2
0
def _markerComparator(x1, x2):
    INDEX_IS_ALIVE = 2
    INDEX_VEHICLE_CLASS = 1
    res = x2[INDEX_IS_ALIVE] - x1[INDEX_IS_ALIVE]
    if res:
        return res
    x1Index = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(x1[INDEX_VEHICLE_CLASS], 100)
    x2Index = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(x2[INDEX_VEHICLE_CLASS], 100)
    res = x1Index - x2Index
    if res:
        return res
    return 0
示例#3
0
def _markerComparator(x1, x2):
    INDEX_IS_ALIVE = 2
    INDEX_VEHICLE_CLASS = 1
    res = x2[INDEX_IS_ALIVE] - x1[INDEX_IS_ALIVE]
    if res:
        return res
    x1Index = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(x1[INDEX_VEHICLE_CLASS], 100)
    x2Index = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(x2[INDEX_VEHICLE_CLASS], 100)
    res = x1Index - x2Index
    if res:
        return res
    return 0
示例#4
0
def markerComparator(x1, x2):
    INDEX_IS_ALIVE = 2
    INDEX_VEHICLE_CLASS = 1
    if x1[INDEX_IS_ALIVE] < x2[INDEX_IS_ALIVE]:
        return 1
    if x1[INDEX_IS_ALIVE] > x2[INDEX_IS_ALIVE]:
        return -1
    x1Index = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(x1[INDEX_VEHICLE_CLASS], 100)
    x2Index = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(x2[INDEX_VEHICLE_CLASS], 100)
    if x1Index < x2Index:
        return -1
    if x1Index > x2Index:
        return 1
    return 0
示例#5
0
def _playerComparator(x1, x2):
    if x1[8] < x2[8]:
        return -1
    if x1[8] > x2[8]:
        return 1
    if x1[15] < x2[15]:
        return 1
    if x1[15] > x2[15]:
        return -1
    vehTypeIdx1 = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(x1[6], 100)
    vehTypeIdx2 = VEHICLE_BATTLE_TYPES_ORDER_INDICES.get(x2[6], 100)
    if vehTypeIdx1 < vehTypeIdx2:
        return -1
    if vehTypeIdx1 > vehTypeIdx2:
        return 1
    if x1[2] < x2[2]:
        return -1
    if x1[2] > x2[2]:
        return 1
    if x1[9] < x2[9]:
        return -1
    if x1[9] > x2[9]:
        return 1
    return 0