mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Merge pull request #4873 from spjspj/master
Remove plane from old player and add in new one
This commit is contained in:
commit
26bc78dc8c
1 changed files with 22 additions and 2 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue