Esempio n. 1
0
        public static Set FromDB(SqlHelper dbo, int id)
        {
            Program.Log("dbo", "Selecting set from database : no " + id);
            var r = dbo.Select(
                new Table("sets", id)
                .Join("pokemons", "sets.pokemon")
                .Join("moves AS move1", "sets.move1")
                .Join("moves AS move2", "sets.move2")
                .Join("moves AS move3", "sets.move3")
                .Join("moves AS move4", "sets.move4")
                .Join("abilities", "sets.ability")
                .Join("items", "sets.item"),
                "sets.name", "pokemons.hp", "pokemons.type1", "pokemons.type2",
                "pokemons.name", "pokemons.hp", "pokemons.atk", "pokemons.def", "pokemons.spa", "pokemons.spd", "pokemons.spe", // baseStat
                "move1.id", "move1.name", "move1.type", "move1.sps", "move1.power", "move1.accuracy", "move1.pp",               // move1
                "move2.id", "move2.name", "move2.type", "move2.sps", "move2.power", "move2.accuracy", "move2.pp",               // move2
                "move3.id", "move3.name", "move3.type", "move3.sps", "move3.power", "move3.accuracy", "move3.pp",               // move3
                "move4.id", "move4.name", "move4.type", "move4.sps", "move4.power", "move4.accuracy", "move4.pp",               // move4
                "items.id", "items.name", "items.uniq", "abilities.id", "abilities.name",                                       // item & ability
                "sets.EV1", "sets.EV2", "sets.nature+", "sets.nature-"                                                          // evDist, nature
                )[0];

            Program.Log("dbo", "\tSelected!");

            EVDist thisEV     = new EVDist(r["sets.EV1"], r["sets.EV2"]);
            Nature thisNature = new Nature(r["sets.nature+"], r["sets.nature-"]);

            int[] baseStat = new int[6];
            for (int k = 0; k < 5; k++)
            {
                baseStat[k] = 2 * int.Parse(r["pokemons." + ((StatTarget)k).ShortString()]) + 5 + 31; // 31: IVs
            }
            baseStat[5] = 2 * int.Parse(r["pokemons.hp"]) + 110 + 31;
            if (thisEV.ev1 == StatTarget.HP || thisEV.ev2 == StatTarget.HP)
            {
                baseStat[5] += 63;
            }

            Base thisBase = new Base(r["pokemons.name"], TypeExtensions.Parse(r["pokemons.type1"]), TypeExtensions.Parse(r["pokemons.type2"]), baseStat);

            Move[] thisMoves = new Move[4];
            for (int k = 1; k < 5; k++)
            {
                List <Effect> moveEffects = new List <Effect>();
                var           r_          = dbo.Select(
                    new Table("moves", int.Parse(r[$"move{k}.id"]))
                    .Join("movesxeffects", "move", "moves.id")
                    .Join("effects", "movesxeffects.effect"),
                    "effects.id", "effects.desc", "movesxeffects.percent", "movesxeffects.value"
                    );
                foreach (var effect in r_)
                {
                    moveEffects.Add(new Effect(int.Parse(effect["effects.id"]), effect["effects.desc"], int.Parse(effect["movesxeffects.percent"]), int.Parse(effect["movesxeffects.value"])));
                }

                thisMoves[k - 1] = new Move(int.Parse(r[$"move{k}.id"]), r[$"move{k}.name"], TypeExtensions.Parse(r[$"move{k}.type"]), SpsExtensions.Parse(r[$"move{k}.sps"]), int.Parse(r[$"move{k}.power"]), int.Parse(r[$"move{k}.accuracy"]), int.Parse(r[$"move{k}.pp"]), moveEffects.ToArray());
            }

            Item    thisItem    = new Item(int.Parse(r["items.id"]), r["items.name"], r["items.uniq"] == "1");
            Ability thisAbility = new Ability(int.Parse(r["abilities.id"]), r["abilities.name"]);

            return(new Set(r["sets.name"], thisBase, thisMoves, thisItem, thisAbility, thisEV, thisNature));
        }
Esempio n. 2
0
        public Set(String customName, Base baseStat, Move[] moves, Item item, Ability ability, EVDist evDist, Nature nature)
        {
            this.customName = customName;

            this.baseStat = baseStat;
            this.Hp       = this[StatTarget.HP];

            this.moves   = moves;
            this.item    = item;
            this.ability = ability;

            this._evDist = evDist;
            this._nature = nature;

            this._indexNextMove = -1;

            this.flags   = Flags.None;
            this._status = Status.None;
        }