Exemplo n.º 1
0
        public static void Run(Login login, Battle battle)
        {
            #if DEBUG
            var authUrl = "http://localhost:3000/get_token";
            var postUrl = Settings.Default.DebugPostUrl;
            #else
            var authUrl = Settings.Default.AuthUrl;
            var postUrl = Settings.Default.PostUrl;
            #endif
            string msg = "";
            CookieContainer cc = new CookieContainer();
            var json = SendRequest(authUrl, login.ToPostParameter(), cc);
            if ("false" == json.success) {
                throw new MiserugeErrorException("ユーザ認証に失敗しました。");
            }

            string parameters =
                String.Join(
                    "&"
                    , login.ToPostParameter()
                    , battle.ToPostParameter()
                    , "authenticity_token=" + json.authenticity_token
                    , "_method=post"
                );

            var json2 = SendRequest(postUrl, parameters, cc);
            foreach (dynamic it in json2.errors) {
                msg = String.Join(Environment.NewLine, msg, it);
            }

            if (!String.IsNullOrEmpty(msg)) {
                throw new MiserugeErrorException(msg, "投稿エラー", MessageBoxIcon.Error, MessageBoxButtons.OK);
            }
        }
Exemplo n.º 2
0
        private bool Validate(Login login, Battle battle)
        {
            string[][] set = {
                new string[] {login.UserId, "ユーザID"}
                , new string[] {login.Password, "パスワード"}
                , new string[] {battle.BattleEnvironmentId, "対戦環境"}
                , new string[] {battle.BattleSystemId, "対戦方式"}
                , new string[] {battle.MatchModeId, "マッチ方式"}
            };

            Requred(set);

            set = new string[][] {
                new string[] {battle.BattleEnvironmentId, "対戦環境"}
                , new string[] {battle.BattleSystemId, "対戦方式"}
                , new string[] {battle.MatchModeId, "マッチ方式"}
                , new string[] {battle.Rate, "レート"}
            };

            ValidPokemonNameList(battle.PokemonNameList);
            ValidNumber(set);

            int rateMin = 500;
            int rateMax = 2000;
            ValidRate(battle.Rate, rateMin, rateMax);

            return ErrorList.Count == 0;
        }
Exemplo n.º 3
0
        public static void ClickPostButton(ControlForm controlForm)
        {
            Login login = new Login();
            login.UserId = Settings.Default.UserId;
            login.Password = Settings.Default.Password;

            Battle battle = new Battle();
            battle.BattleSystemId = controlForm.InputBattleSystemId;
            battle.MatchModeId = controlForm.InputMatchModeId;
            battle.Rate = controlForm.InputRate;
            battle.PokemonTogether = controlForm.InputPokemonName;
            battle.PokemonNameList = controlForm.InputPokemonNameList;

            ValidateInfo info = InputValidateTask.Run(login, battle);

            if (info.Error) {
                MessageBox.Show(info.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return ;
            } else if (info.Warning) {
                DialogResult result = MessageBox.Show(info.Message, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (result == DialogResult.No || result == DialogResult.Cancel) {
                    return;
                }
            }

            ViewController.StartHaveyTask("party post", () => {
                PartyPostTask.Run(login, battle);
                Settings.Default.UserId = login.UserId;
                Settings.Default.Password = login.Password;
                Settings.Default.DefaultBattleEnvironmentId = battle.BattleEnvironmentId;
                Settings.Default.DefaultBattleSystemId = battle.BattleSystemId;
                Settings.Default.DefaultMatchModeId = battle.MatchModeId;
                Settings.Default.Save();
                SettingsController.PostAfter(controlForm);
            });
        }
Exemplo n.º 4
0
 public static ValidateInfo Run(Login login, Battle battle)
 {
     var task = new InputValidateTask();
     task.Validate(login, battle);
     return ValidateInfo.Join(task.ErrorList, task.WarnList);
 }