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);
|
land.tap(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
targetPlayer.getManaPool().emptyPool();
|
targetPlayer.getManaPool().emptyPool(game);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ class PowerSinkCounterUnlessPaysEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...and empties his or her mana pool
|
// ...and empties his or her mana pool
|
||||||
player.getManaPool().emptyPool();
|
player.getManaPool().emptyPool(game);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1169,9 +1169,7 @@ public abstract class GameImpl implements Game, Serializable {
|
||||||
@Override
|
@Override
|
||||||
public void emptyManaPools() {
|
public void emptyManaPools() {
|
||||||
for (Player player: getPlayers().values()) {
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import mage.ConditionalMana;
|
import mage.ConditionalMana;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -54,6 +55,8 @@ import mage.game.events.ManaEvent;
|
||||||
*/
|
*/
|
||||||
public class ManaPool implements Serializable {
|
public class ManaPool implements Serializable {
|
||||||
|
|
||||||
|
private final UUID playerId;
|
||||||
|
|
||||||
private final List<ManaPoolItem> manaItems = new ArrayList<>();
|
private final List<ManaPoolItem> manaItems = new ArrayList<>();
|
||||||
|
|
||||||
private boolean autoPayment; // auto payment from mana pool: true - mode is active
|
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<>();
|
private final Set<ManaType> doNotEmptyManaTypes = new HashSet<>();
|
||||||
|
|
||||||
public ManaPool() {
|
public ManaPool(UUID playerId) {
|
||||||
|
this.playerId = playerId;
|
||||||
autoPayment = true;
|
autoPayment = true;
|
||||||
unlockedManaType = null;
|
unlockedManaType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManaPool(final ManaPool pool) {
|
public ManaPool(final ManaPool pool) {
|
||||||
|
this.playerId = pool.playerId;
|
||||||
for (ManaPoolItem item: pool.manaItems) {
|
for (ManaPoolItem item: pool.manaItems) {
|
||||||
manaItems.add(item.copy());
|
manaItems.add(item.copy());
|
||||||
}
|
}
|
||||||
|
@ -179,7 +184,7 @@ public class ManaPool implements Serializable {
|
||||||
for (ManaType manaType : ManaType.values()) {
|
for (ManaType manaType : ManaType.values()) {
|
||||||
if (item.get(manaType) > 0 && !doNotEmptyManaTypes.contains(manaType)) {
|
if (item.get(manaType) > 0 && !doNotEmptyManaTypes.contains(manaType)) {
|
||||||
if (!item.getDuration().equals(Duration.EndOfTurn) || game.getPhase().getType().equals(TurnPhase.END)) {
|
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);
|
int amount = item.get(manaType);
|
||||||
item.clear(manaType);
|
item.clear(manaType);
|
||||||
item.add(ManaType.COLORLESS, amount);
|
item.add(ManaType.COLORLESS, amount);
|
||||||
|
@ -190,6 +195,9 @@ public class ManaPool implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (item.count() == 0) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
graveyard = new CardsImpl(Zone.GRAVEYARD);
|
graveyard = new CardsImpl(Zone.GRAVEYARD);
|
||||||
abilities = new AbilitiesImpl<>();
|
abilities = new AbilitiesImpl<>();
|
||||||
counters = new Counters();
|
counters = new Counters();
|
||||||
manaPool = new ManaPool();
|
manaPool = new ManaPool(playerId);
|
||||||
library = new Library(playerId);
|
library = new Library(playerId);
|
||||||
sideboard = new CardsImpl(Zone.OUTSIDE);
|
sideboard = new CardsImpl(Zone.OUTSIDE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue