Example #1
0
 def onUnitStateChanged(self, unitState, timeLeft):
     functional = self.unitFunctional
     pInfo = functional.getPlayerInfo()
     rosterSettings = functional.getRosterSettings()
     isCreator = pInfo.isCreator()
     if unitState.isLockedStateChanged():
         vehGetter = pInfo.getVehiclesToSlot
         slotGetter = functional.getSlotState
         slotLabels = map(lambda idx: vo_converters.makeSlotLabel(unitState, slotGetter(idx), isCreator, len(vehGetter(idx))), rosterSettings.getAllSlotsRange())
         self.as_lockUnitS(unitState.isLocked(), slotLabels)
     if isCreator and unitState.isOpenedStateChanged():
         self.as_setOpenedS(unitState.isOpened(), vo_converters.makeUnitStateLabel(unitState))
     self._setActionButtonState()
Example #2
0
 def onUnitFlagsChanged(self, flags, timeLeft):
     functional = self.unitFunctional
     pInfo = functional.getPlayerInfo()
     rosterSettings = functional.getRosterSettings()
     isCreator = pInfo.isCreator()
     if flags.isLockedStateChanged():
         vehGetter = pInfo.getVehiclesToSlot
         slotGetter = functional.getSlotState
         slotLabels = map(lambda idx: vo_converters.makeSlotLabel(flags, slotGetter(idx), isCreator, len(vehGetter(idx))), rosterSettings.getAllSlotsRange())
         self.as_lockUnitS(flags.isLocked(), slotLabels)
     if isCreator and flags.isOpenedStateChanged():
         self.as_setOpenedS(flags.isOpened(), vo_converters.makeUnitStateLabel(flags))
     self._setActionButtonState()
     if flags.isChanged():
         self._updateMembersData()
def makeSortieVO(unitEntity,
                 isCommander,
                 unitMgrID=None,
                 app=None,
                 canInvite=True,
                 maxPlayerCount=MAX_PLAYER_COUNT_ALL):
    fullData = unitEntity.getUnitFullData(unitMgrID=unitMgrID)
    levelsValidation = unitEntity.validateLevels()
    canDoAction, restriction = levelsValidation.isValid, levelsValidation.restriction
    sumLevelsStr = makeTotalLevelLabel(fullData.stats, restriction)
    _, slots = makeStrongholdsSlotsVOs(unitEntity, unitMgrID, app,
                                       maxPlayerCount)
    if fullData.playerInfo.isInSlot:
        disableCanBeTakenButtonInSlots(slots)
    if fullData.flags.isLocked() or unitEntity.isStrongholdUnitFreezed(
    ) or unitEntity.inPlayersMatchingMode():
        setFreezedInSlots(slots)
        canAssignToSlot = False
    else:
        canAssignToSlot = canInvite
    return {
        'canInvite':
        canInvite,
        'isCommander':
        isCommander,
        'isFreezed':
        fullData.flags.isLocked(),
        'canAssignToSlot':
        canAssignToSlot,
        'hasRestrictions':
        fullData.unit.isRosterSet(
            ignored=settings.CREATOR_ROSTER_SLOT_INDEXES),
        'statusLbl':
        makeUnitStateLabel(fullData.flags),
        'statusValue':
        fullData.flags.isOpened(),
        'sumLevelsInt':
        fullData.stats.curTotalLevel,
        'sumLevels':
        sumLevelsStr,
        'sumLevelsError':
        canDoAction,
        'slots':
        slots,
        'description':
        unitEntity.getCensoredComment(unitMgrID=unitMgrID)
    }