mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
merge
This commit is contained in:
commit
e47cf9cefc
25 changed files with 584 additions and 98 deletions
|
@ -86,12 +86,12 @@ class FireballEffect extends OneShotEffect<FireballEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int numTargets = source.getTargets().get(0).getTargets().size();
|
||||
int numTargets = targetPointer.getTargets(source).size();
|
||||
int damage = source.getManaCostsToPay().getX();
|
||||
if (numTargets > 0) {
|
||||
int damagePer = damage/numTargets;
|
||||
if (damagePer > 0) {
|
||||
for (UUID targetId: source.getTargets().get(0).getTargets()) {
|
||||
for (UUID targetId: targetPointer.getTargets(source)) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
permanent.damage(damagePer, source.getSourceId(), game, true, false);
|
||||
|
|
|
@ -88,13 +88,10 @@ class MorbidPlunderEffect extends OneShotEffect<MorbidPlunderEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean result = false;
|
||||
List<UUID> targets = source.getTargets().get(0).getTargets();
|
||||
if (targets.size() > 0) {
|
||||
for (UUID target : targets) {
|
||||
Card card = game.getCard(target);
|
||||
if (card != null) {
|
||||
result |= card.moveToZone(Zone.HAND, source.getId(), game, true);
|
||||
}
|
||||
for (UUID target : targetPointer.getTargets(source)) {
|
||||
Card card = game.getCard(target);
|
||||
if (card != null) {
|
||||
result |= card.moveToZone(Zone.HAND, source.getId(), game, true);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
125
Mage.Sets/src/mage/sets/newphyrexia/HexParasite.java
Normal file
125
Mage.Sets/src/mage/sets/newphyrexia/HexParasite.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* 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.sets.newphyrexia;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continious.BoostSourceEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward
|
||||
*/
|
||||
public class HexParasite extends CardImpl<HexParasite> {
|
||||
|
||||
public HexParasite(UUID ownerId) {
|
||||
super(ownerId, 137, "Hex Parasite", Rarity.RARE, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}");
|
||||
this.expansionSetCode = "NPH";
|
||||
this.subtype.add("Insect");
|
||||
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// {X}{BP}: Remove up to X counters from target permanent. For each counter removed this way, Hex Parasite gets +1/+0 until end of turn.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HexParasiteEffect(), new ManaCostsImpl("{X}{BP}"));
|
||||
ability.addTarget(new TargetPermanent());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public HexParasite(final HexParasite card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HexParasite copy() {
|
||||
return new HexParasite(this);
|
||||
}
|
||||
}
|
||||
|
||||
class HexParasiteEffect extends OneShotEffect<HexParasiteEffect> {
|
||||
|
||||
HexParasiteEffect ( ) {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "Remove up to X counters from target permanent. For each counter removed this way, {this} gets +1/+0 until end of turn";
|
||||
}
|
||||
|
||||
HexParasiteEffect ( HexParasiteEffect effect ) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HexParasiteEffect copy() {
|
||||
return new HexParasiteEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
TargetPermanent target = (TargetPermanent)source.getTargets().get(0);
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (permanent != null && player != null) {
|
||||
int toRemove = source.getManaCostsToPay().getX();
|
||||
int removed = 0;
|
||||
String[] counterNames = permanent.getCounters().keySet().toArray(new String[0]);
|
||||
for (String counterName : counterNames) {
|
||||
if (player.chooseUse(Outcome.Neutral, "Do you want to remove " + counterName + " counters?", game)) {
|
||||
if (permanent.getCounters().get(counterName).getCount() == 1 || toRemove == 1) {
|
||||
permanent.getCounters().removeCounter(counterName, 1);
|
||||
}
|
||||
else {
|
||||
int amount = player.getAmount(1, Math.min(permanent.getCounters().get(counterName).getCount(), toRemove - removed), "How many?", game);
|
||||
if (amount > 0) {
|
||||
removed += amount;
|
||||
permanent.getCounters().removeCounter(counterName, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (removed >= toRemove)
|
||||
break;
|
||||
}
|
||||
game.addEffect(new BoostSourceEffect(removed, 0, Duration.EndOfTurn), source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -92,8 +92,11 @@ class SpellskiteEffect extends OneShotEffect<SpellskiteEffect> {
|
|||
if (spell != null) {
|
||||
Targets targets = spell.getSpellAbility().getTargets();
|
||||
if (targets.size() == 1 && targets.get(0).getTargets().size() == 1) {
|
||||
targets.get(0).clearChosen();
|
||||
targets.get(0).add(source.getSourceId(), game);
|
||||
Target target = targets.get(0);
|
||||
if (target.canTarget(source.getSourceId(), game)) {
|
||||
target.clearChosen();
|
||||
target.add(source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
|
@ -108,9 +111,11 @@ class SpellskiteEffect extends OneShotEffect<SpellskiteEffect> {
|
|||
name = object.getName();
|
||||
}
|
||||
if (name != null && player.chooseUse(Outcome.Neutral, "Change target from " + name + " to {this}?", game)) {
|
||||
target.remove(targetId);
|
||||
target.addTarget(source.getSourceId(), source, game);
|
||||
break;
|
||||
if (target.canTarget(source.getSourceId(), game)) {
|
||||
target.remove(targetId);
|
||||
target.addTarget(source.getSourceId(), source, game);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
235
Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java
Normal file
235
Mage.Sets/src/mage/sets/newphyrexia/VorinclexVoiceOfHunger.java
Normal file
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
* 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.sets.newphyrexia;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.effects.common.SkipNextUntapTargetEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
import mage.abilities.mana.TriggeredManaAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward
|
||||
*/
|
||||
public class VorinclexVoiceOfHunger extends CardImpl<VorinclexVoiceOfHunger> {
|
||||
|
||||
public VorinclexVoiceOfHunger(UUID ownerId) {
|
||||
super(ownerId, 127, "Vorinclex, Voice of Hunger", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{6}{G}{G}");
|
||||
this.expansionSetCode = "NPH";
|
||||
this.supertype.add("Legendary");
|
||||
this.subtype.add("Praetor");
|
||||
|
||||
this.color.setGreen(true);
|
||||
this.power = new MageInt(7);
|
||||
this.toughness = new MageInt(6);
|
||||
|
||||
this.addAbility(TrampleAbility.getInstance());
|
||||
// Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced.
|
||||
this.addAbility(new VorinclexTriggeredAbility1());
|
||||
|
||||
// Whenever an opponent taps a land for mana, that land doesn't untap during its controller's next untap step.
|
||||
this.addAbility(new VorinclexTriggeredAbility2());
|
||||
}
|
||||
|
||||
public VorinclexVoiceOfHunger(final VorinclexVoiceOfHunger card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VorinclexVoiceOfHunger copy() {
|
||||
return new VorinclexVoiceOfHunger(this);
|
||||
}
|
||||
}
|
||||
|
||||
class VorinclexTriggeredAbility1 extends TriggeredManaAbility<VorinclexTriggeredAbility1> {
|
||||
|
||||
private static final String staticText = "Whenever you tap a land for mana, add one mana to your mana pool of any type that land produced.";
|
||||
|
||||
public VorinclexTriggeredAbility1() {
|
||||
super(Zone.BATTLEFIELD, new VorinclexEffect());
|
||||
}
|
||||
|
||||
public VorinclexTriggeredAbility1(VorinclexTriggeredAbility1 ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && event.getPlayerId().equals(controllerId)) {
|
||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||
if (permanent == null) {
|
||||
permanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
|
||||
}
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.LAND)) {
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VorinclexTriggeredAbility1 copy() {
|
||||
return new VorinclexTriggeredAbility1(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return staticText;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class VorinclexEffect extends ManaEffect<VorinclexEffect> {
|
||||
|
||||
public VorinclexEffect() {
|
||||
super();
|
||||
staticText = "add one mana to your mana pool of any type that land produced";
|
||||
}
|
||||
|
||||
public VorinclexEffect(final VorinclexEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent land = game.getPermanent(this.targetPointer.getFirst(source));
|
||||
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
|
||||
Mana types = new Mana();
|
||||
for (ManaAbility ability: mana) {
|
||||
types.add(ability.getNetMana(game));
|
||||
}
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
choice.setMessage("Pick a mana color");
|
||||
if (types.getBlack() > 0)
|
||||
choice.getChoices().add("Black");
|
||||
if (types.getRed() > 0)
|
||||
choice.getChoices().add("Red");
|
||||
if (types.getBlue() > 0)
|
||||
choice.getChoices().add("Blue");
|
||||
if (types.getGreen() > 0)
|
||||
choice.getChoices().add("Green");
|
||||
if (types.getWhite() > 0)
|
||||
choice.getChoices().add("White");
|
||||
if (types.getColorless() > 0)
|
||||
choice.getChoices().add("Colorless");
|
||||
if (choice.getChoices().size() > 0) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (choice.getChoices().size() == 1)
|
||||
choice.setChoice(choice.getChoices().iterator().next());
|
||||
else
|
||||
player.choose(outcome, choice, game);
|
||||
if (choice.getChoice().equals("Black")) {
|
||||
player.getManaPool().changeMana(Mana.BlackMana);
|
||||
return true;
|
||||
}
|
||||
else if (choice.getChoice().equals("Blue")) {
|
||||
player.getManaPool().changeMana(Mana.BlueMana);
|
||||
return true;
|
||||
}
|
||||
else if (choice.getChoice().equals("Red")) {
|
||||
player.getManaPool().changeMana(Mana.RedMana);
|
||||
return true;
|
||||
}
|
||||
else if (choice.getChoice().equals("Green")) {
|
||||
player.getManaPool().changeMana(Mana.GreenMana);
|
||||
return true;
|
||||
}
|
||||
else if (choice.getChoice().equals("White")) {
|
||||
player.getManaPool().changeMana(Mana.WhiteMana);
|
||||
return true;
|
||||
}
|
||||
else if (choice.getChoice().equals("Colorless")) {
|
||||
player.getManaPool().changeMana(Mana.ColorlessMana);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VorinclexEffect copy() {
|
||||
return new VorinclexEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class VorinclexTriggeredAbility2 extends TriggeredAbilityImpl<VorinclexTriggeredAbility2> {
|
||||
|
||||
private static final String staticText = "Whenever an opponent taps a land for mana, that land doesn't untap during its controller's next untap step.";
|
||||
|
||||
public VorinclexTriggeredAbility2() {
|
||||
super(Zone.BATTLEFIELD, new SkipNextUntapTargetEffect());
|
||||
}
|
||||
|
||||
public VorinclexTriggeredAbility2(VorinclexTriggeredAbility2 ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.TAPPED_FOR_MANA && game.getOpponents(controllerId).contains(event.getPlayerId())) {
|
||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||
if (permanent != null && permanent.getCardType().contains(CardType.LAND)) {
|
||||
getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VorinclexTriggeredAbility2 copy() {
|
||||
return new VorinclexTriggeredAbility2(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return staticText;
|
||||
}
|
||||
}
|
|
@ -95,7 +95,7 @@ class ArcTrailEffect extends OneShotEffect {
|
|||
boolean twoDamageDone = false;
|
||||
int damage = 2;
|
||||
|
||||
for ( UUID target : source.getTargets().get(0).getTargets() ) {
|
||||
for ( UUID target : targetPointer.getTargets(source) ) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
|
||||
if ( twoDamageDone ) {
|
||||
|
|
|
@ -83,7 +83,7 @@ class FulgentDistractionEffect extends OneShotEffect<FulgentDistractionEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for ( UUID target : source.getTargets().get(0).getTargets() ) {
|
||||
for ( UUID target : targetPointer.getTargets(source) ) {
|
||||
Permanent creature = game.getPermanent(target);
|
||||
|
||||
List<UUID> copiedAttachments = new ArrayList<UUID>(creature.getAttachments());
|
||||
|
|
|
@ -174,7 +174,7 @@ class LiegeOfTheTangleEffect extends ContinuousEffectImpl<LiegeOfTheTangleEffect
|
|||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (this.affectedObjectsSet) {
|
||||
for (UUID permId: source.getTargets().get(0).getTargets()) {
|
||||
for (UUID permId: targetPointer.getTargets(source)) {
|
||||
objects.add(permId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ class RustTickTapTargetEffect extends TapTargetEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Permanent rustTick = game.getPermanent(source.getSourceId());
|
||||
if (rustTick != null) rustTick.clearConnectedCards();
|
||||
for (UUID target : source.getTargets().get(0).getTargets()) {
|
||||
for (UUID target : targetPointer.getTargets(source)) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
if (permanent != null) {
|
||||
rustTick.addConnectedCard(permanent.getId());
|
||||
|
|
|
@ -28,49 +28,57 @@
|
|||
|
||||
package mage.sets.zendikar;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.condition.common.KickedCondition;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.decorator.ConditionalStaticAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilitySourceEffect;
|
||||
import mage.abilities.keyword.KickerAbility;
|
||||
import mage.abilities.keyword.UnblockableAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.CounterType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @author nantuko, BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class AetherFigment extends CardImpl<AetherFigment> {
|
||||
|
||||
public AetherFigment(UUID ownerId) {
|
||||
super(ownerId, 40, "AEther Figment", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}");
|
||||
this.expansionSetCode = "ZEN";
|
||||
this.subtype.add("Illusion");
|
||||
this.color.setBlue(true);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
private final static String staticText = "If AEther Figment was kicked, it enters the battlefield with two +1/+1 counters on it";
|
||||
|
||||
this.addAbility(UnblockableAbility.getInstance());
|
||||
Ability ability1 = new EntersBattlefieldTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)));
|
||||
KickerAbility ability2 = new KickerAbility(new GainAbilitySourceEffect(ability1, Duration.WhileOnBattlefield), false);
|
||||
ability2.addManaCost(new GenericManaCost(3));
|
||||
this.addAbility(ability2);
|
||||
}
|
||||
public AetherFigment(UUID ownerId) {
|
||||
super(ownerId, 40, "AEther Figment", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}");
|
||||
this.expansionSetCode = "ZEN";
|
||||
this.subtype.add("Illusion");
|
||||
this.color.setBlue(true);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
public AetherFigment(final AetherFigment card) {
|
||||
super(card);
|
||||
}
|
||||
// AEther Figment is unblockable.
|
||||
this.addAbility(UnblockableAbility.getInstance());
|
||||
|
||||
@Override
|
||||
public AetherFigment copy() {
|
||||
return new AetherFigment(this);
|
||||
}
|
||||
// Kicker {3}
|
||||
this.getSpellAbility().addOptionalCost(new GenericManaCost(3));
|
||||
|
||||
// If AEther Figment was kicked, it enters the battlefield with two +1/+1 counters on it
|
||||
Ability ability = new EntersBattlefieldAbility(new ConditionalOneShotEffect(new AddCountersSourceEffect(CounterType.P1P1.createInstance(2)), KickedCondition.getInstance(), ""), staticText);
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
||||
public AetherFigment(final AetherFigment card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AetherFigment copy() {
|
||||
return new AetherFigment(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,35 +27,45 @@
|
|||
*/
|
||||
package mage.sets.zendikar;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.common.KickedCondition;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.decorator.ConditionalContinousEffect;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.common.continious.BoostControlledEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
|
||||
import mage.abilities.keyword.FirstStrikeAbility;
|
||||
import mage.abilities.keyword.KickerAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Loki
|
||||
* @author nantuko, Loki
|
||||
*/
|
||||
public class BoldDefense extends CardImpl<BoldDefense> {
|
||||
|
||||
private final String staticText = "If Bold Defense was kicked, instead creatures you control get +2/+2 and gain first strike until end of turn";
|
||||
|
||||
public BoldDefense(UUID ownerId) {
|
||||
super(ownerId, 3, "Bold Defense", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{W}");
|
||||
this.expansionSetCode = "ZEN";
|
||||
this.color.setWhite(true);
|
||||
Ability kickedAbility = new KickerAbility(new BoostControlledEffect(2, 2, Constants.Duration.EndOfTurn), true);
|
||||
kickedAbility.addCost(new ManaCostsImpl("{3}{W}"));
|
||||
kickedAbility.addEffect(new GainAbilityControlledEffect(FirstStrikeAbility.getInstance(), Constants.Duration.EndOfTurn, FilterCreaturePermanent.getDefault(), false));
|
||||
this.addAbility(kickedAbility);
|
||||
this.getSpellAbility().addEffect(new BoostControlledEffect(1, 1, Constants.Duration.EndOfTurn));
|
||||
|
||||
DynamicValue dn = new BoldDefensePTCount();
|
||||
this.getSpellAbility().addEffect(new BoostControlledEffect(dn, dn, Constants.Duration.EndOfTurn));
|
||||
|
||||
this.getSpellAbility().addOptionalCost(new ManaCostsImpl("{3}{W}"));
|
||||
|
||||
ContinuousEffect effect = new GainAbilityControlledEffect(FirstStrikeAbility.getInstance(), Constants.Duration.EndOfTurn, FilterCreaturePermanent.getDefault(), false);
|
||||
this.getSpellAbility().addEffect(new ConditionalContinousEffect(effect, KickedCondition.getInstance(), staticText));
|
||||
}
|
||||
|
||||
public BoldDefense(final BoldDefense card) {
|
||||
|
@ -67,3 +77,28 @@ public class BoldDefense extends CardImpl<BoldDefense> {
|
|||
return new BoldDefense(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BoldDefensePTCount implements DynamicValue {
|
||||
|
||||
public BoldDefensePTCount() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility) {
|
||||
if (KickedCondition.getInstance().apply(game, sourceAbility)) {
|
||||
return 2;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicValue clone() {
|
||||
return new BoldDefensePTCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -101,7 +101,7 @@ class KhalniGemReturnToHandTargetEffect extends OneShotEffect<KhalniGemReturnToH
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for ( UUID target : source.getTargets().get(0).getTargets() ) {
|
||||
for ( UUID target : targetPointer.getTargets(source) ) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
if ( permanent != null ) {
|
||||
permanent.moveToZone(Zone.HAND, source.getId(), game, true);
|
||||
|
|
|
@ -98,7 +98,7 @@ public class EntersBattlefieldEffect extends ReplacementEffectImpl<EntersBattlef
|
|||
if (text.length() == 0)
|
||||
return "When {this} enters the battlefield, " + baseEffects.getText(mode);
|
||||
else
|
||||
return "When {this} enters the battlefield, " + text;
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -67,19 +67,21 @@ public class DamageMultiEffect extends OneShotEffect<DamageMultiEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Target multiTarget = source.getTargets().get(0);
|
||||
for (UUID target: multiTarget.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
if (permanent != null) {
|
||||
permanent.damage(multiTarget.getTargetAmount(target), source.getId(), game, true, false);
|
||||
}
|
||||
else {
|
||||
Player player = game.getPlayer(target);
|
||||
if (player != null) {
|
||||
player.damage(multiTarget.getTargetAmount(target), source.getId(), game, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (source.getTargets().size() > 0) {
|
||||
Target multiTarget = source.getTargets().get(0);
|
||||
for (UUID target: multiTarget.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
if (permanent != null) {
|
||||
permanent.damage(multiTarget.getTargetAmount(target), source.getId(), game, true, false);
|
||||
}
|
||||
else {
|
||||
Player player = game.getPlayer(target);
|
||||
if (player != null) {
|
||||
player.damage(multiTarget.getTargetAmount(target), source.getId(), game, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class GainLifeTargetEffect extends OneShotEffect<GainLifeTargetEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID playerId: source.getTargets().get(0).getTargets()) {
|
||||
for (UUID playerId: targetPointer.getTargets(source)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.gainLife(life, game);
|
||||
|
|
|
@ -59,7 +59,7 @@ public class SacrificeTargetEffect extends OneShotEffect<SacrificeTargetEffect>
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int affectedTargets = 0;
|
||||
for (UUID permanentId : source.getTargets().get(0).getTargets()) {
|
||||
for (UUID permanentId : targetPointer.getTargets(source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
permanent.sacrifice(source.getSourceId(), game);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class SkipNextUntapTargetEffect extends ReplacementEffectImpl<SkipNextUnt
|
|||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
if (source.getTargets().get(0).getTargets().size() < 2) {
|
||||
if (targetPointer.getTargets(source).size() < 2) {
|
||||
used = true;
|
||||
} else {
|
||||
count++;
|
||||
|
@ -82,7 +82,7 @@ public class SkipNextUntapTargetEffect extends ReplacementEffectImpl<SkipNextUnt
|
|||
// not clear how to turn off the effect for more than one target
|
||||
// especially as some targets may leave the battlefield since the effect creation
|
||||
// so handling this in applies method is the only option for now for such cases
|
||||
if (count == source.getTargets().get(0).getTargets().size()) {
|
||||
if (count == targetPointer.getTargets(source).size()) {
|
||||
// this won't work for targets disappeared before applies() return true
|
||||
used = true;
|
||||
}
|
||||
|
@ -91,18 +91,16 @@ public class SkipNextUntapTargetEffect extends ReplacementEffectImpl<SkipNextUnt
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP &&
|
||||
event.getType() == EventType.UNTAP) {
|
||||
|
||||
for (UUID target : source.getTargets().get(0).getTargets()) {
|
||||
if (event.getTargetId().equals(target)) {
|
||||
if (!usedFor.contains(target)) {
|
||||
usedFor.add(target);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == EventType.UNTAP) {
|
||||
for (UUID target : targetPointer.getTargets(source)) {
|
||||
if (event.getTargetId().equals(target)) {
|
||||
if (!usedFor.contains(target)) {
|
||||
usedFor.add(target);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class TapTargetEffect extends OneShotEffect<TapTargetEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID target: source.getTargets().get(0).getTargets()) {
|
||||
for (UUID target: targetPointer.getTargets(source)) {
|
||||
Permanent permanent = game.getPermanent(target);
|
||||
if (permanent != null) {
|
||||
permanent.tap(game);
|
||||
|
|
|
@ -33,6 +33,8 @@ import mage.Constants.Layer;
|
|||
import mage.Constants.Outcome;
|
||||
import mage.Constants.SubLayer;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
|
@ -44,8 +46,8 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledEffect> {
|
||||
|
||||
protected int power;
|
||||
protected int toughness;
|
||||
private DynamicValue power;
|
||||
private DynamicValue toughness;
|
||||
protected boolean excludeSource;
|
||||
protected FilterCreaturePermanent filter;
|
||||
|
||||
|
@ -53,11 +55,19 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
|
|||
this(power, toughness, duration, FilterCreaturePermanent.getDefault(), false);
|
||||
}
|
||||
|
||||
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration) {
|
||||
this(power, toughness, duration, FilterCreaturePermanent.getDefault(), false);
|
||||
}
|
||||
|
||||
public BoostControlledEffect(int power, int toughness, Duration duration, boolean excludeSource) {
|
||||
this(power, toughness, duration, FilterCreaturePermanent.getDefault(), excludeSource);
|
||||
}
|
||||
|
||||
public BoostControlledEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
|
||||
this(new StaticValue(power), new StaticValue(toughness), duration, filter, excludeSource);
|
||||
}
|
||||
|
||||
public BoostControlledEffect(DynamicValue power, DynamicValue toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
|
||||
super(duration, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||
this.power = power;
|
||||
this.toughness = toughness;
|
||||
|
@ -96,8 +106,8 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
|
|||
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId())) {
|
||||
if (!this.affectedObjectsSet || objects.contains(perm.getId())) {
|
||||
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
|
||||
perm.addPower(power);
|
||||
perm.addToughness(toughness);
|
||||
perm.addPower(power.calculate(game, source));
|
||||
perm.addToughness(toughness.calculate(game, source));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +119,23 @@ public class BoostControlledEffect extends ContinuousEffectImpl<BoostControlledE
|
|||
if (excludeSource)
|
||||
sb.append("Other ");
|
||||
sb.append(filter.getMessage());
|
||||
sb.append(" you control get ").append(String.format("%1$+d/%2$+d", power, toughness));
|
||||
sb.append(" you control get ");
|
||||
|
||||
String p = power.toString();
|
||||
if(!p.startsWith("-")) {
|
||||
sb.append("+");
|
||||
}
|
||||
sb.append(p).append("/");
|
||||
String t = toughness.toString();
|
||||
if(!t.startsWith("-")){
|
||||
if(p.startsWith("-")) {
|
||||
sb.append("-");
|
||||
} else {
|
||||
sb.append("+");
|
||||
}
|
||||
}
|
||||
sb.append(t);
|
||||
|
||||
sb.append((duration==Duration.EndOfTurn?" until end of turn":""));
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class BoostTargetEffect extends ContinuousEffectImpl<BoostTargetEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int affectedTargets = 0;
|
||||
for (UUID permanentId : source.getTargets().get(0).getTargets()) {
|
||||
for (UUID permanentId : targetPointer.getTargets(source)) {
|
||||
Permanent target = (Permanent) game.getPermanent(permanentId);
|
||||
if (target != null) {
|
||||
target.addPower(power.calculate(game, source));
|
||||
|
|
|
@ -67,7 +67,7 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int affectedTargets = 0;
|
||||
for (UUID permanentId : source.getTargets().get(0).getTargets()) {
|
||||
for (UUID permanentId : targetPointer.getTargets(source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
permanent.addAbility(ability);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class LoseAllAbilitiesTargetEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int affectedTargets = 0;
|
||||
for (UUID permanentId : source.getTargets().get(0).getTargets()) {
|
||||
for (UUID permanentId : targetPointer.getTargets(source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
permanent.getAbilities().clear();
|
||||
|
|
47
Mage/src/mage/abilities/mana/TriggeredManaAbility.java
Normal file
47
Mage/src/mage/abilities/mana/TriggeredManaAbility.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright 2011 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.mana;
|
||||
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
|
||||
/**
|
||||
* see 20110715 - 605.1b
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public abstract class TriggeredManaAbility<T extends TriggeredManaAbility<T>> extends TriggeredAbilityImpl<T> {
|
||||
|
||||
public TriggeredManaAbility(Zone zone, ManaEffect effect) {
|
||||
super(zone, effect);
|
||||
}
|
||||
|
||||
public TriggeredManaAbility(final TriggeredManaAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
}
|
|
@ -61,6 +61,7 @@ import java.io.IOException;
|
|||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
import mage.abilities.mana.TriggeredManaAbility;
|
||||
import mage.watchers.common.MorbidWatcher;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
@ -612,9 +613,15 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
|
||||
@Override
|
||||
public void addTriggeredAbility(TriggeredAbility ability) {
|
||||
TriggeredAbility newAbility = (TriggeredAbility) ability.copy();
|
||||
newAbility.newId();
|
||||
state.addTriggeredAbility(newAbility);
|
||||
if (ability instanceof TriggeredManaAbility) {
|
||||
// 20110715 - 605.4
|
||||
ability.resolve(this);
|
||||
}
|
||||
else {
|
||||
TriggeredAbility newAbility = (TriggeredAbility) ability.copy();
|
||||
newAbility.newId();
|
||||
state.addTriggeredAbility(newAbility);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,8 @@ public class FirstTargetPointer implements TargetPointer {
|
|||
@Override
|
||||
public List<UUID> getTargets(Ability source) {
|
||||
ArrayList<UUID> target = new ArrayList<UUID>();
|
||||
target.addAll(source.getTargets().get(0).getTargets());
|
||||
if (source.getTargets().size() > 0)
|
||||
target.addAll(source.getTargets().get(0).getTargets());
|
||||
return target;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue