mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
* Reworked TAPPED_FOR_MANA event handling to include the produced mana in the event.
This commit is contained in:
parent
c5bc99b8de
commit
d26c1000f2
17 changed files with 475 additions and 69 deletions
|
@ -54,8 +54,12 @@ import org.apache.log4j.Logger;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.abilities.effects.common.DynamicManaEffect;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ManaEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
|
@ -346,7 +350,16 @@ public abstract class AbilityImpl implements Ability {
|
|||
if (this.getAbilityType().equals(AbilityType.MANA)) {
|
||||
for (Cost cost: costs) {
|
||||
if (cost instanceof TapSourceCost) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.TAPPED_FOR_MANA, sourceId, sourceId, controllerId));
|
||||
Mana mana = null;
|
||||
Effect effect = getEffects().get(0);
|
||||
if (effect instanceof BasicManaEffect) {
|
||||
mana = ((BasicManaEffect)effect).getMana(game, this);
|
||||
} else if (effect instanceof DynamicManaEffect) {
|
||||
mana = ((DynamicManaEffect)effect).getMana(game, this);
|
||||
}
|
||||
if (mana != null) { // if mana == null the event has to be fires in the mana effect
|
||||
game.fireEvent(new ManaEvent(GameEvent.EventType.TAPPED_FOR_MANA, sourceId, sourceId, controllerId, mana));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ManaEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class TapForManaAllTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final FilterPermanent filter;
|
||||
private final SetTargetPointer setTargetPointer;
|
||||
|
||||
public TapForManaAllTriggeredAbility(Effect effect, FilterPermanent filter, SetTargetPointer setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
this.filter = filter;
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
public TapForManaAllTriggeredAbility(TapForManaAllTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.filter = ability.filter.copy();
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) {
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||
ManaEvent mEvent = (ManaEvent) event;
|
||||
for(Effect effect:getEffects()) {
|
||||
effect.setValue("mana", mEvent.getMana());
|
||||
}
|
||||
switch(setTargetPointer) {
|
||||
case PERMANENT:
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
|
||||
break;
|
||||
case PLAYER:
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getControllerId()));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TapForManaAllTriggeredAbility copy() {
|
||||
return new TapForManaAllTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever " + filter.getMessage() + " for mana, " + super.getRule();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.mana.TriggeredManaAbility;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import static mage.constants.SetTargetPointer.PERMANENT;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ManaEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class TapForManaAllTriggeredManaAbility extends TriggeredManaAbility {
|
||||
|
||||
private final FilterPermanent filter;
|
||||
private final SetTargetPointer setTargetPointer;
|
||||
|
||||
public TapForManaAllTriggeredManaAbility(ManaEffect effect, FilterPermanent filter, SetTargetPointer setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
this.filter = filter;
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
public TapForManaAllTriggeredManaAbility(TapForManaAllTriggeredManaAbility ability) {
|
||||
super(ability);
|
||||
this.filter = ability.filter.copy();
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA) {
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
|
||||
if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||
ManaEvent mEvent = (ManaEvent) event;
|
||||
for(Effect effect:getEffects()) {
|
||||
effect.setValue("mana", mEvent.getMana());
|
||||
}
|
||||
switch(setTargetPointer) {
|
||||
case PERMANENT:
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
|
||||
break;
|
||||
case PLAYER:
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getControllerId()));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TapForManaAllTriggeredManaAbility copy() {
|
||||
return new TapForManaAllTriggeredManaAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever " + filter.getMessage() + " for mana, " + super.getRule();
|
||||
}
|
||||
}
|
|
@ -44,9 +44,14 @@ public class AddConditionalColorlessManaEffect extends ManaEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
player.getManaPool().addMana(manaBuilder.setMana(Mana.ColorlessMana(amount), source, game).build(), game, source);
|
||||
player.getManaPool().addMana(getMana(game, source), game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return manaBuilder.setMana(Mana.ColorlessMana(amount), source, game).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,8 +88,16 @@ public class AddConditionalManaOfAnyColorEffect extends ManaEffect {
|
|||
player.getManaPool().addMana(mana, game, source);
|
||||
result = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
//TODO: TAP_FOR_MANA Event does not support currently to get an amount > 1 of conditional mana
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class AddManaAnyColorAttachedControllerEffect extends ManaEffect {
|
||||
|
||||
public AddManaAnyColorAttachedControllerEffect() {
|
||||
super();
|
||||
staticText = "its controller adds one mana of any color to his or her mana pool";
|
||||
}
|
||||
|
||||
public AddManaAnyColorAttachedControllerEffect(final AddManaAnyColorAttachedControllerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null) {
|
||||
Permanent land = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (land != null) {
|
||||
Player player = game.getPlayer(land.getControllerId());
|
||||
if (player != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
while (!player.choose(outcome, choice, game)) {
|
||||
if (!player.isInGame()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int amount = 1;
|
||||
Mana mana = null;
|
||||
if (choice.getColor().isBlack()) {
|
||||
mana = Mana.BlackMana(amount);
|
||||
} else if (choice.getColor().isBlue()) {
|
||||
mana = Mana.BlueMana(amount);
|
||||
} else if (choice.getColor().isRed()) {
|
||||
mana = Mana.RedMana(amount);
|
||||
} else if (choice.getColor().isGreen()) {
|
||||
mana = Mana.GreenMana(amount);
|
||||
} else if (choice.getColor().isWhite()) {
|
||||
mana = Mana.WhiteMana(amount);
|
||||
}
|
||||
if (mana != null) {
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
player.getManaPool().addMana(mana, game, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddManaAnyColorAttachedControllerEffect copy() {
|
||||
return new AddManaAnyColorAttachedControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -21,31 +21,35 @@ import mage.util.CardUtil;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ManaInAnyCombinationEffect extends ManaEffect {
|
||||
public class AddManaInAnyCombinationEffect extends ManaEffect {
|
||||
|
||||
private ArrayList<ColoredManaSymbol> manaSymbols = new ArrayList<>();
|
||||
private final DynamicValue amount;
|
||||
|
||||
public ManaInAnyCombinationEffect(int amount, ColoredManaSymbol... coloredManaSymbols) {
|
||||
public AddManaInAnyCombinationEffect(int amount) {
|
||||
this(new StaticValue(amount), ColoredManaSymbol.B, ColoredManaSymbol.U, ColoredManaSymbol.R, ColoredManaSymbol.W, ColoredManaSymbol.G);
|
||||
}
|
||||
|
||||
public AddManaInAnyCombinationEffect(int amount, ColoredManaSymbol... coloredManaSymbols) {
|
||||
this(new StaticValue(amount), coloredManaSymbols);
|
||||
}
|
||||
|
||||
public ManaInAnyCombinationEffect(DynamicValue amount, ColoredManaSymbol... coloredManaSymbols) {
|
||||
public AddManaInAnyCombinationEffect(DynamicValue amount, ColoredManaSymbol... coloredManaSymbols) {
|
||||
super();
|
||||
this.manaSymbols.addAll(Arrays.asList(coloredManaSymbols));
|
||||
this.amount = amount;
|
||||
this.staticText = setText();
|
||||
}
|
||||
|
||||
public ManaInAnyCombinationEffect(final ManaInAnyCombinationEffect effect) {
|
||||
public AddManaInAnyCombinationEffect(final AddManaInAnyCombinationEffect effect) {
|
||||
super(effect);
|
||||
this.manaSymbols = effect.manaSymbols;
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManaInAnyCombinationEffect copy() {
|
||||
return new ManaInAnyCombinationEffect(this);
|
||||
public AddManaInAnyCombinationEffect copy() {
|
||||
return new AddManaInAnyCombinationEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,23 +73,33 @@ public class ManaInAnyCombinationEffect extends ManaEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
player.getManaPool().addMana(mana, game, source);
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
player.getManaPool().addMana(mana, game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("Add ");
|
||||
sb.append(CardUtil.numberToText(amount.toString()));
|
||||
sb.append(" mana in any combination of ");
|
||||
int i = 0;
|
||||
for (ColoredManaSymbol coloredManaSymbol: manaSymbols) {
|
||||
i++;
|
||||
if (i > 1) {
|
||||
sb.append(" and/or ");
|
||||
if (manaSymbols.size() == 5) {
|
||||
sb.append("of colors");
|
||||
} else {
|
||||
int i = 0;
|
||||
for (ColoredManaSymbol coloredManaSymbol: manaSymbols) {
|
||||
i++;
|
||||
if (i > 1) {
|
||||
sb.append(" and/or ");
|
||||
}
|
||||
sb.append("{").append(coloredManaSymbol.toString()).append("}");
|
||||
}
|
||||
sb.append("{").append(coloredManaSymbol.toString()).append("}");
|
||||
}
|
||||
sb.append(" to your mana pool");
|
||||
return sb.toString();
|
|
@ -57,8 +57,9 @@ public class AddManaOfAnyColorTargetCanProduceEffect extends ManaEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(this.targetPointer.getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
if (controller != null && permanent != null) {
|
||||
Abilities<ManaAbility> mana = permanent.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
|
||||
Mana types = new Mana();
|
||||
for (ManaAbility ability : mana) {
|
||||
|
@ -67,7 +68,7 @@ public class AddManaOfAnyColorTargetCanProduceEffect extends ManaEffect {
|
|||
}
|
||||
}
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
choice.setMessage("Pick a mana color");
|
||||
choice.setMessage("Pick the type of mana to produce");
|
||||
if (types.getBlack() > 0) {
|
||||
choice.getChoices().add("Black");
|
||||
}
|
||||
|
@ -87,35 +88,37 @@ public class AddManaOfAnyColorTargetCanProduceEffect extends ManaEffect {
|
|||
choice.getChoices().add("Colorless");
|
||||
}
|
||||
if (choice.getChoices().size() > 0) {
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
if (choice.getChoices().size() == 1) {
|
||||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
} else {
|
||||
player.choose(outcome, choice, game);
|
||||
controller.choose(outcome, choice, game);
|
||||
}
|
||||
if (choice.getChoice() == null) {
|
||||
return false;
|
||||
}
|
||||
Mana newMana = new Mana();
|
||||
switch (choice.getChoice()) {
|
||||
case "Black":
|
||||
player.getManaPool().addMana(Mana.BlackMana, game, source);
|
||||
newMana.setBlack(1);
|
||||
return true;
|
||||
case "Blue":
|
||||
player.getManaPool().addMana(Mana.BlueMana, game, source);
|
||||
newMana.setBlue(1);
|
||||
return true;
|
||||
case "Red":
|
||||
player.getManaPool().addMana(Mana.RedMana, game, source);
|
||||
newMana.setRed(1);
|
||||
return true;
|
||||
case "Green":
|
||||
player.getManaPool().addMana(Mana.GreenMana, game, source);
|
||||
newMana.setGreen(1);
|
||||
return true;
|
||||
case "White":
|
||||
player.getManaPool().addMana(Mana.WhiteMana, game, source);
|
||||
newMana.setWhite(1);
|
||||
return true;
|
||||
case "Colorless":
|
||||
player.getManaPool().addMana(Mana.ColorlessMana, game, source);
|
||||
newMana.setColorless(1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
controller.getManaPool().addMana(newMana, game, source);
|
||||
checkToFirePossibleEvents(newMana, game, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -126,4 +129,11 @@ public class AddManaOfAnyColorTargetCanProduceEffect extends ManaEffect {
|
|||
public AddManaOfAnyColorTargetCanProduceEffect copy() {
|
||||
return new AddManaOfAnyColorTargetCanProduceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,24 +17,24 @@ import mage.players.Player;
|
|||
*
|
||||
* @author magenoxx
|
||||
*/
|
||||
public class AddManaToControllersManaPoolEffect extends OneShotEffect {
|
||||
public class AddManaToManaPoolSourceControllerEffect extends OneShotEffect {
|
||||
|
||||
protected Mana mana;
|
||||
|
||||
public AddManaToControllersManaPoolEffect(Mana mana) {
|
||||
public AddManaToManaPoolSourceControllerEffect(Mana mana) {
|
||||
super(Outcome.PutManaInPool);
|
||||
this.mana = mana;
|
||||
this.staticText = "Add " + mana.toString() + " to your mana pool";
|
||||
}
|
||||
|
||||
public AddManaToControllersManaPoolEffect(final AddManaToControllersManaPoolEffect effect) {
|
||||
public AddManaToManaPoolSourceControllerEffect(final AddManaToManaPoolSourceControllerEffect effect) {
|
||||
super(effect);
|
||||
this.mana = effect.mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddManaToControllersManaPoolEffect copy() {
|
||||
return new AddManaToControllersManaPoolEffect(this);
|
||||
public AddManaToManaPoolSourceControllerEffect copy() {
|
||||
return new AddManaToManaPoolSourceControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -18,12 +18,12 @@ import mage.players.Player;
|
|||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class AddManaToManaPoolEffect extends OneShotEffect {
|
||||
public class AddManaToManaPoolTargetControllerEffect extends ManaEffect {
|
||||
|
||||
protected Mana mana;
|
||||
protected boolean emptyOnlyOnTurnsEnd;
|
||||
|
||||
public AddManaToManaPoolEffect(Mana mana, String textManaPoolOwner) {
|
||||
public AddManaToManaPoolTargetControllerEffect(Mana mana, String textManaPoolOwner) {
|
||||
this(mana, textManaPoolOwner, false);
|
||||
}
|
||||
/**
|
||||
|
@ -34,22 +34,22 @@ public class AddManaToManaPoolEffect extends OneShotEffect {
|
|||
* @param emptyOnTurnsEnd if set, the mana will empty only on end of turnstep
|
||||
*
|
||||
*/
|
||||
public AddManaToManaPoolEffect(Mana mana, String textManaPoolOwner, boolean emptyOnTurnsEnd) {
|
||||
super(Outcome.PutManaInPool);
|
||||
public AddManaToManaPoolTargetControllerEffect(Mana mana, String textManaPoolOwner, boolean emptyOnTurnsEnd) {
|
||||
super();
|
||||
this.mana = mana;
|
||||
this.emptyOnlyOnTurnsEnd = emptyOnTurnsEnd;
|
||||
this.staticText = "add " + mana.toString() + " to " + textManaPoolOwner + " mana pool";
|
||||
this.staticText = (textManaPoolOwner.equals("his or her")?"that player adds":"add ") + mana.toString() + " to " + textManaPoolOwner + " mana pool";
|
||||
}
|
||||
|
||||
public AddManaToManaPoolEffect(final AddManaToManaPoolEffect effect) {
|
||||
public AddManaToManaPoolTargetControllerEffect(final AddManaToManaPoolTargetControllerEffect effect) {
|
||||
super(effect);
|
||||
this.mana = effect.mana;
|
||||
this.emptyOnlyOnTurnsEnd = effect.emptyOnlyOnTurnsEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddManaToManaPoolEffect copy() {
|
||||
return new AddManaToManaPoolEffect(this);
|
||||
public AddManaToManaPoolTargetControllerEffect copy() {
|
||||
return new AddManaToManaPoolTargetControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,4 +61,10 @@ public class AddManaToManaPoolEffect extends OneShotEffect {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return mana;
|
||||
}
|
||||
|
||||
}
|
|
@ -39,4 +39,9 @@ public class BasicManaEffect extends ManaEffect {
|
|||
public Mana getMana() {
|
||||
return mana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return mana;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,17 +58,15 @@ public class ChooseColorEffect extends OneShotEffect {
|
|||
if (controller != null && permanent != null) {
|
||||
ChoiceColor choice = new ChoiceColor();
|
||||
while (!choice.isChosen()) {
|
||||
controller.choose(Outcome.PutManaInPool, choice, game);
|
||||
controller.choose(outcome, choice, game);
|
||||
if (!controller.isInGame()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ChoiceColor colorChoice = new ChoiceColor();
|
||||
if (controller.choose(outcome, colorChoice, game)) {
|
||||
game.informPlayers(new StringBuilder(permanent.getLogName()).append(": ").append(controller.getName()).append(" has chosen ").append(colorChoice.getChoice()).toString());
|
||||
game.getState().setValue(source.getSourceId() + "_color", colorChoice.getColor());
|
||||
permanent.addInfo("chosen color", "<font color = 'blue'>Chosen color: " + colorChoice.getColor().getDescription() + "</font>");
|
||||
}
|
||||
game.informPlayers(new StringBuilder(permanent.getLogName()).append(": ").append(controller.getName()).append(" has chosen ").append(choice.getChoice()).toString());
|
||||
game.getState().setValue(source.getSourceId() + "_color", choice.getColor());
|
||||
permanent.addInfo("chosen color", "<font color = 'blue'>Chosen color: " + choice.getColor().getDescription() + "</font>");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class CounterTargetEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean countered = false;
|
||||
for (UUID targetId : source.getTargets().get(0).getTargets()) {
|
||||
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
|
||||
if (game.getStack().counter(targetId, source.getSourceId(), game)) {
|
||||
countered = true;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,11 @@ public class DynamicManaEffect extends BasicManaEffect {
|
|||
return super.getText(mode) + " for each " + amount.getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return computeMana(false, game, source);
|
||||
}
|
||||
|
||||
public Mana computeMana(boolean netMana ,Game game, Ability source){
|
||||
this.computedMana.clear();
|
||||
int count = amount.calculate(game, source, this);
|
||||
|
@ -131,4 +136,5 @@ public class DynamicManaEffect extends BasicManaEffect {
|
|||
}
|
||||
return computedMana;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,8 +28,16 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ManaEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,4 +53,22 @@ public abstract class ManaEffect extends OneShotEffect {
|
|||
super(effect);
|
||||
}
|
||||
|
||||
public abstract Mana getMana(Game game, Ability source);
|
||||
|
||||
/**
|
||||
* Only used for mana effects that decide which mana is produced during resolution of the effect.
|
||||
*
|
||||
* @param mana
|
||||
* @param game
|
||||
* @param source
|
||||
*/
|
||||
public void checkToFirePossibleEvents(Mana mana, Game game, Ability source) {
|
||||
if (source.getAbilityType().equals(AbilityType.MANA)) {
|
||||
for (Cost cost: source.getCosts()) {
|
||||
if (cost instanceof TapSourceCost) {
|
||||
game.fireEvent(new ManaEvent(GameEvent.EventType.TAPPED_FOR_MANA, source.getSourceId(), source.getSourceId(), source.getControllerId(), mana));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,27 +122,37 @@ class AnyColorOpponentLandsProduceManaEffect extends ManaEffect {
|
|||
} else {
|
||||
player.choose(outcome, choice, game);
|
||||
}
|
||||
switch (choice.getChoice()) {
|
||||
case "Black":
|
||||
player.getManaPool().addMana(Mana.BlackMana, game, source);
|
||||
break;
|
||||
case "Blue":
|
||||
player.getManaPool().addMana(Mana.BlueMana, game, source);
|
||||
break;
|
||||
case "Red":
|
||||
player.getManaPool().addMana(Mana.RedMana, game, source);
|
||||
break;
|
||||
case "Green":
|
||||
player.getManaPool().addMana(Mana.GreenMana, game, source);
|
||||
break;
|
||||
case "White":
|
||||
player.getManaPool().addMana(Mana.WhiteMana, game, source);
|
||||
break;
|
||||
if (choice.getChoice() != null) {
|
||||
Mana mana = new Mana();
|
||||
switch (choice.getChoice()) {
|
||||
case "Black":
|
||||
mana.setBlack(1);
|
||||
break;
|
||||
case "Blue":
|
||||
mana.setBlue(1);
|
||||
break;
|
||||
case "Red":
|
||||
mana.setRed(1);
|
||||
break;
|
||||
case "Green":
|
||||
mana.setGreen(1);
|
||||
break;
|
||||
case "White":
|
||||
mana.setWhite(1);
|
||||
break;
|
||||
}
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
player.getManaPool().addMana(mana, game, source);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Mana getManaTypes(Game game, Ability source) {
|
||||
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game);
|
||||
Mana types = new Mana();
|
||||
|
|
|
@ -30,14 +30,18 @@ package mage.abilities.mana;
|
|||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ManaEvent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
|
@ -145,27 +149,35 @@ class CommanderIdentityManaEffect extends ManaEffect {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
Mana mana = new Mana();
|
||||
switch (choice.getChoice()) {
|
||||
case "Black":
|
||||
controller.getManaPool().addMana(Mana.BlackMana, game, source);
|
||||
mana.setBlack(1);
|
||||
break;
|
||||
case "Blue":
|
||||
controller.getManaPool().addMana(Mana.BlueMana, game, source);
|
||||
mana.setBlue(1);
|
||||
break;
|
||||
case "Red":
|
||||
controller.getManaPool().addMana(Mana.RedMana, game, source);
|
||||
mana.setRed(1);
|
||||
break;
|
||||
case "Green":
|
||||
controller.getManaPool().addMana(Mana.GreenMana, game, source);
|
||||
mana.setGreen(1);
|
||||
break;
|
||||
case "White":
|
||||
controller.getManaPool().addMana(Mana.WhiteMana, game, source);
|
||||
mana.setWhite(1);
|
||||
break;
|
||||
}
|
||||
checkToFirePossibleEvents(mana, game, source);
|
||||
controller.getManaPool().addMana(mana, game, source);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana getMana(Game game, Ability source) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue