Fixed a bug that players were not removed properly from matches or tournaments they left before the match or tournament was started.

This commit is contained in:
LevelX2 2013-04-06 02:09:04 +02:00
parent 1df4946135
commit a070c5a8e1
4 changed files with 27 additions and 2 deletions

View file

@ -50,7 +50,10 @@ public interface Match {
boolean isMatchOver();
List<MatchPlayer> getPlayers();
MatchPlayer getPlayer(UUID playerId);
void addPlayer(Player player, Deck deck);
boolean leave(UUID playerId);
void submitDeck(UUID playerId, Deck deck);
void updateDeck(UUID playerId, Deck deck);
void startMatch() throws GameException;

View file

@ -77,6 +77,15 @@ public abstract class MatchImpl implements Match {
players.add(mPlayer);
}
@Override
public boolean leave(UUID playerId) {
MatchPlayer mPlayer = getPlayer(playerId);
if (mPlayer != null) {
return players.remove(mPlayer);
}
return false;
}
@Override
public void startMatch() throws GameException {

View file

@ -102,7 +102,9 @@ public abstract class TournamentImpl implements Tournament {
@Override
public void leave(UUID playerId) {
//TODO: implement this
if (players.containsKey(playerId)) {
players.remove(playerId);
}
}
@Override