* Fixed to the mana pool handling.

This commit is contained in:
LevelX2 2014-10-20 21:26:18 +02:00
parent 46e63861ec
commit 763023b550
5 changed files with 14 additions and 8 deletions

View file

@ -97,7 +97,7 @@ class ManaShortEffect extends OneShotEffect {
land.tap(game);
}
targetPlayer.getManaPool().emptyPool();
targetPlayer.getManaPool().emptyPool(game);
return true;
}

View file

@ -126,7 +126,7 @@ class PowerSinkCounterUnlessPaysEffect extends OneShotEffect {
}
// ...and empties his or her mana pool
player.getManaPool().emptyPool();
player.getManaPool().emptyPool(game);
}
return true;
}

View file

@ -1169,9 +1169,7 @@ public abstract class GameImpl implements Game, Serializable {
@Override
public void emptyManaPools() {
for (Player player: getPlayers().values()) {
if (!replaceEvent(new GameEvent(GameEvent.EventType.EMPTY_MANA_POOL, player.getId(), null, player.getId()))) {
player.getManaPool().emptyPool(this);
}
player.getManaPool().emptyPool(this);
}
}

View file

@ -34,6 +34,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.ConditionalMana;
import mage.Mana;
import mage.abilities.Ability;
@ -54,6 +55,8 @@ import mage.game.events.ManaEvent;
*/
public class ManaPool implements Serializable {
private final UUID playerId;
private final List<ManaPoolItem> manaItems = new ArrayList<>();
private boolean autoPayment; // auto payment from mana pool: true - mode is active
@ -61,12 +64,14 @@ public class ManaPool implements Serializable {
private final Set<ManaType> doNotEmptyManaTypes = new HashSet<>();
public ManaPool() {
public ManaPool(UUID playerId) {
this.playerId = playerId;
autoPayment = true;
unlockedManaType = null;
}
public ManaPool(final ManaPool pool) {
this.playerId = pool.playerId;
for (ManaPoolItem item: pool.manaItems) {
manaItems.add(item.copy());
}
@ -179,7 +184,7 @@ public class ManaPool implements Serializable {
for (ManaType manaType : ManaType.values()) {
if (item.get(manaType) > 0 && !doNotEmptyManaTypes.contains(manaType)) {
if (!item.getDuration().equals(Duration.EndOfTurn) || game.getPhase().getType().equals(TurnPhase.END)) {
if (game.replaceEvent(new GameEvent(GameEvent.EventType.EMPTY_MANA_POOL, null, null, null))) {
if (game.replaceEvent(new GameEvent(GameEvent.EventType.EMPTY_MANA_POOL, playerId, null, playerId))) {
int amount = item.get(manaType);
item.clear(manaType);
item.add(ManaType.COLORLESS, amount);
@ -190,6 +195,9 @@ public class ManaPool implements Serializable {
}
}
}
if (item.count() == 0) {
it.remove();
}
}
return total;
}

View file

@ -226,7 +226,7 @@ public abstract class PlayerImpl implements Player, Serializable {
graveyard = new CardsImpl(Zone.GRAVEYARD);
abilities = new AbilitiesImpl<>();
counters = new Counters();
manaPool = new ManaPool();
manaPool = new ManaPool(playerId);
library = new Library(playerId);
sideboard = new CardsImpl(Zone.OUTSIDE);
}