You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.8 KiB

class Equipe {
int id, score, tour;
float radius;
float posX, posY;
Pion pion;
Equipe(int id) {
this.id = id;
this.score = 0;
this.tour = 0;
// générer un pion pour l'équipe
this.pion = new Pion(this.id);
// récupérer les valeurs de positionnement initial du pion
this.posX = this.pion.posX;
this.posY = this.pion.posY;
this.radius = this.pion.radius;
// afficher l'emplacement de l'équipe
this.update();
}
void update() {
// affichage de l'emplacement d'équipe, qui restera toujours fixe
color bgColor = color(255, 255, 255, 120);
color textColor = color(0,0,0);
fill(bgColor);
stroke(bgColor);
strokeWeight(0.5);
circle(this.posX,this.posY,radius);
fill(textColor);
float textSize = this.radius/4*3;
textSize(textSize);
float pos_x = this.id<9? this.posX-radius/5: this.posX-radius/3;
text(this.id+1, pos_x, this.posY+radius/5);
// affichage des tours
if (this.tour>0) {
color tourColor = color(255, 255, 255, 200);
fill(tourColor);
textSize(textSize);
float pos_y = this.posY+radius/5+30;
if (this.tour>=10) pos_x = pos_x - 6;
text(this.tour, pos_x, pos_y);
}
// mise à jour du pion
this.pion.draw();
}
void setScore(int score) {
if (this.score==score) return;
int oldScore = this.score;
//this.incTour();
println("Equipe", this.id+1, "setScore from", oldScore, "to", score);
this.score = score;
this.update();
Scoreboard.applyScore(this.id, this.score, this.tour);
drawAround(oldScore);
drawAround(this.score);
}
void incTour() {
this.tour++;
}
void decTour() {
if (this.tour==0) return;
this.tour--;
}
void setTour(int tour) {
this.tour = tour;
}
}