Exemplo n.º 1
0
 def leave(self, ctx, callback=None):
     if ctx.getRequestType() != _RQ_TYPE.LEAVE:
         LOG_ERROR('Invalid context to leave prebattle/unit', ctx)
         if callback is not None:
             callback(False)
         return
     elif self.__requestCtx.isProcessing():
         LOG_ERROR('Request is processing', self.__requestCtx)
         if callback is not None:
             callback(False)
         return
     else:
         ctrlType = ctx.getCtrlType()
         formation = self.__collection.getItem(ctx.getCtrlType())
         if formation is not None:
             if formation.hasLockedState():
                 entityType = formation.getEntityType()
                 SystemMessages.pushI18nMessage(
                     messages.getLeaveDisabledMessage(ctrlType, entityType),
                     type=SystemMessages.SM_TYPE.Warning)
                 if callback is not None:
                     callback(False)
                 return
             LOG_DEBUG('Request to leave formation', ctx)
             self.__requestCtx = ctx
             formation.leave(ctx, callback=callback)
         else:
             LOG_ERROR('Functional not found', ctx)
             if callback is not None:
                 callback(False)
         return
Exemplo n.º 2
0
 def leave(self, ctx, callback=None):
     if ctx.getRequestType() != _RQ_TYPE.LEAVE:
         LOG_ERROR("Invalid context to leave prebattle/unit", ctx)
         if callback is not None:
             callback(False)
         return
     elif self.__requestCtx.isProcessing():
         LOG_ERROR("Request is processing", self.__requestCtx)
         if callback is not None:
             callback(False)
         return
     else:
         ctrlType = ctx.getCtrlType()
         formation = self.__collection.getItem(ctx.getCtrlType())
         if formation is not None:
             if formation.hasLockedState():
                 entityType = formation.getEntityType()
                 SystemMessages.pushI18nMessage(
                     messages.getLeaveDisabledMessage(ctrlType, entityType), type=SystemMessages.SM_TYPE.Warning
                 )
                 if callback is not None:
                     callback(False)
                 return
             LOG_DEBUG("Request to leave formation", ctx)
             self.__requestCtx = ctx
             formation.leave(ctx, callback=callback)
         else:
             LOG_ERROR("Functional not found", ctx)
             if callback is not None:
                 callback(False)
         return
Exemplo n.º 3
0
 def __leaveLogic(self, ctx, callback):
     entity = self.__entity
     if not entity.isActive():
         if callback is not None:
             callback(False)
         return
     else:
         ctrlType = ctx.getCtrlType()
         if entity.hasLockedState():
             entityType = entity.getEntityType()
             SystemMessages.pushI18nMessage(messages.getLeaveDisabledMessage(ctrlType, entityType), type=SystemMessages.SM_TYPE.Warning)
             if callback is not None:
                 callback(False)
             return
         LOG_DEBUG('Request to leave formation', ctx)
         self.__requestCtx = ctx
         entity.leave(ctx, callback=callback)
         return
Exemplo n.º 4
0
 def leave(self, ctx, callback=None):
     """
     Asynchronous method for prebattle leaving. Using given context its
     leaves current entity.
     Args:
         ctx: leave context
         callback: request callback
     """
     if ctx.getRequestType() != _RQ_TYPE.LEAVE:
         LOG_ERROR('Invalid context to leave prebattle/unit', ctx)
         if callback is not None:
             callback(False)
         return
     elif self.__requestCtx.isProcessing():
         LOG_ERROR('Request is processing', self.__requestCtx)
         if callback is not None:
             callback(False)
         return
     else:
         entity = self.__entity
         meta = entity.getConfirmDialogMeta(ctx)
         if meta:
             result = yield DialogsInterface.showDialog(meta)
             if not result:
                 if callback is not None:
                     callback(False)
                 return
         if not entity.isActive():
             if callback is not None:
                 callback(False)
             return
         ctrlType = ctx.getCtrlType()
         if entity.hasLockedState():
             entityType = entity.getEntityType()
             SystemMessages.pushI18nMessage(
                 messages.getLeaveDisabledMessage(ctrlType, entityType),
                 type=SystemMessages.SM_TYPE.Warning)
             if callback is not None:
                 callback(False)
             return
         LOG_DEBUG('Request to leave formation', ctx)
         self.__requestCtx = ctx
         entity.leave(ctx, callback=callback)
         return