Beispiel #1
0
 public ResponseData(EResponse code, object data)
 {
     this.Code    = Code;
     this.Message = GetMessage(code);
     Status       = EResponse.OK == code;
     this.Data    = data;
 }
Beispiel #2
0
        public bool canContinue()
        {
            if (!isSaved)
            {
                EResponse response = UI.askQuestion(CONTINUE_QUESTION, CONTINUE_QUESTION_CAPTION);
                bool      res      = false;
                switch (response)
                {
                case EResponse.rYes:
                    saveProject();
                    res = true;
                    break;

                case EResponse.rNo:
                    res = true;
                    break;

                case EResponse.rCancel:
                    res = false;
                    break;
                }
                return(res);
            }
            else
            {
                return(true);
            }
        }
        public void OnException(ExceptionContext context)
        {
            try {
                HttpStatusCode status  = HttpStatusCode.InternalServerError;
                String         message = String.Empty;

                var exceptionType = context.Exception.GetType();
                if (exceptionType == typeof(UnauthorizedAccessException))
                {
                    message = "Unauthorized Access";
                    status  = HttpStatusCode.Unauthorized;
                }
                else if (exceptionType == typeof(NotImplementedException))
                {
                    message = "A server error occurred.";
                    status  = HttpStatusCode.NotImplemented;
                }
                else
                {
                    message = context.Exception.Message;
                    status  = HttpStatusCode.NotFound;
                }
                HttpResponse response = context.HttpContext.Response;
                response.StatusCode  = (int)status;
                response.ContentType = "application/json";
                var err = message + " " + context.Exception.StackTrace;
                SLogger.LogError(err);
                EResponse eResponse = new EResponse();
                response.WriteAsync(JsonConvert.SerializeObject(eResponse.SetErrorResponse((int)ErrorCode.ServerException)));
                context.ExceptionHandled = true; // mark exception as handled
            } catch (Exception e) {
                Debug.WriteLine(e.StackTrace);
            }
        }
Beispiel #4
0
 public ResponseData(EResponse code, object message, object data)
 {
     this.Code    = code;
     this.Message = message;
     this.Data    = data;
     Status       = EResponse.OK == code;
 }
Beispiel #5
0
 public ResponseData(EResponse code)
 {
     this.Code    = Code;
     this.Message = GetMessage(Code);
     this.Data    = null;
     Status       = EResponse.OK == code;
 }
Beispiel #6
0
    protected EResponse DoResponse(EResponse response)
    {
        _action.Response = response;

        ResponseDelayTime = Math.Max(ResponseDelayTime, 0.1f);

        if (ResponseDelayTime > 0f)
        {
            GameManager.Get().StartCoroutine(DoResponseDelay(ResponseDelayTime));
        }
        else
        {
            DoResponseDirectly();
        }

        return(response);
    }
Beispiel #7
0
        private string GetMessage(EResponse code)
        {
            switch (code)
            {
            case EResponse.OK:
            {
                return("Sucess");
            }

            case EResponse.ValidationError:
            {
                return("Validation Error");
            }

            case EResponse.UnexpectedError:
            {
                return("Unexpected Error");
            }

            case EResponse.NoData:
            {
                return("No data");
            }

            case EResponse.NoPermission:
            {
                return("No Permission");
            }

            case EResponse.UnSuccess:
            {
                return("No Permission");
            }

            default:
            {
                return(null);
            }
            }
        }
Beispiel #8
0
        public EResponse showQuestionMessageBox(string question, string caption)
        {
            DialogResult response = MessageBox.Show(question, caption, MessageBoxButtons.YesNoCancel,
                                                    MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            EResponse res = EResponse.rCancel;

            switch (response)
            {
            case DialogResult.Yes:
                res = EResponse.rYes;
                break;

            case DialogResult.No:
                res = EResponse.rNo;
                break;

            case DialogResult.Cancel:
                res = EResponse.rCancel;
                break;
            }
            return(res);
        }
    void OnHandle_ResponseSuteHai()
    {
        List <EKaze> ronPlayers = logicOwner.GetRonPlayers();

        if (ronPlayers.Count > 0)
        {
            if (ronPlayers.Count >= 3 && !GameSettings.AllowRon3)
            {
                logicOwner.Handle_Invalid_RyuuKyoku(); // must.

                logicOwner.RyuuKyokuReason = ERyuuKyokuReason.Ron3;
                owner.ChangeState <LoopState_HandleRyuuKyoKu>();
            }
            else
            {
                logicOwner.Handle_SuteHai_Ron();
                logicOwner.AgariResult = EAgariType.Ron;

                // show ron ui.
                EventManager.Get().SendEvent(UIEventType.Ron_Agari, ronPlayers, logicOwner.FromKaze, logicOwner.SuteHai);

                owner.ChangeState <LoopState_Agari>();
            }
        }
        else
        {
            // ERyuuKyokuReason.Reach4: no one Ron the 4th player's rute hai
            if (logicOwner.Reach4Flag == true)
            {
                logicOwner.Handle_Invalid_RyuuKyoku(); // must.

                logicOwner.RyuuKyokuReason = ERyuuKyokuReason.Reach4;
                owner.ChangeState <LoopState_HandleRyuuKyoKu>();
                return;
            }

            // As DaiMinKan and Pon is availabe to one player at the same time, and their priority is bigger than Chii,
            // perform DaiMinKan and Pon firstly.
            List <EKaze> validKaze = new List <EKaze>();

            foreach (var info in logicOwner.PlayerResponseMap)
            {
                if (info.Value == EResponse.Pon || info.Value == EResponse.DaiMinKan)
                {
                    validKaze.Add(info.Key);
                }
            }

            if (validKaze.Count > 0)
            {
                if (validKaze.Count == 1)
                {
                    EKaze     kaze = validKaze[0];
                    EResponse resp = logicOwner.PlayerResponseMap[kaze];

                    logicOwner.ResetActivePlayer(kaze);

                    switch (resp)
                    {
                    case EResponse.Pon:
                    {
                        logicOwner.Handle_Pon();

                        EventManager.Get().SendEvent(UIEventType.Pon, logicOwner.ActivePlayer, logicOwner.FromKaze);

                        owner.ChangeState <LoopState_AskSelectSuteHai>();
                    }
                    break;

                    case EResponse.DaiMinKan:
                    {
                        logicOwner.Handle_DaiMinKan();

                        EventManager.Get().SendEvent(UIEventType.DaiMinKan, logicOwner.ActivePlayer, logicOwner.FromKaze);

                        if (logicOwner.checkKanCountOverFlow())
                        {
                            logicOwner.Handle_Invalid_RyuuKyoku();     // must.

                            logicOwner.RyuuKyokuReason = ERyuuKyokuReason.KanOver4;
                            owner.ChangeState <LoopState_HandleRyuuKyoKu>();
                        }
                        else
                        {
                            owner.ChangeState <LoopState_PickRinshanHai>();
                        }
                    }
                    break;
                    }
                }
                else
                {
                    throw new MahjongException("More than one player perform Pon or DaiMinKan!?");
                }
            }
            else // no one Pon or DaiMinKan, perform Chii
            {
                foreach (var info in logicOwner.PlayerResponseMap)
                {
                    if (info.Value == EResponse.Chii_Left ||
                        info.Value == EResponse.Chii_Center ||
                        info.Value == EResponse.Chii_Right)
                    {
                        validKaze.Add(info.Key);
                    }
                }

                if (validKaze.Count > 0)
                {
                    if (validKaze.Count == 1)
                    {
                        EKaze     kaze = validKaze[0];
                        EResponse resp = logicOwner.PlayerResponseMap[kaze];

                        logicOwner.ResetActivePlayer(kaze);

                        switch (resp)
                        {
                        case EResponse.Chii_Left:
                        {
                            logicOwner.Handle_ChiiLeft();

                            EventManager.Get().SendEvent(UIEventType.Chii_Left, logicOwner.ActivePlayer, logicOwner.FromKaze);
                        }
                        break;

                        case EResponse.Chii_Center:
                        {
                            logicOwner.Handle_ChiiCenter();

                            EventManager.Get().SendEvent(UIEventType.Chii_Center, logicOwner.ActivePlayer, logicOwner.FromKaze);
                        }
                        break;

                        case EResponse.Chii_Right:
                        {
                            logicOwner.Handle_ChiiRight();

                            EventManager.Get().SendEvent(UIEventType.Chii_Right, logicOwner.ActivePlayer, logicOwner.FromKaze);
                        }
                        break;
                        }

                        owner.ChangeState <LoopState_AskSelectSuteHai>();
                    }
                    else
                    {
                        throw new MahjongException("More than one player perform Chii!?");
                    }
                }
                else // no one handle the sute hai.
                {
                    logicOwner.Handle_SuteHai_Nagashi();

                    owner.ChangeState <LoopState_ToNextLoop>();
                }
            }
        }
    }
Beispiel #10
0
 protected ResponseData ResultResquest(EResponse code, object result = null) => new ResponseData(code: code, data: result);
Beispiel #11
0
        public Response Failed(IRequest req, string text = "", EError error = EError.Error, EResponse r = EResponse.Fail)
        {
            Assert.IsNotNull(req);
            Assert.IsNotNull(req.Owner as IPlayerModel);

            var resp = new Response(req, r, error, text);

            Warn($"{resp}");
            return(resp);
        }
Beispiel #12
0
        public Response Succeed(IRequest req, string text = "", EError error = EError.None, EResponse r = EResponse.Ok)
        {
            Assert.IsNotNull(req);
            Assert.IsNotNull(req.Owner as IPlayerModel);

            return(new Response(req, r, error, text));
        }
Beispiel #13
0
 public Response(IRequest request, EResponse response = EResponse.Ok, EError err = EError.None,
                 string text = "")
     : this(response, err, text)
 {
     Request = request;
 }
Beispiel #14
0
 public Response(EResponse response = EResponse.Ok, EError err = EError.None, string text = "")
 {
     Type  = response;
     Error = err;
     Text  = text;
 }