Merge remote-tracking branch 'production/master' into production_master

This commit is contained in:
Oleg Agafonov 2017-12-31 17:38:36 +04:00
commit c246c4b19c
33 changed files with 598 additions and 284 deletions

View file

@ -119,7 +119,7 @@ class ArbiterOfTheIdealEffect extends OneShotEffect {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.addCounters(new Counter("Manifestation"), source, game);
ContinuousEffect effect = new AddCardTypeTargetEffect(CardType.ENCHANTMENT, Duration.Custom);
ContinuousEffect effect = new AddCardTypeTargetEffect(Duration.Custom, CardType.ENCHANTMENT);
effect.setTargetPointer(new FixedTarget(permanent.getId()));
game.addEffect(effect, source);
}

View file

@ -46,7 +46,7 @@ public class ArgentMutation extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}");
this.getSpellAbility().addEffect(new AddCardTypeTargetEffect(CardType.ARTIFACT, Duration.EndOfTurn));
this.getSpellAbility().addEffect(new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT));
this.getSpellAbility().addTarget(new TargetPermanent());
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
}

View file

@ -65,7 +65,7 @@ public class AshnodsTransmogrant extends CardImpl {
// {T}, Sacrifice Ashnod's Transmogrant: Put a +1/+1 counter on target nonartifact creature. That creature becomes an artifact in addition to its other types.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersTargetEffect(CounterType.P1P1.createInstance()), new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
Effect effect = new AddCardTypeTargetEffect(CardType.ARTIFACT, Duration.WhileOnBattlefield);
Effect effect = new AddCardTypeTargetEffect(Duration.WhileOnBattlefield, CardType.ARTIFACT);
effect.setText("That creature becomes an artifact in addition to its other types");
ability.addEffect(effect);
ability.addTarget(new TargetCreaturePermanent(filter));

View file

@ -0,0 +1,65 @@
/*
* 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.cards.e;
import java.util.UUID;
import mage.abilities.common.CastOnlyIfConditionIsTrueAbility;
import mage.abilities.condition.common.ControlsPermanentsComparedToOpponentsCondition;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.filter.StaticFilters;
import mage.game.permanent.token.SoldierToken;
/**
*
* @author LevelX2
*/
public class EvenTheOdds extends CardImpl {
public EvenTheOdds(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}");
// Cast Even the Odds only if you control fewer creatures than each opponent.
this.addAbility(new CastOnlyIfConditionIsTrueAbility(new ControlsPermanentsComparedToOpponentsCondition(ComparisonType.FEWER_THAN, StaticFilters.FILTER_PERMANENT_CREATURES)));
// Create three 1/1 white Soldier creature tokens.
this.getSpellAbility().addEffect(new CreateTokenEffect(new SoldierToken(), 3));
}
public EvenTheOdds(final EvenTheOdds card) {
super(card);
}
@Override
public EvenTheOdds copy() {
return new EvenTheOdds(this);
}
}

View file

@ -28,18 +28,16 @@
package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.common.CastOnlyIfConditionIsTrueAbility;
import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.SubType;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
/**
@ -49,11 +47,14 @@ import mage.target.common.TargetCreaturePermanent;
public class FeastOfBlood extends CardImpl {
public FeastOfBlood(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}");
// Cast Feast of Blood only if you control two or more Vampires.
this.getSpellAbility().addCost(new FeastOfBloodCost());
this.addAbility(new CastOnlyIfConditionIsTrueAbility(
new PermanentsOnTheBattlefieldCondition(
new FilterControlledCreaturePermanent(SubType.VAMPIRE, "if you control two or more Vampires"),
ComparisonType.MORE_THAN, 1)));
// Destroy target creature. You gain 4 life.
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addEffect(new DestroyTargetEffect());
@ -69,36 +70,3 @@ public class FeastOfBlood extends CardImpl {
return new FeastOfBlood(this);
}
}
class FeastOfBloodCost extends CostImpl {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
static {
filter.add(new SubtypePredicate(SubType.VAMPIRE));
}
public FeastOfBloodCost() {
this.text = "you must control two or more Vampires";
}
public FeastOfBloodCost(final FeastOfBloodCost cost) {
super(cost);
}
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
return game.getBattlefield().contains(filter, controllerId, 2, game);
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
this.paid = true;
return paid;
}
@Override
public FeastOfBloodCost copy() {
return new FeastOfBloodCost(this);
}
}

View file

@ -27,10 +27,9 @@
*/
package mage.cards.f;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.AddCardTypeSourceEffect;
import mage.abilities.keyword.CrewAbility;
import mage.abilities.keyword.HasteAbility;
@ -41,8 +40,6 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import java.util.UUID;
/**
*
* @author emerald000
@ -50,7 +47,7 @@ import java.util.UUID;
public class FleetwheelCruiser extends CardImpl {
public FleetwheelCruiser(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
this.subtype.add(SubType.VEHICLE);
this.power = new MageInt(5);
this.toughness = new MageInt(3);
@ -62,13 +59,8 @@ public class FleetwheelCruiser extends CardImpl {
this.addAbility(HasteAbility.getInstance());
// When Fleetwheel Cruiser enters the battlefield, it becomes an artifact creature until the end of turn.
Effect effect = new AddCardTypeSourceEffect(CardType.ARTIFACT, Duration.EndOfTurn);
effect.setText("it becomes an artifact");
Ability ability = new EntersBattlefieldTriggeredAbility(effect);
effect = new AddCardTypeSourceEffect(CardType.CREATURE, Duration.EndOfTurn);
effect.setText(" creature until end of turn");
ability.addEffect(effect);
this.addAbility(ability);
this.addAbility(new EntersBattlefieldTriggeredAbility(
new AddCardTypeSourceEffect(Duration.EndOfTurn, CardType.ARTIFACT, CardType.CREATURE)));
// Crew 2
this.addAbility(new CrewAbility(2));

View file

@ -27,6 +27,7 @@
*/
package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -48,8 +49,6 @@ import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/**
* @author JRHerlehy
*/
@ -74,7 +73,7 @@ public class HeartOfKiran extends CardImpl {
// You may remove a loyalty counter from a planeswalker you control rather than pay Heart of Kiran's crew cost.
Cost cost = new HeartOfKiranAlternateCrewCost(CounterType.LOYALTY, 1);
Effect effect = new AddCardTypeSourceEffect(CardType.CREATURE, Duration.EndOfTurn);
Effect effect = new AddCardTypeSourceEffect(Duration.EndOfTurn, CardType.CREATURE, CardType.CREATURE);
effect.setText("You may remove a loyalty counter from a planeswalker you control rather than pay {this}'s crew cost");
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, cost));
}
@ -91,8 +90,8 @@ public class HeartOfKiran extends CardImpl {
class HeartOfKiranAlternateCrewCost extends CostImpl {
private CounterType counterTypeToRemove;
private int countersToRemove;
private final CounterType counterTypeToRemove;
private final int countersToRemove;
private static final FilterControlledPlaneswalkerPermanent filter = new FilterControlledPlaneswalkerPermanent("planeswalker you control");

View file

@ -99,6 +99,9 @@ class KarnsTouchEffect extends ContinuousEffectImpl {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!artifact.isArtifact()) {
artifact.addCardType(CardType.ARTIFACT);
}
if (!artifact.isCreature()) {
artifact.addCardType(CardType.CREATURE);
}

View file

@ -50,7 +50,7 @@ public class LiquimetalCoating extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}");
// {T}: Target permanent becomes an artifact in addition to its other types until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCardTypeTargetEffect(CardType.ARTIFACT, Duration.EndOfTurn), new TapSourceCost());
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT), new TapSourceCost());
ability.addTarget(new TargetPermanent());
this.addAbility(ability);
}

View file

@ -60,7 +60,7 @@ public class Memnarch extends CardImpl {
this.toughness = new MageInt(5);
// {1}{U}{U}: Target permanent becomes an artifact in addition to its other types.
Effect effect = new AddCardTypeTargetEffect(CardType.ARTIFACT, Duration.WhileOnBattlefield);
Effect effect = new AddCardTypeTargetEffect(Duration.WhileOnBattlefield, CardType.ARTIFACT);
effect.setText("Target permanent becomes an artifact in addition to its other types");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{1}{U}{U}"));
ability.addTarget(new TargetPermanent());

View file

@ -103,7 +103,7 @@ class MirrorOfTheForebearsCopyEffect extends OneShotEffect {
if (sourcePermanent != null && copyFromPermanent != null) {
game.copyPermanent(Duration.EndOfTurn, copyFromPermanent, sourcePermanent.getId(), source, new EmptyApplyToPermanent());
if (!copyFromPermanent.isArtifact()) {
ContinuousEffect effect = new AddCardTypeTargetEffect(CardType.ARTIFACT, Duration.EndOfTurn);
ContinuousEffect effect = new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT);
effect.setTargetPointer(new FixedTarget(sourcePermanent, game));
game.addEffect(effect, source);
}

View file

@ -55,7 +55,7 @@ public class MyrLandshaper extends CardImpl {
this.toughness = new MageInt(1);
// {tap}: Target land becomes an artifact in addition to its other types until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCardTypeTargetEffect(CardType.ARTIFACT, Duration.EndOfTurn), new TapSourceCost());
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT), new TapSourceCost());
Target target = new TargetLandPermanent();
ability.addTarget(target);
this.addAbility(ability);

View file

@ -67,7 +67,7 @@ public class PeacewalkerColossus extends CardImpl {
this.toughness = new MageInt(6);
// {1}{W}: Another target Vehicle you control becomes an artifact creature until end of turn.
Effect effect = new AddCardTypeTargetEffect(CardType.CREATURE, Duration.EndOfTurn);
Effect effect = new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.CREATURE);
effect.setText("Another target Vehicle you control becomes an artifact creature until end of turn");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{1}{W}"));
ability.addTarget(new TargetControlledPermanent(filter));

View file

@ -27,6 +27,7 @@
*/
package mage.cards.s;
import java.util.UUID;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -34,7 +35,7 @@ import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.ExileFromHandCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ExileFromHandCostCardConvertedMana;
import mage.abilities.effects.PreventionEffectImpl;
import mage.abilities.effects.common.RedirectDamageFromSourceToTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -45,7 +46,6 @@ import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.game.events.DamageEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -53,8 +53,6 @@ import mage.target.TargetSource;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreatureOrPlayer;
import java.util.UUID;
/**
*
* @author LevelX2
@ -62,7 +60,7 @@ import java.util.UUID;
public class ShiningShoal extends CardImpl {
public ShiningShoal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{W}{W}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{W}{W}");
this.subtype.add(SubType.ARCANE);
// You may exile a white card with converted mana cost X from your hand rather than pay Shining Shoal's mana cost
@ -72,7 +70,7 @@ public class ShiningShoal extends CardImpl {
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
// The next X damage that a source of your choice would deal to you and/or creatures you control this turn is dealt to target creature or player instead.
this.getSpellAbility().addEffect(new ShiningShoalPreventDamageTargetEffect(Duration.EndOfTurn, new ExileFromHandCostCardConvertedMana()));
this.getSpellAbility().addEffect(new ShiningShoalRedirectDamageTargetEffect(Duration.EndOfTurn, new ExileFromHandCostCardConvertedMana()));
this.getSpellAbility().addTarget(new TargetSource());
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
}
@ -87,31 +85,29 @@ public class ShiningShoal extends CardImpl {
}
}
class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl {
class ShiningShoalRedirectDamageTargetEffect extends RedirectDamageFromSourceToTargetEffect {
private final DynamicValue dynamicAmount;
private int amount;
public ShiningShoalPreventDamageTargetEffect(Duration duration, DynamicValue dynamicAmount) {
super(duration);
public ShiningShoalRedirectDamageTargetEffect(Duration duration, DynamicValue dynamicAmount) {
super(duration, 0, true);
this.dynamicAmount = dynamicAmount;
staticText = "The next X damage that a source of your choice would deal to you and/or creatures you control this turn is dealt to target creature or player instead";
}
public ShiningShoalPreventDamageTargetEffect(final ShiningShoalPreventDamageTargetEffect effect) {
public ShiningShoalRedirectDamageTargetEffect(final ShiningShoalRedirectDamageTargetEffect effect) {
super(effect);
this.amount = effect.amount;
this.dynamicAmount = effect.dynamicAmount;
}
@Override
public ShiningShoalPreventDamageTargetEffect copy() {
return new ShiningShoalPreventDamageTargetEffect(this);
public ShiningShoalRedirectDamageTargetEffect copy() {
return new ShiningShoalRedirectDamageTargetEffect(this);
}
@Override
public void init(Ability source, Game game) {
this.amount = dynamicAmount.calculate(game, source, this);
amountToRedirect = dynamicAmount.calculate(game, source, this);
}
@Override
@ -119,49 +115,9 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
if (!game.replaceEvent(preventEvent)) {
int prevented;
if (event.getAmount() >= this.amount) {
int damage = amount;
event.setAmount(event.getAmount() - amount);
this.used = true;
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), damage));
prevented = damage;
} else {
int damage = event.getAmount();
event.setAmount(0);
amount -= damage;
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getSourceId(), source.getControllerId(), damage));
prevented = damage;
}
// deal damage now
if (prevented > 0) {
UUID redirectTo = source.getTargets().get(1).getFirstTarget();
Permanent permanent = game.getPermanent(redirectTo);
MageObject sourceObject = game.getObject(source.getFirstTarget());
if (permanent != null) {
game.informPlayers(sourceObject.getIdName() + "deals " + prevented + " to " + permanent.getName() + " instead");
// keep the original source id as it is redirecting
permanent.damage(prevented, event.getSourceId(), game, ((DamageEvent) event).isCombatDamage(), ((DamageEvent) event).isPreventable(), event.getAppliedEffects());
}
Player player = game.getPlayer(redirectTo);
if (player != null) {
game.informPlayers(sourceObject.getIdName() + "deals " + prevented + " to " + player.getLogName() + " instead");
// keep the original source id as it is redirecting
player.damage(prevented, event.getSourceId(), game, ((DamageEvent) event).isCombatDamage(), ((DamageEvent) event).isPreventable(), event.getAppliedEffects());
}
}
}
return false;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!this.used && super.applies(event, source, game)) {
if (!this.used && event.getFlag()) {
// get source of the damage event
MageObject sourceObject = game.getObject(event.getSourceId());
@ -173,7 +129,7 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl {
return false;
}
// do the 2 objects match?
if (sourceObject.getId() != chosenSourceObject.getId()) {
if (!sourceObject.getId().equals(chosenSourceObject.getId())) {
return false;
}
@ -183,6 +139,7 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl {
if (permanent != null && permanent.isCreature()) {
if (permanent.getControllerId().equals(source.getControllerId())) {
// it's your creature
redirectTarget = source.getTargets().get(1);
return true;
}
}
@ -191,6 +148,7 @@ class ShiningShoalPreventDamageTargetEffect extends PreventionEffectImpl {
if (player != null) {
if (player.getId().equals(source.getControllerId())) {
// it is you
redirectTarget = source.getTargets().get(1);
return true;
}
}

View file

@ -44,12 +44,15 @@ import mage.constants.*;
public class SilverskinArmor extends CardImpl {
public SilverskinArmor(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
this.subtype.add(SubType.EQUIPMENT);
this.addAbility(new EquipAbility(Outcome.BoostCreature, new ManaCostsImpl("{2}")));
// Equipped creature gets +1/+1 and is an artifact in addition to its other types.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1, 1, Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AddCardTypeAttachedEffect(CardType.ARTIFACT, Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT)));
// Equip {2}
this.addAbility(new EquipAbility(Outcome.BoostCreature, new ManaCostsImpl("{2}")));
}
public SilverskinArmor(final SilverskinArmor card) {

View file

@ -56,6 +56,7 @@ public class SydriGalvanicGenius extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("artifact creature");
private static final FilterArtifactPermanent filterNonCreature = new FilterArtifactPermanent("noncreature artifact");
static {
filter.add(new CardTypePredicate(CardType.ARTIFACT));
filter.add(new CardTypePredicate(CardType.CREATURE));
@ -63,7 +64,7 @@ public class SydriGalvanicGenius extends CardImpl {
}
public SydriGalvanicGenius(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{W}{U}{B}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{U}{B}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ARTIFICER);
@ -119,6 +120,9 @@ class SydriGalvanicGeniusEffect extends ContinuousEffectImpl {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!artifact.isArtifact()) {
artifact.addCardType(CardType.ARTIFACT);
}
if (!artifact.isCreature()) {
artifact.addCardType(CardType.CREATURE);
}
@ -140,7 +144,6 @@ class SydriGalvanicGeniusEffect extends ContinuousEffectImpl {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.PTChangingEffects_7 || layer == Layer.TypeChangingEffects_4;

View file

@ -31,7 +31,6 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
@ -41,12 +40,12 @@ import mage.abilities.effects.common.continuous.SetPowerToughnessTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.FilterCard;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.StaticFilters;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.players.Player;
@ -66,7 +65,7 @@ public class TezzeretAgentOfBolas extends CardImpl {
}
public TezzeretAgentOfBolas(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.PLANESWALKER},"{2}{U}{B}");
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{U}{B}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.TEZZERET);
@ -76,7 +75,7 @@ public class TezzeretAgentOfBolas extends CardImpl {
this.addAbility(new LoyaltyAbility(new LookLibraryAndPickControllerEffect(5, 1, filter, true), 1));
// -1: Target artifact becomes an artifact creature with base power and toughness 5/5.
Effect effect = new AddCardTypeTargetEffect(CardType.CREATURE, Duration.EndOfGame);
Effect effect = new AddCardTypeTargetEffect(Duration.EndOfGame, CardType.ARTIFACT, CardType.CREATURE);
effect.setText("Target artifact becomes an artifact creature");
LoyaltyAbility ability1 = new LoyaltyAbility(effect, -1);
effect = new SetPowerToughnessTargetEffect(5, 5, Duration.EndOfGame);
@ -105,12 +104,6 @@ public class TezzeretAgentOfBolas extends CardImpl {
class TezzeretAgentOfBolasEffect2 extends OneShotEffect {
final static FilterControlledPermanent filter = new FilterControlledPermanent("artifacts");
static {
filter.add(new CardTypePredicate(CardType.ARTIFACT));
}
public TezzeretAgentOfBolasEffect2() {
super(Outcome.DrawCard);
staticText = "Target player loses X life and you gain X life, where X is twice the number of artifacts you control";
@ -127,16 +120,16 @@ class TezzeretAgentOfBolasEffect2 extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
DynamicValue value = new PermanentsOnBattlefieldCount(filter);
int count = value.calculate(game, source, this) * 2;
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
player.loseLife(count, game, false);
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.gainLife(count, game);
int count = new PermanentsOnBattlefieldCount(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT).calculate(game, source, this) * 2;
if (count > 0) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
targetPlayer.loseLife(count, game, false);
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.gainLife(count, game);
}
}
return true;
}

View file

@ -65,7 +65,7 @@ public class ThranForge extends CardImpl {
.setText("Until end of turn, target nonartifact creature gets +1/+0"),
new GenericManaCost(2));
ability.addEffect(
new AddCardTypeTargetEffect(CardType.ARTIFACT, Duration.EndOfTurn)
new AddCardTypeTargetEffect(Duration.EndOfTurn, CardType.ARTIFACT)
.setText("and becomes an artifact in addition to its other types")
);
ability.addTarget(new TargetPermanent(filter));

View file

@ -55,11 +55,11 @@ import mage.game.permanent.Permanent;
public class TitaniasSong extends CardImpl {
public TitaniasSong(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{G}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}");
// Each noncreature artifact loses all abilities and becomes an artifact creature with power and toughness each equal to its converted mana cost. If Titania's Song leaves the battlefield, this effect continues until end of turn.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new TitaniasSongEffect(Duration.WhileOnBattlefield)));
this.addAbility(new LeavesBattlefieldTriggeredAbility(new TitaniasSongEffect(Duration.EndOfTurn), false));
this.addAbility(new LeavesBattlefieldTriggeredAbility(new TitaniasSongEffect(Duration.EndOfTurn), false));
}
public TitaniasSong(final TitaniasSong card) {
@ -71,12 +71,15 @@ public class TitaniasSong extends CardImpl {
return new TitaniasSong(this);
}
}
class TitaniasSongEffect extends ContinuousEffectImpl {
private static final FilterArtifactPermanent filter = new FilterArtifactPermanent();
static {
filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
}
public TitaniasSongEffect(Duration duration) {
super(duration, Outcome.BecomeCreature);
staticText = "Each noncreature artifact loses its abilities and is an artifact creature with power and toughness each equal to its converted mana cost";
@ -97,8 +100,8 @@ class TitaniasSongEffect extends ContinuousEffectImpl {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
affectedObjectList.clear();
for(Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)){
if(permanent != null){
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
if (permanent != null) {
affectedObjectList.add(new MageObjectReference(permanent, game));
permanent.addCardType(CardType.CREATURE);
}
@ -106,18 +109,18 @@ class TitaniasSongEffect extends ContinuousEffectImpl {
}
break;
case AbilityAddingRemovingEffects_6:
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null){
permanent.removeAllAbilities(source.getSourceId(), game);
}
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
permanent.removeAllAbilities(source.getSourceId(), game);
}
break;
}
break;
case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null){
if (permanent != null) {
int manaCost = permanent.getConvertedManaCost();
permanent.getPower().setValue(manaCost);
permanent.getToughness().setValue(manaCost);
@ -133,7 +136,6 @@ class TitaniasSongEffect extends ContinuousEffectImpl {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.PTChangingEffects_7 || layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4;

View file

@ -35,7 +35,6 @@ import mage.abilities.costs.common.DiscardCardCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -43,6 +42,7 @@ import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.predicate.Predicates;
@ -113,6 +113,9 @@ class ToymakerEffect extends ContinuousEffectImpl {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!artifact.isArtifact()) {
artifact.addCardType(CardType.ARTIFACT);
}
if (!artifact.isCreature()) {
artifact.addCardType(CardType.CREATURE);
}

View file

@ -76,7 +76,7 @@ public class XathridGorgon extends CardImpl {
Effect effect = new GainAbilityTargetEffect(DefenderAbility.getInstance(), Duration.Custom);
effect.setText("It gains defender");
ability.addEffect(effect);
effect = new AddCardTypeTargetEffect(CardType.ARTIFACT, Duration.Custom);
effect = new AddCardTypeTargetEffect(Duration.Custom, CardType.ARTIFACT);
effect.setText("and becomes a colorless artifact in addition to its other types");
ability.addEffect(effect);
ability.addEffect(new BecomesColorTargetEffect(new ObjectColor(), Duration.Custom, ""));

View file

@ -36,12 +36,12 @@ import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.PhaseStep;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.predicate.Predicates;
@ -125,7 +125,12 @@ class XenicPoltergeistEffect extends ContinuousEffectImpl {
UUID permanentId = targetPointer.getFirst(game, source);
Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId);
if (permanent != null) {
permanent.addCardType(CardType.CREATURE);
if (!permanent.isArtifact()) {
permanent.addCardType(CardType.ARTIFACT);
}
if (!permanent.isCreature()) {
permanent.addCardType(CardType.CREATURE);
}
}
}
break;

View file

@ -1,7 +1,29 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* 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;

View file

@ -0,0 +1,59 @@
/*
* 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.condition.Condition;
import mage.constants.Zone;
/**
*
* @author LevelX2
*/
public class CastOnlyIfConditionIsTrueAbility extends SimpleStaticAbility {
public CastOnlyIfConditionIsTrueAbility(Condition condition) {
this(condition, null);
}
public CastOnlyIfConditionIsTrueAbility(Condition condition, String effectText) {
super(Zone.ALL, new CastOnlyIfConditionIsTrueEffect(condition));
this.setRuleAtTheTop(true);
if (effectText != null) {
getEffects().get(0).setText(effectText);
}
}
private CastOnlyIfConditionIsTrueAbility(final CastOnlyIfConditionIsTrueAbility ability) {
super(ability);
}
@Override
public CastOnlyIfConditionIsTrueAbility copy() {
return new CastOnlyIfConditionIsTrueAbility(this);
}
}

View file

@ -0,0 +1,85 @@
/*
* 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.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author LevelX2
*/
public class CastOnlyIfConditionIsTrueEffect extends ContinuousRuleModifyingEffectImpl {
private final Condition condition;
public CastOnlyIfConditionIsTrueEffect(Condition condition) {
super(Duration.EndOfGame, Outcome.Detriment);
this.condition = condition;
staticText = setText();
}
private CastOnlyIfConditionIsTrueEffect(final CastOnlyIfConditionIsTrueEffect effect) {
super(effect);
this.condition = effect.condition;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
// has to return true, if the spell cannot be cast in the current phase / step
if (event.getSourceId().equals(source.getSourceId())) {
if (condition != null && !condition.apply(game, source)) {
return true;
}
}
return false; // cast not prevented by this effect
}
@Override
public CastOnlyIfConditionIsTrueEffect copy() {
return new CastOnlyIfConditionIsTrueEffect(this);
}
private String setText() {
StringBuilder sb = new StringBuilder("cast {this} only ");
if (condition != null) {
sb.append(' ').append(condition.toString());
}
return sb.toString();
}
}

View file

@ -0,0 +1,76 @@
/*
* 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.condition.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.constants.ComparisonType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class ControlsPermanentsComparedToOpponentsCondition implements Condition {
private final ComparisonType type;
private final FilterPermanent filterPermanent;
public ControlsPermanentsComparedToOpponentsCondition(ComparisonType type, FilterPermanent filterPermanent) {
this.type = type;
this.filterPermanent = filterPermanent;
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int ownNumber = game.getBattlefield().countAll(filterPermanent, source.getControllerId(), game);
for (UUID playerId : game.getOpponents(source.getControllerId())) {
if (!ComparisonType.compare(ownNumber, type, game.getBattlefield().countAll(filterPermanent, playerId, game))) {
return false;
}
}
}
return true;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("if you control ");
sb.append(type.getText1()).append(" ");
sb.append(filterPermanent.getMessage()).append(" ");
sb.append(type.getText2());
sb.append(" each opponent");
return sb.toString();
}
}

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
@ -38,8 +37,9 @@ import mage.game.permanent.Permanent;
* @author nantuko
*/
public class AddCardTypeAttachedEffect extends ContinuousEffectImpl {
private CardType addedCardType;
private AttachmentType attachmentType;
private final CardType addedCardType;
private final AttachmentType attachmentType;
public AddCardTypeAttachedEffect(CardType addedCardType, Duration duration, AttachmentType attachmentType) {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
@ -59,8 +59,9 @@ public class AddCardTypeAttachedEffect extends ContinuousEffectImpl {
Permanent equipment = game.getPermanent(source.getSourceId());
if (equipment != null && equipment.getAttachedTo() != null) {
Permanent target = game.getPermanent(equipment.getAttachedTo());
if (target != null && !target.getCardType().contains(addedCardType))
if (target != null && !target.getCardType().contains(addedCardType)) {
target.addCardType(addedCardType);
}
}
return true;
}

View file

@ -1,90 +1,112 @@
/*
* 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.continuous;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* @author emerald000
*/
public class AddCardTypeSourceEffect extends ContinuousEffectImpl {
private final CardType addedCardType;
public AddCardTypeSourceEffect(CardType addedCardType, Duration duration) {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
this.addedCardType = addedCardType;
if (addedCardType == CardType.ENCHANTMENT) {
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
}
}
public AddCardTypeSourceEffect(final AddCardTypeSourceEffect effect) {
super(effect);
this.addedCardType = effect.addedCardType;
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()), game));
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && affectedObjectList.contains(new MageObjectReference(permanent, game))) {
permanent.addCardType(addedCardType);
return true;
} else if (this.getDuration() == Duration.Custom) {
this.discard();
}
return false;
}
@Override
public AddCardTypeSourceEffect copy() {
return new AddCardTypeSourceEffect(this);
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
sb.append("{this} becomes ").append(addedCardType.toString()).append(" in addition to its other types " + this.getDuration().toString());
return sb.toString();
}
}
/*
* 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.continuous;
import java.util.ArrayList;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
* @author emerald000
*/
public class AddCardTypeSourceEffect extends ContinuousEffectImpl {
private final ArrayList<CardType> addedCardTypes = new ArrayList<>();
public AddCardTypeSourceEffect(Duration duration, CardType... addedCardType) {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
for (CardType cardType : addedCardType) {
this.addedCardTypes.add(cardType);
if (cardType == CardType.ENCHANTMENT) {
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
} else if (cardType == CardType.ARTIFACT) {
dependencyTypes.add(DependencyType.ArtifactAddingRemoving);
}
}
}
public AddCardTypeSourceEffect(final AddCardTypeSourceEffect effect) {
super(effect);
this.addedCardTypes.addAll(effect.addedCardTypes);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()), game));
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && affectedObjectList.contains(new MageObjectReference(permanent, game))) {
for (CardType cardType : addedCardTypes) {
if (!permanent.getCardType().contains(cardType)) {
permanent.addCardType(cardType);
}
}
return true;
} else if (this.getDuration() == Duration.Custom) {
this.discard();
}
return false;
}
@Override
public AddCardTypeSourceEffect copy() {
return new AddCardTypeSourceEffect(this);
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
StringBuilder sb = new StringBuilder();
sb.append("{this} becomes ");
boolean article = false;
for (CardType cardType : addedCardTypes) {
if (!article) {
if (cardType.toString().startsWith("A") || cardType.toString().startsWith("E")) {
sb.append("an ");
} else {
sb.append("a ");
}
article = true;
}
sb.append(cardType.toString().toLowerCase()).append(" ");
}
sb.append(" in addition to its other types ").append(this.getDuration().toString());
return sb.toString();
}
}

View file

@ -27,6 +27,7 @@
*/
package mage.abilities.effects.common.continuous;
import java.util.ArrayList;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
@ -45,21 +46,24 @@ import mage.game.permanent.Permanent;
*/
public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
private final CardType addedCardType;
private final ArrayList<CardType> addedCardTypes = new ArrayList<>();
public AddCardTypeTargetEffect(CardType addedCardType, Duration duration) {
public AddCardTypeTargetEffect(Duration duration, CardType... addedCardType) {
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
this.addedCardType = addedCardType;
if (addedCardType == CardType.ENCHANTMENT) {
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
} else if (addedCardType == CardType.ARTIFACT) {
dependencyTypes.add(DependencyType.ArtifactAddingRemoving);
for (CardType cardType : addedCardType) {
this.addedCardTypes.add(cardType);
if (cardType == CardType.ENCHANTMENT) {
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
} else if (cardType == CardType.ARTIFACT) {
dependencyTypes.add(DependencyType.ArtifactAddingRemoving);
}
}
}
public AddCardTypeTargetEffect(final AddCardTypeTargetEffect effect) {
super(effect);
this.addedCardType = effect.addedCardType;
this.addedCardTypes.addAll(effect.addedCardTypes);
}
@Override
@ -68,8 +72,10 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
for (UUID targetId : targetPointer.getTargets(game, source)) {
Permanent target = game.getPermanent(targetId);
if (target != null) {
if (!target.getCardType().contains(addedCardType)) {
target.addCardType(addedCardType);
for (CardType cardType : addedCardTypes) {
if (!target.getCardType().contains(cardType)) {
target.addCardType(cardType);
}
}
result = true;
}
@ -93,7 +99,23 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
return staticText;
}
StringBuilder sb = new StringBuilder();
sb.append("Target ").append(mode.getTargets().get(0).getTargetName()).append(" becomes ").append(addedCardType.toString()).append(" in addition to its other types until end of turn");
sb.append("Target ").append(mode.getTargets().get(0).getTargetName()).append(" becomes ");
boolean article = false;
for (CardType cardType : addedCardTypes) {
if (!article) {
if (cardType.toString().startsWith("A") || cardType.toString().startsWith("E")) {
sb.append("an ");
} else {
sb.append("a ");
}
article = true;
}
sb.append(cardType.toString().toLowerCase()).append(" ");
}
sb.append("in addition to its other types");
if (getDuration().equals(Duration.EndOfTurn)) {
sb.append(" until end of turn");
}
return sb.toString();
}
}

View file

@ -1,7 +1,29 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
* 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.ruleModifying;

View file

@ -54,8 +54,8 @@ public class CrewAbility extends SimpleActivatedAbility {
private final int value;
public CrewAbility(int value) {
super(Zone.BATTLEFIELD, new AddCardTypeSourceEffect(CardType.ARTIFACT, Duration.EndOfTurn), new CrewCost(value));
this.addEffect(new AddCardTypeSourceEffect(CardType.CREATURE, Duration.EndOfTurn));
super(Zone.BATTLEFIELD, new AddCardTypeSourceEffect(Duration.EndOfTurn, CardType.ARTIFACT), new CrewCost(value));
this.addEffect(new AddCardTypeSourceEffect(Duration.EndOfTurn, CardType.ARTIFACT, CardType.CREATURE));
this.value = value;
}

View file

@ -4,12 +4,16 @@ package mage.constants;
* Created by IGOUDT on 5-3-2017.
*/
public enum ComparisonType {
MORE_THAN(">"), FEWER_THAN("<"), EQUAL_TO("==");
MORE_THAN(">", "more", "than"), FEWER_THAN("<", "fewer", "than"), EQUAL_TO("==", "equal", "to");
String operator;
String text1;
String text2;
ComparisonType(String op) {
operator = op;
ComparisonType(String op, String text1, String text2) {
this.operator = op;
this.text1 = text1;
this.text2 = text2;
}
@Override
@ -17,6 +21,13 @@ public enum ComparisonType {
return operator;
}
public String getText1() {
return text1;
}
public String getText2() {
return text2;
}
public static boolean compare(int source, ComparisonType comparison, int target) {
switch (comparison) {

View file

@ -36,7 +36,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterControlledArtifactPermanent;
import static mage.filter.StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT;
import mage.game.command.Emblem;
import mage.target.TargetPermanent;
@ -49,13 +49,13 @@ public class TezzeretTheSchemerEmblem extends Emblem {
public TezzeretTheSchemerEmblem() {
this.setName("Emblem Tezzeret");
Effect effect = new AddCardTypeTargetEffect(CardType.CREATURE, Duration.EndOfGame);
Effect effect = new AddCardTypeTargetEffect(Duration.EndOfGame, CardType.ARTIFACT, CardType.CREATURE);
effect.setText("target artifact you control becomes an artifact creature");
Ability ability = new BeginningOfCombatTriggeredAbility(Zone.COMMAND, effect, TargetController.YOU, false, true);
effect = new SetPowerToughnessTargetEffect(5, 5, Duration.EndOfGame);
effect.setText("with base power and toughness 5/5");
ability.addEffect(effect);
ability.addTarget(new TargetPermanent(new FilterControlledArtifactPermanent()));
ability.addTarget(new TargetPermanent(FILTER_CONTROLLED_PERMANENT_ARTIFACT));
this.getAbilities().add(ability);
}
}