Exemplo n.º 1
0
        public async Task <ActionOutput> DoAction(ActionEnum input)
        {
            string act = string.Empty;

            switch (input)
            {
            case ActionEnum.H1:
                act = "1h";
                break;

            case ActionEnum.H2:
                act = "2h";
                break;

            case ActionEnum.H4:
                act = "4h";
                break;

            case ActionEnum.H8:
                act = "8h";
                break;

            case ActionEnum.FloorBonus:
                act = "floorBonus";
                break;

            default:
                act = input.ToString().ToLower() + Global.DoActionVersion;
                break;
            }
            var json = new ActionInput {
                Action = act
            };
            HttpContent contentPost = new StringContent(json.ToJsonString(), Encoding.UTF8, "application/json");
            var         response    = await Client.PostAsync("my-kirito/doaction", contentPost);

            Console.WriteLine("{0} {1} {2}", "開始行動", input.GetDescriptionText(), response.StatusCode);
            var content = response.Content;

            if (response.IsSuccessStatusCode)
            {
                var output = await content.ReadAsJsonAsync <ActionOutput>();

                Console.WriteLine(output.Message);
                if (output != null && output.Gained != null && output.Gained.Hp != null)
                {
                    await WriteJson(output.Gained, input);
                }
                return(output);
            }

            await OnErrorOccur(response.StatusCode, content, "行動", 1);

            return(null);
        }
Exemplo n.º 2
0
        public async Task <ActionOutput> DoAction(ActionEnum input)
        {
            var json = new ActionInput {
                Action = input.ToString().ToLower() + Global.DoActionVersion
            };
            HttpContent contentPost = new StringContent(json.ToJsonString(), Encoding.UTF8, "application/json");
            var         response    = await Client.PostAsync("my-kirito/doaction", contentPost);

            Console.WriteLine("{0} {1} {2}", "開始行動", input.GetDescriptionText(), response.StatusCode);
            var content = response.Content;

            if (response.IsSuccessStatusCode)
            {
                var output = await content.ReadAsJsonAsync <ActionOutput>();

                Console.WriteLine(output.Message);
                return(output);
            }

            await OnErrorOccur(response.StatusCode, content, "行動", ConsoleColor.Yellow);

            return(null);
        }