mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
* Drain Power - Improved conditonal mana handling.
This commit is contained in:
parent
940fe603c6
commit
0ceb5fc88f
4 changed files with 35 additions and 70 deletions
|
|
@ -32,7 +32,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
|
|
@ -42,11 +41,13 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.filter.predicate.permanent.PermanentInListPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.ManaPoolItem;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.TargetPlayer;
|
||||
|
|
@ -80,7 +81,7 @@ class DrainPowerEffect extends OneShotEffect {
|
|||
private static final FilterLandPermanent filter = new FilterLandPermanent();
|
||||
|
||||
public DrainPowerEffect() {
|
||||
super(Outcome.Tap);
|
||||
super(Outcome.PutManaInPool);
|
||||
this.staticText = "Target player activates a mana ability of each land they control. Then that player loses all unspent mana and you add the mana lost this way";
|
||||
}
|
||||
|
||||
|
|
@ -132,8 +133,8 @@ class DrainPowerEffect extends OneShotEffect {
|
|||
break;
|
||||
}
|
||||
|
||||
List<Permanent> permList = new ArrayList<Permanent>(manaAbilitiesMap.keySet());
|
||||
Permanent permanent = null;
|
||||
List<Permanent> permList = new ArrayList<>(manaAbilitiesMap.keySet());
|
||||
Permanent permanent;
|
||||
if (permList.size() > 1 || target != null) {
|
||||
FilterLandPermanent filter2 = new FilterLandPermanent("land you control to tap for mana (remaining: " + permList.size() + ')');
|
||||
filter2.add(new PermanentInListPredicate(permList));
|
||||
|
|
@ -168,9 +169,13 @@ class DrainPowerEffect extends OneShotEffect {
|
|||
// This empties the former player’s mana pool and causes the mana emptied this way to be put into the latter player’s mana pool. Which permanents, spells, and/or
|
||||
// abilities produced that mana are unchanged, as are any restrictions or additional effects associated with any of that mana.
|
||||
// TODO: retain riders associated with drained mana
|
||||
Mana mana = targetPlayer.getManaPool().getMana();
|
||||
List<ManaPoolItem> manaItems = targetPlayer.getManaPool().getManaItems();
|
||||
targetPlayer.getManaPool().emptyPool(game);
|
||||
controller.getManaPool().addMana(mana, game, source);
|
||||
for (ManaPoolItem manaPoolItem : manaItems) {
|
||||
controller.getManaPool().addMana(
|
||||
manaPoolItem.isConditional() ? manaPoolItem.getConditionalMana() : manaPoolItem.getMana(),
|
||||
game, source, Duration.EndOfTurn.equals(manaPoolItem.getDuration()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -90,56 +90,6 @@ public class TorgaarFamineIncarnate extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
//class TorgaarFamineIncarnateSacrificeCost extends CostImpl {
|
||||
//
|
||||
// int numbSacrificed = 0;
|
||||
//
|
||||
// public TorgaarFamineIncarnateSacrificeCost() {
|
||||
// this.text = "sacrifice any number of creatures";
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public TorgaarFamineIncarnateSacrificeCost(final TorgaarFamineIncarnateSacrificeCost cost) {
|
||||
// super(cost);
|
||||
// this.numbSacrificed = cost.numbSacrificed;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
// TargetControlledCreaturePermanent target
|
||||
// = new TargetControlledCreaturePermanent(0, Integer.MAX_VALUE,
|
||||
// new FilterControlledCreaturePermanent("select any number of creatures to sacrifice. "
|
||||
// + "This spell costs {2} less to cast for each creature sacrificed this way"), true);
|
||||
// Player player = game.getPlayer(controllerId);
|
||||
// if (player != null) {
|
||||
// player.chooseTarget(Outcome.Benefit, target, ability, game);
|
||||
// for (UUID creatureId : target.getTargets()) {
|
||||
// Permanent creature = game.getPermanent(creatureId);
|
||||
// if (creature != null) {
|
||||
// if (creature.sacrifice(sourceId, game)) {
|
||||
// numbSacrificed++;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// this.paid = true;
|
||||
// return paid;
|
||||
// }
|
||||
//
|
||||
// public int getNumbSacrificed() {
|
||||
// return numbSacrificed;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public TorgaarFamineIncarnateSacrificeCost copy() {
|
||||
// return new TorgaarFamineIncarnateSacrificeCost(this);
|
||||
// }
|
||||
//}
|
||||
class TorgaarFamineIncarnateEffect extends OneShotEffect {
|
||||
|
||||
public TorgaarFamineIncarnateEffect() {
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ public class AddConditionalManaOfAnyColorEffect extends ManaEffect {
|
|||
staticText = "Add "
|
||||
+ (amount instanceof StaticValue ? (CardUtil.numberToText(((StaticValue) amount).toString())) : "")
|
||||
+ " mana "
|
||||
+ (oneChoice ? "of any"
|
||||
+ (amount instanceof StaticValue && (((StaticValue) amount).toString()).equals("1") ? "" : " one")
|
||||
+ " color" : "in any combination of colors")
|
||||
+ (oneChoice || (amount instanceof StaticValue && (((StaticValue) amount).toString()).equals("1"))
|
||||
? "of any" + (amount instanceof StaticValue && (((StaticValue) amount).toString()).equals("1") ? "" : " one") + " color"
|
||||
: "in any combination of colors")
|
||||
+ ". " + manaBuilder.getRule();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -395,7 +395,8 @@ public class ManaPool implements Serializable {
|
|||
Mana mana = manaToAdd.copy();
|
||||
if (!game.replaceEvent(new ManaEvent(EventType.ADD_MANA, source.getId(), source.getSourceId(), playerId, mana))) {
|
||||
if (mana instanceof ConditionalMana) {
|
||||
ManaPoolItem item = new ManaPoolItem((ConditionalMana) mana, source.getSourceObject(game), source.getOriginalId());
|
||||
ManaPoolItem item = new ManaPoolItem((ConditionalMana) mana, source.getSourceObject(game),
|
||||
((ConditionalMana) mana).getManaProducerOriginalId() != null ? ((ConditionalMana) mana).getManaProducerOriginalId() : source.getOriginalId());
|
||||
if (emptyOnTurnsEnd) {
|
||||
item.setDuration(Duration.EndOfTurn);
|
||||
}
|
||||
|
|
@ -505,4 +506,13 @@ public class ManaPool implements Serializable {
|
|||
public boolean isEmpty() {
|
||||
return count() == 0;
|
||||
}
|
||||
|
||||
public List<ManaPoolItem> getManaItems() {
|
||||
List<ManaPoolItem> itemsCopy = new ArrayList<>();
|
||||
for (ManaPoolItem manaItem : manaItems) {
|
||||
itemsCopy.add(manaItem.copy());
|
||||
}
|
||||
return itemsCopy;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue