Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Pokemon
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Pokemon> roster = new List<Pokemon>();
- List<Pokemon> matchUp = new List<Pokemon>();
- // INITIALIZE YOUR THREE POKEMONS HERE
- List<Move> charMoves = new List<Move>();
- charMoves.Add(new Move("\nEmber [0]"));
- charMoves.Add(new Move("Fire Blast [1]"));
- List<Move> bulbaMoves = new List<Move>();
- bulbaMoves.Add(new Move("\nCut [0]"));
- bulbaMoves.Add(new Move("Mega Drain [1]"));
- bulbaMoves.Add(new Move("Razor Leafes [2]"));
- List<Move> squirMoves = new List<Move>();
- squirMoves.Add(new Move("\nBubble [0]"));
- squirMoves.Add(new Move("Bite [1]"));
- Pokemon Charmander = new Pokemon("Charmander", 3, 52, 43, 39, Elements.Fire, charMoves);
- Pokemon Bulbasaur = new Pokemon("Bulbasaur", 3, 49, 49, 45, Elements.Grass, bulbaMoves);
- Pokemon Squirtle = new Pokemon("Squirtle", 2, 48, 65, 44, Elements.Water, squirMoves);
- roster.Add(Charmander);
- roster.Add(Bulbasaur);
- roster.Add(Squirtle);
- Console.WriteLine("Welcome to the world of Pokemon!\nThe available commands are list/fight/heal/quit");
- while (true)
- {
- Console.WriteLine("\nPlease enter a command");
- switch (Console.ReadLine())
- {
- case "list":
- // PRINT THE POKEMONS IN THE ROSTER HERE
- Console.WriteLine("Squirtle " + "Bulbasaur " + "Charmander ");
- break;
- case "fight":
- //PRINT INSTRUCTIONS AND POSSIBLE POKEMONS (SEE SLIDES FOR EXAMPLE OF EXECUTION)
- Console.Write("CHOOSE WHO SHOULD FIGHT!\n" +
- "Pick two of the following: Charmander, Bulbasaur and Squirtle\n");
- //READ INPUT, REMEMBER IT SHOULD BE TWO POKEMON NAMES
- string input = Console.ReadLine();
- string[] chosen = input.Split(' ');
- Pokemon player = null;
- Pokemon enemy = null;
- if (chosen[0] == "Bulbasaur")
- {
- matchUp.Insert(0, Bulbasaur);
- }
- if (chosen[0] == "Charmander")
- {
- matchUp.Insert(0, Charmander);
- }
- if (chosen[0] == "Squirtle")
- {
- matchUp.Insert(0, Squirtle);
- }
- if (chosen[1] == "Bulbasaur")
- {
- matchUp.Insert(1, Bulbasaur);
- }
- if (chosen[1] == "Charmander")
- {
- matchUp.Insert(1, Charmander);
- }
- if (chosen[1] == "Squirtle")
- {
- matchUp.Insert(1, Squirtle);
- }
- player = matchUp.First();
- enemy = matchUp.Last();
- //BE SURE TO CHECK THE POKEMON NAMES THE USER WROTE ARE VALID (IN THE ROSTER) AND IF THEY ARE IN FACT 2!
- //if everything is fine and we have 2 pokemons let's make them fight
- if (player != null && enemy != null && player != enemy)
- {
- Console.WriteLine("A wild " + enemy.Name + " appears!");
- Console.Write(player.Name + " I choose you! ");
- //BEGIN FIGHT LOOP
- while (player.Hp > 0 && enemy.Hp > 0)
- {
- //PRINT POSSIBLE MOVES
- Console.Write("What move should we use?");
- if (player == Bulbasaur)
- {
- foreach (Move pokemon in bulbaMoves)
- {
- Console.WriteLine(pokemon.Name);
- }
- }
- if (player == Charmander)
- {
- foreach (Move pokemon in charMoves)
- {
- Console.WriteLine(pokemon.Name);
- }
- }
- if (player == Squirtle)
- {
- foreach (Move pokemon in squirMoves)
- {
- Console.WriteLine(pokemon.Name);
- }
- }
- if (chosen == "0")
- {
- }
- //GET USER ANSWER, BE SURE TO CHECK IF IT'S A VALID MOVE, OTHERWISE ASK AGAIN
- int move = -1;
- //CALCULATE AND APPLY DAMAGE
- int damage = -1;
- //print the move and damage
- Console.WriteLine(player.Name + " uses " + player.Moves[move].Name + ". " + enemy.Name + " loses " + damage + " HP");
- //if the enemy is not dead yet, it attacks
- if (enemy.Hp > 0)
- {
- //CHOOSE A RANDOM MOVE BETWEEN THE ENEMY MOVES AND USE IT TO ATTACK THE PLAYER
- Random rand = new Random();
- /*the C# random is a bit different than the Unity random
- * you can ask for a number between [0,X) (X not included) by writing
- * rand.Next(X)
- * where X is a number
- */
- int enemyMove = -1;
- int enemyDamage = -1;
- //print the move and damage
- Console.WriteLine(enemy.Name + " uses " + enemy.Moves[enemyMove].Name + ". " + player.Name + " loses " + enemyDamage + " HP");
- }
- }
- //The loop is over, so either we won or lost
- if (enemy.Hp <= 0)
- {
- Console.WriteLine(enemy.Name + " faints, you won!");
- }
- else
- {
- Console.WriteLine(player.Name + " faints, you lost...");
- }
- }
- //otherwise let's print an error message
- else
- {
- Console.WriteLine("Invalid pokemons!");
- }
- break;
- case "heal":
- //RESTORE ALL POKEMONS IN THE ROSTER
- Console.WriteLine("All pokemons have been healed");
- break;
- case "quit":
- Environment.Exit(0);
- break;
- default:
- Console.WriteLine("Unknown command");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement