mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
add nullchecks for game.getObject
This commit is contained in:
parent
09dd9d5a26
commit
da3c861344
80 changed files with 408 additions and 354 deletions
|
@ -78,6 +78,9 @@ class AbeyanceEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (source.getFirstTarget() != null && source.getFirstTarget().equals(event.getPlayerId())) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if(object == null){
|
||||
return false;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
||||
if (object.isInstant() || object.isSorcery()) {
|
||||
return true;
|
||||
|
|
|
@ -98,19 +98,19 @@ class AcolytesRewardEffect extends PreventionEffectImpl {
|
|||
result = true;
|
||||
}
|
||||
if (toPrevent > 0) {
|
||||
game.informPlayers(new StringBuilder("Acolyte's Reward ").append("prevented ").append(toPrevent).append(" to ").append(targetCreature.getName()).toString());
|
||||
game.informPlayers("Acolyte's Reward prevented " + toPrevent + " to " + targetCreature.getName());
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent));
|
||||
|
||||
Player targetPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
|
||||
if (targetPlayer != null) {
|
||||
targetPlayer.damage(toPrevent, source.getSourceId(), game, false, true);
|
||||
game.informPlayers(new StringBuilder("Acolyte's Reward ").append("deals ").append(toPrevent).append(" damage to ").append(targetPlayer.getLogName()).toString());
|
||||
game.informPlayers("Acolyte's Reward deals " + toPrevent + " damage to " + targetPlayer.getLogName());
|
||||
} else {
|
||||
Permanent targetDamageCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||
if (targetDamageCreature != null) {
|
||||
targetDamageCreature.damage(toPrevent, source.getSourceId(), game, false, true);
|
||||
game.informPlayers(new StringBuilder("Acolyte's Reward ").append("deals ").append(toPrevent).append(" damage to ").append(targetDamageCreature.getName()).toString());
|
||||
game.informPlayers("Acolyte's Reward deals " + toPrevent + " damage to " + targetDamageCreature.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class AdviceFromTheFaeEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
if (controller != null) {
|
||||
if (controller != null && mageObject != null) {
|
||||
Set<Card> topCards = controller.getLibrary().getTopCards(game, 5);
|
||||
Cards cardsFromLibrary = new CardsImpl();
|
||||
for (Card card : topCards) {
|
||||
|
|
|
@ -100,7 +100,7 @@ class AllianceOfArmsEffect extends OneShotEffect {
|
|||
payed = true;
|
||||
}
|
||||
}
|
||||
game.informPlayers(new StringBuilder(player.getLogName()).append(" pays {").append(xValue).append("}.").toString());
|
||||
game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
|
||||
return xValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,9 +91,7 @@ class AvenEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("If you do, that creature has base power and toughness 3/1 and has flying for as long as it has a feather counter on it");
|
||||
return sb.toString();
|
||||
return "If you do, that creature has base power and toughness 3/1 and has flying for as long as it has a feather counter on it";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class AvenShrineTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
MageObject mageObject = game.getObject(sourceId);
|
||||
if (spell != null) {
|
||||
if (spell != null && mageObject != null) {
|
||||
game.getState().setValue("avenShrine" + mageObject, spell);
|
||||
return true;
|
||||
}
|
||||
|
@ -91,21 +91,23 @@ class AvenShrineEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
int count = 0;
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
Spell spell = (Spell) game.getState().getValue("avenShrine" + mageObject);
|
||||
if (spell != null) {
|
||||
Player controller = game.getPlayer(spell.getControllerId());
|
||||
if (controller != null) {
|
||||
String name = spell.getName();
|
||||
FilterCard filterCardName = new FilterCard();
|
||||
filterCardName.add(new NamePredicate(name));
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filterCardName, game);
|
||||
if(mageObject != null) {
|
||||
Spell spell = (Spell) game.getState().getValue("avenShrine" + mageObject);
|
||||
if (spell != null) {
|
||||
Player controller = game.getPlayer(spell.getControllerId());
|
||||
if (controller != null) {
|
||||
String name = spell.getName();
|
||||
FilterCard filterCardName = new FilterCard();
|
||||
filterCardName.add(new NamePredicate(name));
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filterCardName, game);
|
||||
}
|
||||
}
|
||||
controller.gainLife(count, game, source);
|
||||
return true;
|
||||
}
|
||||
controller.gainLife(count, game, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -106,7 +106,7 @@ class BalaGedThiefEffect extends OneShotEffect {
|
|||
Card card = revealedCards.get(targetInHand.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
targetPlayer.discard(card, source, game);
|
||||
game.informPlayers(new StringBuilder("Bala Ged Thief: ").append(targetPlayer.getLogName()).append(" discarded ").append(card.getName()).toString());
|
||||
game.informPlayers("Bala Ged Thief: " + targetPlayer.getLogName() + " discarded " + card.getName());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -112,7 +112,7 @@ class BaneAlleyBrokerDrawExileEffect extends OneShotEffect {
|
|||
Card card = game.getCard(target.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (card != null && sourceObject != null) {
|
||||
if (card.moveToExile(CardUtil.getCardExileZoneId(game, source), new StringBuilder(sourceObject.getName()).toString(), source.getSourceId(), game)) {
|
||||
if (card.moveToExile(CardUtil.getCardExileZoneId(game, source), sourceObject.getName(), source.getSourceId(), game)) {
|
||||
card.setFaceDown(true, game);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -105,6 +105,6 @@ class BlazeCommandoTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return new StringBuilder("Whenever an instant or sorcery spell you control deals damage, ").append(super.getRule()).toString();
|
||||
return "Whenever an instant or sorcery spell you control deals damage, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,13 +75,15 @@ class BlazingHopeTarget extends TargetCreaturePermanent {
|
|||
int count = 0;
|
||||
Player controller = game.getPlayer(sourceControllerId);
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId())) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (controller != null && permanent.getPower().getValue() >= controller.getLife()) {
|
||||
count++;
|
||||
if (count >= remainingTargets) {
|
||||
return true;
|
||||
if(targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId())) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (controller != null && permanent.getPower().getValue() >= controller.getLife()) {
|
||||
count++;
|
||||
if (count >= remainingTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class BloodlineShamanEffect extends OneShotEffect {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||
if (controller != null && controller.choose(outcome, typeChoice, game)) {
|
||||
if (controller != null && sourceObject != null && controller.choose(outcome, typeChoice, game)) {
|
||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||
FilterCard filterSubtype = new FilterCard();
|
||||
filterSubtype.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
|
|
|
@ -178,7 +178,7 @@ class BombSquadBeginningEffect extends OneShotEffect {
|
|||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
||||
permanent.addCounters(CounterType.FUSE.createInstance(), source, game);
|
||||
|
||||
game.informPlayers(new StringBuilder(card.getName()).append(" puts a fuse counter on ").append(permanent.getName()).toString());
|
||||
game.informPlayers(card.getName() + " puts a fuse counter on " + permanent.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class BraceForImpactPreventDamageTargetEffect extends PreventionEffectImpl {
|
|||
Permanent targetPermanent = game.getPermanent(source.getTargets().getFirstTarget());
|
||||
if (targetPermanent != null) {
|
||||
targetPermanent.addCounters(CounterType.P1P1.createInstance(prevented), source, game);
|
||||
game.informPlayers(new StringBuilder("Brace for Impact: Prevented ").append(prevented).append(" damage ").toString());
|
||||
game.informPlayers("Brace for Impact: Prevented " + prevented + " damage ");
|
||||
game.informPlayers("Brace for Impact: Adding " + prevented + " +1/+1 counters to " + targetPermanent.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class BrandedBrawlersCantBlockEffect extends RestrictionEffect {
|
|||
public BrandedBrawlersCantBlockEffect(FilterPermanent filter) {
|
||||
super(Duration.WhileOnBattlefield);
|
||||
this.filter = filter;
|
||||
staticText = new StringBuilder("{this} can't attack if you control ").append(filter.getMessage()).toString();
|
||||
staticText = "{this} can't attack if you control " + filter.getMessage();
|
||||
}
|
||||
|
||||
public BrandedBrawlersCantBlockEffect(final BrandedBrawlersCantBlockEffect effect) {
|
||||
|
|
|
@ -67,7 +67,7 @@ class CabalShrineTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
MageObject mageObject = game.getObject(sourceId);
|
||||
if (spell != null) {
|
||||
if (spell != null && mageObject != null) {
|
||||
game.getState().setValue("cabalShrine" + mageObject, spell);
|
||||
return true;
|
||||
}
|
||||
|
@ -91,21 +91,23 @@ class CabalShrineEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
int count = 0;
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
Spell spell = (Spell) game.getState().getValue("cabalShrine" + mageObject);
|
||||
if (spell != null) {
|
||||
Player controller = game.getPlayer(spell.getControllerId());
|
||||
if (controller != null) {
|
||||
String name = spell.getName();
|
||||
FilterCard filterCardName = new FilterCard();
|
||||
filterCardName.add(new NamePredicate(name));
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filterCardName, game);
|
||||
if(mageObject != null) {
|
||||
Spell spell = (Spell) game.getState().getValue("cabalShrine" + mageObject);
|
||||
if (spell != null) {
|
||||
Player controller = game.getPlayer(spell.getControllerId());
|
||||
if (controller != null) {
|
||||
String name = spell.getName();
|
||||
FilterCard filterCardName = new FilterCard();
|
||||
filterCardName.add(new NamePredicate(name));
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filterCardName, game);
|
||||
}
|
||||
}
|
||||
controller.discard(count, false, source, game);
|
||||
return true;
|
||||
}
|
||||
controller.discard(count, false, source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -92,8 +92,8 @@ class CandlesGlowPreventDamageTargetEffect extends PreventionEffectImpl {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
controller.gainLife(prevented, game, source);
|
||||
game.informPlayers(new StringBuilder("Candles' Glow: Prevented ").append(prevented).append(" damage ").toString());
|
||||
game.informPlayers(new StringBuilder("Candles' Glow: ").append(controller.getLogName()).append(" gained ").append(prevented).append("life").toString());
|
||||
game.informPlayers("Candles' Glow: Prevented " + prevented + " damage ");
|
||||
game.informPlayers("Candles' Glow: " + controller.getLogName() + " gained " + prevented + "life");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,8 +98,7 @@ class CarpetOfFlowersTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder("At the beginning of each of your main phases, if you haven't added mana with this ability this turn, ");
|
||||
return sb.append(super.getRule()).toString();
|
||||
return "At the beginning of each of your main phases, if you haven't added mana with this ability this turn, " + super.getRule();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ class CavernOfSoulsManaCondition extends CreatureCastManaCondition {
|
|||
if (super.apply(game, source)) {
|
||||
// check: ... of the chosen type
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (creatureType != null && object.hasSubtype(creatureType, game)) {
|
||||
if (creatureType != null && object != null && object.hasSubtype(creatureType, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ class CephalidShrineTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
MageObject mageObject = game.getObject(sourceId);
|
||||
if (spell != null) {
|
||||
if (spell != null && mageObject != null) {
|
||||
game.getState().setValue("cephalidShrine" + mageObject, spell);
|
||||
return true;
|
||||
}
|
||||
|
@ -93,31 +93,33 @@ class CephalidShrineEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
int count = 0;
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
Spell spell = (Spell) game.getState().getValue("cephalidShrine" + mageObject);
|
||||
if (spell != null) {
|
||||
Player controller = game.getPlayer(spell.getControllerId());
|
||||
if (controller != null) {
|
||||
String name = spell.getName();
|
||||
FilterCard filterCardName = new FilterCard();
|
||||
filterCardName.add(new NamePredicate(name));
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filterCardName, game);
|
||||
if(mageObject != null) {
|
||||
Spell spell = (Spell) game.getState().getValue("cephalidShrine" + mageObject);
|
||||
if (spell != null) {
|
||||
Player controller = game.getPlayer(spell.getControllerId());
|
||||
if (controller != null) {
|
||||
String name = spell.getName();
|
||||
FilterCard filterCardName = new FilterCard();
|
||||
filterCardName.add(new NamePredicate(name));
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filterCardName, game);
|
||||
}
|
||||
}
|
||||
// even if the cost is 0, we still offer
|
||||
Cost cost = new GenericManaCost(count);
|
||||
if (game.getStack().contains((StackObject) spell)
|
||||
&& cost.canPay(source, source.getSourceId(), controller.getId(), game)
|
||||
&& controller.chooseUse(outcome, "Pay " + cost.getText() + " to prevent countering " + spell.getName() + "?", source, game)
|
||||
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false)
|
||||
&& cost.isPaid()) {
|
||||
return false;
|
||||
} else {
|
||||
spell.counter(source.getId(), game);
|
||||
game.informPlayers(spell.getName() + " has been countered due to " + controller.getName() + " not paying " + cost.getText());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// even if the cost is 0, we still offer
|
||||
Cost cost = new GenericManaCost(count);
|
||||
if (game.getStack().contains((StackObject) spell)
|
||||
&& cost.canPay(source, source.getSourceId(), controller.getId(), game)
|
||||
&& controller.chooseUse(outcome, "Pay " + cost.getText() + " to prevent countering " + spell.getName() + "?", source, game)
|
||||
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false)
|
||||
&& cost.isPaid()) {
|
||||
return false;
|
||||
} else {
|
||||
spell.counter(source.getId(), game);
|
||||
game.informPlayers(spell.getName() + " has been countered due to " + controller.getName() + " not paying " + cost.getText());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ class CharmbreakerDevilsEffect extends OneShotEffect {
|
|||
if (cards.length > 0) {
|
||||
Card card = cards[RandomUtil.nextInt(cards.length)];
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
|
||||
game.informPlayers(new StringBuilder("Charmbreaker Devils: ").append(card.getName()).append(" returned to the hand of ").append(player.getLogName()).toString());
|
||||
game.informPlayers("Charmbreaker Devils: " + card.getName() + " returned to the hand of " + player.getLogName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ class CollectiveVoyageEffect extends OneShotEffect {
|
|||
game.removeBookmark(bookmark);
|
||||
}
|
||||
}
|
||||
game.informPlayers(new StringBuilder(player.getLogName()).append(" pays {").append(xValue).append("}.").toString());
|
||||
game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
|
||||
return xValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class ColossalWhaleAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return new StringBuilder("Whenever {this} attacks, ").append(super.getRule()).toString();
|
||||
return "Whenever {this} attacks, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
|
@ -27,7 +28,6 @@ import mage.target.Target;
|
|||
import mage.target.TargetPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
*/
|
||||
public final class CrownOfTheAges extends CardImpl {
|
||||
|
@ -107,7 +107,7 @@ class CrownOfTheAgesEffect extends OneShotEffect {
|
|||
}
|
||||
// Check for protection
|
||||
MageObject auraObject = game.getObject(aura.getId());
|
||||
if (creatureToAttachAura.cantBeAttachedBy(auraObject, game)) {
|
||||
if (auraObject != null && creatureToAttachAura.cantBeAttachedBy(auraObject, game)) {
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ class CrushUnderfootEffect extends OneShotEffect {
|
|||
&& controller.chooseTarget(outcome, target, source, game)) {
|
||||
Permanent giant = game.getPermanent(target.getFirstTarget());
|
||||
if (giant != null) {
|
||||
game.informPlayers(new StringBuilder("Crush Underfoot: Choosen Giant is").append(giant.getName()).toString());
|
||||
game.informPlayers("Crush Underfoot: Chosen Giant is " + giant.getName());
|
||||
Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
if (targetCreature != null) {
|
||||
targetCreature.damage(giant.getPower().getValue(), source.getSourceId(), game, false, true);
|
||||
|
|
|
@ -85,7 +85,7 @@ class CurseOfChaosTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return new StringBuilder("Whenever a player attacks enchanted player with one or more creatures, ").append(super.getRule()).toString();
|
||||
return "Whenever a player attacks enchanted player with one or more creatures, " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.EnumSet;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -27,13 +28,12 @@ import mage.target.TargetPermanent;
|
|||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class DaringThief extends CardImpl {
|
||||
|
||||
public DaringThief(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.subtype.add(SubType.ROGUE);
|
||||
|
||||
|
@ -41,7 +41,7 @@ public final class DaringThief extends CardImpl {
|
|||
this.toughness = new MageInt(3);
|
||||
|
||||
// Inspired - Whenever Daring Thief becomes untapped, you may exchange control of target nonland permanent you control and target permanent an opponent controls that shares a card type with it.
|
||||
Ability ability = new InspiredAbility(new ExchangeControlTargetEffect(Duration.EndOfGame,
|
||||
Ability ability = new InspiredAbility(new ExchangeControlTargetEffect(Duration.EndOfGame,
|
||||
"you may exchange control of target nonland permanent you control and target permanent an opponent controls that shares a card type with it", false, true), true);
|
||||
ability.addTarget(new TargetControlledPermanentSharingOpponentPermanentCardType());
|
||||
ability.addTarget(new DaringThiefSecondTarget());
|
||||
|
@ -59,23 +59,23 @@ public final class DaringThief extends CardImpl {
|
|||
}
|
||||
|
||||
class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetControlledPermanent {
|
||||
|
||||
|
||||
public TargetControlledPermanentSharingOpponentPermanentCardType() {
|
||||
super();
|
||||
this.filter = this.filter.copy();
|
||||
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
|
||||
setTargetName("nonland permanent you control");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public TargetControlledPermanentSharingOpponentPermanentCardType(final TargetControlledPermanentSharingOpponentPermanentCardType target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(controllerId, id, source, game)) {
|
||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(source.getSourceId(), controllerId, game);
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
for (CardType type : permanent.getCardType()) {
|
||||
if (cardTypes.contains(type)) {
|
||||
return true;
|
||||
|
@ -84,36 +84,38 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
// get all cardtypes from opponents permanents
|
||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(sourceId, sourceControllerId, game);
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
for (CardType type : permanent.getCardType()) {
|
||||
if (cardTypes.contains(type)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
break;
|
||||
}
|
||||
if (targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
for (CardType type : permanent.getCardType()) {
|
||||
if (cardTypes.contains(type)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TargetControlledPermanentSharingOpponentPermanentCardType copy() {
|
||||
return new TargetControlledPermanentSharingOpponentPermanentCardType(this);
|
||||
}
|
||||
|
||||
|
||||
private EnumSet<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Player controller = game.getPlayer(sourceControllerId);
|
||||
EnumSet<CardType> cardTypes =EnumSet.noneOf(CardType.class);
|
||||
EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class);
|
||||
if (controller != null) {
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(sourceControllerId, game)) {
|
||||
if (controller.hasOpponent(permanent.getControllerId(), game)) {
|
||||
cardTypes.addAll(permanent.getCardType());
|
||||
}
|
||||
|
@ -127,20 +129,20 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
|
|||
class DaringThiefSecondTarget extends TargetPermanent {
|
||||
|
||||
private Permanent firstTarget = null;
|
||||
|
||||
|
||||
public DaringThiefSecondTarget() {
|
||||
super();
|
||||
this.filter = this.filter.copy();
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
setTargetName("permanent an opponent controls that shares a card type with it");
|
||||
}
|
||||
}
|
||||
|
||||
public DaringThiefSecondTarget(final DaringThiefSecondTarget target) {
|
||||
super(target);
|
||||
this.firstTarget = target.firstTarget;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(id, source, game)) {
|
||||
|
@ -152,29 +154,31 @@ class DaringThiefSecondTarget extends TargetPermanent {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
if (firstTarget != null) {
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (permanent.shareTypes(firstTarget)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
if (targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (permanent.shareTypes(firstTarget)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
|
||||
firstTarget = game.getPermanent(source.getFirstTarget());
|
||||
return super.chooseTarget(Outcome.Damage, playerId, source, game);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaringThiefSecondTarget copy() {
|
||||
return new DaringThiefSecondTarget(this);
|
||||
|
|
|
@ -89,7 +89,7 @@ class DaxosOfMeletisEffect extends OneShotEffect {
|
|||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
if (card != null && sourceObject != null) {
|
||||
// move card to exile
|
||||
controller.moveCardsToExile(card, source, game, true, exileId, sourceObject.getIdName());
|
||||
// player gains life
|
||||
|
|
|
@ -75,7 +75,7 @@ class DeadbridgeChantEffect extends OneShotEffect {
|
|||
text = " put onto battlefield for ";
|
||||
}
|
||||
card.moveToZone(targetZone, source.getSourceId(), game, false);
|
||||
game.informPlayers(new StringBuilder("Deadbridge Chant: ").append(card.getName()).append(text).append(player.getLogName()).toString());
|
||||
game.informPlayers("Deadbridge Chant: " + card.getName() + text + player.getLogName());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public final class DeathDenied extends CardImpl {
|
|||
if (ability instanceof SpellAbility) {
|
||||
ability.getTargets().clear();
|
||||
int xValue = ability.getManaCostsToPay().getX();
|
||||
Target target = new TargetCardInYourGraveyard(xValue, new FilterCreatureCard(new StringBuilder(xValue).append(xValue != 1 ? " creature cards" : "creature card").append(" from your graveyard").toString()));
|
||||
Target target = new TargetCardInYourGraveyard(xValue, new FilterCreatureCard((xValue != 1 ? " creature cards" : "creature card") + " from your graveyard"));
|
||||
ability.addTarget(target);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ class DecayingSoilTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return new StringBuilder("Whenever a ").append(filter.getMessage()).append(" is put into your graveyard from the battlefield, ").append(super.getRule()).toString();
|
||||
return "Whenever a " + filter.getMessage() + " is put into your graveyard from the battlefield, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class DiscipleOfDeceitEffect extends OneShotEffect {
|
|||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
String targetName = new StringBuilder("card with converted mana cost of ").append(card.getConvertedManaCost()).toString();
|
||||
String targetName = "card with converted mana cost of " + card.getConvertedManaCost();
|
||||
FilterCard filter = new FilterCard(targetName);
|
||||
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, card.getConvertedManaCost()));
|
||||
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
|
||||
|
|
|
@ -96,7 +96,7 @@ class DropOfHoneyEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
if (permanentToDestroy != null) {
|
||||
game.informPlayers(new StringBuilder(sourcePermanent.getName()).append(" chosen creature: ").append(permanentToDestroy.getName()).toString());
|
||||
game.informPlayers(sourcePermanent.getName() + " chosen creature: " + permanentToDestroy.getName());
|
||||
return permanentToDestroy.destroy(source.getSourceId(), game, true);
|
||||
}
|
||||
return true;
|
||||
|
@ -128,6 +128,6 @@ class DropOfHoneyStateTriggeredAbility extends StateTriggeredAbility {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return new StringBuilder("When there are no creatures on the battlefield, ").append(super.getRule()).toString() ;
|
||||
return "When there are no creatures on the battlefield, " + super.getRule();
|
||||
}
|
||||
}
|
|
@ -119,10 +119,10 @@ public final class DustOfMoments extends CardImpl {
|
|||
card.addCounters(counter, source, game);
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ")
|
||||
.append(controller.getLogName()).append(getActionStr()).append('s')
|
||||
.append(counter.getCount()).append(' ').append(counterName.toLowerCase(Locale.ENGLISH))
|
||||
.append(" counter on ").append(card.getName()).toString());
|
||||
game.informPlayers(sourceObject.getName() + ": " +
|
||||
controller.getLogName() + getActionStr() + 's' +
|
||||
counter.getCount() + ' ' + counterName.toLowerCase(Locale.ENGLISH) +
|
||||
" counter on " + card.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,10 +144,10 @@ public final class DustOfMoments extends CardImpl {
|
|||
card.addCounters(counter, source, game);
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ")
|
||||
.append(controller.getLogName()).append(getActionStr()).append("s ")
|
||||
.append(counter.getCount()).append(' ').append(counterName.toLowerCase(Locale.ENGLISH))
|
||||
.append(" counter on ").append(card.getName()).toString());
|
||||
game.informPlayers(sourceObject.getName() + ": " +
|
||||
controller.getLogName() + getActionStr() + "s " +
|
||||
counter.getCount() + ' ' + counterName.toLowerCase(Locale.ENGLISH) +
|
||||
" counter on " + card.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class DwarvenShrineTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
MageObject mageObject = game.getObject(sourceId);
|
||||
if (spell != null) {
|
||||
if (spell != null && mageObject != null) {
|
||||
game.getState().setValue("dwarvenShrine" + mageObject, spell);
|
||||
return true;
|
||||
}
|
||||
|
@ -90,21 +90,23 @@ class DwarvenShrineEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
int count = 0;
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject);
|
||||
if (spell != null) {
|
||||
Player controller = game.getPlayer(spell.getControllerId());
|
||||
if (controller != null) {
|
||||
String name = spell.getName();
|
||||
FilterCard filterCardName = new FilterCard();
|
||||
filterCardName.add(new NamePredicate(name));
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filterCardName, game);
|
||||
if(mageObject != null) {
|
||||
Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject);
|
||||
if (spell != null) {
|
||||
Player controller = game.getPlayer(spell.getControllerId());
|
||||
if (controller != null) {
|
||||
String name = spell.getName();
|
||||
FilterCard filterCardName = new FilterCard();
|
||||
filterCardName.add(new NamePredicate(name));
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
count += player.getGraveyard().count(filterCardName, game);
|
||||
}
|
||||
}
|
||||
controller.damage(count * 2, mageObject.getId(), game, false, true);
|
||||
return true;
|
||||
}
|
||||
controller.damage(count * 2, mageObject.getId(), game, false, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -71,7 +71,7 @@ class ElbrusTheBindingBladeEffect extends OneShotEffect {
|
|||
if (attachedTo != null) {
|
||||
attachedTo.removeAttachment(equipment.getId(), game);
|
||||
equipment.transform(game);
|
||||
game.informPlayers(new StringBuilder(equipment.getName()).append(" transforms into ").append(equipment.getSecondCardFace().getName()).toString());
|
||||
game.informPlayers(equipment.getName() + " transforms into " + equipment.getSecondCardFace().getName());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
package mage.cards.e;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -22,7 +23,6 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class ElvishSoultiller extends CardImpl {
|
||||
|
@ -69,18 +69,20 @@ class ElvishSoultillerEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
Choice typeChoice = new ChoiceCreatureType(mageObject);
|
||||
if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||
if (controller != null && mageObject != null) {
|
||||
Choice typeChoice = new ChoiceCreatureType(mageObject);
|
||||
if (controller.choose(outcome, typeChoice, game)) {
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||
}
|
||||
Cards cardsToLibrary = new CardsImpl();
|
||||
FilterCreatureCard filter = new FilterCreatureCard();
|
||||
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
cardsToLibrary.addAll(controller.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game));
|
||||
controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false);
|
||||
controller.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
Cards cardsToLibrary = new CardsImpl();
|
||||
FilterCreatureCard filter = new FilterCreatureCard();
|
||||
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
cardsToLibrary.addAll(controller.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game));
|
||||
controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false);
|
||||
controller.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent {
|
|||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
if (watcher != null && targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && watcher.damageSources.contains(permanent.getId())) {
|
||||
if (!notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
|
|
|
@ -56,15 +56,18 @@ class ExtinctionEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||
if (player != null && player.choose(outcome, typeChoice, game)) {
|
||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
||||
creature.destroy(source.getSourceId(), game, true);
|
||||
if (player != null && sourceObject != null) {
|
||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||
|
||||
if (player.choose(outcome, typeChoice, game)) {
|
||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
||||
creature.destroy(source.getSourceId(), game, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
|
||||
package mage.cards.g;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
|
@ -13,11 +9,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
|||
import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect;
|
||||
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.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
|
@ -27,20 +19,24 @@ import mage.players.Player;
|
|||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2 & L_J
|
||||
*/
|
||||
public final class GauntletsOfChaos extends CardImpl {
|
||||
|
||||
public GauntletsOfChaos(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{5}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}");
|
||||
|
||||
// {5}, Sacrifice Gauntlets of Chaos: Exchange control of target artifact, creature, or land you control and target permanent an opponent controls that shares one of those types with it. If those permanents are exchanged this way, destroy all Auras attached to them.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExchangeControlTargetEffect(Duration.EndOfGame,
|
||||
"exchange control of target artifact, creature, or land you control and target permanent an opponent controls that shares one of those types with it."
|
||||
+ " If those permanents are exchanged this way, destroy all Auras attached to them", false, true, true),
|
||||
new ManaCostsImpl("{5}")
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExchangeControlTargetEffect(Duration.EndOfGame,
|
||||
"exchange control of target artifact, creature, or land you control and target permanent an opponent controls that shares one of those types with it."
|
||||
+ " If those permanents are exchanged this way, destroy all Auras attached to them", false, true, true),
|
||||
new ManaCostsImpl("{5}")
|
||||
);
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
ability.addTarget(new GauntletsOfChaosFirstTarget());
|
||||
|
@ -59,7 +55,7 @@ public final class GauntletsOfChaos extends CardImpl {
|
|||
}
|
||||
|
||||
class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
||||
|
||||
|
||||
public GauntletsOfChaosFirstTarget() {
|
||||
super();
|
||||
this.filter = this.filter.copy();
|
||||
|
@ -68,17 +64,17 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
|||
new CardTypePredicate(CardType.CREATURE),
|
||||
new CardTypePredicate(CardType.LAND)));
|
||||
setTargetName("artifact, creature, or land you control");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public GauntletsOfChaosFirstTarget(final GauntletsOfChaosFirstTarget target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(controllerId, id, source, game)) {
|
||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(source.getSourceId(), controllerId, game);
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
for (CardType type : permanent.getCardType()) {
|
||||
if (cardTypes.contains(type)) {
|
||||
return true;
|
||||
|
@ -87,36 +83,38 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
// get all cardtypes from opponents permanents
|
||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(sourceId, sourceControllerId, game);
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
for (CardType type : permanent.getCardType()) {
|
||||
if (cardTypes.contains(type)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
break;
|
||||
}
|
||||
if (targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
for (CardType type : permanent.getCardType()) {
|
||||
if (cardTypes.contains(type)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GauntletsOfChaosFirstTarget copy() {
|
||||
return new GauntletsOfChaosFirstTarget(this);
|
||||
}
|
||||
|
||||
|
||||
private EnumSet<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Player controller = game.getPlayer(sourceControllerId);
|
||||
EnumSet<CardType> cardTypes =EnumSet.noneOf(CardType.class);
|
||||
EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class);
|
||||
if (controller != null) {
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(sourceControllerId, game)) {
|
||||
if (controller.hasOpponent(permanent.getControllerId(), game)) {
|
||||
cardTypes.addAll(permanent.getCardType());
|
||||
}
|
||||
|
@ -130,20 +128,20 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
|||
class GauntletsOfChaosSecondTarget extends TargetPermanent {
|
||||
|
||||
private Permanent firstTarget = null;
|
||||
|
||||
|
||||
public GauntletsOfChaosSecondTarget() {
|
||||
super();
|
||||
this.filter = this.filter.copy();
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
setTargetName("permanent an opponent controls that shares one of those types with it");
|
||||
}
|
||||
}
|
||||
|
||||
public GauntletsOfChaosSecondTarget(final GauntletsOfChaosSecondTarget target) {
|
||||
super(target);
|
||||
this.firstTarget = target.firstTarget;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(id, source, game)) {
|
||||
|
@ -155,29 +153,31 @@ class GauntletsOfChaosSecondTarget extends TargetPermanent {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
if (firstTarget != null) {
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (permanent.shareTypes(firstTarget)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
if (targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (permanent.shareTypes(firstTarget)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
|
||||
firstTarget = game.getPermanent(source.getFirstTarget());
|
||||
return super.chooseTarget(Outcome.Damage, playerId, source, game);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public GauntletsOfChaosSecondTarget copy() {
|
||||
return new GauntletsOfChaosSecondTarget(this);
|
||||
|
|
|
@ -117,8 +117,10 @@ class GlamerSpinnersEffect extends OneShotEffect {
|
|||
}
|
||||
// Check for protection
|
||||
MageObject auraObject = game.getObject(auraId);
|
||||
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
|
||||
passed = false;
|
||||
if(auraObject != null) {
|
||||
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
|
||||
passed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class GnarlrootTrapperManaCondition extends CreatureCastManaCondition {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
if (super.apply(game, source)) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (object.hasSubtype(SubType.ELF, game)
|
||||
if (object != null && object.hasSubtype(SubType.ELF, game)
|
||||
&& object.isCreature()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ class GrenzoHavocRaiserEffect extends OneShotEffect {
|
|||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
if (card != null && sourceObject != null) {
|
||||
// move card to exile
|
||||
controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
||||
// Add effects only if the card has a spellAbility (e.g. not for lands).
|
||||
|
|
|
@ -68,7 +68,7 @@ class GridMonitorEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getPlayerId().equals(source.getControllerId())) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (object.isCreature()) {
|
||||
if (object != null && object.isCreature()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ class GrimReminderWatcher extends Watcher {
|
|||
MageObject spell = game.getObject(event.getTargetId());
|
||||
UUID playerId = event.getPlayerId();
|
||||
if (playerId != null && spell != null) {
|
||||
playersCastSpell.putIfAbsent(spell.getName(), new HashSet());
|
||||
playersCastSpell.putIfAbsent(spell.getName(), new HashSet<>());
|
||||
playersCastSpell.get(spell.getName()).add(playerId);
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ class GrimReminderWatcher extends Watcher {
|
|||
}
|
||||
|
||||
public Set<UUID> getPlayersCastSpell(String spellName) {
|
||||
return playersCastSpell.getOrDefault(spellName, new HashSet());
|
||||
return playersCastSpell.getOrDefault(spellName, new HashSet<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -172,7 +172,7 @@ class GrimoireThiefCounterspellEffect extends OneShotEffect {
|
|||
Cards cards = new CardsImpl();
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
Set<UUID> exileZones = (Set<UUID>) game.getState().getValue(GrimoireThief.VALUE_PREFIX + source.getSourceId().toString());
|
||||
if (exileZones != null) {
|
||||
if (exileZones != null && sourceObject != null) {
|
||||
for (ExileZone exileZone : game.getExile().getExileZones()) {
|
||||
if (!exileZone.isEmpty()) {
|
||||
cards.addAll(exileZone.getCards(game));
|
||||
|
|
|
@ -79,7 +79,7 @@ class GrinningTotemSearchAndExileEffect extends OneShotEffect {
|
|||
Player you = game.getPlayer(source.getControllerId());
|
||||
Player targetOpponent = game.getPlayer(source.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (you != null && targetOpponent != null) {
|
||||
if (you != null && targetOpponent != null && sourceObject != null) {
|
||||
if (targetOpponent.getLibrary().hasCards()) {
|
||||
TargetCardInLibrary targetCard = new TargetCardInLibrary();
|
||||
if (you.searchLibrary(targetCard, game, targetOpponent.getId())) {
|
||||
|
|
|
@ -72,7 +72,7 @@ class HandToHandEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
if (game.getPhase().getType() == TurnPhase.COMBAT) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
||||
if (object.isInstant()) {
|
||||
if (object != null && object.isInstant()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ class HavenOfTheSpiritManaCondition extends CreatureCastManaCondition {
|
|||
public boolean apply(Game game, Ability source, UUID manaProducer, Cost costToPay) {
|
||||
if (super.apply(game, source)) {
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (object.hasSubtype(SubType.DRAGON, game)
|
||||
if (object != null && object.hasSubtype(SubType.DRAGON, game)
|
||||
&& object.isCreature()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ class HeraldsHornEffect extends OneShotEffect {
|
|||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
|
||||
// Look at the top card of your library.
|
||||
if (controller != null && controller.getLibrary().hasCards()) {
|
||||
if (controller != null && controller.getLibrary().hasCards() && sourceObject != null) {
|
||||
Card card = controller.getLibrary().getFromTop(game);
|
||||
Cards cards = new CardsImpl(card);
|
||||
controller.lookAtCards(sourceObject.getIdName(), cards, game);
|
||||
|
|
|
@ -79,7 +79,7 @@ class JadeMonolithRedirectionEffect extends ReplacementEffectImpl {
|
|||
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
DamageEvent damageEvent = (DamageEvent) event;
|
||||
if (controller != null && targetCreature != null) {
|
||||
if (controller != null && targetCreature != null && sourceObject != null) {
|
||||
controller.damage(damageEvent.getAmount(), damageEvent.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
|
||||
StringBuilder sb = new StringBuilder(sourceObject != null ? sourceObject.getLogName() : "");
|
||||
sb.append(": ").append(damageEvent.getAmount()).append(" damage redirected from ").append(targetCreature.getLogName());
|
||||
|
|
|
@ -76,7 +76,7 @@ class JusticeTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
MageObject sourceObject = game.getObject(event.getSourceId());
|
||||
if (sourceObject.getColor(game).isRed()) {
|
||||
if (sourceObject != null && sourceObject.getColor(game).isRed()) {
|
||||
if (sourceObject instanceof Permanent && sourceObject.isCreature()
|
||||
|| sourceObject instanceof Spell) {
|
||||
this.getEffects().get(0).setValue("damageAmount", event.getAmount());
|
||||
|
|
|
@ -84,7 +84,7 @@ class KeeperOfTheBeastsTarget extends TargetPlayer {
|
|||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
Player controller = game.getPlayer(sourceControllerId);
|
||||
if (controller != null) {
|
||||
if (controller != null && targetSource != null) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null
|
||||
|
|
|
@ -88,7 +88,7 @@ class KeeperOfTheLightTarget extends TargetPlayer {
|
|||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
Player controller = game.getPlayer(sourceControllerId);
|
||||
if (controller != null) {
|
||||
if (controller != null && targetSource != null) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null
|
||||
|
|
|
@ -80,8 +80,8 @@ class ChooseLetterEffect extends OneShotEffect {
|
|||
ChoiceImpl choice = new ChoiceImpl(true);
|
||||
choice.setMessage("Choose letter");
|
||||
Set<String> choices = new HashSet<>();
|
||||
for (Character letter = 'A'; letter <= 'Z'; letter++) {
|
||||
choices.add(letter.toString());
|
||||
for (char letter = 'A'; letter <= 'Z'; letter++) {
|
||||
choices.add(Character.toString(letter));
|
||||
}
|
||||
choice.setChoices(choices);
|
||||
|
||||
|
@ -122,8 +122,8 @@ class MonkeyMonkeyMonkeyCount implements DynamicValue {
|
|||
if (permanent != null && game.getState().getValue(mageObject.getId() + "_letter") != null) {
|
||||
int letters = 0;
|
||||
for (Permanent p : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), sourceAbility.getControllerId(), sourceAbility.getSourceId(), game)) {
|
||||
Character initial = Character.toUpperCase(p.getName().charAt(0));
|
||||
if (initial.toString().equals(game.getState().getValue(mageObject.getId() + "_letter"))) {
|
||||
char initial = Character.toUpperCase(p.getName().charAt(0));
|
||||
if (Character.toString(initial).equals(game.getState().getValue(mageObject.getId() + "_letter"))) {
|
||||
letters++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class PatriarchsBiddingEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null) {
|
||||
if (controller != null && sourceObject != null) {
|
||||
Set<String> chosenTypes = new HashSet<>();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
|
|
|
@ -97,7 +97,7 @@ class PillarOfOriginsManaCondition extends CreatureCastManaCondition {
|
|||
if (super.apply(game, source)) {
|
||||
// check: ... of the chosen type
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (creatureType != null && object.hasSubtype(creatureType, game)) {
|
||||
if (creatureType != null && object != null && object.hasSubtype(creatureType, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,10 +80,12 @@ class ETBSinceYourLastTurnTarget extends TargetCreaturePermanent {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
ETBSinceYourLastTurnWatcher watcher = (ETBSinceYourLastTurnWatcher) game.getState().getWatchers().get(ETBSinceYourLastTurnWatcher.class.getSimpleName());
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if(watcher.enteredSinceLastTurn(sourceControllerId, new MageObjectReference(permanent.getId(), game))) {
|
||||
return true;
|
||||
if(targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (watcher.enteredSinceLastTurn(sourceControllerId, new MageObjectReference(permanent.getId(), game))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,9 +73,11 @@ class TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent extends
|
|||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
if(targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
|
@ -121,10 +123,12 @@ class PucasMischiefSecondTarget extends TargetPermanent {
|
|||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
if (firstTarget != null) {
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (firstTarget.getConvertedManaCost() >= permanent.getConvertedManaCost()) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
if (targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (firstTarget.getConvertedManaCost() >= permanent.getConvertedManaCost()) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,13 +82,15 @@ class ReciprocateTarget extends TargetPermanent {
|
|||
}
|
||||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||
&& watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) {
|
||||
count++;
|
||||
if (count >= remainingTargets) {
|
||||
return true;
|
||||
if(targetSource != null) {
|
||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||
&& watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) {
|
||||
count++;
|
||||
if (count >= remainingTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,12 +119,14 @@ class RemembranceEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
cardName = (String) game.getState().getValue(mageObject + "nameOfPermanent");
|
||||
if (controller != null
|
||||
&& cardName != null) {
|
||||
FilterCard filterCard = new FilterCard("card named " + cardName);
|
||||
filterCard.add(new NamePredicate(cardName));
|
||||
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filterCard), true, true).apply(game, source);
|
||||
if(mageObject != null) {
|
||||
cardName = (String) game.getState().getValue(mageObject + "nameOfPermanent");
|
||||
if (controller != null
|
||||
&& cardName != null) {
|
||||
FilterCard filterCard = new FilterCard("card named " + cardName);
|
||||
filterCard.add(new NamePredicate(cardName));
|
||||
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filterCard), true, true).apply(game, source);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -66,15 +66,17 @@ class RiptideChronologistEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||
if (player != null && player.choose(outcome, typeChoice, game)) {
|
||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
||||
creature.untap(game);
|
||||
if (player != null && sourceObject != null) {
|
||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||
if (player.choose(outcome, typeChoice, game)) {
|
||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
||||
creature.untap(game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ class SamiteMinistrationEffect extends PreventionEffectImpl {
|
|||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
PreventionEffectData preventionData = preventDamageAction(event, source, game);
|
||||
MageObject sourceObject = game.getObject(event.getSourceId());
|
||||
if (sourceObject.getColor(game).isBlack() || sourceObject.getColor(game).isRed()) {
|
||||
if (sourceObject != null && (sourceObject.getColor(game).isBlack() || sourceObject.getColor(game).isRed())) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
player.gainLife(preventionData.getPreventedDamage(), game, source);
|
||||
|
|
|
@ -4,6 +4,7 @@ package mage.cards.s;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -28,13 +29,12 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class SatyrFiredancer extends CardImpl {
|
||||
|
||||
public SatyrFiredancer(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT,CardType.CREATURE},"{1}{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{1}{R}");
|
||||
this.subtype.add(SubType.SATYR);
|
||||
|
||||
this.power = new MageInt(1);
|
||||
|
@ -47,7 +47,7 @@ public final class SatyrFiredancer extends CardImpl {
|
|||
public SatyrFiredancer(final SatyrFiredancer card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
if (ability instanceof SatyrFiredancerTriggeredAbility) {
|
||||
|
@ -59,7 +59,7 @@ public final class SatyrFiredancer extends CardImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SatyrFiredancer copy() {
|
||||
return new SatyrFiredancer(this);
|
||||
|
@ -97,15 +97,15 @@ class SatyrFiredancerTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (isControlledBy(game.getControllerId(event.getSourceId()))) {
|
||||
MageObject damageSource = game.getObject(event.getSourceId());
|
||||
if (damageSource != null) {
|
||||
if (damageSource != null) {
|
||||
if (game.getOpponents(getControllerId()).contains(event.getTargetId())) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (object.isInstant() || object.isSorcery()) {
|
||||
if (object != null && (object.isInstant() || object.isSorcery())) {
|
||||
if (!(damageSource instanceof StackObject) || !handledStackObjects.contains(damageSource.getId())) {
|
||||
if (damageSource instanceof StackObject) {
|
||||
handledStackObjects.add(damageSource.getId());
|
||||
}
|
||||
for (Effect effect: this.getEffects()) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId())); // used by adjust targets
|
||||
effect.setValue("damage", event.getAmount());
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class SatyrFiredancerDamageEffect extends OneShotEffect {
|
|||
if (targetCreature != null && controller != null) {
|
||||
int damage = (Integer) this.getValue("damage");
|
||||
if (damage > 0) {
|
||||
targetCreature.damage(damage, source.getSourceId(), game, false, true);
|
||||
targetCreature.damage(damage, source.getSourceId(), game, false, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -72,14 +72,16 @@ class TargetPermanentsThatShareCardType extends TargetPermanent {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<CardType> cardTypes = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
for (CardType cardType :permanent.getCardType()) {
|
||||
if (cardTypes.contains(cardType)) {
|
||||
return true;
|
||||
if(targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
for (CardType cardType : permanent.getCardType()) {
|
||||
if (cardTypes.contains(cardType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
cardTypes.addAll(permanent.getCardType());
|
||||
}
|
||||
cardTypes.addAll(permanent.getCardType());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -103,7 +103,7 @@ class ShiningShoalRedirectDamageTargetEffect extends RedirectDamageFromSourceToT
|
|||
return false;
|
||||
}
|
||||
// do the 2 objects match?
|
||||
if (!sourceObject.getId().equals(chosenSourceObject.getId())) {
|
||||
if (chosenSourceObject == null || !sourceObject.getId().equals(chosenSourceObject.getId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,9 +78,11 @@ class TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent extend
|
|||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
if(targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
|
@ -126,10 +128,12 @@ class SpawnbrokerSecondTarget extends TargetPermanent {
|
|||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
if (firstTarget != null) {
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (firstTarget.getPower().getValue() >= permanent.getPower().getValue()) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
if(targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (firstTarget.getPower().getValue() >= permanent.getPower().getValue()) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ class SphinxsDecreeCantCastEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
if (opponentId.equals(event.getPlayerId())) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
||||
if (object.isInstant() || object.isSorcery()) {
|
||||
if (object != null && (object.isInstant() || object.isSorcery())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ class StaffOfTheLetterMagusEffect extends OneShotEffect {
|
|||
int lifegainValue = 0;
|
||||
String spellName = spell.getName();
|
||||
for (int i = 0; i < spellName.length(); i++) {
|
||||
Character letter = spellName.charAt(i);
|
||||
char letter = spellName.charAt(i);
|
||||
String chosenLetter = (String) game.getState().getValue(mageObject.getId() + "_letter");
|
||||
if (Character.isLetter(letter) && Character.toUpperCase(letter) == chosenLetter.charAt(0)) {
|
||||
lifegainValue++;
|
||||
|
|
|
@ -85,7 +85,7 @@ class StolenStrategyEffect extends OneShotEffect {
|
|||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
if (card != null && sourceObject != null) {
|
||||
// move card to exile
|
||||
controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
||||
// Add effects only if the card has a spellAbility (e.g. not for lands).
|
||||
|
|
|
@ -85,14 +85,13 @@ class TariffEffect extends OneShotEffect {
|
|||
|
||||
Permanent creatureToPayFor = chooseOnePermanent(game, player, creatures);
|
||||
|
||||
if (creatureToPayFor != null) {
|
||||
if (creatureToPayFor != null && sourceObject != null) {
|
||||
ManaCosts manaCost = ManaCosts.removeVariableManaCost(creatureToPayFor.getManaCost());
|
||||
String message = new StringBuilder("Pay ").append(manaCost.getText()).append(" (otherwise sacrifice ")
|
||||
.append(creatureToPayFor.getName()).append(")?").toString();
|
||||
String message = "Pay " + manaCost.getText() + " (otherwise sacrifice " +
|
||||
creatureToPayFor.getName() + ")?";
|
||||
if (player.chooseUse(Outcome.Benefit, message, source, game)) {
|
||||
if (manaCost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
|
||||
game.informPlayers(new StringBuilder(sourceObject != null ? sourceObject.getName() : "")
|
||||
.append(": ").append(player.getLogName()).append(" has paid").toString());
|
||||
game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " has paid");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,10 +78,12 @@ class TargetCreatureWithPowerLessThanNumberOfCardsInYourGraveyard extends Target
|
|||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if(permanent.getPower().getValue() < game.getPlayer(sourceControllerId).getGraveyard().size()) {
|
||||
return true;
|
||||
if(targetSource != null) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (permanent.getPower().getValue() < game.getPlayer(sourceControllerId).getGraveyard().size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class TobiasBeckettEffect extends OneShotEffect {
|
|||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||
Card card = opponent.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
if (card != null && sourceObject != null) {
|
||||
// move card to exile
|
||||
controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
||||
// Add effects only if the card has a spellAbility (e.g. not for lands).
|
||||
|
|
|
@ -72,6 +72,9 @@ class ToppleTargetCreature extends TargetCreaturePermanent {
|
|||
List<Permanent> activePermanents = game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game);
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
if(targetSource == null){
|
||||
return possibleTargets;
|
||||
}
|
||||
for (Permanent permanent : activePermanents) {
|
||||
if (permanent.getPower().getValue() > maxPower) {
|
||||
maxPower = permanent.getPower().getValue();
|
||||
|
|
|
@ -107,6 +107,9 @@ class TriumphOfGerrardTargetCreature extends TargetControlledCreaturePermanent {
|
|||
List<Permanent> activePermanents = game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game);
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
if(targetSource == null){
|
||||
return possibleTargets;
|
||||
}
|
||||
for (Permanent permanent : activePermanents) {
|
||||
if (permanent.getPower().getValue() > maxPower) {
|
||||
maxPower = permanent.getPower().getValue();
|
||||
|
|
|
@ -64,31 +64,33 @@ class TsabosDecreeEffect extends OneShotEffect {
|
|||
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (player != null) {
|
||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||
if (!player.choose(outcome, typeChoice, game)) {
|
||||
return false;
|
||||
}
|
||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||
targetPlayer.revealCards("hand of " + targetPlayer.getName(), targetPlayer.getHand(), game);
|
||||
FilterCard filterCard = new FilterCard();
|
||||
filterCard.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
List<Card> toDiscard = new ArrayList<>();
|
||||
for (Card card : targetPlayer.getHand().getCards(game)) {
|
||||
if (filterCard.match(card, game)) {
|
||||
toDiscard.add(card);
|
||||
if(sourceObject != null) {
|
||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||
if (!player.choose(outcome, typeChoice, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (Card card : toDiscard) {
|
||||
targetPlayer.discard(card, source, game);
|
||||
}
|
||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
||||
if (creature.isControlledBy(targetPlayer.getId())) {
|
||||
creature.destroy(source.getSourceId(), game, true);
|
||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||
targetPlayer.revealCards("hand of " + targetPlayer.getName(), targetPlayer.getHand(), game);
|
||||
FilterCard filterCard = new FilterCard();
|
||||
filterCard.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
List<Card> toDiscard = new ArrayList<>();
|
||||
for (Card card : targetPlayer.getHand().getCards(game)) {
|
||||
if (filterCard.match(card, game)) {
|
||||
toDiscard.add(card);
|
||||
}
|
||||
}
|
||||
for (Card card : toDiscard) {
|
||||
targetPlayer.discard(card, source, game);
|
||||
}
|
||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
||||
if (creature.isControlledBy(targetPlayer.getId())) {
|
||||
creature.destroy(source.getSourceId(), game, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ class UnclaimedTerritoryManaCondition extends CreatureCastManaCondition {
|
|||
if (super.apply(game, source)) {
|
||||
// check: ... of the chosen type
|
||||
MageObject object = game.getObject(source.getSourceId());
|
||||
if (creatureType != null && object.hasSubtype(creatureType, game)) {
|
||||
if (creatureType != null && object != null && object.hasSubtype(creatureType, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,13 +72,13 @@ class LookAtRandomCardEffect extends OneShotEffect {
|
|||
Player you = game.getPlayer(source.getControllerId());
|
||||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (you != null && targetPlayer != null) {
|
||||
if (you != null && targetPlayer != null && sourceObject != null) {
|
||||
if(!targetPlayer.getHand().isEmpty())
|
||||
{
|
||||
Cards randomCard = new CardsImpl();
|
||||
Card card = targetPlayer.getHand().getRandom(game);
|
||||
randomCard.add(card);
|
||||
you.lookAtCards(sourceObject != null ? sourceObject.getName() : null, randomCard, game);
|
||||
you.lookAtCards(sourceObject.getName(), randomCard, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class VerdantSuccessionTriggeredAbility extends TriggeredAbilityImpl {
|
|||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
MageObject mageObject = game.getObject(sourceId);
|
||||
if (permanent != null
|
||||
if (permanent != null && mageObject != null
|
||||
&& filter.match(permanent, game)) {
|
||||
game.getState().setValue("verdantSuccession" + mageObject, permanent);
|
||||
return true;
|
||||
|
@ -119,21 +119,23 @@ class VerdantSuccessionEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
permanent = (Permanent) game.getState().getValue("verdantSuccession" + mageObject);
|
||||
if (permanent != null) {
|
||||
Player controller = game.getPlayer(permanent.getControllerId());
|
||||
if (controller != null) {
|
||||
FilterCard filterCard = new FilterCard("Card named " + permanent.getName());
|
||||
filterCard.add(new NamePredicate(permanent.getName()));
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filterCard);
|
||||
controller.searchLibrary(target, game);
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null
|
||||
&& controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
||||
controller.shuffleLibrary(source, game);
|
||||
if(mageObject != null) {
|
||||
permanent = (Permanent) game.getState().getValue("verdantSuccession" + mageObject);
|
||||
if (permanent != null) {
|
||||
Player controller = game.getPlayer(permanent.getControllerId());
|
||||
if (controller != null) {
|
||||
FilterCard filterCard = new FilterCard("Card named " + permanent.getName());
|
||||
filterCard.add(new NamePredicate(permanent.getName()));
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filterCard);
|
||||
controller.searchLibrary(target, game);
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null
|
||||
&& controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
||||
controller.shuffleLibrary(source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class VillainousWealthEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
if (controller != null) {
|
||||
if (controller != null && mageObject != null) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
FilterCard filter = new FilterNonlandCard();
|
||||
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
package mage.cards.w;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
|
@ -22,7 +23,6 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
*/
|
||||
public final class WalkingDesecration extends CardImpl {
|
||||
|
@ -64,14 +64,18 @@ class WalkingDesecrationEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||
if (player != null && player.choose(outcome, typeChoice, game)) {
|
||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
if (player != null) {
|
||||
if (sourceObject != null) {
|
||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||
if (player.choose(outcome, typeChoice, game)) {
|
||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
|
||||
game.addEffect(effect, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue