public void Continue() { string trainerPokemons = @"C:\Users\Erdem\source\repos\Pokemon\Pokemon\playerPokemonsSave.csv"; string wildPokemons = @"C:\Users\Erdem\source\repos\Pokemon\Pokemon\wildPokemonsSave.csv"; string storedPokemons = @"C:\Users\Erdem\source\repos\Pokemon\Pokemon\storedPokemonsSave.csv"; x.RetrievePokemons(trainerPokemons, Game.trainer.Bag.Pokemons); x.RetrievePokemons(wildPokemons, Program.pokemons); x.RetrievePokemons(storedPokemons, PokeCenter.StoredPokemons); string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Erdem\source\repos\Pokemon\Pokemon\inventory.txt"); Game.trainer.Gold = int.Parse(lines[0]); Console.WriteLine("Please, enter your trainer's name: "); trainer.Name = Console.ReadLine(); Potion potion = new Potion(); Pokeball pokeball = new Pokeball(); for (int i = 0; i < int.Parse(lines[1]); i++) { trainer.Bag.addPokeball(pokeball); } for (int i = 0; i < int.Parse(lines[2]); i++) { trainer.Bag.addPotion(potion); } trainer.Journey(); }
private void buttonBuy_Click(object sender, EventArgs e) { bool newItem = true; int j = 0; if (lastListBox == listBoxPokeballs) { Pokeball aux = new Pokeball(lastListBox.SelectedIndex + 1); if (FormGame.player.money >= aux.price) FormGame.player.money -= aux.price; else return; List<Pokeball> tmp = FormGame.player.pokeballs; for (int i = 0; i < tmp.Count; ++i) if (tmp[i].type == lastListBox.SelectedIndex + 1) { j = i; newItem = false; break; } if (newItem) { tmp.Add(new Pokeball(lastListBox.SelectedIndex + 1)); tmp[tmp.Count - 1].number = 1; } else tmp[j].number += 1; } if(lastListBox == listBoxPotions) { Potion aux = new Potion(lastListBox.SelectedIndex + 1); if (FormGame.player.money >= aux.price) FormGame.player.money -= aux.price; else return; List<Potion> tmp = FormGame.player.potions; for (int i = 0; i < tmp.Count; ++i) if (tmp[i].type == lastListBox.SelectedIndex + 1) { j = i; newItem = false; break; } if (newItem) { tmp.Add(new Potion(lastListBox.SelectedIndex + 1)); tmp[tmp.Count - 1].number = 1; } else tmp[j].number += 1; } ChangeMoney(); }
public void addPokeball(Pokeball pokeball) { if (pokeballs.Count < 6) { pokeballs.Add(pokeball); } else { Console.WriteLine("Your bag is full!"); } }
static void Main(string[] args) { Pokemon pikachu = new Pokemon("Pikachu", "Electric", 35, 10, 55, 40, 90, 190); Pokemon magikarp = new Pokemon("Magikarp", "Water", 100, 10, 10, 55, 80, 255); while (true) { Pokeball pokeball = new Pokeball(); pokeball.PokeballCatchRate(BallType.MasterBall); Console.WriteLine(pokeball.CatchPokemon(pikachu)); Console.ReadKey(); GUI gui = new GUI(); gui.PokemonAreana(pikachu, magikarp); } //gui.PokemonMenu(); }
public void NewGame() { string path = @"C:\Users\Erdem\source\repos\Pokemon\Pokemon\pokemonDB.csv"; x.RetrievePokemons(path, Program.pokemons); Console.WriteLine("Please, enter your trainer's name: "); trainer.Name = Console.ReadLine(); Potion potion = new Potion(); Pokeball pokeball = new Pokeball(); for (int i = 0; i < 3; i++) { trainer.Bag.addPotion(potion); trainer.Bag.addPokeball(pokeball); } Console.WriteLine("Please, choose a Pokemon (1 - Bulbasaur, 2 - Charmander, 3 - Squirtle): "); int index = int.Parse(Console.ReadLine()) - 1; trainer.Bag.addPokemon(Program.pokemons[index], index); Console.WriteLine("You've caught a " + trainer.Bag.Pokemons[0].Name + "!"); trainer.Journey(); }
public static void Shop() { while (true) { Console.WriteLine($"\nYou've got {Game.trainer.Gold}G!"); Console.WriteLine("\nWhat do you wanna buy?"); Console.WriteLine("1 - Potions"); Console.WriteLine("2 - Pokeballs"); Console.WriteLine("3 - PC"); Console.WriteLine("4 - Go back to the PokeCenter"); string choice = Console.ReadLine(); if (choice.Equals("1")) { Console.WriteLine("\nBuy 1 Potion for 25G? (1 - Yes, 2 - Cancel)"); if (Console.ReadLine().Equals("1")) { if (Game.trainer.Gold >= 25) { Game.trainer.Gold -= 25; Potion potion = new Potion(); Game.trainer.Bag.addPotion(potion); } else { Console.WriteLine("You don't have enough gold!"); } } else { continue; } } else if (choice.Equals("2")) { Console.WriteLine("\nBuy 1 Pokeball for 25G? (1 - Yes, 2 - Cancel)"); if (Console.ReadLine().Equals("1")) { if (Game.trainer.Gold >= 25) { Game.trainer.Gold -= 25; Pokeball pokeball = new Pokeball(); Game.trainer.Bag.addPokeball(pokeball); } else { Console.WriteLine("You don't have enough gold!"); } } else { continue; } } else if (choice.Equals("3")) { Console.WriteLine("\nChoose the pokemon that you would like to get: "); Console.WriteLine("____________________________________________"); for (int i = 0; i < StoredPokemons.Count; i++) { Console.WriteLine($"{i + 1} - {StoredPokemons[i].Name}"); } int change1 = int.Parse(Console.ReadLine()) - 1; Console.WriteLine("\nChoose the Pokemon that you would like to change: "); Console.WriteLine("_____________________________________________"); for (int i = 0; i < Game.trainer.Bag.Pokemons.Count; i++) { Console.WriteLine($"{i + 1} - {Game.trainer.Bag.Pokemons[i].Name}"); } int change2 = int.Parse(Console.ReadLine()) - 1; StoredPokemons.Add(Game.trainer.Bag.Pokemons[change2]); Game.trainer.Bag.Pokemons.RemoveAt(change2); Game.trainer.Bag.Pokemons.Add(StoredPokemons[change1]); StoredPokemons.RemoveAt(change1); } else { break; } } Enter(); }
private void buttonStartGame_Click(object sender, EventArgs e) { if (selectedNr < 0) { labelError.Text = "Select a starter pokemon"; labelError.Show(); return; } if (tbName.Text == "") { labelError.Text = "Select a name for your trainer"; labelError.Show(); return; } string[] words = tbName.Text.Split(); if(words[0] != tbName.Text) { labelError.Text = "Your name can not contain spaces"; labelError.Show(); return; } applicationIsRunning = true; Character player = new Character(tbName.Text); int pokeNr; switch (selectedNr) { case 0: pokeNr = 1; break; case 1: pokeNr = 4; break; case 2: pokeNr = 7; break; case 3: pokeNr = 152; break; case 4: pokeNr = 155; break; case 5: pokeNr = 158; break; case 6: pokeNr = 252; break; case 7: pokeNr = 255; break; case 8: pokeNr = 258; break; case 9: pokeNr = 387; break; case 10: pokeNr = 390; break; default: pokeNr = 393; break; } Pokemons pokemon = new Pokemons(pokeNr, 5); FormPokedex.SeePokemon(pokeNr); FormPokedex.OwnPokemon(pokeNr); // starting pokemon pokemon.lovebase = 50; pokemon.EarnLove(100, 20, 30); player.AddPokemon(pokemon); // starting items Pokeball pball = new Pokeball(1); pball.number = 5; player.pokeballs.Add(pball); // starting money player.money = 1000; // starting food player.food = 10; new FormGame(player).Show(); this.Close(); }
public void StopActionFromTrainer(Character trainer) { if (trainer.index == 117) { FormGame.map = new Map(mapNumber, FormGame.OX - 7, FormGame.OY - 6); return; } trainerDefeated[trainer.index] = true; if(trainer.index >= 118 && trainer.index <= 120) { player.HealTeam(); characters.Clear(); actionpoint.Clear(); LoadTournament(trainer.index - 116); return; } if(trainer.index == 121) { new FormEndGame(1).Show(); mainForm.Close(); } if (trainer.index == 9) // first gym { mainForm.ShowMessage("John the Lumberjack: Aaaaah, not again! I'm surprised. Congratulations! Here, take this badge, you deserve it! Oh, and take this, too. It is a HM: Cut. You can teach your pokemons this move how many times you want. Check your bag."); player.TMs.Add(new Attack(15)); // give Cut player.badges = 1; } if (trainer.index == 19) // second gym { mainForm.ShowMessage("Desmond: Excellent skills! Here is your badge and a pleasant surprise - TM: Calm Mind. But be careful! You can teach your pokemons a HM how many times you want, but after you teach one a TM, you will lose the TM forever. The Calm Mind should help you approach the Haunted House without fear."); player.TMs.Add(new Attack(347)); // give Calm Mind player.badges = 2; } if (trainer.index == 25) // third gym { mainForm.ShowMessage("Magic Stan: I guess you can't be a great magician in a small village like this. But you have talent. Here, take HM: Surf. With it you can surf on water and go towards new horizons!"); player.TMs.Add(new Attack(57)); // give Surf player.badges = 3; } if (trainer.index == 64) // fourth gym { mainForm.ShowMessage("Aviana: Oh my God! I was so blinded by power that i didn't notice how polluted our waters were. I should be taking care of these problems right away!"); player.badges = 4; } if (trainer.index == 79) // fifth gym { mainForm.ShowMessage("Farmer: YOOHOO! What a battle! Take a pair of goggles to go in the desert. Oh, and you should take this TM: Dig. Dig in the desert to find hidden secrets."); player.TMs.Add(new Attack(91)); // give Dig player.badges = 5; } if (trainer.index == 93) // sixth gym { mainForm.ShowMessage("Isolde: I feel something strange coming from the north."); player.badges = 6; } if (trainer.index == 99) // seventh gym { mainForm.ShowMessage("Charles&Clotilde Dubois: Mon dieu! We did not expect that! C'est dommage, you win..."); player.badges = 7; } if (trainer.index == 116) // eighth gym { mainForm.ShowMessage("Edmund the Wise: Oh, you are gifted. I guess this is your last badge. Take it and become the tournament champion!"); player.badges = 8; } if (trainer.index == 103) // fake gym { mainForm.ShowMessage(player.name + ": Oh, you are the leader of Team Rocket!\nGiovanni: How could a prick interfere with my plans?\n\nYou recovered a Master Ball from Team Rocket!"); Pokeball pball = new Pokeball(4); pball.number = 1; player.pokeballs.Add(pball); } if (trainer.index >= 39 && trainer.index <= 43 && trainerDefeated[39] && trainerDefeated[40] && trainerDefeated[41] && trainerDefeated[42] && trainerDefeated[43]) // open gates for Lucas the Fighter { mainForm.ShowMessage("Lucas the Fighter: Hmm, I know you. You beat my older brother, John the Lumberjack. But can you handle my superior strength?"); structures.Clear(); } if (trainer.index == 38) // Lucas the Fighter { mainForm.ShowMessage("Lucas the Fighter: What the hell... whatever, you deserve the prize. I will teach your pokemon the best fighting move: Focus Punch. But be careful at its downsides."); actionAfterDialog = 3; } if (trainer.index >= 45 && trainer.index <= 49 && trainerDefeated[45] && trainerDefeated[46] && trainerDefeated[47] && trainerDefeated[48] && trainerDefeated[49]) // open gates for Dino Senior { mainForm.ShowMessage("Dino Senior: Haha, you're a shifty one!"); structures.Clear(); } if (trainer.index == 44) // Dino Senior { mainForm.ShowMessage("Dino Senior: Bravos! Take this TM: Draco Meteor. It is a very strong move, but not so many pokemons can learn it."); player.TMs.Add(new Attack(434)); // give Draco Meteor } if (trainer.index >= 54 && trainer.index <= 62) // Get evolution stones from Team Rocket { EvolutionItem evolitem = new EvolutionItem(trainer.index - 53); player.evolutionItems.Add(evolitem); mainForm.ShowMessage("You recovered " + evolitem.name + " from Team Rocket!"); } if (trainer.index >= 54 && trainer.index <= 62 && trainerDefeated[54] && trainerDefeated[55] && trainerDefeated[56] && trainerDefeated[57] && trainerDefeated[58] && trainerDefeated[59] && trainerDefeated[60] && trainerDefeated[61] && trainerDefeated[62]) // Team Rocket Squad 1 defeated { FormGame.map = new Map(mapNumber, FormGame.OX - 7, FormGame.OY - 6); } if (trainer.index >= 88 && trainer.index <= 92) // Get other evolution items from Team Rocket { int aux = (trainer.index - 88) * 3; EvolutionItem evolitem1 = new EvolutionItem(aux + 10); EvolutionItem evolitem2 = new EvolutionItem(aux + 11); EvolutionItem evolitem3 = new EvolutionItem(aux + 12); player.evolutionItems.Add(evolitem1); player.evolutionItems.Add(evolitem2); player.evolutionItems.Add(evolitem3); mainForm.ShowMessage("You recovered " + evolitem1.name + ", " + evolitem2.name + " and " + evolitem3.name + " from Team Rocket!"); } if (trainer.index >= 88 && trainer.index <= 92 && trainerDefeated[88] && trainerDefeated[89] && trainerDefeated[90] && trainerDefeated[91] && trainerDefeated[92]) // Team Rocket Squad 2 defeated { FormGame.map = new Map(mapNumber, FormGame.OX - 7, FormGame.OY - 6); } }
private void timerLoading_Tick(object sender, EventArgs e) { points = (points + 1) % 4; labelLoading.Text = "Loading"; for (int i = 1; i <= points; ++i) labelLoading.Text += "."; if (Resources.resourcesDone) { timerLoading.Stop(); applicationIsRunning = true; if(newGame) new FormCharacterCreation().Show(); else { StreamReader sr = new StreamReader(Application.StartupPath + "\\game.sav"); string line; string[] words; line = sr.ReadLine(); words = line.Split(); Character player = new Character(words[0]); player.money = Convert.ToInt32(words[1]); player.badges = Convert.ToInt32(words[2]); player.healingcenter = Convert.ToInt32(words[3]); player.food = Convert.ToInt32(words[4]); line = sr.ReadLine(); words = line.Split(); int pokeCount = Convert.ToInt32(words[0]); for(int i=0;i<pokeCount;++i) { line = sr.ReadLine(); words = line.Split(); Pokemons pokemon = new Pokemons(Convert.ToInt32(words[0]), 1); pokemon.level = Convert.ToInt32(words[1]); pokemon.gender = Convert.ToInt32(words[2]); pokemon.name = words[3] + ""; pokemon.lovebase = (float)Convert.ToDouble(words[4]); pokemon.EarnLove((float)Convert.ToDouble(words[5]), (float)Convert.ToDouble(words[6]), (float)Convert.ToDouble(words[7])); pokemon.hp = (float)Convert.ToDouble(words[8]); pokemon.hpmax = (float)Convert.ToDouble(words[9]); pokemon.atk = (float)Convert.ToDouble(words[10]); pokemon.def = (float)Convert.ToDouble(words[11]); pokemon.spatk = (float)Convert.ToDouble(words[12]); pokemon.spdef = (float)Convert.ToDouble(words[13]); pokemon.speed = (float)Convert.ToDouble(words[14]); pokemon.xp = Convert.ToInt32(words[15]); line = sr.ReadLine(); words = line.Split(); pokemon.moves = new List<Attack>(); int moveCount = Convert.ToInt32(words[0]); for (int j = 0; j < moveCount; ++j) { Attack move = new Attack(Convert.ToInt32(words[1 + j * 2])); move.PP = Convert.ToInt32(words[2 + j * 2]); pokemon.LearnMove(move); } player.AddPokemon(pokemon); } line = sr.ReadLine(); words = line.Split(); int pokeLabCount = Convert.ToInt32(words[0]); for (int i = 0; i < pokeLabCount; ++i) { line = sr.ReadLine(); words = line.Split(); Pokemons pokemon = new Pokemons(Convert.ToInt32(words[0]), 1); pokemon.level = Convert.ToInt32(words[1]); pokemon.gender = Convert.ToInt32(words[2]); pokemon.name = words[3] + ""; pokemon.lovebase = (float)Convert.ToDouble(words[4]); pokemon.EarnLove((float)Convert.ToDouble(words[5]), (float)Convert.ToDouble(words[6]), (float)Convert.ToDouble(words[7])); pokemon.hp = (float)Convert.ToDouble(words[8]); pokemon.hpmax = (float)Convert.ToDouble(words[9]); pokemon.atk = (float)Convert.ToDouble(words[10]); pokemon.def = (float)Convert.ToDouble(words[11]); pokemon.spatk = (float)Convert.ToDouble(words[12]); pokemon.spdef = (float)Convert.ToDouble(words[13]); pokemon.speed = (float)Convert.ToDouble(words[14]); pokemon.xp = Convert.ToInt32(words[15]); line = sr.ReadLine(); words = line.Split(); pokemon.moves = new List<Attack>(); int moveCount = Convert.ToInt32(words[0]); for (int j = 0; j < moveCount; ++j) { Attack move = new Attack(Convert.ToInt32(words[1 + j * 2])); move.PP = Convert.ToInt32(words[2 + j * 2]); pokemon.LearnMove(move); } player.pokemonsLab.Add(pokemon); } line = sr.ReadLine(); words = line.Split(); int pokeballCount = Convert.ToInt32(words[0]); for (int i = 0; i < pokeballCount;++i ) { Pokeball ball = new Pokeball(Convert.ToInt32(words[1 + i * 2])); ball.number = Convert.ToInt32(words[2 + i * 2]); player.pokeballs.Add(ball); } line = sr.ReadLine(); words = line.Split(); int potionCount = Convert.ToInt32(words[0]); for (int i = 0; i < potionCount; ++i) { Potion pot = new Potion(Convert.ToInt32(words[1 + i * 2])); pot.number = Convert.ToInt32(words[2 + i * 2]); player.potions.Add(pot); } line = sr.ReadLine(); words = line.Split(); int TMCount = Convert.ToInt32(words[0]); for (int i = 0; i < TMCount; ++i) { player.TMs.Add(new Attack(Convert.ToInt32(words[1 + i]))); } line = sr.ReadLine(); words = line.Split(); int EvolutionItemsCount = Convert.ToInt32(words[0]); for (int i = 0; i < EvolutionItemsCount; ++i) { player.evolutionItems.Add(new EvolutionItem(Convert.ToInt32(words[1 + i]))); } FormGame formGame = new FormGame(player); line = sr.ReadLine(); words = line.Split(); FormGame.map = new Map(Convert.ToInt32(words[0]), Convert.ToInt32(words[1]), Convert.ToInt32(words[2])); FormGame.gameTime = Convert.ToInt32(words[3]); Map.lastTimeGym = Convert.ToInt32(words[4]); line = sr.ReadLine(); words = line.Split(); for (int i = 0; i < 200;++i ) { if (Convert.ToInt32(words[i]) == 1) Map.trainerDefeated[i] = true; } line = sr.ReadLine(); words = line.Split(); for (int i = 1; i < 494; ++i) { if (Convert.ToInt32(words[i - 1]) == 1) Map.pokemonDefeated[i] = true; } line = sr.ReadLine(); words = line.Split(); FormPokedex.seen = Convert.ToInt32(words[0]); FormPokedex.owned = Convert.ToInt32(words[1]); line = sr.ReadLine(); words = line.Split(); for (int i = 1; i < 494; ++i) if (Convert.ToInt32(words[i - 1]) == 1) FormPokedex.inPokedex[i] = true; line = sr.ReadLine(); words = line.Split(); for (int i = 1; i < 494; ++i) if (Convert.ToInt32(words[i - 1]) == 1) FormPokedex.ownedPokemon[i] = true; line = sr.ReadLine(); words = line.Split(); for (int i = 1; i < 494; ++i) { string nameString = words[i - 1] + ""; if (nameString != "-") FormPokedex.names[i] = nameString; } formGame.Show(); sr.Close(); } this.Close(); } }
private void listBox_SelectedIndexChanged(object sender, EventArgs e) { ListBox lb = (ListBox)sender; if (lb.SelectedIndex > lb.Items.Count || lb.SelectedIndex < 0) return; if (lb == listBoxPokeballs) { listBoxPotions.ClearSelected(); listBoxOthers.ClearSelected(); Pokeball tmp = new Pokeball(lb.SelectedIndex + 1); tbDescription.Text = tmp.description; } if (lb == listBoxPotions) { listBoxPokeballs.ClearSelected(); listBoxOthers.ClearSelected(); Potion tmp = new Potion(lb.SelectedIndex + 1); tbDescription.Text = tmp.description; } lastListBox = lb; }
public void ThrowBall(Pokeball ball) { if (enemyTrainer != null) { tbHistory.Text = "You can not use a pokeball in a battle with a trainer!\n" + tbHistory.Text; return; } pokeball = ball; // Master Ball was used if (pokeball.type == 4) player.usedMasterBall = true; // update the numbers of pokeballs ball.number -= 1; if (ball.number == 0) player.pokeballs.Remove(ball); // catch chance formula float catchChance = (enemyPokemon.catchrate / 255f) * (enemyPokemon.hpmax / enemyPokemon.hp) * 4.5f * ball.chance; // pause game waitTime = true; drawBall = true; pokeballPoint = new PointF(430, 70); pokeballTimerCount = 0; pokeballTimer.Start(); battleScreen.Invalidate(); if (rand.Next() % 100 + 1 < catchChance) pokemonWasCaught = true; else pokemonWasCaught = false; }