Esempio n. 1
0
        protected internal override void Enter()
        {
            Task.Run(async() =>
            {
                var login = new EvoApiRequester <
                    evoapi.ProtocolModels.Auth.Login.Request,
                    evoapi.ProtocolModels.Auth.Login.Response>();
                var setFirstOnetime = new EvoApiRequester <
                    evoapi.ProtocolModels.PlayerInformation.SetFirstOnetime.Request,
                    evoapi.ProtocolModels.PlayerInformation.SetFirstOnetime.Response>();

                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.Warning($"Already exists (playerId:{resLogin.Payload.playerId}).");
                        continue;
                    }

                    setFirstOnetime.request.playerName = account.Name;
                    var resSetFirstOnetime             = await setFirstOnetime.PostAsync(
                        $"{resLogin.Payload.token}"
                        );

                    if (resSetFirstOnetime.StatusCode != System.Net.HttpStatusCode.OK)
                    {
                        continue;
                    }

                    ConsoleWriter.Succeeded(
                        $"{resLogin.Payload.playerId}:{resSetFirstOnetime.Payload.initialLevel}"
                        );
                }

                StateMachine.SendEvent(Main.EventTrigger.Next);
            });
        }
Esempio n. 2
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);
            });
        }
Esempio n. 3
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);
            });
        }