2022-10-15 18:39:27 +02:00
|
|
|
|
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 Nom;
|
|
|
|
|
private List<Pokemon> Team;
|
|
|
|
|
private int currentPokemonIndex;
|
|
|
|
|
|
|
|
|
|
public Player(string nom) {
|
|
|
|
|
this.Nom = nom;
|
|
|
|
|
this.Team = new List<Pokemon>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void choosePokemon(Pokemon pkm) {
|
|
|
|
|
this.Team.Add(pkm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getNom() {
|
|
|
|
|
return this.Nom;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Pokemon> getTeam() {
|
|
|
|
|
return this.Team;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCurrentPokemonIndex(int i) {
|
|
|
|
|
this.currentPokemonIndex = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Pokemon getCurrentPokemon() {
|
|
|
|
|
return this.getTeam()[currentPokemonIndex];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool canStillFight() {
|
|
|
|
|
int pkmCount = this.Team.Count;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(Pokemon pkm in Team) {
|
|
|
|
|
if(!pkm.isAlive()) {
|
|
|
|
|
pkmCount--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pkmCount == 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-13 22:03:05 +02:00
|
|
|
|
public override string ToString() {
|
2022-10-15 18:39:27 +02:00
|
|
|
|
String sb = "";
|
|
|
|
|
sb += this.Nom + " a pour pokémons : ";
|
|
|
|
|
foreach (Pokemon p in this.Team) {
|
|
|
|
|
sb += p.getName() + ". ";
|
|
|
|
|
}
|
|
|
|
|
return sb;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|