2022-10-15 18:39:27 +02:00

61 lines
1.5 KiB
C#

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;
}
public override string ToString() {
String sb = "";
sb += this.Nom + " a pour pokémons : ";
foreach (Pokemon p in this.Team) {
sb += p.getName() + ". ";
}
return sb;
}
}
}