mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Fixed to the mana pool handling.
This commit is contained in:
parent
46e63861ec
commit
763023b550
5 changed files with 14 additions and 8 deletions
|
@ -97,7 +97,7 @@ class ManaShortEffect extends OneShotEffect {
|
|||
land.tap(game);
|
||||
}
|
||||
|
||||
targetPlayer.getManaPool().emptyPool();
|
||||
targetPlayer.getManaPool().emptyPool(game);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ class PowerSinkCounterUnlessPaysEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
// ...and empties his or her mana pool
|
||||
player.getManaPool().emptyPool();
|
||||
player.getManaPool().emptyPool(game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1169,11 +1169,9 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void applyEffects() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue