Merge pull request #4873 from spjspj/master

Remove plane from old player and add in new one
This commit is contained in:
spjspj 2018-04-27 13:26:20 +10:00 committed by GitHub
commit 26bc78dc8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2565,14 +2565,34 @@ public abstract class GameImpl implements Game, Serializable {
}
}
//Remove all emblems the player controls
//Remove all emblems/plane the player controls
boolean addPlaneAgain = false;
for (Iterator<CommandObject> it = this.getState().getCommand().iterator(); it.hasNext();) {
CommandObject obj = it.next();
if ((obj instanceof Emblem || obj instanceof Plane) && obj.getControllerId().equals(playerId)) {
((Emblem) obj).discardEffects();// This may not be the best fix but it works
if (obj instanceof Emblem) {
((Emblem) obj).discardEffects();// This may not be the best fix but it works
}
if (obj instanceof Plane) {
((Plane) obj).discardEffects();
// Readd a new one
addPlaneAgain = true;
}
it.remove();
}
}
if (addPlaneAgain) {
boolean addedAgain = false;
for (Player aplayer : state.getPlayers().values()) {
if (!aplayer.hasLeft() && !addedAgain) {
addedAgain = true;
Plane plane = Plane.getRandomPlane();
plane.setControllerId(aplayer.getId());
addPlane(plane, null, aplayer.getId());
}
}
}
Iterator<Entry<UUID, Card>> it = gameCards.entrySet().iterator();