Esempio n. 1
0
 /* The public Trainer constructor takes the name, rank, difficulty, team, and dialogue of the Trainer.
  * The fields are all set appropriately from the parameters. */
 public Trainer(string name, TrainerRank rank, TrainerDifficulty difficulty, Pokemon[] trainerPokemon, string dialogue, byte pokemonCount)
 {
     trainerName     = name;
     this.rank       = rank;
     this.difficulty = difficulty;
     Array.Copy(trainerPokemon, this.trainerPokemon, 6);
     this.dialogue = dialogue;
 }
Esempio n. 2
0
        /* The AddTrainer() function allows the user to add an NPC trainer manually.
         * It needs the PokemonDataManager and MoveManager as arguments since it uses them to create the trainer's team. */
        public static void AddTrainer(PokemonDataManager pokemonDataManager, MoveManager moveManager)
        {
            Border("PkmnEngine Editor - New Trainer");

            /* The user is prompted to enter the Trainer's name. */
            Console.WriteLine("Enter Trainer Name (must be unique for now)");
            string name = Console.ReadLine();

            /* If the TrainerManager already contains a Trainer with the entered name, the user is prompted to ask if they want to overwrite it. */
            if (TrainerManager.Trainers.ContainsKey(name))
            {
                Console.WriteLine("Trainer with name {0} already exists. Overwrite? (y/n)", TrainerManager.Trainers[name].TrainerName);
                string choice = Console.ReadLine();

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

            /* Otherwise, the user will then enter all the Trainer's details into the program. */
            Console.WriteLine("Enter Trainer Rank (Normal, Grunt, Elite, GymLeader, EliteFour, Champion)");
            TrainerRank rank = ParseEnum <TrainerRank>(Console.ReadLine());

            Console.WriteLine("Enter Trainer Difficulty (VeryEasy, Easy, Normal, Hard, VeryHard)");
            TrainerDifficulty difficulty = ParseEnum <TrainerDifficulty>(Console.ReadLine());

            Console.WriteLine("How many Pokemon does the trainer have? (Max 6)");
            byte pokemonCount = byte.Parse(Console.ReadLine());

            Pokemon[] pokemonTeam = new Pokemon[6];
            System.Threading.Thread.Sleep(500);

            /* After taking the Trainer information, the program then gets data about the Trainer's Pokemon team from the user.
             * The floor loop iterates through each Pokemon in the team according to the count specified by the user. */
            for (int i = 0; i < pokemonCount; i++)
            {
                Border("PkmnEngine Editor - New Trainer - Pokemon #" + (i + 1));
                Console.WriteLine("Enter ID of Pokemon species.");
                byte        id      = byte.Parse(Console.ReadLine());
                PokemonData species = pokemonDataManager.PokemonData[id];
                Console.WriteLine("Enter level of Pokemon. (1-100)");
                byte   level = byte.Parse(Console.ReadLine());
                Gender gender;
                if (species.CanHaveGender)
                {
                    Console.WriteLine("Enter gender of Pokemon (Male/Female).");
                    gender = ParseEnum <Gender>(Console.ReadLine());
                }
                else
                {
                    gender = Gender.none;
                }
                Console.WriteLine("How many moves does the Pokemon have?");
                byte   moveCount    = byte.Parse(Console.ReadLine());
                Move[] pokemonMoves = new Move[4];

                /* Similarly to the iteraton through the Pokemon team, the program also iterates through each Pokemon's moveset. */
                for (int j = 0; j < moveCount; j++)
                {
                    Console.WriteLine("Enter name of move #" + (j + 1));
                    pokemonMoves[j] = moveManager.Moves[Console.ReadLine()];
                }

                /* Each new Pokemon is constructed using the parameters passed in, and added to the pokemonTeam array. */
                Pokemon pokemon = new Pokemon(species, gender, pokemonMoves, level, rank);
                pokemonTeam[i] = pokemon;
                System.Threading.Thread.Sleep(500);
            }
            Border("PkmnEngine Editor - Add Pokemon");

            /* Finally, the user enters the Trainer dialogue (what the NPC says when you fight them). */
            Console.WriteLine("Enter the test dialogue for the trainer:");
            string dialogue = Console.ReadLine();

            /* The new Trainer is constructed and added to the TrainerManager. */
            Trainer trainer = new Trainer(name, rank, difficulty, pokemonTeam, dialogue, pokemonCount);

            TrainerManager.AddTrainer(trainer);
        }