Пример #1
0
        protected internal override void Enter()
        {
            Task.Run(async() =>
            {
                ConsoleWriter.Prompt("Input [account type] > ");
                var accounttype = await InputPrompt.Create();

                ConsoleWriter.Prompt("Input [account] > ");
                var account = await InputPrompt.Create();

                ConsoleWriter.Prompt("Input [password] > ");
                var password = await InputPassPrompt.Create();


                var accountType = evolib.Account.Type.Dev1;
                var authToken   = "";
                if (accounttype == "inky")
                {
                    accountType     = evolib.Account.Type.Inky;
                    var accessToken = "";

                    {
                        var requester              = new evolib.Multiplatform.Inky.Login3();
                        requester.request.email    = account;
                        requester.request.password = password;
                        var response = await requester.PostAsync();
                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            accessToken = response.Payload.data.access_token;
                        }
                    }
                    if (!string.IsNullOrEmpty(accessToken))
                    {
                        var requester = new evolib.Multiplatform.Inky.LoginTemp();
                        var response  = await requester.PostAsync(accessToken);
                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            authToken = response.Payload.data.access_token;
                        }
                    }
                }

                var handShakeKeeper
                    = await HandShakeKeeper.CreateAsync(account, password,
                                                        authToken, accountType);

                if (handShakeKeeper != null)
                {
                    ConsoleWriter.Action("session keepon.");
                    ConsoleWriter.Info($"Bearer {handShakeKeeper.Token}");
                    ConsoleWriter.Prompt("<Press [Enter] key to exit>");
                    await InputPrompt.Create();

                    await handShakeKeeper.CancelAsync();
                }


                StateMachine.SendEvent(Main.EventTrigger.Next);
            });
        }
Пример #2
0
        protected internal override void Enter()
        {
            Task.Run(async() =>
            {
                ConsoleWriter.Prompt("Input [your account] > ");
                var account = await InputPrompt.Create();


                ConsoleWriter.Prompt("Input [your password] > ");
                var password = await InputPassPrompt.Create();


                ConsoleWriter.Action("Login...");

                var login = new EvoApiRequester <
                    evoapi.ProtocolModels.Auth.Login.Request,
                    evoapi.ProtocolModels.Auth.Login.Response>();

                login.request.account        = account;
                login.request.password       = password;
                login.request.packageVersion = new int[] { 99, };
                var resLogin = await login.PostAsync();

                if (resLogin.StatusCode != System.Net.HttpStatusCode.OK ||
                    resLogin.Payload.playerId == 0)
                {
                    ConsoleWriter.Error("Login is failed.");
                    StateMachine.SendEvent(Main.EventTrigger.Continue);
                    return;
                }

                if (0 == (resLogin.Payload.initialLevel
                          & evolib.PlayerInformation.InitialLevelFlg.Name))
                {
                    ConsoleWriter.Error("Player has no name.");
                    StateMachine.SendEvent(Main.EventTrigger.Continue);
                    return;
                }

                GlobalSettings.MyAccount  = account;
                GlobalSettings.MyPassword = password;
                GlobalSettings.MyPlayerId = resLogin.Payload.playerId;
                StateMachine.SendEvent(Main.EventTrigger.Next);
                ConsoleWriter.Succeeded("ok.");
            });
        }
Пример #3
0
        protected internal override void Enter()
        {
            Task.Run(async() =>
            {
                ConsoleWriter.Prompt("Input [env] > ");
                var input = await InputPrompt.Create();
                var env   = $"{input}";

                foreach (Env e in Enum.GetValues(typeof(Env)))
                {
                    if (Enum.GetName(typeof(Env), e) == env)
                    {
                        GlobalSettings.TargetEnv = e;

                        ConsoleWriter.Action("Checking version of TSS ...");

                        var tssVersion = new EvoApiRequester <
                            evoapi.ProtocolModels.Test.TssVersion.Request,
                            evoapi.ProtocolModels.Test.TssVersion.Response>();
                        var res = await tssVersion.PostAsync();
                        if (res.StatusCode == System.Net.HttpStatusCode.OK &&
                            new Version(res.Payload.limitVersion)
                            <= new Version(GlobalSettings.FileVersionInfo.ProductVersion))
                        {
                            StateMachine.SendEvent(Main.EventTrigger.Next);
                            ConsoleWriter.Succeeded("ok.");
                            return;
                        }


                        var limitVer = (res.StatusCode == System.Net.HttpStatusCode.OK)
                                                        ? res.Payload.limitVersion
                                                        : "server Unimplemented";

                        ConsoleWriter.Error($"Different version. Update to ver.({limitVer})");
                        StateMachine.SendEvent(Main.EventTrigger.Continue);
                        return;
                    }
                }

                ConsoleWriter.Error($"{input}: env not found.");
                StateMachine.SendEvent(Main.EventTrigger.Continue);
            });
        }
Пример #4
0
        protected internal override void Enter()
        {
            Task.Run(async() =>
            {
                var login = new EvoApiRequester <
                    evoapi.ProtocolModels.Auth.Login.Request,
                    evoapi.ProtocolModels.Auth.Login.Response>();

                var personals =
                    new Queue <ReportBattleResult.Personal>();

                {
                    var matchCnt = (evolib.Social.MaxRecentPlayersCnt
                                    + evolib.Battle.MatchPlayersNum - 1 - 1)
                                   / (evolib.Battle.MatchPlayersNum - 1);

                    var stackNum = matchCnt * (evolib.Battle.MatchPlayersNum - 1);

                    foreach (var account in TestAccounts.Actors())
                    {
                        login.request.account        = account.Account;
                        login.request.password       = account.Password;
                        login.request.packageVersion = new int[] { 99, };

                        var resLogin = await login.PostAsync();

                        if (resLogin.StatusCode != System.Net.HttpStatusCode.OK ||
                            resLogin.Payload.playerId == 0)
                        {
                            ConsoleWriter.Error($"Login is failed.");
                            break;
                        }

                        if (0 == (resLogin.Payload.initialLevel
                                  & evolib.PlayerInformation.InitialLevelFlg.Name))
                        {
                            ConsoleWriter.Error("Player has no name.");
                            break;
                        }

                        personals.Enqueue(new ReportBattleResult.Personal
                        {
                            playerId   = resLogin.Payload.playerId,
                            playerName = account.Name,
                            result     = evolib.Battle.Result.DRAW,
                            side       = (personals.Count % 2 == 0)
                                                                        ? evolib.Battle.Side.Earthnoid
                                                                        : evolib.Battle.Side.Spacenoid,
                        }
                                          );

                        ConsoleWriter.Action($"{account.Account} Logined...");

                        if (stackNum == personals.Count)
                        {
                            break;
                        }
                    }
                }

                var handShakeKeeper = await HandShakeKeeper.CreateAsync(
                    TestAccounts.DsAccount,
                    TestAccounts.DsPassword
                    );

                if (handShakeKeeper != null)
                {
                    var reportBattleResult = new EvoApiRequester <
                        ReportBattleResult.Request,
                        ReportBattleResult.Response>();


                    while (true)
                    {
                        var personalList = new List <ReportBattleResult.Personal>();
                        for (int i = 0; i < Battle.MatchPlayersNum - 1; i++)
                        {
                            if (0 < personals.Count)
                            {
                                personalList.Add(personals.Dequeue());
                            }
                        }
                        if (personalList.Count == 0)
                        {
                            break;
                        }

                        personalList.Add(new ReportBattleResult.Personal
                        {
                            playerId   = GlobalSettings.MyPlayerId,
                            playerName = "abcd",
                            result     = Battle.Result.DRAW,
                            side       = personalList[personalList.Count - 1].side.Opponet(),
                        });

                        reportBattleResult.request.personals = personalList.ToArray();

                        var resReportBattleResult = await reportBattleResult.PostAsync(
                            $"{handShakeKeeper.Token}"
                            );

                        if (resReportBattleResult.StatusCode != System.Net.HttpStatusCode.OK)
                        {
                            ConsoleWriter.Error("ReportBattleResult is Failed.");
                            break;
                        }

                        ConsoleWriter.Succeeded("ReportBattleResult is Succeeded.");
                    }

                    await handShakeKeeper.CancelAsync();
                }

                StateMachine.SendEvent(Main.EventTrigger.Next);
            });
        }
Пример #5
0
        protected internal override void Enter()
        {
            Task.Run(async() =>
            {
                var login = new EvoApiRequester <
                    evoapi.ProtocolModels.Auth.Login.Request,
                    evoapi.ProtocolModels.Auth.Login.Response>();

                var alreadyFriends  = new Dictionary <long, int>();
                var alreadyRequests = new Dictionary <long, int>();

                {
                    login.request.account        = GlobalSettings.MyAccount;
                    login.request.password       = GlobalSettings.MyPassword;
                    login.request.packageVersion = new int[] { 99, };
                    var resLogin = await login.PostAsync();

                    if (resLogin.StatusCode != System.Net.HttpStatusCode.OK)
                    {
                        return;
                    }

                    var getFriends = new EvoApiRequester <
                        evoapi.ProtocolModels.Social.GetFriends.Request,
                        evoapi.ProtocolModels.Social.GetFriends.Response>();
                    var resGetFriends = await getFriends.PostAsync(
                        $"{resLogin.Payload.token}"
                        );

                    resGetFriends.Payload.lists.Friends.ForEach(
                        i => alreadyFriends[i.playerId] = 0
                        );
                    resGetFriends.Payload.lists.Requests.ForEach(
                        i => alreadyRequests[i.playerId] = 0
                        );
                }


                var friendRequest = new EvoApiRequester <
                    evoapi.ProtocolModels.Social.SendFriendRequest.Request,
                    evoapi.ProtocolModels.Social.SendFriendRequest.Response>();
                friendRequest.request.playerId = GlobalSettings.MyPlayerId;
                foreach (var account in TestAccounts.Actors())
                {
                    if (evolib.Social.MaxFriendRequestsCnt <= alreadyRequests.Count)
                    {
                        ConsoleWriter.Succeeded($"Reached limit requests.");
                        break;
                    }

                    login.request.account        = account.Account;
                    login.request.password       = account.Password;
                    login.request.packageVersion = new int[] { 99, };
                    var resLogin = await login.PostAsync();

                    ConsoleWriter.Action($"Try ({account.Account}).");

                    if (resLogin.StatusCode != System.Net.HttpStatusCode.OK ||
                        resLogin.Payload.playerId == 0)
                    {
                        ConsoleWriter.Error($"Login is failed.");
                        break;
                    }

                    if (0 == (resLogin.Payload.initialLevel
                              & evolib.PlayerInformation.InitialLevelFlg.Name))
                    {
                        ConsoleWriter.Error("Player has no name.");
                        break;
                    }

                    if (alreadyFriends.ContainsKey(resLogin.Payload.playerId))
                    {
                        ConsoleWriter.Warning($"Already friend.");
                        continue;
                    }

                    if (alreadyRequests.ContainsKey(resLogin.Payload.playerId))
                    {
                        ConsoleWriter.Warning($"Already request.");
                        continue;
                    }

                    var resFriendRequest = await friendRequest.PostAsync(
                        $"{resLogin.Payload.token}"
                        );

                    if (resFriendRequest.StatusCode != System.Net.HttpStatusCode.OK ||
                        !resFriendRequest.Payload.ok)
                    {
                        ConsoleWriter.Warning($"Request is Failed.");
                        continue;
                    }

                    alreadyRequests[resLogin.Payload.playerId] = 123;

                    ConsoleWriter.Succeeded(
                        $"request from player:{resLogin.Payload.playerId}"
                        );
                }

                StateMachine.SendEvent(Main.EventTrigger.Next);
            });
        }