début projet pokemon

This commit is contained in:
2022-10-13 13:53:26 +02:00
parent 6c800f4e6f
commit a94c17f1a0
15 changed files with 1710 additions and 7 deletions

146
projet/GameManager.cs Normal file
View File

@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.projet {
public class GameManager {
public static void AlterPokemonStat(String stat, double value, Pokemon p) {
switch(stat) {
case "PV":
p.setPV((int)Math.Floor(p.getPV() * value));
break;
case "ATKPhys":
p.setATKPhys(((int)Math.Floor(p.getATKPhys() * value)));
break;
case "ATKSpe":
p.setATKSpe(((int)Math.Floor(p.getATKSpe() * value)));
break;
case "DEFPhys":
p.setDefPhys(((int)Math.Floor(p.getDEFPhys() * value)));
break;
case "DEFSpe":
p.setDefSpe(((int)Math.Floor(p.getDEFSpe() * value)));
break;
case "Speed":
p.setSpeed(((int)Math.Floor(p.getSpeed() * value)));
break;
default:
break;
}
}
public void ApplyNatureEffect(Enum nature, Pokemon p) {
switch(nature) { //malus
case Nature.BOLD:
case Nature.CALM:
case Nature.MODEST:
case Nature.TIMID:
AlterPokemonStat("ATKPhys", 0.9, p);
break;
case Nature.MILD:
case Nature.GENTLE:
case Nature.HASTY:
case Nature.LONELY:
AlterPokemonStat("DEFPhys", 0.9, p);
break;
case Nature.JOLLY:
case Nature.IMPISH:
case Nature.CAREFUL:
case Nature.ADAMANT:
AlterPokemonStat("ATKSpe", 0.9, p);
break;
case Nature.RASH:
case Nature.LAX:
case Nature.NAUGHTY:
case Nature.NAIVE:
AlterPokemonStat("DEFSpe", 0.9, p);
break;
case Nature.BRAVE:
case Nature.QUIET:
case Nature.SASSY:
case Nature.RELAXED:
AlterPokemonStat("Speed", 0.9, p);
break;
default:
break;
}
switch(nature) { //bonus
case Nature.BRAVE:
case Nature.NAUGHTY:
case Nature.ADAMANT:
case Nature.LONELY:
AlterPokemonStat("ATKPhys", 1.1, p);
break;
case Nature.BOLD:
case Nature.LAX:
case Nature.IMPISH:
case Nature.RELAXED:
AlterPokemonStat("DEFPhys", 1.1, p);
break;
case Nature.QUIET:
case Nature.MILD:
case Nature.RASH:
case Nature.MODEST:
AlterPokemonStat("ATKSpe", 1.1, p);
break;
case Nature.CALM:
case Nature.GENTLE:
case Nature.SASSY:
case Nature.CAREFUL:
AlterPokemonStat("DEFSpe", 1.1, p);
break;
case Nature.JOLLY:
case Nature.NAIVE:
case Nature.HASTY:
case Nature.TIMID:
AlterPokemonStat("Speed", 1.1, p);
break;
default:
break;
}
}
public void ApplyPlayerEffect(String playerName, Pokemon p) {
switch(playerName) {
case "Applejack":
AlterPokemonStat("PV", 0.95, p);
break;
case "Rainbow Dash":
AlterPokemonStat("ATKPhys", 1.03, p);
break;
case "Twilight Sparkle":
AlterPokemonStat("Speed", 1.07, p);
break;
case "Pinkie Pie":
AlterPokemonStat("DEFPhys", 1.04, p);
break;
case "Fluttershy":
AlterPokemonStat("DEFPhys", 0.96, p);
break;
case "Izzy Moonbow":
AlterPokemonStat("PV", 1.05, p);
AlterPokemonStat("Speed", 0.95, p);
break;
case "Zipp Storm":
AlterPokemonStat("PV", 0.95, p);
AlterPokemonStat("Speed", 1.05, p);
break;
case "Sunny Starscout":
AlterPokemonStat("ATKSpe", 1.03, p);
break;
case "Derpy Hooves":
AlterPokemonStat("PV", 0.95, p);
break;
default:
break;
}
}
}
}

35
projet/Nature.cs Normal file
View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.projet {
public enum Nature {
BOLD,
QUIRKY,
BRAVE,
CALM,
QUIET,
DOCILE,
MILD,
RASH,
GENTLE,
HARDY,
JOLLY,
LAX,
IMPISH,
SASSY,
NAUGHTY,
MODEST,
NAIVE,
HASTY,
CAREFUL,
BASHFUL,
RELAXED,
ADAMANT,
SERIOUS,
LONELY,
TIMID
}
}

25
projet/Player.cs Normal file
View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.projet {
public class Player {
private string Name;
private string Description;
private int level;
private List<Pokemon> PC;
private List<Pokemon> Team;
#pragma warning disable CS8618 // Un champ non-nullable doit contenir une valeur non-null lors de la fermeture du constructeur. Envisagez de déclarer le champ comme nullable.
public Player(string Name, string Description, List<Pokemon> PC) {
this.Name = Name;
this.Description = Description;
this.PC = PC;
this.level = PC.Count;
this.Team = new List<Pokemon>(6);
}
}
}

124
projet/Pokemon.cs Normal file
View File

@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.projet {
public abstract class Pokemon {
private readonly string Name;
private Type Type;
private Nature Nature;
private int PV;
private int PC;
private int ATKPhys;
private int ATKSpe;
private int DEFPhys;
private int DEFSpe;
private int Speed;
public Pokemon(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) {
this.Name = Name;
this.PV = PV;
this.ATKPhys = ATKPhys;
this.ATKSpe = ATKSpe;
this.DEFPhys = DEFPhys;
this.DEFSpe = DEFSpe;
this.Speed = Speed;
}
public virtual void PhysAttack(Pokemon cible) {
}
public virtual void SpeAttack(Pokemon cible) {
}
public void getDamage(int d) {
this.PV -= d;
}
public Boolean hasEnoughtPC() {
return (this.getPC() > 0);
}
public Boolean isAlive() {
return (this.getPV() > 0);
}
public override string ToString() {
return this.getName() + " - PV : " + getPV() + ", PC = " + getPC();
}
public void setPV(int pv) {
this.PV = pv;
}
internal void setPC(int pc) {
this.PC = pc;
}
internal void setType(Type t) {
this.Type = t;
}
public void setATKPhys(int atk) {
this.ATKPhys = atk;
}
public void setATKSpe(int atk) {
this.ATKSpe = atk;
}
public void setDefPhys(int def) {
this.DEFPhys = def;
}
public void setDefSpe(int def) {
this.DEFSpe = def;
}
public void setSpeed(int speed) {
this.Speed = speed;
}
public String getName() {
return this.Name;
}
public Type getType() {
return this.Type;
}
public Nature GetNature() {
return this.Nature;
}
public int getPV() {
return this.PV;
}
public int getPC() {
return this.PC;
}
public int getATKPhys() {
return this.ATKPhys;
}
public int getATKSpe() {
return this.ATKSpe;
}
public int getDEFPhys() {
return this.DEFPhys;
}
public int getDEFSpe() {
return this.DEFSpe;
}
public int getSpeed() {
return this.Speed;
}
}
}

55
projet/PokemonElectric.cs Normal file
View File

@ -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 PokemonElectric : Pokemon {
public PokemonElectric(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.ELECTRIC);
}
public override void PhysAttack(Pokemon cible) {
this.setPC(this.getPC() - 1);
int damage = cible.getDEFPhys() - this.getATKPhys();
if(cible.getType().Equals(Type.GROUND)) {
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.STEEL) ||
cible.getType().Equals(Type.WATER)) {
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.GROUND)) {
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);
}
}
}
}

54
projet/PokemonFire.cs Normal file
View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.projet {
public class PokemonFire : Pokemon {
public PokemonFire(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) {
base.setPC(100);
this.setType(Type.FIRE);
}
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.DRAGON) ||
cible.getType().Equals(Type.WATER) ||
cible.getType().Equals(Type.FIRE) ||
cible.getType().Equals(Type.ROCK)) {
damage /= 2;
}
if(cible.getType().Equals(Type.GRASS) ||
cible.getType().Equals(Type.BUG) ||
cible.getType().Equals(Type.ICE) ||
cible.getType().Equals(Type.STEEL)) {
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.DRAGON) ||
cible.getType().Equals(Type.WATER) ||
cible.getType().Equals(Type.FIRE) ||
cible.getType().Equals(Type.ROCK)) {
damage /= 2;
}
if(cible.getType().Equals(Type.GRASS) ||
cible.getType().Equals(Type.BUG) ||
cible.getType().Equals(Type.ICE) ||
cible.getType().Equals(Type.STEEL)) {
damage *= 2;
}
cible.getDamage(damage);
}
}
}
}

58
projet/PokemonGrass.cs Normal file
View File

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.projet {
public class PokemonGrass : Pokemon {
public PokemonGrass(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.GRASS);
}
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.DRAGON) ||
cible.getType().Equals(Type.FIRE) ||
cible.getType().Equals(Type.BUG) ||
cible.getType().Equals(Type.GRASS) ||
cible.getType().Equals(Type.POISON) ||
cible.getType().Equals(Type.FLYING)) {
damage /= 2;
}
if(cible.getType().Equals(Type.WATER) ||
cible.getType().Equals(Type.ROCK) ||
cible.getType().Equals(Type.GROUND)) {
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.DRAGON) ||
cible.getType().Equals(Type.FIRE) ||
cible.getType().Equals(Type.BUG) ||
cible.getType().Equals(Type.GRASS) ||
cible.getType().Equals(Type.POISON) ||
cible.getType().Equals(Type.FLYING)) {
damage /= 2;
}
if(cible.getType().Equals(Type.WATER) ||
cible.getType().Equals(Type.ROCK) ||
cible.getType().Equals(Type.GROUND)) {
damage *= 2;
}
cible.getDamage(damage);
}
}
}
}

43
projet/PokemonNormal.cs Normal file
View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.projet {
public class PokemonNormal : Pokemon {
public PokemonNormal(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) {
base.setPC(90);
this.setType(Type.NORMAL);
}
public override void PhysAttack(Pokemon cible) {
this.setPC(this.getPC() - 2);
int damage = cible.getDEFPhys() - this.getATKPhys();
if(cible.getType().Equals(Type.GHOST)) {
damage = 0;
}
if(damage > 0) {
if(cible.getType().Equals(Type.STEEL) || 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.STEEL) || cible.getType().Equals(Type.ROCK)) {
damage /= 2;
}
cible.getDamage(damage);
}
}
}
}

50
projet/PokemonWater.cs Normal file
View File

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.projet {
public class PokemonWater : Pokemon {
public PokemonWater(string Name, int PV, int ATKPhys, int ATKSpe, int DEFPhys, int DEFSpe, int Speed) : base(Name, PV, ATKPhys, ATKSpe, DEFPhys, DEFSpe, Speed) {
base.setPC(90);
this.setType(Type.WATER);
}
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.DRAGON) ||
cible.getType().Equals(Type.WATER) ||
cible.getType().Equals(Type.GRASS)) {
damage /= 2;
}
if(cible.getType().Equals(Type.FIRE) ||
cible.getType().Equals(Type.ROCK) ||
cible.getType().Equals(Type.GROUND)) {
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.DRAGON) ||
cible.getType().Equals(Type.WATER) ||
cible.getType().Equals(Type.GRASS)) {
damage /= 2;
}
if(cible.getType().Equals(Type.FIRE) ||
cible.getType().Equals(Type.ROCK) ||
cible.getType().Equals(Type.GROUND)) {
damage *= 2;
}
cible.getDamage(damage);
}
}
}
}

28
projet/Type.cs Normal file
View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Programmation_objet_TLESIO21.projet {
public enum Type {
NORMAL,
GRASS,
FIRE,
WATER,
ELECTRIC,
FLYING,
BUG,
ROCK,
GROUND,
PSYCHIC,
POISON,
GHOST,
DARK,
STEEL,
COMBAT,
ICE,
DRAGON,
FAIRY
}
}