コード例 #1
0
 /* The main Move constructor takes the name, power, accuracy, priority, type, maximum PP, and flags of the move.
  * All the parameters are set appropriately. Array.Copy() is used to copy the flags array. */
 public Move(string name, byte power, byte accuracy, sbyte priority, MoveCategory moveCategory, PkmnType moveType, byte maxPP, bool[] flags)
 {
     this.name     = name;
     this.power    = power;
     this.accuracy = accuracy;
     this.priority = priority;
     this.category = moveCategory;
     this.type     = moveType;
     pp            = new AttributePair(maxPP);
     this.flags    = new bool[20];
     Array.Copy(flags, this.flags, 20);
 }
コード例 #2
0
ファイル: Battle.cs プロジェクト: Metasynic/PkmnEngine
        /* This function applies type effectiveness multipliers to damage.
         * The damage is first changed to a decimal to ensure accuracy.
         * For each of the defending Pokemon's (one or two) types, a TypePair key is created with the attacking move's type.
         * The Mechanics.TypeMatchups dictionary is checked to see if it contains a multiplier for the TypePair.
         * If a multiplier is found, it is applied to the damage. Before being returned, the damage is converted back to a whole number. */
        public static ushort TypeCheck(ushort damage, PkmnType atkType, List <PkmnType> defTypes)
        {
            decimal calculatedDamage = damage;

            foreach (PkmnType defType in defTypes)
            {
                TypePair tp = new TypePair(atkType, defType);
                if (PkmnUtils.TypeMatchups.ContainsKey(tp))
                {
                    calculatedDamage *= PkmnUtils.TypeMatchups[tp];
                }
            }
            return((ushort)calculatedDamage);
        }
コード例 #3
0
ファイル: Battle.cs プロジェクト: Metasynic/PkmnEngine
 public TypePair(PkmnType atk, PkmnType def)
 {
     AttackType  = atk;
     DefenceType = def;
 }
コード例 #4
0
        /* This function allows the user to manually add a new move to the MoveManager. */
        public static void NewMove()
        {
            Border("PkmnEngine Editor - New Move");

            /* The program prompts the user for the name of the move, and the user inputs it. */
            Console.WriteLine("Enter Name of move.");
            string name = Console.ReadLine();

            /* If a move with the same name already exists, then the user is given a warning before it is overwritten. */
            if (MoveManager.Moves.ContainsKey(name))
            {
                Console.WriteLine("Move {0} already exists. Overwrite (y/n)?", name);
                string choice = Console.ReadLine();
                if (choice[0] != 'Y' && choice[0] != 'y')
                {
                    /* If the user does not want to override the move, the function returns. */
                    return;
                }

                /* Otherwise, the user is happy to overwrite the move and the function proceeds. */
                Console.WriteLine("Move will be overwitten.");
            }

            /* One by one, every property of the move is entered by the user and parsed into its correct type. */
            Console.WriteLine("Enter Power of move.");
            byte power = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter Accuracy of move.");
            byte accuracy = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter Priority of move.");
            sbyte priority = sbyte.Parse(Console.ReadLine());

            Console.WriteLine("Enter Category of move.");
            MoveCategory type = ParseEnum <MoveCategory>(Console.ReadLine());

            Console.WriteLine("Enter Type of move.");
            PkmnType element = ParseEnum <PkmnType>(Console.ReadLine());

            Console.WriteLine("Enter Max PP of move.");
            byte pp = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter 20 flags of move, as T and F, without spaces.");

            /* When it comes to the array of bit flags, each character in the input is parsed into T -> true, F -> false. */
            char[] flagchars = Console.ReadLine().ToLower().ToCharArray();
            bool[] flags     = new bool[20];
            for (int i = 0; i < 20; i++)
            {
                if (flagchars[i] == 't')
                {
                    flags[i] = true;
                }
                else if (flagchars[i] == 'f')
                {
                    flags[i] = false;
                }
                else
                {
                    throw new Exception("Invalid Move Flag was entered.");
                }
            }

            /* Finally, the Move is constructed using the properties entered by the user, and it is added to the MoveManager. */
            Move move = new Move(name, power, accuracy, priority, type, element, pp, flags);

            MoveManager.Moves.Add(move.Name, move);
        }
コード例 #5
0
ファイル: PokemonData.cs プロジェクト: Metasynic/PkmnEngine
        /* The public constructor for a PokemonData takes a lot of parameters. */
        public PokemonData(string pokemonName, byte baseHP, byte baseAttack, byte baseDefence, byte baseSpecialAttack, byte baseSpecialDefence, byte baseSpeed, ushort id, PkmnType type, PkmnType?secondType, bool canHaveGender, string species, double weightKg, double heightM, EggGroup eggGroup, EggGroup?secondEggGroup, ushort baseExp, byte captureRate, byte baseHappiness, GrowthRate growthRate, byte eggCycles, byte maleRatio, byte femaleRatio, EvYield evYield)
        {
            /* The majority of the fields are set directly using the parameters passed in. */
            PokemonName        = pokemonName;
            BaseHP             = baseHP;
            BaseAttack         = baseAttack;
            BaseDefence        = baseDefence;
            BaseSpecialAttack  = baseSpecialAttack;
            BaseSpecialDefence = baseSpecialDefence;
            BaseSpeed          = baseSpeed;
            ID            = id;
            CanHaveGender = canHaveGender;
            Species       = species;
            WeightKg      = weightKg;
            HeightM       = heightM;
            BaseExp       = baseExp;
            CaptureRate   = captureRate;
            BaseHappiness = baseHappiness;
            GrowthRate    = growthRate;
            EggCycles     = eggCycles;
            GenderRatio   = new GenderRatio(maleRatio, femaleRatio);
            EvYield       = evYield;

            /* For the Type and EggGroups properties, which can contain one or two values each,
             * the second parameter can be passed as null.
             * If the second parameter is null, the lists will only contain one item.
             * If the second parameter has a value, the lists will contain two items. */
            Type = new List <PkmnType>();
            Type.Add(type);
            if (secondType.HasValue)
            {
                Type.Add(secondType.Value);
            }
            EggGroups = new List <EggGroup>();
            EggGroups.Add(eggGroup);
            if (secondEggGroup.HasValue)
            {
                EggGroups.Add(secondEggGroup.Value);
            }
        }
コード例 #6
0
        /* This function allows a user to add a new Pokemon species manually. */
        public static void AddPokemon()
        {
            Border("PkmnEngine Editor - Add New Pokemon");

            /* First, the user enters the ID for the Pokemon they're adding. */
            Console.WriteLine("Enter the ID of the Pokemon you wish to add.");
            ushort id = ushort.Parse(Console.ReadLine());

            /* If a PokemonData with that ID already exists, the user is prompted asking if they want to overwrite it. */
            if (PokemonDataManager.PokemonData.ContainsKey(id))
            {
                Console.WriteLine("Pokemon with ID {0} already exists [{1}]. Overwrite? (y/n)", id, PokemonDataManager.PokemonData[id].PokemonName);
                string choice = Console.ReadLine();

                /* If they don't want to overwrite, the function returns. */
                if (choice[0] != 'y' && choice[0] != 'Y')
                {
                    return;
                }
                Console.WriteLine("Pokemon will be overwritten.");
            }

            /* If the user chooses to overwrite the PokemonData, they will then enter all the new information about the PokemonData. */
            Console.WriteLine("Enter name of Pokemon.");
            string name = Console.ReadLine();

            Console.WriteLine("Enter Base HP of Pokemon.");
            byte baseHP = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter Base Attack of Pokemon.");
            byte baseAttack = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter Base Defence of Pokemon.");
            byte baseDefence = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter Base Special Attack of Pokemon.");
            byte baseSpecialAttack = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter Base Special Defence of Pokemon.");
            byte baseSpecialDefence = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter Base Speed of Pokemon.");
            byte baseSpeed = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter whether Pokemon can have genders (True/False).");
            bool canHaveGender = bool.Parse(Console.ReadLine());

            Console.WriteLine("Enter type of Pokemon.");
            PkmnType type = ParseEnum <PkmnType>(Console.ReadLine());

            Console.WriteLine("Enter second type of Pokemon (null for single types).");
            string secondType = Console.ReadLine();

            Console.WriteLine("Enter species description, e.g. Gyarados is \"Atrocious\".");
            string species = Console.ReadLine();

            species = species + " Pokemon"; // Converts "Atrocious" into "Atrocious Pokemon", for example
            Console.WriteLine("Enter the weight of the Pokemon in KG.");
            double weightKg = double.Parse(Console.ReadLine());

            Console.WriteLine("Enter the height of the Pokemon in M.");
            double heightM = double.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Egg Group of the Pokemon.");
            EggGroup eggGroup = ParseEnum <EggGroup>(Console.ReadLine());

            Console.WriteLine("Enter the second Egg Group of the Pokemon (can be null).");
            string secondEggGroup = Console.ReadLine();

            Console.WriteLine("Enter the Base Experience of the Pokemon.");
            ushort baseExp = ushort.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Capture Rate of the Pokemon.");
            byte captureRate = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Base Happiness of the Pokemon.");
            byte baseHappiness = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Growth Rate of the Pokemon.");
            GrowthRate growthRate = ParseEnum <GrowthRate>(Console.ReadLine());

            Console.WriteLine("Enter the Male Gender Ratio of the Pokemon out of 100 (0 for genderless).");
            byte maleRatio = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Female Gender Ratio of the Pokemon out of 100 (0 for genderless).");
            byte femaleRatio = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Egg Cycle count of the Pokemon.");
            byte eggCycles = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the HP EV Yield of the Pokemon.");
            byte hpEvYield = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Attack EV Yield of the Pokemon.");
            byte atkEvYield = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Defence EV Yield of the Pokemon.");
            byte defEvYield = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Special Attack EV Yield of the Pokemon.");
            byte spAtkEvYield = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Special Defence EV Yield of the Pokemon.");
            byte spDefEvYield = byte.Parse(Console.ReadLine());

            Console.WriteLine("Enter the Speed EV Yield of the Pokemon.");
            byte    spdEvYield = byte.Parse(Console.ReadLine());
            EvYield evYield    = new EvYield(hpEvYield, atkEvYield, defEvYield, spAtkEvYield, spDefEvYield, spdEvYield);

            /* Once everything has been calculated, the base stat total is calculated and displayed. */
            int stattotal = (baseHP + baseAttack + baseDefence + baseSpecialAttack + baseSpecialDefence + baseSpeed);

            Console.WriteLine("Stat total is {0}. Adding Pokemon...", stattotal);

            /* One of four possible constructor calls is made, depending on whether the secondType and secondEggGroup are null or not. */
            if (secondType == "null" || secondType == "Null")
            {
                if (secondEggGroup == "null" || secondEggGroup == "Null")
                {
                    PokemonDataManager.PokemonData.Add(id, new PokemonData(name, baseHP, baseAttack, baseDefence, baseSpecialAttack, baseSpecialDefence, baseSpeed, id, type, null, canHaveGender, species, weightKg, heightM, eggGroup, null, baseExp, captureRate, baseHappiness, growthRate, eggCycles, maleRatio, femaleRatio, evYield));
                }
                else
                {
                    EggGroup otherEggGroup = ParseEnum <EggGroup>(secondEggGroup);
                    PokemonDataManager.PokemonData.Add(id, new PokemonData(name, baseHP, baseAttack, baseDefence, baseSpecialAttack, baseSpecialDefence, baseSpeed, id, type, null, canHaveGender, species, weightKg, heightM, eggGroup, otherEggGroup, baseExp, captureRate, baseHappiness, growthRate, eggCycles, maleRatio, femaleRatio, evYield));
                }
            }
            else // secondType != "null" || secondType != "Null"
            {
                PkmnType otherType = ParseEnum <PkmnType>(secondType);
                if (secondEggGroup == "null" || secondEggGroup == "Null")
                {
                    PokemonDataManager.PokemonData.Add(id, new PokemonData(name, baseHP, baseAttack, baseDefence, baseSpecialAttack, baseSpecialDefence, baseSpeed, id, type, otherType, canHaveGender, species, weightKg, heightM, eggGroup, null, baseExp, captureRate, baseHappiness, growthRate, eggCycles, maleRatio, femaleRatio, evYield));
                }
                else
                {
                    EggGroup otherEggGroup = ParseEnum <EggGroup>(secondEggGroup);
                    PokemonDataManager.PokemonData.Add(id, new PokemonData(name, baseHP, baseAttack, baseDefence, baseSpecialAttack, baseSpecialDefence, baseSpeed, id, type, otherType, canHaveGender, species, weightKg, heightM, eggGroup, otherEggGroup, baseExp, captureRate, baseHappiness, growthRate, eggCycles, maleRatio, femaleRatio, evYield));
                }
            }
            Console.WriteLine("{0} has been added successfully!", name);
            System.Threading.Thread.Sleep(2000);
        }