2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.habbohotel.games;
|
|
|
|
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
|
|
|
import gnu.trove.set.hash.THashSet;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class GameTeam {
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
public final GameTeamColors teamColor;
|
2019-05-26 20:14:53 +02:00
|
|
|
private final THashSet<GamePlayer> members;
|
2018-07-06 15:30:00 +02:00
|
|
|
private int teamScore;
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public GameTeam(GameTeamColors teamColor) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.teamColor = teamColor;
|
|
|
|
|
2018-09-28 21:25:00 +02:00
|
|
|
this.members = new THashSet<>();
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void initialise() {
|
|
|
|
for (GamePlayer player : this.members) {
|
2018-07-06 15:30:00 +02:00
|
|
|
player.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.teamScore = 0;
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void reset() {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.members.clear();
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void addTeamScore(int teamScore) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.teamScore += teamScore;
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getTeamScore() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.teamScore;
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public synchronized int getTotalScore() {
|
2018-07-06 15:30:00 +02:00
|
|
|
int score = this.teamScore;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
for (GamePlayer player : this.members) {
|
2018-07-06 15:30:00 +02:00
|
|
|
score += player.getScore();
|
|
|
|
}
|
|
|
|
|
|
|
|
return score;
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void addMember(GamePlayer gamePlayer) {
|
|
|
|
synchronized (this.members) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.members.add(gamePlayer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void removeMember(GamePlayer gamePlayer) {
|
|
|
|
synchronized (this.members) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.members.remove(gamePlayer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public THashSet<GamePlayer> getMembers() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.members;
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isMember(Habbo habbo) {
|
|
|
|
for (GamePlayer p : this.members) {
|
|
|
|
if (p.getHabbo().equals(habbo)) {
|
2018-07-06 15:30:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-08 23:32:00 +02:00
|
|
|
|
2018-07-06 15:30:00 +02:00
|
|
|
@Deprecated
|
2019-05-26 20:14:53 +02:00
|
|
|
public GamePlayer getPlayerForHabbo(Habbo habbo) {
|
|
|
|
for (GamePlayer p : this.members) {
|
|
|
|
if (p.getHabbo().equals(habbo)) {
|
2018-07-06 15:30:00 +02:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|