예제 #1
0
        private static PokemonData ImportFromPO(Match m)
        {
            // 1: Nickname
            // 2: Form
            // 3: Pokemon
            // 4: Gender
            // 5: Item
            // 6: Ability
            // 7: EVs
            // 8: Nature
            // 9~12: Moves

            var hasNickname = m.Groups[3].Value.Length > 0;
            var pname       = m.Groups[3].Value;

            if (!hasNickname)
            {
                pname = m.Groups[1].Value;
            }
            var pm      = new PokemonData(GameString.PokemonSpecies(pname).Number, 0);
            var Item    = GameString.Item(m.Groups[5].Value);
            var Ability = GameString.Ability(m.Groups[6].Value);
            var Nature  = GameString.Nature(m.Groups[8].Value);

            pm.Gender = GetGender(m.Groups[4].Value);
            if (hasNickname)
            {
                pm.Name = m.Groups[1].Value;
            }
            pm.Item = Item;
            if (Ability != 0)
            {
                pm.Ability = Ability;
            }
            if (Nature != null)
            {
                pm.Nature = Nature.Value;
            }
            pm.Ev.Hp    = TryMatch(m.Groups[7].Value, @"(\d+) HP", 1, 0);
            pm.Ev.Atk   = TryMatch(m.Groups[7].Value, @"(\d+) Atk", 1, 0);
            pm.Ev.Def   = TryMatch(m.Groups[7].Value, @"(\d+) Def", 1, 0);
            pm.Ev.SpAtk = TryMatch(m.Groups[7].Value, @"(\d+) SAtk", 1, 0);
            pm.Ev.SpDef = TryMatch(m.Groups[7].Value, @"(\d+) SDef", 1, 0);
            pm.Ev.Speed = TryMatch(m.Groups[7].Value, @"(\d+) Spd", 1, 0);
            foreach (Match m2 in Regex.Matches(m.Groups[9].Value, @"\- (.+?)(?: \[(.+?)\])*\n"))
            {
                var Move = GameString.Move(m2.Groups[1].Value);
                if (Move != null)
                {
                    pm.AddMove(Move);
                }
            }
            return(pm);
        }
예제 #2
0
        private static PokemonData ImportFromPS(Match m)
        {
            // 1: Nickname
            // 2: Form
            // 3: Pokemon
            // 4: Gender
            // 5: Item
            // 6: Ability
            // 7: EVs
            // 8: Nature
            // 9: IVs(?)
            // 10~13: Moves

            var hasNickname = m.Groups[3].Value.Length > 0;
            var pname       = m.Groups[3].Value;

            if (!hasNickname)
            {
                pname = m.Groups[1].Value;
            }
            int form = 0;

            if (m.Groups[2].Value.Contains("Alola") || m.Groups[2].Value.Contains("Therian") || m.Groups[2].Value.Contains("Attack") || m.Groups[2].Value.Contains("Heat") || m.Groups[2].Value.Contains("White") || m.Groups[2].Value.Contains("Unbound"))
            {
                form = 1;
            }
            if (m.Groups[2].Value.Contains("Attack") || m.Groups[2].Value.Contains("Wash") || m.Groups[2].Value.Contains("Black"))
            {
                form = 2;
            }
            if (m.Groups[2].Value.Contains("Defence") || m.Groups[2].Value.Contains("Frost"))
            {
                form = 3;
            }
            if (m.Groups[2].Value.Contains("Speed") || m.Groups[2].Value.Contains("Fan"))
            {
                form = 4;
            }
            if (m.Groups[2].Value.Contains("Mow"))
            {
                form = 5;
            }
            var pm      = new PokemonData(GameString.PokemonSpecies(pname).Number, form);
            var Item    = GameString.Item(m.Groups[5].Value);
            var Ability = GameString.Ability(m.Groups[6].Value);
            var Nature  = GameString.Nature(m.Groups[8].Value);

            pm.Gender = GetGender(m.Groups[4].Value);
            if (hasNickname)
            {
                pm.Name = m.Groups[1].Value;
            }
            pm.Item = Item;
            if (Ability != 0)
            {
                pm.Ability = Ability;
            }
            if (Nature != null)
            {
                pm.Nature = Nature.Value;
            }
            pm.Ev.Hp    = TryMatch(m.Groups[7].Value, @"(\d+) HP", 1, 0);
            pm.Ev.Atk   = TryMatch(m.Groups[7].Value, @"(\d+) Atk", 1, 0);
            pm.Ev.Def   = TryMatch(m.Groups[7].Value, @"(\d+) Def", 1, 0);
            pm.Ev.SpAtk = TryMatch(m.Groups[7].Value, @"(\d+) SpA", 1, 0);
            pm.Ev.SpDef = TryMatch(m.Groups[7].Value, @"(\d+) SpD", 1, 0);
            pm.Ev.Speed = TryMatch(m.Groups[7].Value, @"(\d+) Spe", 1, 0);
            if (m.Groups[9].Value.Contains("IVs"))
            {
                pm.Iv.Hp    = TryMatch(m.Groups[9].Value, @"(\d+) HP", 1, 31);
                pm.Iv.Atk   = TryMatch(m.Groups[9].Value, @"(\d+) Atk", 1, 31);
                pm.Iv.Def   = TryMatch(m.Groups[9].Value, @"(\d+) Def", 1, 31);
                pm.Iv.SpAtk = TryMatch(m.Groups[9].Value, @"(\d+) SpA", 1, 31);
                pm.Iv.SpDef = TryMatch(m.Groups[9].Value, @"(\d+) SpD", 1, 31);
                pm.Iv.Speed = TryMatch(m.Groups[9].Value, @"(\d+) Spe", 1, 31);
            }
            foreach (Match m2 in Regex.Matches(m.Groups[m.Groups.Count - 1].Value, @"\- (.+?)(?: \[(.+?)\])*( )*\n"))
            {
                var Move = GameString.Move(m2.Groups[1].Value);
                if (Move != null)
                {
                    pm.AddMove(Move);
                }
            }
            return(pm);
        }
예제 #3
0
        private static PokemonData ImportFromPBO(Match m)
        {
            // 1: Nickname
            // 2: Pokemon
            // 3: Level
            // 4: Gender
            // 5: Ability
            // 6: Nature
            // 7: IVs
            // 8: EVs
            // 9: Happiness
            // 10: Items
            // 11: Moves
            int i;
            var form = GameString.PokemonForm(m.Groups[2].Value);
            var pm   = new PokemonData(form.Species.Number, form.Index);

            pm.Name = m.Groups[1].Value;
            if (int.TryParse(m.Groups[3].Value, out i))
            {
                pm.Lv = i;
            }
            pm.Gender = GetGender(m.Groups[4].Value);
            var ab = GameString.Ability(m.Groups[5].Value);

            if (ab != 0)
            {
                pm.Ability = ab;
            }
            pm.Nature = GameString.Nature(m.Groups[6].Value) ?? PokemonNature.Hardy;
            if (m.Groups[9].Value.Length > 0 && int.TryParse(m.Groups[9].Value, out i))
            {
                pm.Happiness = i;
            }
            pm.Item = GameString.Item(m.Groups[10].Value);

            if (!string.IsNullOrEmpty(m.Groups[7].Value))
            {
                var ivs = m.Groups[7].Value.Split('/');
                if (int.TryParse(ivs[0], out i))
                {
                    pm.Iv.Hp = i;
                }
                if (int.TryParse(ivs[1], out i))
                {
                    pm.Iv.Atk = i;
                }
                if (int.TryParse(ivs[2], out i))
                {
                    pm.Iv.Def = i;
                }
                if (int.TryParse(ivs[3], out i))
                {
                    pm.Iv.SpAtk = i;
                }
                if (int.TryParse(ivs[4], out i))
                {
                    pm.Iv.SpDef = i;
                }
                if (int.TryParse(ivs[5], out i))
                {
                    pm.Iv.Speed = i;
                }
            }

            var evs = m.Groups[8].Value.Split('/');

            if (int.TryParse(evs[0], out i))
            {
                pm.Ev.Hp = i;
            }
            if (int.TryParse(evs[1], out i))
            {
                pm.Ev.Atk = i;
            }
            if (int.TryParse(evs[2], out i))
            {
                pm.Ev.Def = i;
            }
            if (int.TryParse(evs[3], out i))
            {
                pm.Ev.SpAtk = i;
            }
            if (int.TryParse(evs[4], out i))
            {
                pm.Ev.SpDef = i;
            }
            if (int.TryParse(evs[5], out i))
            {
                pm.Ev.Speed = i;
            }

            foreach (var s in Regex.Replace(m.Groups[11].Value, @"\[.+?\]", "").Split('/'))
            {
                var move = GameString.Move(s);
                if (move != null)
                {
                    pm.AddMove(move);
                }
            }

            return(pm);
        }