From 34b6e157c8c632cb6b075522b9dc5c1fad2d8921 Mon Sep 17 00:00:00 2001 From: OMGiTzPomPom Date: Thu, 13 Oct 2022 22:03:05 +0200 Subject: [PATCH] debut gameManager --- Program.cs | 6 +- {txt => csv}/Characters.csv | 3 +- {txt => csv}/Pokemon.csv | 4 +- projet/GameManager.cs | 185 +++++++++++++++++++++++++- projet/Nature.cs | 3 +- projet/Player.cs | 4 + projet/Pokemon.cs | 4 + projet/Type.cs | 2 +- projet/Types/PokemonBug.cs | 59 ++++++++ projet/Types/PokemonDark.cs | 49 +++++++ projet/Types/PokemonDragon.cs | 49 +++++++ projet/{ => Types}/PokemonElectric.cs | 0 projet/Types/PokemonFairy.cs | 51 +++++++ projet/Types/PokemonFighting.cs | 63 +++++++++ projet/{ => Types}/PokemonFire.cs | 0 projet/Types/PokemonFlying.cs | 51 +++++++ projet/Types/PokemonGhost.cs | 51 +++++++ projet/{ => Types}/PokemonGrass.cs | 0 projet/Types/PokemonGround.cs | 57 ++++++++ projet/Types/PokemonIce.cs | 55 ++++++++ projet/{ => Types}/PokemonNormal.cs | 0 projet/Types/PokemonPoison.cs | 57 ++++++++ projet/Types/PokemonPsychic.cs | 53 ++++++++ projet/Types/PokemonRock.cs | 51 +++++++ projet/Types/PokemonSteel.cs | 53 ++++++++ projet/{ => Types}/PokemonWater.cs | 0 26 files changed, 902 insertions(+), 8 deletions(-) rename {txt => csv}/Characters.csv (88%) rename {txt => csv}/Pokemon.csv (99%) create mode 100644 projet/Types/PokemonBug.cs create mode 100644 projet/Types/PokemonDark.cs create mode 100644 projet/Types/PokemonDragon.cs rename projet/{ => Types}/PokemonElectric.cs (100%) create mode 100644 projet/Types/PokemonFairy.cs create mode 100644 projet/Types/PokemonFighting.cs rename projet/{ => Types}/PokemonFire.cs (100%) create mode 100644 projet/Types/PokemonFlying.cs create mode 100644 projet/Types/PokemonGhost.cs rename projet/{ => Types}/PokemonGrass.cs (100%) create mode 100644 projet/Types/PokemonGround.cs create mode 100644 projet/Types/PokemonIce.cs rename projet/{ => Types}/PokemonNormal.cs (100%) create mode 100644 projet/Types/PokemonPoison.cs create mode 100644 projet/Types/PokemonPsychic.cs create mode 100644 projet/Types/PokemonRock.cs create mode 100644 projet/Types/PokemonSteel.cs rename projet/{ => Types}/PokemonWater.cs (100%) diff --git a/Program.cs b/Program.cs index 6497b81..db4d7ce 100644 --- a/Program.cs +++ b/Program.cs @@ -2,6 +2,10 @@ public class Program { public static void Main(string[] args) { - + GameManager gm = new GameManager(); + gm.initializeGame(); + + Console.WriteLine(gm.GetPlayers()[0]); + Console.WriteLine(""); } } \ No newline at end of file diff --git a/txt/Characters.csv b/csv/Characters.csv similarity index 88% rename from txt/Characters.csv rename to csv/Characters.csv index 57dbfea..e132d46 100644 --- a/txt/Characters.csv +++ b/csv/Characters.csv @@ -1,4 +1,5 @@ -Applejack;Applejack est une honnête dresseuse pokémon et sait faire preuve d'un grand altruisme envers les pokémon. Elle vit et travaille à la Ferme de la Douce Baie Oran.;Ses Pokémons ont un bonus de PV de 5% +//Nom;Description;Effet +Applejack;Applejack est une honnête dresseuse pokémon et sait faire preuve d'un grand altruisme envers les pokémon. Elle vit et travaille à la Ferme de la Douce Baie Oran.;Ses Pokémons ont un bonus de PV de 5% Rainbow Dash;Rainbow Dash est une loyale dresseuse pokémon. Elle est en charge de la météo de Pokeville;Ses Pokémons ont un bonus d'ATKPhys de 3% Twilight Sparkle;Twilight Sparkle est une dresseuse pokémon avec un talent inné. Elle a la capacité d'élever ses pokémons avec aisance. Elle vit dans le palais royal du Bourg Galop;Ses Pokémons ont un bonus de vitesse de 7% Pinkie Pie;Pinkie Pie est une souriante dresseuse pokémon. Elle fait sourire tous les pokémons en un instant. Elle vit avec sa famille dans une ferme de production de caillous à Mérouville.;Ses Pokémons ont un bonus de DEFPhys de 4% diff --git a/txt/Pokemon.csv b/csv/Pokemon.csv similarity index 99% rename from txt/Pokemon.csv rename to csv/Pokemon.csv index e2b9db5..747b79e 100644 --- a/txt/Pokemon.csv +++ b/csv/Pokemon.csv @@ -1,4 +1,4 @@ -name;type;hp;attack;defense;sp_attack;sp_defense;speed +//Name;Type;Hp;Attack;Defense;Sp_attack;Sp_defense;Speed Bulbasaur;Grass;45;49;49;65;65;45 Ivysaur;Grass;60;62;63;80;80;60 Venusaur;Grass;80;82;83;100;100;80 @@ -14,7 +14,7 @@ Squirtle;Water;44;48;65;50;64;43 Wartortle;Water;59;63;80;65;80;58 Blastoise;Water;79;83;100;85;105;78 Mega Blastoise;Water;79;103;120;135;115;78 -Gigantamax Blasoise;Blastoise;79;83;100;85;105;78 +Gigantamax Blastoise;Water;79;83;100;85;105;78 Caterpie;Bug;45;30;35;20;20;45 Metapod;Bug;50;20;55;25;25;30 Butterfree;Bug;60;45;50;90;80;70 diff --git a/projet/GameManager.cs b/projet/GameManager.cs index 335ddeb..79d0412 100644 --- a/projet/GameManager.cs +++ b/projet/GameManager.cs @@ -3,11 +3,186 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.IO; namespace Programmation_objet_TLESIO21.projet { public class GameManager { - public static void AlterPokemonStat(String stat, double value, Pokemon p) { + private string Path; + private List pkm = new List(); + private List players = new List(); + + public GameManager() { + this.Path = "../../../csv/"; + } + + private static int getRandom(int max) { + Random r = new Random(); + return r.Next(max); + } + + private Nature GenerateNature() { + switch (getRandom(25)) { + case 0: + return Nature.BOLD; + case 1: + return Nature.QUIRKY; + case 2: + return Nature.BRAVE; + case 3: + return Nature.CALM; + case 4: + return Nature.QUIET; + case 5: + return Nature.DOCILE; + case 6: + return Nature.MILD; + case 7: + return Nature.RASH; + case 8: + return Nature.GENTLE; + case 9: + return Nature.HARDY; + case 10: + return Nature.JOLLY; + case 11: + return Nature.LAX; + case 12: + return Nature.IMPISH; + case 13: + return Nature.SASSY; + case 14: + return Nature.NAUGHTY; + case 15: + return Nature.MODEST; + case 16: + return Nature.NAIVE; + case 17: + return Nature.HASTY; + case 18: + return Nature.CAREFUL; + case 19: + return Nature.BASHFUL; + case 20: + return Nature.RELAXED; + case 21: + return Nature.ADAMANT; + case 22: + return Nature.SERIOUS; + case 23: + return Nature.LONELY; + case 24: + return Nature.TIMID; + default: + return Nature.NULL; + } + } + + private Pokemon? CreatePokemon(String s) { + String[] tab = s.Split(";"); + switch (tab[1]) { + case "Normal": + return new PokemonNormal(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Grass": + return new PokemonGrass(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Fire": + return new PokemonFire(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Water": + return new PokemonWater(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Electric": + return new PokemonElectric(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Flying": + return new PokemonFlying(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Bug": + return new PokemonBug(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Rock": + return new PokemonRock(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Ground": + return new PokemonGround(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Psychic": + return new PokemonPsychic(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Poison": + return new PokemonPoison(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Ghost": + return new PokemonGhost(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Dark": + return new PokemonDark(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Steel": + return new PokemonSteel(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Fighting": + return new PokemonFighting(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Ice": + return new PokemonIce(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Dragon": + return new PokemonDragon(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + case "Fairy": + return new PokemonFairy(tab[0], int.Parse(tab[2]), int.Parse(tab[3]), int.Parse(tab[5]), int.Parse(tab[4]), int.Parse(tab[6]), int.Parse(tab[7])); + default: + return null; + } + } + + private Player createPlayer(String s) { + String[] tab = s.Split(";"); + List pokemons = new List(); + for(int i = 0; i < getRandom(30)+7; ++i) { + pokemons.Add(pkm.ElementAt(getRandom(1072))); + } + + foreach (Pokemon pkm in pokemons) { + Nature n = GenerateNature(); + pkm.SetNature(n); + this.ApplyNatureEffect(n, pkm); + this.ApplyPlayerEffect(tab[0], pkm); + } + + return new Player(tab[0], tab[1], pokemons); + } + + public void initializeGame() { + String line; + try { + //Pass the file path and file name to the StreamReader constructor + StreamReader srPkm = new StreamReader(this.Path + "Pokemon.csv"); + StreamReader srPerso = new StreamReader(this.Path + "Characters.csv"); + + //Read the first line of text + line = srPkm.ReadLine(); + //Continue to read until you reach end of file + while (line != null) { + if (line[0] == '/') { + line = srPkm.ReadLine(); + } + //write the line to console window + pkm.Add(CreatePokemon(line)); + //Read the next line + line = srPkm.ReadLine(); + } + //close the file + srPkm.Close(); + + //Read the first line of text + line = srPerso.ReadLine(); + //Continue to read until you reach end of file + while (line != null) { + if (line[0] == '/') { + line = srPerso.ReadLine(); + } + //write the line to console window + players.Add(createPlayer(line)); + //Read the next line + line = srPerso.ReadLine(); + } + //close the file + srPkm.Close(); + + + } catch (Exception e) { + Console.WriteLine("Exception: " + e.Message); + } + } + + public void AlterPokemonStat(String stat, double value, Pokemon p) { switch(stat) { case "PV": p.setPV((int)Math.Floor(p.getPV() * value)); @@ -108,7 +283,7 @@ namespace Programmation_objet_TLESIO21.projet { public void ApplyPlayerEffect(String playerName, Pokemon p) { switch(playerName) { case "Applejack": - AlterPokemonStat("PV", 0.95, p); + AlterPokemonStat("PV", 1.05, p); break; case "Rainbow Dash": AlterPokemonStat("ATKPhys", 1.03, p); @@ -141,6 +316,12 @@ namespace Programmation_objet_TLESIO21.projet { } } + public List GetPokemons() { + return this.pkm; + } + public List GetPlayers() { + return this.players; + } } } diff --git a/projet/Nature.cs b/projet/Nature.cs index 8a3ab47..36d05a1 100644 --- a/projet/Nature.cs +++ b/projet/Nature.cs @@ -30,6 +30,7 @@ namespace Programmation_objet_TLESIO21.projet { ADAMANT, SERIOUS, LONELY, - TIMID + TIMID, + NULL } } diff --git a/projet/Player.cs b/projet/Player.cs index 52c043f..1c7da5d 100644 --- a/projet/Player.cs +++ b/projet/Player.cs @@ -21,5 +21,9 @@ namespace Programmation_objet_TLESIO21.projet { this.Team = new List(6); } + public override string ToString() { + return this.Name + " est level " + this.level + ". Ses pokemon sont : " + this.PC.ToString(); + } + } } diff --git a/projet/Pokemon.cs b/projet/Pokemon.cs index d28ef36..f1b9420 100644 --- a/projet/Pokemon.cs +++ b/projet/Pokemon.cs @@ -49,6 +49,10 @@ namespace Programmation_objet_TLESIO21.projet { return this.getName() + " - PV : " + getPV() + ", PC = " + getPC(); } + public void SetNature(Nature n) { + this.Nature = n; + } + public void setPV(int pv) { this.PV = pv; } diff --git a/projet/Type.cs b/projet/Type.cs index 083624c..8a7e700 100644 --- a/projet/Type.cs +++ b/projet/Type.cs @@ -20,7 +20,7 @@ namespace Programmation_objet_TLESIO21.projet { GHOST, DARK, STEEL, - COMBAT, + FIGHTING, ICE, DRAGON, FAIRY diff --git a/projet/Types/PokemonBug.cs b/projet/Types/PokemonBug.cs new file mode 100644 index 0000000..8e1406f --- /dev/null +++ b/projet/Types/PokemonBug.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonBug : Pokemon { + + public PokemonBug(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(92); + this.setType(Type.BUG); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 2); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(damage > 0) { + if(cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.FAIRY) || + cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.POISON) || + cible.getType().Equals(Type.GHOST) || + cible.getType().Equals(Type.FLYING)) { + damage /= 2; + } + if(cible.getType().Equals(Type.GRASS) || + cible.getType().Equals(Type.PSYCHIC) || + cible.getType().Equals(Type.DARK)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 3); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if(damage > 0) { + if (cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.FAIRY) || + cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.POISON) || + cible.getType().Equals(Type.GHOST) || + cible.getType().Equals(Type.FLYING)) { + damage /= 2; + } + if (cible.getType().Equals(Type.GRASS) || + cible.getType().Equals(Type.PSYCHIC) || + cible.getType().Equals(Type.DARK)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/Types/PokemonDark.cs b/projet/Types/PokemonDark.cs new file mode 100644 index 0000000..4fbc9cf --- /dev/null +++ b/projet/Types/PokemonDark.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonDark : Pokemon { + + public PokemonDark(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(95); + this.setType(Type.DARK); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 4); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(damage > 0) { + if(cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.FAIRY) || + cible.getType().Equals(Type.DARK)) { + damage /= 2; + } + if(cible.getType().Equals(Type.PSYCHIC) || + cible.getType().Equals(Type.GHOST)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 2); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if(damage > 0) { + if (cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.FAIRY) || + cible.getType().Equals(Type.DARK)) { + damage /= 2; + } + if (cible.getType().Equals(Type.PSYCHIC) || + cible.getType().Equals(Type.GHOST)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/Types/PokemonDragon.cs b/projet/Types/PokemonDragon.cs new file mode 100644 index 0000000..3e9bcb2 --- /dev/null +++ b/projet/Types/PokemonDragon.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonDragon : Pokemon { + + public PokemonDragon(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(125); + this.setType(Type.DRAGON); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 1); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(cible.getType().Equals(Type.FAIRY)) { + damage = 0; + } + if(damage > 0) { + if(cible.getType().Equals(Type.STEEL)) { + damage /= 2; + } + if(cible.getType().Equals(Type.DRAGON)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 1); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if (cible.getType().Equals(Type.FAIRY)) { + damage = 0; + } + if (damage > 0) { + if (cible.getType().Equals(Type.STEEL)) { + damage /= 2; + } + if (cible.getType().Equals(Type.DRAGON)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/PokemonElectric.cs b/projet/Types/PokemonElectric.cs similarity index 100% rename from projet/PokemonElectric.cs rename to projet/Types/PokemonElectric.cs diff --git a/projet/Types/PokemonFairy.cs b/projet/Types/PokemonFairy.cs new file mode 100644 index 0000000..c99159d --- /dev/null +++ b/projet/Types/PokemonFairy.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonFairy : Pokemon { + + public PokemonFairy(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(106); + this.setType(Type.FAIRY); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 2); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(damage > 0) { + if(cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.POISON)) { + damage /= 2; + } + if(cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.DRAGON) || + cible.getType().Equals(Type.DARK)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 4); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if(damage > 0) { + if (cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.POISON)) { + damage /= 2; + } + if (cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.DRAGON) || + cible.getType().Equals(Type.DARK)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/Types/PokemonFighting.cs b/projet/Types/PokemonFighting.cs new file mode 100644 index 0000000..bdf4308 --- /dev/null +++ b/projet/Types/PokemonFighting.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonFighting : Pokemon { + + public PokemonFighting(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(102); + this.setType(Type.FIGHTING); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 4); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(cible.getType().Equals(Type.GHOST)) { + damage = 0; + } + if(damage > 0) { + if(cible.getType().Equals(Type.PSYCHIC) || + cible.getType().Equals(Type.FLYING) || + cible.getType().Equals(Type.BUG) || + cible.getType().Equals(Type.FAIRY)) { + damage /= 2; + } + if(cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.NORMAL) || + cible.getType().Equals(Type.DARK) || + cible.getType().Equals(Type.ICE) || + cible.getType().Equals(Type.ROCK)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 1); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if (cible.getType().Equals(Type.GHOST)) { + damage = 0; + } + if (damage > 0) { + if (cible.getType().Equals(Type.PSYCHIC) || + cible.getType().Equals(Type.FLYING) || + cible.getType().Equals(Type.BUG) || + cible.getType().Equals(Type.FAIRY)) { + damage /= 2; + } + if (cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.NORMAL) || + cible.getType().Equals(Type.DARK) || + cible.getType().Equals(Type.ICE) || + cible.getType().Equals(Type.ROCK)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/PokemonFire.cs b/projet/Types/PokemonFire.cs similarity index 100% rename from projet/PokemonFire.cs rename to projet/Types/PokemonFire.cs diff --git a/projet/Types/PokemonFlying.cs b/projet/Types/PokemonFlying.cs new file mode 100644 index 0000000..df2f8f6 --- /dev/null +++ b/projet/Types/PokemonFlying.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonFlying : Pokemon { + + public PokemonFlying(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(120); + this.setType(Type.FLYING); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 4); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(damage > 0) { + if(cible.getType().Equals(Type.ROCK) || + cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.ELECTRIC)) { + damage /= 2; + } + if(cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.BUG) || + cible.getType().Equals(Type.GRASS)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 2); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if(damage > 0) { + if (cible.getType().Equals(Type.ROCK) || + cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.ELECTRIC)) { + damage /= 2; + } + if (cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.BUG) || + cible.getType().Equals(Type.GRASS)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/Types/PokemonGhost.cs b/projet/Types/PokemonGhost.cs new file mode 100644 index 0000000..d0dd5f9 --- /dev/null +++ b/projet/Types/PokemonGhost.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonGhost : Pokemon { + + public PokemonGhost(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(80); + this.setType(Type.GHOST); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 3); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(cible.getType().Equals(Type.NORMAL)) { + damage = 0; + } + if(damage > 0) { + if(cible.getType().Equals(Type.DARK)) { + damage /= 2; + } + if(cible.getType().Equals(Type.PSYCHIC) || + cible.getType().Equals(Type.GHOST)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 1); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if (cible.getType().Equals(Type.NORMAL)) { + damage = 0; + } + if (damage > 0) { + if (cible.getType().Equals(Type.DARK)) { + damage /= 2; + } + if (cible.getType().Equals(Type.PSYCHIC) || + cible.getType().Equals(Type.GHOST)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/PokemonGrass.cs b/projet/Types/PokemonGrass.cs similarity index 100% rename from projet/PokemonGrass.cs rename to projet/Types/PokemonGrass.cs diff --git a/projet/Types/PokemonGround.cs b/projet/Types/PokemonGround.cs new file mode 100644 index 0000000..f489773 --- /dev/null +++ b/projet/Types/PokemonGround.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonGround : Pokemon { + + public PokemonGround(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(110); + this.setType(Type.ELECTRIC); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 3); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(cible.getType().Equals(Type.FLYING)) { + damage = 0; + } + if(damage > 0) { + if(cible.getType().Equals(Type.BUG) || + cible.getType().Equals(Type.GRASS)) { + damage /= 2; + } + if(cible.getType().Equals(Type.ROCK) || + cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.POISON) || + cible.getType().Equals(Type.ELECTRIC)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 4); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if(cible.getType().Equals(Type.FLYING)) { + damage = 0; + } + if(damage > 0) { + if(cible.getType().Equals(Type.DRAGON) || + cible.getType().Equals(Type.GRASS) || + cible.getType().Equals(Type.ELECTRIC)) { + damage /= 2; + } + if(cible.getType().Equals(Type.FLYING) || + cible.getType().Equals(Type.WATER)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/Types/PokemonIce.cs b/projet/Types/PokemonIce.cs new file mode 100644 index 0000000..09edd92 --- /dev/null +++ b/projet/Types/PokemonIce.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonIce : Pokemon { + + public PokemonIce(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(85); + this.setType(Type.ICE); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 2); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(damage > 0) { + if(cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.WATER) || + cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.ICE)) { + damage /= 2; + } + if(cible.getType().Equals(Type.DRAGON) || + cible.getType().Equals(Type.GRASS) || + cible.getType().Equals(Type.GROUND) || + cible.getType().Equals(Type.FLYING)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 3); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if (damage > 0) { + if (cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.WATER) || + cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.ICE)) { + damage /= 2; + } + if (cible.getType().Equals(Type.DRAGON) || + cible.getType().Equals(Type.GRASS) || + cible.getType().Equals(Type.GROUND) || + cible.getType().Equals(Type.FLYING)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/PokemonNormal.cs b/projet/Types/PokemonNormal.cs similarity index 100% rename from projet/PokemonNormal.cs rename to projet/Types/PokemonNormal.cs diff --git a/projet/Types/PokemonPoison.cs b/projet/Types/PokemonPoison.cs new file mode 100644 index 0000000..fb92863 --- /dev/null +++ b/projet/Types/PokemonPoison.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonPoison : Pokemon { + + public PokemonPoison(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(110); + this.setType(Type.POISON); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 2); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(cible.getType().Equals(Type.STEEL)) { + damage = 0; + } + if(damage > 0) { + if(cible.getType().Equals(Type.POISON) || + cible.getType().Equals(Type.ROCK) || + cible.getType().Equals(Type.GROUND) || + cible.getType().Equals(Type.GHOST)) { + damage /= 2; + } + if(cible.getType().Equals(Type.FAIRY) || + cible.getType().Equals(Type.GRASS)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 2); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if (cible.getType().Equals(Type.STEEL)) { + damage = 0; + } + if (damage > 0) { + if (cible.getType().Equals(Type.POISON) || + cible.getType().Equals(Type.ROCK) || + cible.getType().Equals(Type.GROUND) || + cible.getType().Equals(Type.GHOST)) { + damage /= 2; + } + if (cible.getType().Equals(Type.FAIRY) || + cible.getType().Equals(Type.GRASS)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/Types/PokemonPsychic.cs b/projet/Types/PokemonPsychic.cs new file mode 100644 index 0000000..fc3ce42 --- /dev/null +++ b/projet/Types/PokemonPsychic.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonPsychic: Pokemon { + + public PokemonPsychic(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(80); + this.setType(Type.PSYCHIC); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 1); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(cible.getType().Equals(Type.DARK)) { + damage = 0; + } + if(damage > 0) { + if(cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.PSYCHIC)) { + damage /= 2; + } + if(cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.POISON)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 3); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if (cible.getType().Equals(Type.DARK)) { + damage = 0; + } + if (damage > 0) { + if (cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.PSYCHIC)) { + damage /= 2; + } + if (cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.POISON)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/Types/PokemonRock.cs b/projet/Types/PokemonRock.cs new file mode 100644 index 0000000..924b23a --- /dev/null +++ b/projet/Types/PokemonRock.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonRock : Pokemon { + + public PokemonRock(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(105); + this.setType(Type.ROCK); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 4); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(damage > 0) { + if(cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.GROUND)) { + damage /= 2; + } + if(cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.ICE) || + cible.getType().Equals(Type.BUG)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 2); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if(damage > 0) { + if(cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.FIGHTING) || + cible.getType().Equals(Type.GROUND)) { + damage /= 2; + } + if(cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.ICE) || + cible.getType().Equals(Type.BUG)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/Types/PokemonSteel.cs b/projet/Types/PokemonSteel.cs new file mode 100644 index 0000000..77ae47a --- /dev/null +++ b/projet/Types/PokemonSteel.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Programmation_objet_TLESIO21.projet { + public class PokemonSteel : Pokemon { + + public PokemonSteel(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) { + base.setPC(105); + this.setType(Type.STEEL); + } + + public override void PhysAttack(Pokemon cible) { + this.setPC(this.getPC() - 3); + int damage = cible.getDEFPhys() - this.getATKPhys(); + if(damage > 0) { + if(cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.WATER) || + cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.ELECTRIC)) { + damage /= 2; + } + if(cible.getType().Equals(Type.FAIRY) || + cible.getType().Equals(Type.ICE) || + cible.getType().Equals(Type.ROCK)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + + public override void SpeAttack(Pokemon cible) { + this.setPC(this.getPC() - 2); + int damage = cible.getDEFSpe() - this.getATKSpe(); + if(damage > 0) { + if (cible.getType().Equals(Type.STEEL) || + cible.getType().Equals(Type.WATER) || + cible.getType().Equals(Type.FIRE) || + cible.getType().Equals(Type.ELECTRIC)) { + damage /= 2; + } + if (cible.getType().Equals(Type.FAIRY) || + cible.getType().Equals(Type.ICE) || + cible.getType().Equals(Type.ROCK)) { + damage *= 2; + } + cible.getDamage(damage); + } + } + } +} diff --git a/projet/PokemonWater.cs b/projet/Types/PokemonWater.cs similarity index 100% rename from projet/PokemonWater.cs rename to projet/Types/PokemonWater.cs