mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +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) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (source.getFirstTarget() != null && source.getFirstTarget().equals(event.getPlayerId())) {
|
if (source.getFirstTarget() != null && source.getFirstTarget().equals(event.getPlayerId())) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
|
if(object == null){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
||||||
if (object.isInstant() || object.isSorcery()) {
|
if (object.isInstant() || object.isSorcery()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -98,19 +98,19 @@ class AcolytesRewardEffect extends PreventionEffectImpl {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
if (toPrevent > 0) {
|
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,
|
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE,
|
||||||
source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent));
|
source.getControllerId(), source.getSourceId(), source.getControllerId(), toPrevent));
|
||||||
|
|
||||||
Player targetPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
|
Player targetPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
|
||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
targetPlayer.damage(toPrevent, source.getSourceId(), game, false, true);
|
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 {
|
} else {
|
||||||
Permanent targetDamageCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
Permanent targetDamageCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
|
||||||
if (targetDamageCreature != null) {
|
if (targetDamageCreature != null) {
|
||||||
targetDamageCreature.damage(toPrevent, source.getSourceId(), game, false, true);
|
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) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
if (controller != null) {
|
if (controller != null && mageObject != null) {
|
||||||
Set<Card> topCards = controller.getLibrary().getTopCards(game, 5);
|
Set<Card> topCards = controller.getLibrary().getTopCards(game, 5);
|
||||||
Cards cardsFromLibrary = new CardsImpl();
|
Cards cardsFromLibrary = new CardsImpl();
|
||||||
for (Card card : topCards) {
|
for (Card card : topCards) {
|
||||||
|
|
|
@ -100,7 +100,7 @@ class AllianceOfArmsEffect extends OneShotEffect {
|
||||||
payed = true;
|
payed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
game.informPlayers(new StringBuilder(player.getLogName()).append(" pays {").append(xValue).append("}.").toString());
|
game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
|
||||||
return xValue;
|
return xValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,7 @@ class AvenEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText(Mode mode) {
|
public String getText(Mode mode) {
|
||||||
StringBuilder sb = new StringBuilder();
|
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";
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class AvenShrineTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||||
MageObject mageObject = game.getObject(sourceId);
|
MageObject mageObject = game.getObject(sourceId);
|
||||||
if (spell != null) {
|
if (spell != null && mageObject != null) {
|
||||||
game.getState().setValue("avenShrine" + mageObject, spell);
|
game.getState().setValue("avenShrine" + mageObject, spell);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ class AvenShrineEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
|
if(mageObject != null) {
|
||||||
Spell spell = (Spell) game.getState().getValue("avenShrine" + mageObject);
|
Spell spell = (Spell) game.getState().getValue("avenShrine" + mageObject);
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
Player controller = game.getPlayer(spell.getControllerId());
|
Player controller = game.getPlayer(spell.getControllerId());
|
||||||
|
@ -108,6 +109,7 @@ class AvenShrineEffect extends OneShotEffect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ class BalaGedThiefEffect extends OneShotEffect {
|
||||||
Card card = revealedCards.get(targetInHand.getFirstTarget(), game);
|
Card card = revealedCards.get(targetInHand.getFirstTarget(), game);
|
||||||
if (card != null) {
|
if (card != null) {
|
||||||
targetPlayer.discard(card, source, game);
|
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;
|
return true;
|
||||||
|
|
|
@ -112,7 +112,7 @@ class BaneAlleyBrokerDrawExileEffect extends OneShotEffect {
|
||||||
Card card = game.getCard(target.getFirstTarget());
|
Card card = game.getCard(target.getFirstTarget());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
if (card != null && sourceObject != null) {
|
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);
|
card.setFaceDown(true, game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,6 @@ class BlazeCommandoTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
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,6 +75,7 @@ class BlazingHopeTarget extends TargetCreaturePermanent {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
Player controller = game.getPlayer(sourceControllerId);
|
Player controller = game.getPlayer(sourceControllerId);
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if(targetSource != null) {
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId())) {
|
if (!targets.containsKey(permanent.getId())) {
|
||||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
|
@ -87,6 +88,7 @@ class BlazingHopeTarget extends TargetCreaturePermanent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class BloodlineShamanEffect extends OneShotEffect {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
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());
|
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||||
FilterCard filterSubtype = new FilterCard();
|
FilterCard filterSubtype = new FilterCard();
|
||||||
filterSubtype.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
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)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
|
||||||
permanent.addCounters(CounterType.FUSE.createInstance(), source, 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ class BraceForImpactPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
Permanent targetPermanent = game.getPermanent(source.getTargets().getFirstTarget());
|
Permanent targetPermanent = game.getPermanent(source.getTargets().getFirstTarget());
|
||||||
if (targetPermanent != null) {
|
if (targetPermanent != null) {
|
||||||
targetPermanent.addCounters(CounterType.P1P1.createInstance(prevented), source, game);
|
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());
|
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) {
|
public BrandedBrawlersCantBlockEffect(FilterPermanent filter) {
|
||||||
super(Duration.WhileOnBattlefield);
|
super(Duration.WhileOnBattlefield);
|
||||||
this.filter = filter;
|
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) {
|
public BrandedBrawlersCantBlockEffect(final BrandedBrawlersCantBlockEffect effect) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ class CabalShrineTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||||
MageObject mageObject = game.getObject(sourceId);
|
MageObject mageObject = game.getObject(sourceId);
|
||||||
if (spell != null) {
|
if (spell != null && mageObject != null) {
|
||||||
game.getState().setValue("cabalShrine" + mageObject, spell);
|
game.getState().setValue("cabalShrine" + mageObject, spell);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ class CabalShrineEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
|
if(mageObject != null) {
|
||||||
Spell spell = (Spell) game.getState().getValue("cabalShrine" + mageObject);
|
Spell spell = (Spell) game.getState().getValue("cabalShrine" + mageObject);
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
Player controller = game.getPlayer(spell.getControllerId());
|
Player controller = game.getPlayer(spell.getControllerId());
|
||||||
|
@ -108,6 +109,7 @@ class CabalShrineEffect extends OneShotEffect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,8 @@ class CandlesGlowPreventDamageTargetEffect extends PreventionEffectImpl {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null) {
|
if (controller != null) {
|
||||||
controller.gainLife(prevented, game, source);
|
controller.gainLife(prevented, game, source);
|
||||||
game.informPlayers(new StringBuilder("Candles' Glow: Prevented ").append(prevented).append(" damage ").toString());
|
game.informPlayers("Candles' Glow: Prevented " + prevented + " damage ");
|
||||||
game.informPlayers(new StringBuilder("Candles' Glow: ").append(controller.getLogName()).append(" gained ").append(prevented).append("life").toString());
|
game.informPlayers("Candles' Glow: " + controller.getLogName() + " gained " + prevented + "life");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,7 @@ class CarpetOfFlowersTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
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 "At the beginning of each of your main phases, if you haven't added mana with this ability this turn, " + super.getRule();
|
||||||
return sb.append(super.getRule()).toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ class CavernOfSoulsManaCondition extends CreatureCastManaCondition {
|
||||||
if (super.apply(game, source)) {
|
if (super.apply(game, source)) {
|
||||||
// check: ... of the chosen type
|
// check: ... of the chosen type
|
||||||
MageObject object = game.getObject(source.getSourceId());
|
MageObject object = game.getObject(source.getSourceId());
|
||||||
if (creatureType != null && object.hasSubtype(creatureType, game)) {
|
if (creatureType != null && object != null && object.hasSubtype(creatureType, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ class CephalidShrineTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||||
MageObject mageObject = game.getObject(sourceId);
|
MageObject mageObject = game.getObject(sourceId);
|
||||||
if (spell != null) {
|
if (spell != null && mageObject != null) {
|
||||||
game.getState().setValue("cephalidShrine" + mageObject, spell);
|
game.getState().setValue("cephalidShrine" + mageObject, spell);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ class CephalidShrineEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
|
if(mageObject != null) {
|
||||||
Spell spell = (Spell) game.getState().getValue("cephalidShrine" + mageObject);
|
Spell spell = (Spell) game.getState().getValue("cephalidShrine" + mageObject);
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
Player controller = game.getPlayer(spell.getControllerId());
|
Player controller = game.getPlayer(spell.getControllerId());
|
||||||
|
@ -121,6 +122,7 @@ class CephalidShrineEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ class CharmbreakerDevilsEffect extends OneShotEffect {
|
||||||
if (cards.length > 0) {
|
if (cards.length > 0) {
|
||||||
Card card = cards[RandomUtil.nextInt(cards.length)];
|
Card card = cards[RandomUtil.nextInt(cards.length)];
|
||||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class CollectiveVoyageEffect extends OneShotEffect {
|
||||||
game.removeBookmark(bookmark);
|
game.removeBookmark(bookmark);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
game.informPlayers(new StringBuilder(player.getLogName()).append(" pays {").append(xValue).append("}.").toString());
|
game.informPlayers(player.getLogName() + " pays {" + xValue + "}.");
|
||||||
return xValue;
|
return xValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ class ColossalWhaleAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return new StringBuilder("Whenever {this} attacks, ").append(super.getRule()).toString();
|
return "Whenever {this} attacks, " + super.getRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
package mage.cards.c;
|
package mage.cards.c;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
@ -27,7 +28,6 @@ import mage.target.Target;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author spjspj
|
* @author spjspj
|
||||||
*/
|
*/
|
||||||
public final class CrownOfTheAges extends CardImpl {
|
public final class CrownOfTheAges extends CardImpl {
|
||||||
|
@ -107,7 +107,7 @@ class CrownOfTheAgesEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
// Check for protection
|
// Check for protection
|
||||||
MageObject auraObject = game.getObject(aura.getId());
|
MageObject auraObject = game.getObject(aura.getId());
|
||||||
if (creatureToAttachAura.cantBeAttachedBy(auraObject, game)) {
|
if (auraObject != null && creatureToAttachAura.cantBeAttachedBy(auraObject, game)) {
|
||||||
passed = false;
|
passed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ class CrushUnderfootEffect extends OneShotEffect {
|
||||||
&& controller.chooseTarget(outcome, target, source, game)) {
|
&& controller.chooseTarget(outcome, target, source, game)) {
|
||||||
Permanent giant = game.getPermanent(target.getFirstTarget());
|
Permanent giant = game.getPermanent(target.getFirstTarget());
|
||||||
if (giant != null) {
|
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));
|
Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||||
if (targetCreature != null) {
|
if (targetCreature != null) {
|
||||||
targetCreature.damage(giant.getPower().getValue(), source.getSourceId(), game, false, true);
|
targetCreature.damage(giant.getPower().getValue(), source.getSourceId(), game, false, true);
|
||||||
|
|
|
@ -85,7 +85,7 @@ class CurseOfChaosTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
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
|
@Override
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -27,13 +28,12 @@ import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
import mage.target.common.TargetControlledPermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class DaringThief extends CardImpl {
|
public final class DaringThief extends CardImpl {
|
||||||
|
|
||||||
public DaringThief(UUID ownerId, CardSetInfo setInfo) {
|
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.HUMAN);
|
||||||
this.subtype.add(SubType.ROGUE);
|
this.subtype.add(SubType.ROGUE);
|
||||||
|
|
||||||
|
@ -91,7 +91,8 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
|
||||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(sourceId, sourceControllerId, game);
|
Set<CardType> cardTypes = getOpponentPermanentCardTypes(sourceId, sourceControllerId, game);
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if (targetSource != null) {
|
||||||
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
for (CardType type : permanent.getCardType()) {
|
for (CardType type : permanent.getCardType()) {
|
||||||
if (cardTypes.contains(type)) {
|
if (cardTypes.contains(type)) {
|
||||||
|
@ -101,6 +102,7 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,9 +113,9 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
|
||||||
|
|
||||||
private EnumSet<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
private EnumSet<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Player controller = game.getPlayer(sourceControllerId);
|
Player controller = game.getPlayer(sourceControllerId);
|
||||||
EnumSet<CardType> cardTypes =EnumSet.noneOf(CardType.class);
|
EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class);
|
||||||
if (controller != null) {
|
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)) {
|
if (controller.hasOpponent(permanent.getControllerId(), game)) {
|
||||||
cardTypes.addAll(permanent.getCardType());
|
cardTypes.addAll(permanent.getCardType());
|
||||||
}
|
}
|
||||||
|
@ -158,6 +160,7 @@ class DaringThiefSecondTarget extends TargetPermanent {
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
if (firstTarget != null) {
|
if (firstTarget != null) {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if (targetSource != null) {
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if (permanent.shareTypes(firstTarget)) {
|
if (permanent.shareTypes(firstTarget)) {
|
||||||
|
@ -166,6 +169,7 @@ class DaringThiefSecondTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ class DaxosOfMeletisEffect extends OneShotEffect {
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||||
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
||||||
if (card != null) {
|
if (card != null && sourceObject != null) {
|
||||||
// move card to exile
|
// move card to exile
|
||||||
controller.moveCardsToExile(card, source, game, true, exileId, sourceObject.getIdName());
|
controller.moveCardsToExile(card, source, game, true, exileId, sourceObject.getIdName());
|
||||||
// player gains life
|
// player gains life
|
||||||
|
|
|
@ -75,7 +75,7 @@ class DeadbridgeChantEffect extends OneShotEffect {
|
||||||
text = " put onto battlefield for ";
|
text = " put onto battlefield for ";
|
||||||
}
|
}
|
||||||
card.moveToZone(targetZone, source.getSourceId(), game, false);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public final class DeathDenied extends CardImpl {
|
||||||
if (ability instanceof SpellAbility) {
|
if (ability instanceof SpellAbility) {
|
||||||
ability.getTargets().clear();
|
ability.getTargets().clear();
|
||||||
int xValue = ability.getManaCostsToPay().getX();
|
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);
|
ability.addTarget(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ class DecayingSoilTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
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) {
|
if (card == null) {
|
||||||
return false;
|
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);
|
FilterCard filter = new FilterCard(targetName);
|
||||||
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, card.getConvertedManaCost()));
|
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, card.getConvertedManaCost()));
|
||||||
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
|
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true).apply(game, source);
|
||||||
|
|
|
@ -96,7 +96,7 @@ class DropOfHoneyEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (permanentToDestroy != null) {
|
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 permanentToDestroy.destroy(source.getSourceId(), game, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -128,6 +128,6 @@ class DropOfHoneyStateTriggeredAbility extends StateTriggeredAbility {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
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);
|
card.addCounters(counter, source, game);
|
||||||
}
|
}
|
||||||
if (!game.isSimulation()) {
|
if (!game.isSimulation()) {
|
||||||
game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ")
|
game.informPlayers(sourceObject.getName() + ": " +
|
||||||
.append(controller.getLogName()).append(getActionStr()).append('s')
|
controller.getLogName() + getActionStr() + 's' +
|
||||||
.append(counter.getCount()).append(' ').append(counterName.toLowerCase(Locale.ENGLISH))
|
counter.getCount() + ' ' + counterName.toLowerCase(Locale.ENGLISH) +
|
||||||
.append(" counter on ").append(card.getName()).toString());
|
" counter on " + card.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,10 +144,10 @@ public final class DustOfMoments extends CardImpl {
|
||||||
card.addCounters(counter, source, game);
|
card.addCounters(counter, source, game);
|
||||||
}
|
}
|
||||||
if (!game.isSimulation()) {
|
if (!game.isSimulation()) {
|
||||||
game.informPlayers(new StringBuilder(sourceObject.getName()).append(": ")
|
game.informPlayers(sourceObject.getName() + ": " +
|
||||||
.append(controller.getLogName()).append(getActionStr()).append("s ")
|
controller.getLogName() + getActionStr() + "s " +
|
||||||
.append(counter.getCount()).append(' ').append(counterName.toLowerCase(Locale.ENGLISH))
|
counter.getCount() + ' ' + counterName.toLowerCase(Locale.ENGLISH) +
|
||||||
.append(" counter on ").append(card.getName()).toString());
|
" counter on " + card.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ class DwarvenShrineTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||||
MageObject mageObject = game.getObject(sourceId);
|
MageObject mageObject = game.getObject(sourceId);
|
||||||
if (spell != null) {
|
if (spell != null && mageObject != null) {
|
||||||
game.getState().setValue("dwarvenShrine" + mageObject, spell);
|
game.getState().setValue("dwarvenShrine" + mageObject, spell);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,7 @@ class DwarvenShrineEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
|
if(mageObject != null) {
|
||||||
Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject);
|
Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject);
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
Player controller = game.getPlayer(spell.getControllerId());
|
Player controller = game.getPlayer(spell.getControllerId());
|
||||||
|
@ -107,6 +108,7 @@ class DwarvenShrineEffect extends OneShotEffect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class ElbrusTheBindingBladeEffect extends OneShotEffect {
|
||||||
if (attachedTo != null) {
|
if (attachedTo != null) {
|
||||||
attachedTo.removeAttachment(equipment.getId(), game);
|
attachedTo.removeAttachment(equipment.getId(), game);
|
||||||
equipment.transform(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;
|
package mage.cards.e;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -22,7 +23,6 @@ import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class ElvishSoultiller extends CardImpl {
|
public final class ElvishSoultiller extends CardImpl {
|
||||||
|
@ -69,8 +69,9 @@ class ElvishSoultillerEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
|
if (controller != null && mageObject != null) {
|
||||||
Choice typeChoice = new ChoiceCreatureType(mageObject);
|
Choice typeChoice = new ChoiceCreatureType(mageObject);
|
||||||
if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
|
if (controller.choose(outcome, typeChoice, game)) {
|
||||||
if (!game.isSimulation()) {
|
if (!game.isSimulation()) {
|
||||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||||
}
|
}
|
||||||
|
@ -82,6 +83,7 @@ class ElvishSoultillerEffect extends OneShotEffect {
|
||||||
controller.shuffleLibrary(source, game);
|
controller.shuffleLibrary(source, game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TargetCreaturePermanentThatDealtDamageThisTurn extends TargetPermanent {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get(SourceDidDamageWatcher.class.getSimpleName());
|
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)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && watcher.damageSources.contains(permanent.getId())) {
|
if (!targets.containsKey(permanent.getId()) && watcher.damageSources.contains(permanent.getId())) {
|
||||||
if (!notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
|
|
|
@ -56,8 +56,10 @@ class ExtinctionEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
|
if (player != null && sourceObject != null) {
|
||||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||||
if (player != null && player.choose(outcome, typeChoice, game)) {
|
|
||||||
|
if (player.choose(outcome, typeChoice, game)) {
|
||||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||||
|
@ -66,6 +68,7 @@ class ExtinctionEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
|
|
||||||
package mage.cards.g;
|
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.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
@ -13,11 +9,7 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect;
|
import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.TargetController;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||||
|
@ -27,14 +19,18 @@ import mage.players.Player;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
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
|
* @author LevelX2 & L_J
|
||||||
*/
|
*/
|
||||||
public final class GauntletsOfChaos extends CardImpl {
|
public final class GauntletsOfChaos extends CardImpl {
|
||||||
|
|
||||||
public GauntletsOfChaos(UUID ownerId, CardSetInfo setInfo) {
|
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.
|
// {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,
|
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExchangeControlTargetEffect(Duration.EndOfGame,
|
||||||
|
@ -94,7 +90,8 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
||||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(sourceId, sourceControllerId, game);
|
Set<CardType> cardTypes = getOpponentPermanentCardTypes(sourceId, sourceControllerId, game);
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if (targetSource != null) {
|
||||||
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
for (CardType type : permanent.getCardType()) {
|
for (CardType type : permanent.getCardType()) {
|
||||||
if (cardTypes.contains(type)) {
|
if (cardTypes.contains(type)) {
|
||||||
|
@ -104,6 +101,7 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +112,9 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
||||||
|
|
||||||
private EnumSet<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
private EnumSet<CardType> getOpponentPermanentCardTypes(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Player controller = game.getPlayer(sourceControllerId);
|
Player controller = game.getPlayer(sourceControllerId);
|
||||||
EnumSet<CardType> cardTypes =EnumSet.noneOf(CardType.class);
|
EnumSet<CardType> cardTypes = EnumSet.noneOf(CardType.class);
|
||||||
if (controller != null) {
|
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)) {
|
if (controller.hasOpponent(permanent.getControllerId(), game)) {
|
||||||
cardTypes.addAll(permanent.getCardType());
|
cardTypes.addAll(permanent.getCardType());
|
||||||
}
|
}
|
||||||
|
@ -161,6 +159,7 @@ class GauntletsOfChaosSecondTarget extends TargetPermanent {
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
if (firstTarget != null) {
|
if (firstTarget != null) {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if (targetSource != null) {
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if (permanent.shareTypes(firstTarget)) {
|
if (permanent.shareTypes(firstTarget)) {
|
||||||
|
@ -169,6 +168,7 @@ class GauntletsOfChaosSecondTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,11 +117,13 @@ class GlamerSpinnersEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
// Check for protection
|
// Check for protection
|
||||||
MageObject auraObject = game.getObject(auraId);
|
MageObject auraObject = game.getObject(auraId);
|
||||||
|
if(auraObject != null) {
|
||||||
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
|
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
|
||||||
passed = false;
|
passed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (passed) {
|
if (passed) {
|
||||||
LinkedList<UUID> aurasToAttach = new LinkedList<>();
|
LinkedList<UUID> aurasToAttach = new LinkedList<>();
|
||||||
aurasToAttach.addAll(auras);
|
aurasToAttach.addAll(auras);
|
||||||
|
|
|
@ -92,7 +92,7 @@ class GnarlrootTrapperManaCondition extends CreatureCastManaCondition {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (super.apply(game, source)) {
|
if (super.apply(game, source)) {
|
||||||
MageObject object = game.getObject(source.getSourceId());
|
MageObject object = game.getObject(source.getSourceId());
|
||||||
if (object.hasSubtype(SubType.ELF, game)
|
if (object != null && object.hasSubtype(SubType.ELF, game)
|
||||||
&& object.isCreature()) {
|
&& object.isCreature()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ class GrenzoHavocRaiserEffect extends OneShotEffect {
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||||
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
||||||
if (card != null) {
|
if (card != null && sourceObject != null) {
|
||||||
// move card to exile
|
// move card to exile
|
||||||
controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
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).
|
// 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) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getPlayerId().equals(source.getControllerId())) {
|
if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getPlayerId().equals(source.getControllerId())) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
if (object.isCreature()) {
|
if (object != null && object.isCreature()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ class GrimReminderWatcher extends Watcher {
|
||||||
MageObject spell = game.getObject(event.getTargetId());
|
MageObject spell = game.getObject(event.getTargetId());
|
||||||
UUID playerId = event.getPlayerId();
|
UUID playerId = event.getPlayerId();
|
||||||
if (playerId != null && spell != null) {
|
if (playerId != null && spell != null) {
|
||||||
playersCastSpell.putIfAbsent(spell.getName(), new HashSet());
|
playersCastSpell.putIfAbsent(spell.getName(), new HashSet<>());
|
||||||
playersCastSpell.get(spell.getName()).add(playerId);
|
playersCastSpell.get(spell.getName()).add(playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ class GrimReminderWatcher extends Watcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<UUID> getPlayersCastSpell(String spellName) {
|
public Set<UUID> getPlayersCastSpell(String spellName) {
|
||||||
return playersCastSpell.getOrDefault(spellName, new HashSet());
|
return playersCastSpell.getOrDefault(spellName, new HashSet<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -172,7 +172,7 @@ class GrimoireThiefCounterspellEffect extends OneShotEffect {
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
Set<UUID> exileZones = (Set<UUID>) game.getState().getValue(GrimoireThief.VALUE_PREFIX + source.getSourceId().toString());
|
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()) {
|
for (ExileZone exileZone : game.getExile().getExileZones()) {
|
||||||
if (!exileZone.isEmpty()) {
|
if (!exileZone.isEmpty()) {
|
||||||
cards.addAll(exileZone.getCards(game));
|
cards.addAll(exileZone.getCards(game));
|
||||||
|
|
|
@ -79,7 +79,7 @@ class GrinningTotemSearchAndExileEffect extends OneShotEffect {
|
||||||
Player you = game.getPlayer(source.getControllerId());
|
Player you = game.getPlayer(source.getControllerId());
|
||||||
Player targetOpponent = game.getPlayer(source.getFirstTarget());
|
Player targetOpponent = game.getPlayer(source.getFirstTarget());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
if (you != null && targetOpponent != null) {
|
if (you != null && targetOpponent != null && sourceObject != null) {
|
||||||
if (targetOpponent.getLibrary().hasCards()) {
|
if (targetOpponent.getLibrary().hasCards()) {
|
||||||
TargetCardInLibrary targetCard = new TargetCardInLibrary();
|
TargetCardInLibrary targetCard = new TargetCardInLibrary();
|
||||||
if (you.searchLibrary(targetCard, game, targetOpponent.getId())) {
|
if (you.searchLibrary(targetCard, game, targetOpponent.getId())) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ class HandToHandEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
if (game.getPhase().getType() == TurnPhase.COMBAT) {
|
if (game.getPhase().getType() == TurnPhase.COMBAT) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
||||||
if (object.isInstant()) {
|
if (object != null && object.isInstant()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ class HavenOfTheSpiritManaCondition extends CreatureCastManaCondition {
|
||||||
public boolean apply(Game game, Ability source, UUID manaProducer, Cost costToPay) {
|
public boolean apply(Game game, Ability source, UUID manaProducer, Cost costToPay) {
|
||||||
if (super.apply(game, source)) {
|
if (super.apply(game, source)) {
|
||||||
MageObject object = game.getObject(source.getSourceId());
|
MageObject object = game.getObject(source.getSourceId());
|
||||||
if (object.hasSubtype(SubType.DRAGON, game)
|
if (object != null && object.hasSubtype(SubType.DRAGON, game)
|
||||||
&& object.isCreature()) {
|
&& object.isCreature()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ class HeraldsHornEffect extends OneShotEffect {
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
|
|
||||||
// Look at the top card of your library.
|
// 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);
|
Card card = controller.getLibrary().getFromTop(game);
|
||||||
Cards cards = new CardsImpl(card);
|
Cards cards = new CardsImpl(card);
|
||||||
controller.lookAtCards(sourceObject.getIdName(), cards, game);
|
controller.lookAtCards(sourceObject.getIdName(), cards, game);
|
||||||
|
|
|
@ -79,7 +79,7 @@ class JadeMonolithRedirectionEffect extends ReplacementEffectImpl {
|
||||||
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
|
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
DamageEvent damageEvent = (DamageEvent) event;
|
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());
|
controller.damage(damageEvent.getAmount(), damageEvent.getSourceId(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
|
||||||
StringBuilder sb = new StringBuilder(sourceObject != null ? sourceObject.getLogName() : "");
|
StringBuilder sb = new StringBuilder(sourceObject != null ? sourceObject.getLogName() : "");
|
||||||
sb.append(": ").append(damageEvent.getAmount()).append(" damage redirected from ").append(targetCreature.getLogName());
|
sb.append(": ").append(damageEvent.getAmount()).append(" damage redirected from ").append(targetCreature.getLogName());
|
||||||
|
|
|
@ -76,7 +76,7 @@ class JusticeTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
MageObject sourceObject = game.getObject(event.getSourceId());
|
MageObject sourceObject = game.getObject(event.getSourceId());
|
||||||
if (sourceObject.getColor(game).isRed()) {
|
if (sourceObject != null && sourceObject.getColor(game).isRed()) {
|
||||||
if (sourceObject instanceof Permanent && sourceObject.isCreature()
|
if (sourceObject instanceof Permanent && sourceObject.isCreature()
|
||||||
|| sourceObject instanceof Spell) {
|
|| sourceObject instanceof Spell) {
|
||||||
this.getEffects().get(0).setValue("damageAmount", event.getAmount());
|
this.getEffects().get(0).setValue("damageAmount", event.getAmount());
|
||||||
|
|
|
@ -84,7 +84,7 @@ class KeeperOfTheBeastsTarget extends TargetPlayer {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
Player controller = game.getPlayer(sourceControllerId);
|
Player controller = game.getPlayer(sourceControllerId);
|
||||||
if (controller != null) {
|
if (controller != null && targetSource != null) {
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null
|
if (player != null
|
||||||
|
|
|
@ -88,7 +88,7 @@ class KeeperOfTheLightTarget extends TargetPlayer {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
Player controller = game.getPlayer(sourceControllerId);
|
Player controller = game.getPlayer(sourceControllerId);
|
||||||
if (controller != null) {
|
if (controller != null && targetSource != null) {
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
if (player != null
|
if (player != null
|
||||||
|
|
|
@ -80,8 +80,8 @@ class ChooseLetterEffect extends OneShotEffect {
|
||||||
ChoiceImpl choice = new ChoiceImpl(true);
|
ChoiceImpl choice = new ChoiceImpl(true);
|
||||||
choice.setMessage("Choose letter");
|
choice.setMessage("Choose letter");
|
||||||
Set<String> choices = new HashSet<>();
|
Set<String> choices = new HashSet<>();
|
||||||
for (Character letter = 'A'; letter <= 'Z'; letter++) {
|
for (char letter = 'A'; letter <= 'Z'; letter++) {
|
||||||
choices.add(letter.toString());
|
choices.add(Character.toString(letter));
|
||||||
}
|
}
|
||||||
choice.setChoices(choices);
|
choice.setChoices(choices);
|
||||||
|
|
||||||
|
@ -122,8 +122,8 @@ class MonkeyMonkeyMonkeyCount implements DynamicValue {
|
||||||
if (permanent != null && game.getState().getValue(mageObject.getId() + "_letter") != null) {
|
if (permanent != null && game.getState().getValue(mageObject.getId() + "_letter") != null) {
|
||||||
int letters = 0;
|
int letters = 0;
|
||||||
for (Permanent p : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), sourceAbility.getControllerId(), sourceAbility.getSourceId(), game)) {
|
for (Permanent p : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), sourceAbility.getControllerId(), sourceAbility.getSourceId(), game)) {
|
||||||
Character initial = Character.toUpperCase(p.getName().charAt(0));
|
char initial = Character.toUpperCase(p.getName().charAt(0));
|
||||||
if (initial.toString().equals(game.getState().getValue(mageObject.getId() + "_letter"))) {
|
if (Character.toString(initial).equals(game.getState().getValue(mageObject.getId() + "_letter"))) {
|
||||||
letters++;
|
letters++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ class PatriarchsBiddingEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
if (controller != null) {
|
if (controller != null && sourceObject != null) {
|
||||||
Set<String> chosenTypes = new HashSet<>();
|
Set<String> chosenTypes = new HashSet<>();
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
|
|
|
@ -97,7 +97,7 @@ class PillarOfOriginsManaCondition extends CreatureCastManaCondition {
|
||||||
if (super.apply(game, source)) {
|
if (super.apply(game, source)) {
|
||||||
// check: ... of the chosen type
|
// check: ... of the chosen type
|
||||||
MageObject object = game.getObject(source.getSourceId());
|
MageObject object = game.getObject(source.getSourceId());
|
||||||
if (creatureType != null && object.hasSubtype(creatureType, game)) {
|
if (creatureType != null && object != null && object.hasSubtype(creatureType, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,13 +80,15 @@ class ETBSinceYourLastTurnTarget extends TargetCreaturePermanent {
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
ETBSinceYourLastTurnWatcher watcher = (ETBSinceYourLastTurnWatcher) game.getState().getWatchers().get(ETBSinceYourLastTurnWatcher.class.getSimpleName());
|
ETBSinceYourLastTurnWatcher watcher = (ETBSinceYourLastTurnWatcher) game.getState().getWatchers().get(ETBSinceYourLastTurnWatcher.class.getSimpleName());
|
||||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if(targetSource != null) {
|
||||||
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if(watcher.enteredSinceLastTurn(sourceControllerId, new MageObjectReference(permanent.getId(), game))) {
|
if (watcher.enteredSinceLastTurn(sourceControllerId, new MageObjectReference(permanent.getId(), game))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,11 +73,13 @@ class TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent extends
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if(targetSource != null) {
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
possibleTargets.add(permanent.getId());
|
possibleTargets.add(permanent.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,6 +123,7 @@ class PucasMischiefSecondTarget extends TargetPermanent {
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
if (firstTarget != null) {
|
if (firstTarget != null) {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if (targetSource != null) {
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if (firstTarget.getConvertedManaCost() >= permanent.getConvertedManaCost()) {
|
if (firstTarget.getConvertedManaCost() >= permanent.getConvertedManaCost()) {
|
||||||
|
@ -129,6 +132,7 @@ class PucasMischiefSecondTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ class ReciprocateTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if(targetSource != null) {
|
||||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId);
|
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||||
|
@ -92,6 +93,7 @@ class ReciprocateTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ class RemembranceEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
|
if(mageObject != null) {
|
||||||
cardName = (String) game.getState().getValue(mageObject + "nameOfPermanent");
|
cardName = (String) game.getState().getValue(mageObject + "nameOfPermanent");
|
||||||
if (controller != null
|
if (controller != null
|
||||||
&& cardName != null) {
|
&& cardName != null) {
|
||||||
|
@ -126,6 +127,7 @@ class RemembranceEffect extends OneShotEffect {
|
||||||
filterCard.add(new NamePredicate(cardName));
|
filterCard.add(new NamePredicate(cardName));
|
||||||
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filterCard), true, true).apply(game, source);
|
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filterCard), true, true).apply(game, source);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,8 +66,9 @@ class RiptideChronologistEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
|
if (player != null && sourceObject != null) {
|
||||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||||
if (player != null && player.choose(outcome, typeChoice, game)) {
|
if (player.choose(outcome, typeChoice, game)) {
|
||||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||||
|
@ -76,6 +77,7 @@ class RiptideChronologistEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ class SamiteMinistrationEffect extends PreventionEffectImpl {
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
PreventionEffectData preventionData = preventDamageAction(event, source, game);
|
PreventionEffectData preventionData = preventDamageAction(event, source, game);
|
||||||
MageObject sourceObject = game.getObject(event.getSourceId());
|
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());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.gainLife(preventionData.getPreventedDamage(), game, source);
|
player.gainLife(preventionData.getPreventedDamage(), game, source);
|
||||||
|
|
|
@ -4,6 +4,7 @@ package mage.cards.s;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -28,13 +29,12 @@ import mage.target.common.TargetCreaturePermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class SatyrFiredancer extends CardImpl {
|
public final class SatyrFiredancer extends CardImpl {
|
||||||
|
|
||||||
public SatyrFiredancer(UUID ownerId, CardSetInfo setInfo) {
|
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.subtype.add(SubType.SATYR);
|
||||||
|
|
||||||
this.power = new MageInt(1);
|
this.power = new MageInt(1);
|
||||||
|
@ -100,12 +100,12 @@ class SatyrFiredancerTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
if (damageSource != null) {
|
if (damageSource != null) {
|
||||||
if (game.getOpponents(getControllerId()).contains(event.getTargetId())) {
|
if (game.getOpponents(getControllerId()).contains(event.getTargetId())) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
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.contains(damageSource.getId())) {
|
||||||
if (damageSource instanceof StackObject) {
|
if (damageSource instanceof StackObject) {
|
||||||
handledStackObjects.add(damageSource.getId());
|
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.setTargetPointer(new FixedTarget(event.getTargetId())); // used by adjust targets
|
||||||
effect.setValue("damage", event.getAmount());
|
effect.setValue("damage", event.getAmount());
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,10 @@ class TargetPermanentsThatShareCardType extends TargetPermanent {
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Set<CardType> cardTypes = new HashSet<>();
|
Set<CardType> cardTypes = new HashSet<>();
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if(targetSource != null) {
|
||||||
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
for (CardType cardType :permanent.getCardType()) {
|
for (CardType cardType : permanent.getCardType()) {
|
||||||
if (cardTypes.contains(cardType)) {
|
if (cardTypes.contains(cardType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -82,6 +83,7 @@ class TargetPermanentsThatShareCardType extends TargetPermanent {
|
||||||
cardTypes.addAll(permanent.getCardType());
|
cardTypes.addAll(permanent.getCardType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ class ShiningShoalRedirectDamageTargetEffect extends RedirectDamageFromSourceToT
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// do the 2 objects match?
|
// do the 2 objects match?
|
||||||
if (!sourceObject.getId().equals(chosenSourceObject.getId())) {
|
if (chosenSourceObject == null || !sourceObject.getId().equals(chosenSourceObject.getId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,11 +78,13 @@ class TargetControlledCreatureWithPowerGreaterOrLessThanOpponentPermanent extend
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if(targetSource != null) {
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
possibleTargets.add(permanent.getId());
|
possibleTargets.add(permanent.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +128,7 @@ class SpawnbrokerSecondTarget extends TargetPermanent {
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
if (firstTarget != null) {
|
if (firstTarget != null) {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if(targetSource != null) {
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if (firstTarget.getPower().getValue() >= permanent.getPower().getValue()) {
|
if (firstTarget.getPower().getValue() >= permanent.getPower().getValue()) {
|
||||||
|
@ -134,6 +137,7 @@ class SpawnbrokerSecondTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ class SphinxsDecreeCantCastEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
if (opponentId.equals(event.getPlayerId())) {
|
if (opponentId.equals(event.getPlayerId())) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
MageObject object = game.getObject(event.getSourceId());
|
||||||
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
|
||||||
if (object.isInstant() || object.isSorcery()) {
|
if (object != null && (object.isInstant() || object.isSorcery())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ class StaffOfTheLetterMagusEffect extends OneShotEffect {
|
||||||
int lifegainValue = 0;
|
int lifegainValue = 0;
|
||||||
String spellName = spell.getName();
|
String spellName = spell.getName();
|
||||||
for (int i = 0; i < spellName.length(); i++) {
|
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");
|
String chosenLetter = (String) game.getState().getValue(mageObject.getId() + "_letter");
|
||||||
if (Character.isLetter(letter) && Character.toUpperCase(letter) == chosenLetter.charAt(0)) {
|
if (Character.isLetter(letter) && Character.toUpperCase(letter) == chosenLetter.charAt(0)) {
|
||||||
lifegainValue++;
|
lifegainValue++;
|
||||||
|
|
|
@ -85,7 +85,7 @@ class StolenStrategyEffect extends OneShotEffect {
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||||
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
Card card = damagedPlayer.getLibrary().getFromTop(game);
|
||||||
if (card != null) {
|
if (card != null && sourceObject != null) {
|
||||||
// move card to exile
|
// move card to exile
|
||||||
controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
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).
|
// 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);
|
Permanent creatureToPayFor = chooseOnePermanent(game, player, creatures);
|
||||||
|
|
||||||
if (creatureToPayFor != null) {
|
if (creatureToPayFor != null && sourceObject != null) {
|
||||||
ManaCosts manaCost = ManaCosts.removeVariableManaCost(creatureToPayFor.getManaCost());
|
ManaCosts manaCost = ManaCosts.removeVariableManaCost(creatureToPayFor.getManaCost());
|
||||||
String message = new StringBuilder("Pay ").append(manaCost.getText()).append(" (otherwise sacrifice ")
|
String message = "Pay " + manaCost.getText() + " (otherwise sacrifice " +
|
||||||
.append(creatureToPayFor.getName()).append(")?").toString();
|
creatureToPayFor.getName() + ")?";
|
||||||
if (player.chooseUse(Outcome.Benefit, message, source, game)) {
|
if (player.chooseUse(Outcome.Benefit, message, source, game)) {
|
||||||
if (manaCost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
|
if (manaCost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
|
||||||
game.informPlayers(new StringBuilder(sourceObject != null ? sourceObject.getName() : "")
|
game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " has paid");
|
||||||
.append(": ").append(player.getLogName()).append(" has paid").toString());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,13 +78,15 @@ class TargetCreatureWithPowerLessThanNumberOfCardsInYourGraveyard extends Target
|
||||||
@Override
|
@Override
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if(targetSource != null) {
|
||||||
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if(permanent.getPower().getValue() < game.getPlayer(sourceControllerId).getGraveyard().size()) {
|
if (permanent.getPower().getValue() < game.getPlayer(sourceControllerId).getGraveyard().size()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ class TobiasBeckettEffect extends OneShotEffect {
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||||
Card card = opponent.getLibrary().getFromTop(game);
|
Card card = opponent.getLibrary().getFromTop(game);
|
||||||
if (card != null) {
|
if (card != null && sourceObject != null) {
|
||||||
// move card to exile
|
// move card to exile
|
||||||
controller.moveCardToExileWithInfo(card, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
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).
|
// 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);
|
List<Permanent> activePermanents = game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game);
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if(targetSource == null){
|
||||||
|
return possibleTargets;
|
||||||
|
}
|
||||||
for (Permanent permanent : activePermanents) {
|
for (Permanent permanent : activePermanents) {
|
||||||
if (permanent.getPower().getValue() > maxPower) {
|
if (permanent.getPower().getValue() > maxPower) {
|
||||||
maxPower = permanent.getPower().getValue();
|
maxPower = permanent.getPower().getValue();
|
||||||
|
|
|
@ -107,6 +107,9 @@ class TriumphOfGerrardTargetCreature extends TargetControlledCreaturePermanent {
|
||||||
List<Permanent> activePermanents = game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game);
|
List<Permanent> activePermanents = game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game);
|
||||||
Set<UUID> possibleTargets = new HashSet<>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
|
if(targetSource == null){
|
||||||
|
return possibleTargets;
|
||||||
|
}
|
||||||
for (Permanent permanent : activePermanents) {
|
for (Permanent permanent : activePermanents) {
|
||||||
if (permanent.getPower().getValue() > maxPower) {
|
if (permanent.getPower().getValue() > maxPower) {
|
||||||
maxPower = permanent.getPower().getValue();
|
maxPower = permanent.getPower().getValue();
|
||||||
|
|
|
@ -64,6 +64,7 @@ class TsabosDecreeEffect extends OneShotEffect {
|
||||||
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
if(sourceObject != null) {
|
||||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||||
if (!player.choose(outcome, typeChoice, game)) {
|
if (!player.choose(outcome, typeChoice, game)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -90,6 +91,7 @@ class TsabosDecreeEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ class UnclaimedTerritoryManaCondition extends CreatureCastManaCondition {
|
||||||
if (super.apply(game, source)) {
|
if (super.apply(game, source)) {
|
||||||
// check: ... of the chosen type
|
// check: ... of the chosen type
|
||||||
MageObject object = game.getObject(source.getSourceId());
|
MageObject object = game.getObject(source.getSourceId());
|
||||||
if (creatureType != null && object.hasSubtype(creatureType, game)) {
|
if (creatureType != null && object != null && object.hasSubtype(creatureType, game)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,13 +72,13 @@ class LookAtRandomCardEffect extends OneShotEffect {
|
||||||
Player you = game.getPlayer(source.getControllerId());
|
Player you = game.getPlayer(source.getControllerId());
|
||||||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
if (you != null && targetPlayer != null) {
|
if (you != null && targetPlayer != null && sourceObject != null) {
|
||||||
if(!targetPlayer.getHand().isEmpty())
|
if(!targetPlayer.getHand().isEmpty())
|
||||||
{
|
{
|
||||||
Cards randomCard = new CardsImpl();
|
Cards randomCard = new CardsImpl();
|
||||||
Card card = targetPlayer.getHand().getRandom(game);
|
Card card = targetPlayer.getHand().getRandom(game);
|
||||||
randomCard.add(card);
|
randomCard.add(card);
|
||||||
you.lookAtCards(sourceObject != null ? sourceObject.getName() : null, randomCard, game);
|
you.lookAtCards(sourceObject.getName(), randomCard, game);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ class VerdantSuccessionTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
&& ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||||
MageObject mageObject = game.getObject(sourceId);
|
MageObject mageObject = game.getObject(sourceId);
|
||||||
if (permanent != null
|
if (permanent != null && mageObject != null
|
||||||
&& filter.match(permanent, game)) {
|
&& filter.match(permanent, game)) {
|
||||||
game.getState().setValue("verdantSuccession" + mageObject, permanent);
|
game.getState().setValue("verdantSuccession" + mageObject, permanent);
|
||||||
return true;
|
return true;
|
||||||
|
@ -119,6 +119,7 @@ class VerdantSuccessionEffect extends OneShotEffect {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
|
if(mageObject != null) {
|
||||||
permanent = (Permanent) game.getState().getValue("verdantSuccession" + mageObject);
|
permanent = (Permanent) game.getState().getValue("verdantSuccession" + mageObject);
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
Player controller = game.getPlayer(permanent.getControllerId());
|
Player controller = game.getPlayer(permanent.getControllerId());
|
||||||
|
@ -137,6 +138,7 @@ class VerdantSuccessionEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ class VillainousWealthEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
MageObject mageObject = game.getObject(source.getSourceId());
|
MageObject mageObject = game.getObject(source.getSourceId());
|
||||||
if (controller != null) {
|
if (controller != null && mageObject != null) {
|
||||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||||
FilterCard filter = new FilterNonlandCard();
|
FilterCard filter = new FilterNonlandCard();
|
||||||
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
|
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
package mage.cards.w;
|
package mage.cards.w;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -22,7 +23,6 @@ import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author fireshoes
|
* @author fireshoes
|
||||||
*/
|
*/
|
||||||
public final class WalkingDesecration extends CardImpl {
|
public final class WalkingDesecration extends CardImpl {
|
||||||
|
@ -64,8 +64,10 @@ class WalkingDesecrationEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
|
if (player != null) {
|
||||||
|
if (sourceObject != null) {
|
||||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||||
if (player != null && player.choose(outcome, typeChoice, game)) {
|
if (player.choose(outcome, typeChoice, game)) {
|
||||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||||
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||||
|
@ -73,6 +75,8 @@ class WalkingDesecrationEffect extends OneShotEffect {
|
||||||
game.addEffect(effect, source);
|
game.addEffect(effect, source);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue