Merge origin/master

This commit is contained in:
LevelX2 2019-01-07 11:39:10 +01:00
commit 7ef0a5f654
31 changed files with 136 additions and 238 deletions

View file

@ -94,8 +94,4 @@ class BattletideAlchemistEffect extends PreventionEffectImpl {
return event.getType() == EventType.DAMAGE_PLAYER;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return super.applies(event, source, game);
}
}

View file

@ -117,7 +117,7 @@ class CloneShellDiesEffect extends OneShotEffect {
List<UUID> imprinted = permanent.getImprinted();
if (!imprinted.isEmpty()) {
Card imprintedCard = game.getCard(imprinted.get(0));
if (imprinted != null) {
if (imprintedCard != null) {
imprintedCard.setFaceDown(false, game);
if (imprintedCard.isCreature()) {
controller.moveCards(imprintedCard, Zone.BATTLEFIELD, source, game);

View file

@ -226,11 +226,6 @@ class CyclopeanTombCounterWatcher extends Watcher {
}
}
@Override
public void reset() {
super.reset();
}
public Set<MageObjectReference> landMiredByCyclopeanTombInstance(MageObjectReference mor, Game game) {
if (counterData.containsKey(mor)) {
return counterData.get(mor);

View file

@ -98,10 +98,6 @@ class DreadWightTriggeredAbility extends TriggeredAbilityImpl {
return false;
}
@Override
public String getRule() {
return super.getRule();
}
}
class DreadWightEffect extends OneShotEffect {

View file

@ -124,11 +124,9 @@ class EyeOfTheStormEffect1 extends OneShotEffect {
&& !eyeOfTheStorm.getImprinted().isEmpty()) {
CardsImpl copiedCards = new CardsImpl();
for (UUID uuid : eyeOfTheStorm.getImprinted()) {
card = game.getCard(uuid);
// Check if owner of card is still in game
if (card != null
&& game.getPlayer(card.getOwnerId()) != null) {
card = game.getCard(uuid);
if (card != null && game.getPlayer(card.getOwnerId()) != null) {
if (card.isSplitCard()) {
copiedCards.add(((SplitCard) card).getLeftHalfCard());
copiedCards.add(((SplitCard) card).getRightHalfCard());

View file

@ -1,7 +1,5 @@
package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.ManaCostsImpl;
@ -18,14 +16,16 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInGraveyard;
import mage.target.common.TargetOpponent;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class ForgottenLore extends CardImpl {
public ForgottenLore(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{G}");
// Target opponent chooses a card in your graveyard. You may pay {G}. If you do, repeat this process except that opponent can't choose a card already chosen for Forgotten Lore. Then put the last chosen card into your hand.
this.getSpellAbility().addEffect(new ForgottenLoreEffect());
@ -62,8 +62,7 @@ class ForgottenLoreEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
if(you != null && opponent != null)
{
if (you != null && opponent != null) {
FilterCard filter = new FilterCard();
filter.add(new OwnerIdPredicate(you.getId()));
Cost cost = new ManaCostsImpl("{G}");
@ -73,31 +72,31 @@ class ForgottenLoreEffect extends OneShotEffect {
do {
chosenCard = new TargetCardInGraveyard(filter);
chosenCard.setNotTarget(true);
if(chosenCard.canChoose(opponent.getId(), game)) {
if (chosenCard.canChoose(opponent.getId(), game)) {
opponent.chooseTarget(Outcome.ReturnToHand, chosenCard, source, game);
card = game.getCard(chosenCard.getFirstTarget());
filter.add(Predicates.not(new CardIdPredicate(card.getId())));
game.informPlayers("Forgotten Lore: " + opponent.getLogName() + " has chosen " + card.getLogName());
}
else {
if (card != null) {
filter.add(Predicates.not(new CardIdPredicate(card.getId())));
game.informPlayers("Forgotten Lore: " + opponent.getLogName() + " has chosen " + card.getLogName());
}
} else {
done = true;
}
if(!done) {
if(cost.canPay(source, source.getSourceId(), you.getId(), game) && you.chooseUse(Outcome.Benefit, "Pay {G} to choose a different card ?", source, game)) {
if (!done) {
if (cost.canPay(source, source.getSourceId(), you.getId(), game) && you.chooseUse(Outcome.Benefit, "Pay {G} to choose a different card ?", source, game)) {
cost.clearPaid();
if(!cost.pay(source, game, source.getSourceId(), you.getId(), false, null)) {
if (!cost.pay(source, game, source.getSourceId(), you.getId(), false, null)) {
done = true;
}
}
else {
} else {
done = true;
}
}
} while(!done);
} while (!done);
if(card != null) {
if (card != null) {
Cards cardsToHand = new CardsImpl();
cardsToHand.add(card);
you.moveCards(cardsToHand, Zone.HAND, source, game);

View file

@ -1,7 +1,5 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -15,8 +13,8 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
@ -26,8 +24,9 @@ import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class GalepowderMage extends CardImpl {
@ -39,7 +38,7 @@ public final class GalepowderMage extends CardImpl {
}
public GalepowderMage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}");
this.subtype.add(SubType.KITHKIN);
this.subtype.add(SubType.WIZARD);
@ -87,10 +86,10 @@ class GalepowderMageEffect extends OneShotEffect {
if (controller != null && sourceObject != null) {
if (getTargetPointer().getFirst(game, source) != null) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (permanent != null) {
UUID exileId = UUID.randomUUID();
if (controller.moveCardToExileWithInfo(permanent, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true)) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect();
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));

View file

@ -1,7 +1,5 @@
package mage.cards.g;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
@ -16,14 +14,15 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class GatherSpecimens extends CardImpl {
public GatherSpecimens(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{U}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}{U}{U}");
// If a creature would enter the battlefield under an opponent's control this turn, it enters the battlefield under your control instead.
this.getSpellAbility().addEffect(new GatherSpecimensReplacementEffect());
@ -70,7 +69,7 @@ class GatherSpecimensReplacementEffect extends ReplacementEffectImpl {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
&& ((ZoneChangeEvent) event).getToZone().match(Zone.BATTLEFIELD)) {
Card card = game.getCard(event.getTargetId());
if (card.isCreature()) { // TODO: Bestow Card cast as Enchantment probably not handled correctly
if (card != null && card.isCreature()) { // TODO: Bestow Card cast as Enchantment probably not handled correctly
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && controller.hasOpponent(event.getPlayerId(), game)) {
return true;
@ -79,9 +78,7 @@ class GatherSpecimensReplacementEffect extends ReplacementEffectImpl {
}
if (event.getType() == GameEvent.EventType.CREATE_TOKEN && event.getFlag()) { // flag indicates if it's a creature token
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && controller.hasOpponent(event.getPlayerId(), game)) {
return true;
}
return controller != null && controller.hasOpponent(event.getPlayerId(), game);
}
return false;
}

View file

@ -1,6 +1,5 @@
package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -20,8 +19,9 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author spjspj
*/
public final class GeodeGolem extends CardImpl {
@ -68,7 +68,6 @@ class GeodeGolemEffect extends OneShotEffect {
for (UUID commanderId : controller.getCommandersIds()) {
if (game.getState().getZone(commanderId) == Zone.COMMAND) {
Card commander = game.getCard(commanderId);
if (commander != null && game.getState().getZone(commanderId) == Zone.COMMAND) {
SpellAbility ability = commander.getSpellAbility();
SpellAbility newAbility = commander.getSpellAbility().copy();

View file

@ -88,11 +88,6 @@ class GuildmagesForumWatcher extends Watcher {
}
}
@Override
public void reset() {
super.reset();
}
}
class GuildmagesForumEntersBattlefieldEffect extends ReplacementEffectImpl {

View file

@ -1,14 +1,8 @@
package mage.cards.h;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterCard;
@ -16,9 +10,11 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInHand;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class HintOfInsanity extends CardImpl {
@ -62,8 +58,6 @@ class HintOfInsanityEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
FilterCard filter = new FilterCard("card from your hand");
Player targetPlayer = game.getPlayer(source.getFirstTarget());
String nameOfChosenCard;
Card chosenCard;
if (targetPlayer != null) {
TargetCardInHand targetCard = new TargetCardInHand(filter);
targetCard.setNotTarget(true);
@ -72,12 +66,12 @@ class HintOfInsanityEffect extends OneShotEffect {
targetPlayer.revealCards("Hint of Insanity Reveal", cardsInHand, game);
if (!cardsInHand.isEmpty()
&& targetPlayer.choose(Outcome.Discard, targetCard, source.getSourceId(), game)) {
chosenCard = game.getCard(targetCard.getFirstTarget());
nameOfChosenCard = chosenCard.getName();
for (Card card : cardsInHand.getCards(game)) {
if (card.getName().equals(nameOfChosenCard)
&& !card.isLand()) {
targetPlayer.discard(card, source, game);
Card chosenCard = game.getCard(targetCard.getFirstTarget());
if (chosenCard != null) {
for (Card card : cardsInHand.getCards(game)) {
if (CardUtil.haveSameNames(card, chosenCard) && !card.isLand()) {
targetPlayer.discard(card, source, game);
}
}
}
return true;

View file

@ -1,7 +1,5 @@
package mage.cards.i;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -12,11 +10,7 @@ import mage.abilities.effects.common.ExileUntilSourceLeavesEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterNonlandPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.ExileZone;
@ -26,8 +20,9 @@ import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class IxalansBinding extends CardImpl {
@ -80,10 +75,10 @@ class IxalansBindingReplacementEffect extends ContinuousRuleModifyingEffectImpl
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Card card = game.getCard(event.getSourceId());
if(event.getPlayerId().equals(source.getControllerId())){
if (event.getPlayerId().equals(source.getControllerId())) {
return false;
}
Card card = game.getCard(event.getSourceId());
if (sourcePermanent != null && card != null) {
UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (exileZone != null) {

View file

@ -1,9 +1,5 @@
package mage.cards.j;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -17,25 +13,24 @@ import mage.abilities.keyword.SuspendAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.common.FilterNonlandCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class JhoiraOfTheGhitu extends CardImpl {
public JhoiraOfTheGhitu(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{R}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD);
@ -83,13 +78,17 @@ class JhoiraOfTheGhituSuspendEffect extends OneShotEffect {
return false;
}
List<Card> cards = new ArrayList<>();
for (Cost cost: source.getCosts()) {
for (Cost cost : source.getCosts()) {
if (cost instanceof ExileFromHandCost) {
cards = ((ExileFromHandCost) cost).getCards();
}
}
if (cards != null && !cards.isEmpty()) {
// always one card to exile
Card card = game.getCard(cards.get(0).getId());
if (card == null) {
return false;
}
boolean hasSuspend = card.getAbilities().containsClass(SuspendAbility.class);
UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);

View file

@ -1,13 +1,5 @@
package mage.cards.j;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
@ -15,12 +7,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
@ -31,8 +18,9 @@ import mage.players.Player;
import mage.target.TargetCard;
import mage.target.TargetPlayer;
import java.util.*;
/**
*
* @author Quercitron
*/
public final class Juxtapose extends CardImpl {
@ -89,7 +77,6 @@ class JuxtaposeEffect extends ContinuousEffectImpl {
public void init(Ability source, Game game) {
Player you = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = game.getCard(source.getSourceId());
if (you != null && targetPlayer != null) {
Permanent permanent1 = chooseOnePermanentsWithTheHighestCMC(game, you, filter);
@ -109,6 +96,7 @@ class JuxtaposeEffect extends ContinuousEffectImpl {
permanent1.changeControllerId(targetPlayer.getId(), game);
permanent2.changeControllerId(you.getId(), game);
MageObject sourceObject = game.getCard(source.getSourceId());
game.informPlayers((sourceObject != null ? sourceObject.getLogName() : "") + ": " + you.getLogName() +
" and " + targetPlayer.getLogName() + " exchange control of " + permanent1.getLogName() +
" and " + permanent2.getName());

View file

@ -1,7 +1,5 @@
package mage.cards.k;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
@ -21,8 +19,9 @@ import mage.target.Target;
import mage.target.TargetPermanent;
import mage.target.common.TargetLandPermanent;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class Kudzu extends CardImpl {
@ -73,7 +72,6 @@ class KudzuEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent kudzu = game.getPermanentOrLKIBattlefield(source.getSourceId());
Card kudzuCard = game.getCard(source.getSourceId());
if (kudzu != null) {
Permanent enchantedLand = game.getPermanentOrLKIBattlefield(kudzu.getAttachedTo());
Player controller = game.getPlayer(source.getControllerId());
@ -86,8 +84,8 @@ class KudzuEffect extends OneShotEffect {
if (!game.getBattlefield().getAllActivePermanents(CardType.LAND).isEmpty()) { //lands are available on the battlefield
Target target = new TargetLandPermanent();
target.setNotTarget(true); //not a target, it is chosen
if (kudzuCard != null
&& landsController != null) {
Card kudzuCard = game.getCard(source.getSourceId());
if (kudzuCard != null && landsController != null) {
if (landsController.choose(Outcome.Detriment, target, source.getId(), game)) {
if (target.getFirstTarget() != null) {
Permanent landChosen = game.getPermanent(target.getFirstTarget());

View file

@ -1,7 +1,5 @@
package mage.cards.l;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -17,11 +15,7 @@ import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -32,8 +26,9 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class LegionsInitiative extends CardImpl {
@ -47,7 +42,7 @@ public final class LegionsInitiative extends CardImpl {
}
public LegionsInitiative(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{R}{W}");
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{R}{W}");
// Red creatures you control get +1/+0.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 0, Duration.WhileOnBattlefield, filterRedCreature)));
@ -136,12 +131,14 @@ class LegionsInitiativeReturnFromExileEffect extends OneShotEffect {
exile = exile.copy();
for (UUID cardId : exile) {
Card card = game.getCard(cardId);
card.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
Permanent returnedCreature = game.getPermanent(cardId);
if (returnedCreature != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(returnedCreature.getId()));
game.addEffect(effect, source);
if (card != null) {
card.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
Permanent returnedCreature = game.getPermanent(cardId);
if (returnedCreature != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(returnedCreature.getId()));
game.addEffect(effect, source);
}
}
}
game.getExile().getExileZone(source.getSourceId()).clear();

View file

@ -62,10 +62,10 @@ class LightUpTheStageEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (controller != null) {
Set<Card> cards = controller.getLibrary().getTopCards(game, 2);
controller.moveCardsToExile(cards, source, game, true, CardUtil.getCardExileZoneId(game, source), sourceCard.getIdName());
Card sourceCard = game.getCard(source.getSourceId());
controller.moveCardsToExile(cards, source, game, true, CardUtil.getCardExileZoneId(game, source), sourceCard != null ? sourceCard.getIdName() : "");
for (Card card : cards) {
ContinuousEffect effect = new LightUpTheStageMayPlayEffect();
@ -107,9 +107,7 @@ class LightUpTheStageMayPlayEffect extends AsThoughEffectImpl {
@Override
public boolean isInactive(Ability source, Game game) {
if (castOnTurn != game.getTurnNum() && game.getPhase().getStep().getType() == PhaseStep.END_TURN) {
if (game.isActivePlayer(source.getControllerId())) {
return true;
}
return game.isActivePlayer(source.getControllerId());
}
return false;
}

View file

@ -94,11 +94,6 @@ class MartyrdomActivatedAbility extends ActivatedAbilityImpl {
this.caster = ability.caster;
}
@Override
public Effects getEffects(Game game, EffectType effectType) {
return super.getEffects(game, effectType);
}
@Override
public ActivationStatus canActivate(UUID playerId, Game game) {
if (playerId.equals(caster)) {

View file

@ -77,11 +77,6 @@ class MerseineActivatedAbility extends SimpleActivatedAbility {
super(ability);
}
@Override
public Effects getEffects(Game game, EffectType effectType) {
return super.getEffects(game, effectType);
}
@Override
public ActivationStatus canActivate(UUID playerId, Game game) {
Permanent sourcePermanent = game.getBattlefield().getPermanent(this.getSourceId());

View file

@ -1,7 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
@ -13,17 +11,13 @@ import mage.abilities.keyword.TrampleAbility;
import mage.cards.Card;
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.SubLayer;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author L_J
*/
public final class MinionOfTheWastes extends CardImpl {
@ -39,7 +33,7 @@ public final class MinionOfTheWastes extends CardImpl {
// As Minion of the Wastes enters the battlefield, pay any amount of life. The amount you pay can't be more than the total number of white nontoken permanents your opponents control plus the total number of white cards in their graveyards.
this.addAbility(new AsEntersBattlefieldAbility(new MinionOfTheWastesEffect()));
// Minion of the Wastes's power and toughness are each equal to the life paid as it entered the battlefield.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new InfoEffect("{this}'s power and toughness are each equal to the life paid as it entered the battlefield")));
}
@ -74,10 +68,10 @@ class MinionOfTheWastesEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card sourceCard = game.getCard(source.getSourceId());
int payAmount = controller.getAmount(0, controller.getLife(), "Pay any amount of life", game);
controller.loseLife(payAmount, game, false);
game.informPlayers(sourceCard.getLogName() + ": " + controller.getLogName() +
Card sourceCard = game.getCard(source.getSourceId());
game.informPlayers((sourceCard != null ? sourceCard.getLogName() : "") + ": " + controller.getLogName() +
" pays " + payAmount + " life");
game.addEffect(new SetPowerToughnessSourceEffect(payAmount, payAmount, Duration.Custom, SubLayer.SetPT_7b), source);
return true;

View file

@ -1,6 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -8,21 +7,18 @@ import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.TransformAbility;
import mage.cards.Card;
import mage.constants.SubType;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
import mage.watchers.common.CreatureWasCastWatcher;
import java.util.UUID;
/**
*
* @author TheElk801
*/
public final class Mistcaller extends CardImpl {
@ -96,14 +92,14 @@ class ContainmentPriestReplacementEffect extends ReplacementEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) {
if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD) {
Card card = game.getCard(event.getTargetId());
Object entersTransformed = game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + event.getTargetId());
if (entersTransformed instanceof Boolean && (Boolean) entersTransformed && card.getSecondCardFace() != null) {
card = card.getSecondCardFace();
}
if (card.isCreature()) { // TODO: Bestow Card cast as Enchantment probably not handled correctly
CreatureWasCastWatcher watcher = game.getState().getWatcher(CreatureWasCastWatcher.class);
if (watcher != null && !watcher.wasCreatureCastThisTurn(event.getTargetId())) {
return true;
if (card != null) {
Object entersTransformed = game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + event.getTargetId());
if (entersTransformed instanceof Boolean && (Boolean) entersTransformed && card.getSecondCardFace() != null) {
card = card.getSecondCardFace();
}
if (card != null && card.isCreature()) { // TODO: Bestow Card cast as Enchantment probably not handled correctly
CreatureWasCastWatcher watcher = game.getState().getWatcher(CreatureWasCastWatcher.class);
return watcher != null && !watcher.wasCreatureCastThisTurn(event.getTargetId());
}
}
}

View file

@ -1,7 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -14,8 +12,9 @@ import mage.game.Game;
import mage.game.permanent.token.MoltenBirthElementalToken;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class MoltenBirth extends CardImpl {
@ -57,13 +56,15 @@ class MoltenBirthEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card molten = game.getCard(source.getSourceId());
if (controller != null) {
MoltenBirthElementalToken token = new MoltenBirthElementalToken();
token.putOntoBattlefield(2, game, source.getSourceId(), source.getControllerId());
if (controller.flipCoin(game)) {
molten.moveToZone(Zone.HAND, source.getSourceId(), game, true);
game.informPlayers(controller.getLogName() + " won the flip. " + molten.getLogName() + " is returned to " + controller.getLogName() + "'s hand.");
Card molten = game.getCard(source.getSourceId());
if (molten != null) {
molten.moveToZone(Zone.HAND, source.getSourceId(), game, true);
game.informPlayers(controller.getLogName() + " won the flip. " + molten.getLogName() + " is returned to " + controller.getLogName() + "'s hand.");
}
}
return true;
}

View file

@ -59,11 +59,6 @@ class NightcreepLandEffect extends BecomesBasicLandTargetEffect {
this.setTargetPointer(new FixedTargets(targets, game));
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
return super.apply(layer, sublayer, source, game);
}
@Override
public NightcreepLandEffect copy() {
return new NightcreepLandEffect(this);
@ -88,11 +83,6 @@ class NightcreepCreatureEffect extends BecomesColorTargetEffect {
this.setTargetPointer(new FixedTargets(targets, game));
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
return super.apply(layer, sublayer, source, game);
}
@Override
public NightcreepCreatureEffect copy() {
return new NightcreepCreatureEffect(this);

View file

@ -98,8 +98,4 @@ class PatriciansScornWatcher extends Watcher {
}
}
@Override
public void reset() {
super.reset();
}
}

View file

@ -64,11 +64,6 @@ class TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent extends
super(target);
}
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
return super.canTarget(controllerId, id, source, game);
}
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<>();

View file

@ -69,11 +69,6 @@ class TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent extend
super(target);
}
@Override
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
return super.canTarget(controllerId, id, source, game);
}
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<>();

View file

@ -1,7 +1,5 @@
package mage.abilities.effects;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
@ -19,6 +17,8 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInGraveyard;
import java.util.UUID;
/**
* Cards with the Aura subtype don't change the zone they are in, if there is no
* valid target on the battlefield. Also, when entering the battlefield and it
@ -60,6 +60,9 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
Card card = game.getCard(event.getTargetId());
UUID sourceId = event.getSourceId();
UUID controllerId = event.getPlayerId();
if (card == null) {
return false;
}
if (game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null) {
card = card.getSecondCardFace();
@ -149,7 +152,6 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
}
Player targetPlayer = game.getPlayer(targetId);
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
card = game.getCard(event.getTargetId());
card.removeFromZone(game, fromZone, sourceId);
PermanentCard permanent = new PermanentCard(card, (controllingPlayer == null ? card.getOwnerId() : controllingPlayer.getId()), game);
ZoneChangeEvent zoneChangeEvent = new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD);
@ -184,14 +186,12 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD
&& (((ZoneChangeEvent) event).getFromZone() != Zone.STACK)) {
Card card = game.getCard(event.getTargetId());
if (card != null && (card.isEnchantment() && card.hasSubtype(SubType.AURA, game)
return card != null && (card.isEnchantment() && card.hasSubtype(SubType.AURA, game)
|| // in case of transformable enchantments
(game.getState().getValue(TransformAbility.VALUE_KEY_ENTER_TRANSFORMED + card.getId()) != null
&& card.getSecondCardFace() != null
&& card.getSecondCardFace().isEnchantment()
&& card.getSecondCardFace().hasSubtype(SubType.AURA, game)))) {
return true;
}
&& card.getSecondCardFace() != null
&& card.getSecondCardFace().isEnchantment()
&& card.getSecondCardFace().hasSubtype(SubType.AURA, game)));
}
return false;
}

View file

@ -1,8 +1,5 @@
package mage.abilities.effects.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -14,11 +11,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.EmptyToken;
@ -27,8 +20,11 @@ import mage.util.CardUtil;
import mage.util.functions.ApplyToPermanent;
import mage.util.functions.EmptyApplyToPermanent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public class CreateTokenCopyTargetEffect extends OneShotEffect {
@ -73,12 +69,11 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
}
/**
*
* @param playerId null the token is controlled/owned by the controller of
* the source ability
* @param playerId null the token is controlled/owned by the controller of
* the source ability
* @param additionalCardType the token gains this card type in addition
* @param hasHaste the token gains haste
* @param number number of tokens to put into play
* @param hasHaste the token gains haste
* @param number number of tokens to put into play
* @param tapped
* @param attacking
*/
@ -165,7 +160,7 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
copyFrom = game.getCard(getTargetPointer().getFirst(game, source));
}
if (permanent == null && copyFrom == null) {
if (copyFrom == null) {
return false;
}

View file

@ -1,8 +1,5 @@
package mage.abilities.effects.common.discard;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
@ -20,8 +17,10 @@ import mage.target.TargetCard;
import mage.target.common.TargetCardInHand;
import mage.util.CardUtil;
import java.util.List;
import java.util.UUID;
/**
*
* @author noxx
*/
public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
@ -98,7 +97,6 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (player != null && controller != null) {
if (revealAllCards) {
this.numberCardsToReveal = new StaticValue(player.getHand().size());
@ -125,6 +123,7 @@ public class DiscardCardYouChooseTargetEffect extends OneShotEffect {
revealedCards.addAll(player.getHand());
}
Card sourceCard = game.getCard(source.getSourceId());
player.revealCards(sourceCard != null ? sourceCard.getIdName() + " (" + sourceCard.getZoneChangeCounter(game) + ')' : "Discard", revealedCards, game);
boolean result = true;

View file

@ -544,7 +544,7 @@ public class GameState implements Serializable, Copyable<GameState> {
return watcherClass.cast(watchers.get(watcherClass.getSimpleName(), uuid.toString()));
}
public <T extends Watcher> T getWatcher(Class<T> watcherClass,String prefix) {
public <T extends Watcher> T getWatcher(Class<T> watcherClass, String prefix) {
return watcherClass.cast(watchers.get(watcherClass.getSimpleName(), prefix));
}
@ -776,7 +776,9 @@ public class GameState implements Serializable, Copyable<GameState> {
ZoneChangeEvent castEvent = (ZoneChangeEvent) event;
UUID targetId = castEvent.getTargetId();
Card card = game.getCard(targetId);
movedCards.add(card);
if (card != null) {
movedCards.add(card);
}
}
ZoneChangeData eventData = entry.getKey();
if (!movedCards.isEmpty()) {
@ -1117,7 +1119,7 @@ public class GameState implements Serializable, Copyable<GameState> {
this.watchers.add(watcher);
}
public void resetWatchers(){
public void resetWatchers() {
this.watchers.reset();
}

View file

@ -186,7 +186,9 @@ public class Library implements Serializable {
Map<String, Card> cards = new HashMap<>();
for (UUID cardId : library) {
Card card = game.getCard(cardId);
cards.putIfAbsent(card.getName(), card);
if (card != null) {
cards.putIfAbsent(card.getName(), card);
}
}
return cards.values();
}