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,21 +91,23 @@ 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());
|
||||||
Spell spell = (Spell) game.getState().getValue("avenShrine" + mageObject);
|
if(mageObject != null) {
|
||||||
if (spell != null) {
|
Spell spell = (Spell) game.getState().getValue("avenShrine" + mageObject);
|
||||||
Player controller = game.getPlayer(spell.getControllerId());
|
if (spell != null) {
|
||||||
if (controller != null) {
|
Player controller = game.getPlayer(spell.getControllerId());
|
||||||
String name = spell.getName();
|
if (controller != null) {
|
||||||
FilterCard filterCardName = new FilterCard();
|
String name = spell.getName();
|
||||||
filterCardName.add(new NamePredicate(name));
|
FilterCard filterCardName = new FilterCard();
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
filterCardName.add(new NamePredicate(name));
|
||||||
Player player = game.getPlayer(playerId);
|
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||||
if (player != null) {
|
Player player = game.getPlayer(playerId);
|
||||||
count += player.getGraveyard().count(filterCardName, game);
|
if (player != null) {
|
||||||
|
count += player.getGraveyard().count(filterCardName, game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
controller.gainLife(count, game, source);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
controller.gainLife(count, game, source);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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,13 +75,15 @@ 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);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if(targetSource != null) {
|
||||||
if (!targets.containsKey(permanent.getId())) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
if (!targets.containsKey(permanent.getId())) {
|
||||||
if (controller != null && permanent.getPower().getValue() >= controller.getLife()) {
|
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
count++;
|
if (controller != null && permanent.getPower().getValue() >= controller.getLife()) {
|
||||||
if (count >= remainingTargets) {
|
count++;
|
||||||
return true;
|
if (count >= remainingTargets) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,21 +91,23 @@ 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());
|
||||||
Spell spell = (Spell) game.getState().getValue("cabalShrine" + mageObject);
|
if(mageObject != null) {
|
||||||
if (spell != null) {
|
Spell spell = (Spell) game.getState().getValue("cabalShrine" + mageObject);
|
||||||
Player controller = game.getPlayer(spell.getControllerId());
|
if (spell != null) {
|
||||||
if (controller != null) {
|
Player controller = game.getPlayer(spell.getControllerId());
|
||||||
String name = spell.getName();
|
if (controller != null) {
|
||||||
FilterCard filterCardName = new FilterCard();
|
String name = spell.getName();
|
||||||
filterCardName.add(new NamePredicate(name));
|
FilterCard filterCardName = new FilterCard();
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
filterCardName.add(new NamePredicate(name));
|
||||||
Player player = game.getPlayer(playerId);
|
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||||
if (player != null) {
|
Player player = game.getPlayer(playerId);
|
||||||
count += player.getGraveyard().count(filterCardName, game);
|
if (player != null) {
|
||||||
|
count += player.getGraveyard().count(filterCardName, game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
controller.discard(count, false, source, game);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
controller.discard(count, false, source, game);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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,31 +93,33 @@ 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());
|
||||||
Spell spell = (Spell) game.getState().getValue("cephalidShrine" + mageObject);
|
if(mageObject != null) {
|
||||||
if (spell != null) {
|
Spell spell = (Spell) game.getState().getValue("cephalidShrine" + mageObject);
|
||||||
Player controller = game.getPlayer(spell.getControllerId());
|
if (spell != null) {
|
||||||
if (controller != null) {
|
Player controller = game.getPlayer(spell.getControllerId());
|
||||||
String name = spell.getName();
|
if (controller != null) {
|
||||||
FilterCard filterCardName = new FilterCard();
|
String name = spell.getName();
|
||||||
filterCardName.add(new NamePredicate(name));
|
FilterCard filterCardName = new FilterCard();
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
filterCardName.add(new NamePredicate(name));
|
||||||
Player player = game.getPlayer(playerId);
|
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||||
if (player != null) {
|
Player player = game.getPlayer(playerId);
|
||||||
count += player.getGraveyard().count(filterCardName, game);
|
if (player != null) {
|
||||||
|
count += player.getGraveyard().count(filterCardName, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// even if the cost is 0, we still offer
|
||||||
|
Cost cost = new GenericManaCost(count);
|
||||||
|
if (game.getStack().contains((StackObject) spell)
|
||||||
|
&& cost.canPay(source, source.getSourceId(), controller.getId(), game)
|
||||||
|
&& controller.chooseUse(outcome, "Pay " + cost.getText() + " to prevent countering " + spell.getName() + "?", source, game)
|
||||||
|
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false)
|
||||||
|
&& cost.isPaid()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
spell.counter(source.getId(), game);
|
||||||
|
game.informPlayers(spell.getName() + " has been countered due to " + controller.getName() + " not paying " + cost.getText());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// even if the cost is 0, we still offer
|
|
||||||
Cost cost = new GenericManaCost(count);
|
|
||||||
if (game.getStack().contains((StackObject) spell)
|
|
||||||
&& cost.canPay(source, source.getSourceId(), controller.getId(), game)
|
|
||||||
&& controller.chooseUse(outcome, "Pay " + cost.getText() + " to prevent countering " + spell.getName() + "?", source, game)
|
|
||||||
&& cost.pay(source, game, source.getSourceId(), controller.getId(), false)
|
|
||||||
&& cost.isPaid()) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
spell.counter(source.getId(), game);
|
|
||||||
game.informPlayers(spell.getName() + " has been countered due to " + controller.getName() + " not paying " + cost.getText());
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ class CharmbreakerDevilsEffect extends OneShotEffect {
|
||||||
if (cards.length > 0) {
|
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);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public final class DaringThief extends CardImpl {
|
||||||
this.toughness = new MageInt(3);
|
this.toughness = new MageInt(3);
|
||||||
|
|
||||||
// Inspired - Whenever Daring Thief becomes untapped, you may exchange control of target nonland permanent you control and target permanent an opponent controls that shares a card type with it.
|
// Inspired - Whenever Daring Thief becomes untapped, you may exchange control of target nonland permanent you control and target permanent an opponent controls that shares a card type with it.
|
||||||
Ability ability = new InspiredAbility(new ExchangeControlTargetEffect(Duration.EndOfGame,
|
Ability ability = new InspiredAbility(new ExchangeControlTargetEffect(Duration.EndOfGame,
|
||||||
"you may exchange control of target nonland permanent you control and target permanent an opponent controls that shares a card type with it", false, true), true);
|
"you may exchange control of target nonland permanent you control and target permanent an opponent controls that shares a card type with it", false, true), true);
|
||||||
ability.addTarget(new TargetControlledPermanentSharingOpponentPermanentCardType());
|
ability.addTarget(new TargetControlledPermanentSharingOpponentPermanentCardType());
|
||||||
ability.addTarget(new DaringThiefSecondTarget());
|
ability.addTarget(new DaringThiefSecondTarget());
|
||||||
|
@ -59,23 +59,23 @@ public final class DaringThief extends CardImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetControlledPermanent {
|
class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetControlledPermanent {
|
||||||
|
|
||||||
public TargetControlledPermanentSharingOpponentPermanentCardType() {
|
public TargetControlledPermanentSharingOpponentPermanentCardType() {
|
||||||
super();
|
super();
|
||||||
this.filter = this.filter.copy();
|
this.filter = this.filter.copy();
|
||||||
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
|
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
|
||||||
setTargetName("nonland permanent you control");
|
setTargetName("nonland permanent you control");
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetControlledPermanentSharingOpponentPermanentCardType(final TargetControlledPermanentSharingOpponentPermanentCardType target) {
|
public TargetControlledPermanentSharingOpponentPermanentCardType(final TargetControlledPermanentSharingOpponentPermanentCardType target) {
|
||||||
super(target);
|
super(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||||
if (super.canTarget(controllerId, id, source, game)) {
|
if (super.canTarget(controllerId, id, source, game)) {
|
||||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(source.getSourceId(), controllerId, game);
|
Set<CardType> cardTypes = getOpponentPermanentCardTypes(source.getSourceId(), controllerId, game);
|
||||||
Permanent permanent = game.getPermanent(id);
|
Permanent permanent = game.getPermanent(id);
|
||||||
for (CardType type : permanent.getCardType()) {
|
for (CardType type : permanent.getCardType()) {
|
||||||
if (cardTypes.contains(type)) {
|
if (cardTypes.contains(type)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -84,36 +84,38 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
// get all cardtypes from opponents permanents
|
// get all cardtypes from opponents permanents
|
||||||
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) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
for (CardType type : permanent.getCardType()) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if (cardTypes.contains(type)) {
|
for (CardType type : permanent.getCardType()) {
|
||||||
possibleTargets.add(permanent.getId());
|
if (cardTypes.contains(type)) {
|
||||||
break;
|
possibleTargets.add(permanent.getId());
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TargetControlledPermanentSharingOpponentPermanentCardType copy() {
|
public TargetControlledPermanentSharingOpponentPermanentCardType copy() {
|
||||||
return new TargetControlledPermanentSharingOpponentPermanentCardType(this);
|
return new TargetControlledPermanentSharingOpponentPermanentCardType(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -127,20 +129,20 @@ class TargetControlledPermanentSharingOpponentPermanentCardType extends TargetCo
|
||||||
class DaringThiefSecondTarget extends TargetPermanent {
|
class DaringThiefSecondTarget extends TargetPermanent {
|
||||||
|
|
||||||
private Permanent firstTarget = null;
|
private Permanent firstTarget = null;
|
||||||
|
|
||||||
public DaringThiefSecondTarget() {
|
public DaringThiefSecondTarget() {
|
||||||
super();
|
super();
|
||||||
this.filter = this.filter.copy();
|
this.filter = this.filter.copy();
|
||||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||||
setTargetName("permanent an opponent controls that shares a card type with it");
|
setTargetName("permanent an opponent controls that shares a card type with it");
|
||||||
}
|
}
|
||||||
|
|
||||||
public DaringThiefSecondTarget(final DaringThiefSecondTarget target) {
|
public DaringThiefSecondTarget(final DaringThiefSecondTarget target) {
|
||||||
super(target);
|
super(target);
|
||||||
this.firstTarget = target.firstTarget;
|
this.firstTarget = target.firstTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
if (super.canTarget(id, source, game)) {
|
if (super.canTarget(id, source, game)) {
|
||||||
|
@ -152,29 +154,31 @@ class DaringThiefSecondTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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<>();
|
||||||
if (firstTarget != null) {
|
if (firstTarget != null) {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if (targetSource != null) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (permanent.shareTypes(firstTarget)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
possibleTargets.add(permanent.getId());
|
if (permanent.shareTypes(firstTarget)) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
|
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
|
||||||
firstTarget = game.getPermanent(source.getFirstTarget());
|
firstTarget = game.getPermanent(source.getFirstTarget());
|
||||||
return super.chooseTarget(Outcome.Damage, playerId, source, game);
|
return super.chooseTarget(Outcome.Damage, playerId, source, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DaringThiefSecondTarget copy() {
|
public DaringThiefSecondTarget copy() {
|
||||||
return new DaringThiefSecondTarget(this);
|
return new DaringThiefSecondTarget(this);
|
||||||
|
|
|
@ -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,21 +90,23 @@ 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());
|
||||||
Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject);
|
if(mageObject != null) {
|
||||||
if (spell != null) {
|
Spell spell = (Spell) game.getState().getValue("dwarvenShrine" + mageObject);
|
||||||
Player controller = game.getPlayer(spell.getControllerId());
|
if (spell != null) {
|
||||||
if (controller != null) {
|
Player controller = game.getPlayer(spell.getControllerId());
|
||||||
String name = spell.getName();
|
if (controller != null) {
|
||||||
FilterCard filterCardName = new FilterCard();
|
String name = spell.getName();
|
||||||
filterCardName.add(new NamePredicate(name));
|
FilterCard filterCardName = new FilterCard();
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
filterCardName.add(new NamePredicate(name));
|
||||||
Player player = game.getPlayer(playerId);
|
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||||
if (player != null) {
|
Player player = game.getPlayer(playerId);
|
||||||
count += player.getGraveyard().count(filterCardName, game);
|
if (player != null) {
|
||||||
|
count += player.getGraveyard().count(filterCardName, game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
controller.damage(count * 2, mageObject.getId(), game, false, true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
controller.damage(count * 2, mageObject.getId(), game, false, true);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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,18 +69,20 @@ 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());
|
||||||
Choice typeChoice = new ChoiceCreatureType(mageObject);
|
if (controller != null && mageObject != null) {
|
||||||
if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
|
Choice typeChoice = new ChoiceCreatureType(mageObject);
|
||||||
if (!game.isSimulation()) {
|
if (controller.choose(outcome, typeChoice, game)) {
|
||||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
if (!game.isSimulation()) {
|
||||||
|
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
|
||||||
|
}
|
||||||
|
Cards cardsToLibrary = new CardsImpl();
|
||||||
|
FilterCreatureCard filter = new FilterCreatureCard();
|
||||||
|
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||||
|
cardsToLibrary.addAll(controller.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game));
|
||||||
|
controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false);
|
||||||
|
controller.shuffleLibrary(source, game);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
Cards cardsToLibrary = new CardsImpl();
|
|
||||||
FilterCreatureCard filter = new FilterCreatureCard();
|
|
||||||
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
|
||||||
cardsToLibrary.addAll(controller.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game));
|
|
||||||
controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false);
|
|
||||||
controller.shuffleLibrary(source, game);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
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,15 +56,18 @@ 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());
|
||||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
if (player != null && sourceObject != null) {
|
||||||
if (player != null && player.choose(outcome, typeChoice, game)) {
|
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
|
||||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
if (player.choose(outcome, typeChoice, game)) {
|
||||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||||
creature.destroy(source.getSourceId(), game, true);
|
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||||
|
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
||||||
|
creature.destroy(source.getSourceId(), game, true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
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,20 +19,24 @@ 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,
|
||||||
"exchange control of target artifact, creature, or land you control and target permanent an opponent controls that shares one of those types with it."
|
"exchange control of target artifact, creature, or land you control and target permanent an opponent controls that shares one of those types with it."
|
||||||
+ " If those permanents are exchanged this way, destroy all Auras attached to them", false, true, true),
|
+ " If those permanents are exchanged this way, destroy all Auras attached to them", false, true, true),
|
||||||
new ManaCostsImpl("{5}")
|
new ManaCostsImpl("{5}")
|
||||||
);
|
);
|
||||||
ability.addCost(new SacrificeSourceCost());
|
ability.addCost(new SacrificeSourceCost());
|
||||||
ability.addTarget(new GauntletsOfChaosFirstTarget());
|
ability.addTarget(new GauntletsOfChaosFirstTarget());
|
||||||
|
@ -59,7 +55,7 @@ public final class GauntletsOfChaos extends CardImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
||||||
|
|
||||||
public GauntletsOfChaosFirstTarget() {
|
public GauntletsOfChaosFirstTarget() {
|
||||||
super();
|
super();
|
||||||
this.filter = this.filter.copy();
|
this.filter = this.filter.copy();
|
||||||
|
@ -68,17 +64,17 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
||||||
new CardTypePredicate(CardType.CREATURE),
|
new CardTypePredicate(CardType.CREATURE),
|
||||||
new CardTypePredicate(CardType.LAND)));
|
new CardTypePredicate(CardType.LAND)));
|
||||||
setTargetName("artifact, creature, or land you control");
|
setTargetName("artifact, creature, or land you control");
|
||||||
}
|
}
|
||||||
|
|
||||||
public GauntletsOfChaosFirstTarget(final GauntletsOfChaosFirstTarget target) {
|
public GauntletsOfChaosFirstTarget(final GauntletsOfChaosFirstTarget target) {
|
||||||
super(target);
|
super(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||||
if (super.canTarget(controllerId, id, source, game)) {
|
if (super.canTarget(controllerId, id, source, game)) {
|
||||||
Set<CardType> cardTypes = getOpponentPermanentCardTypes(source.getSourceId(), controllerId, game);
|
Set<CardType> cardTypes = getOpponentPermanentCardTypes(source.getSourceId(), controllerId, game);
|
||||||
Permanent permanent = game.getPermanent(id);
|
Permanent permanent = game.getPermanent(id);
|
||||||
for (CardType type : permanent.getCardType()) {
|
for (CardType type : permanent.getCardType()) {
|
||||||
if (cardTypes.contains(type)) {
|
if (cardTypes.contains(type)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -87,36 +83,38 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
// get all cardtypes from opponents permanents
|
// get all cardtypes from opponents permanents
|
||||||
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) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
for (CardType type : permanent.getCardType()) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if (cardTypes.contains(type)) {
|
for (CardType type : permanent.getCardType()) {
|
||||||
possibleTargets.add(permanent.getId());
|
if (cardTypes.contains(type)) {
|
||||||
break;
|
possibleTargets.add(permanent.getId());
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GauntletsOfChaosFirstTarget copy() {
|
public GauntletsOfChaosFirstTarget copy() {
|
||||||
return new GauntletsOfChaosFirstTarget(this);
|
return new GauntletsOfChaosFirstTarget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -130,20 +128,20 @@ class GauntletsOfChaosFirstTarget extends TargetControlledPermanent {
|
||||||
class GauntletsOfChaosSecondTarget extends TargetPermanent {
|
class GauntletsOfChaosSecondTarget extends TargetPermanent {
|
||||||
|
|
||||||
private Permanent firstTarget = null;
|
private Permanent firstTarget = null;
|
||||||
|
|
||||||
public GauntletsOfChaosSecondTarget() {
|
public GauntletsOfChaosSecondTarget() {
|
||||||
super();
|
super();
|
||||||
this.filter = this.filter.copy();
|
this.filter = this.filter.copy();
|
||||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||||
setTargetName("permanent an opponent controls that shares one of those types with it");
|
setTargetName("permanent an opponent controls that shares one of those types with it");
|
||||||
}
|
}
|
||||||
|
|
||||||
public GauntletsOfChaosSecondTarget(final GauntletsOfChaosSecondTarget target) {
|
public GauntletsOfChaosSecondTarget(final GauntletsOfChaosSecondTarget target) {
|
||||||
super(target);
|
super(target);
|
||||||
this.firstTarget = target.firstTarget;
|
this.firstTarget = target.firstTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
if (super.canTarget(id, source, game)) {
|
if (super.canTarget(id, source, game)) {
|
||||||
|
@ -155,29 +153,31 @@ class GauntletsOfChaosSecondTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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<>();
|
||||||
if (firstTarget != null) {
|
if (firstTarget != null) {
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if (targetSource != null) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (permanent.shareTypes(firstTarget)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
possibleTargets.add(permanent.getId());
|
if (permanent.shareTypes(firstTarget)) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
|
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game) {
|
||||||
firstTarget = game.getPermanent(source.getFirstTarget());
|
firstTarget = game.getPermanent(source.getFirstTarget());
|
||||||
return super.chooseTarget(Outcome.Damage, playerId, source, game);
|
return super.chooseTarget(Outcome.Damage, playerId, source, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GauntletsOfChaosSecondTarget copy() {
|
public GauntletsOfChaosSecondTarget copy() {
|
||||||
return new GauntletsOfChaosSecondTarget(this);
|
return new GauntletsOfChaosSecondTarget(this);
|
||||||
|
|
|
@ -117,8 +117,10 @@ class GlamerSpinnersEffect extends OneShotEffect {
|
||||||
}
|
}
|
||||||
// Check for protection
|
// Check for protection
|
||||||
MageObject auraObject = game.getObject(auraId);
|
MageObject auraObject = game.getObject(auraId);
|
||||||
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
|
if(auraObject != null) {
|
||||||
passed = false;
|
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
|
||||||
|
passed = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,10 +80,12 @@ 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) {
|
||||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if(watcher.enteredSinceLastTurn(sourceControllerId, new MageObjectReference(permanent.getId(), game))) {
|
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
return true;
|
if (watcher.enteredSinceLastTurn(sourceControllerId, new MageObjectReference(permanent.getId(), game))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,11 @@ class TargetControlledPermanentWithCMCGreaterOrLessThanOpponentPermanent extends
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
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);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if(targetSource != null) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
possibleTargets.add(permanent.getId());
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
|
@ -121,10 +123,12 @@ 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);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if (targetSource != null) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (firstTarget.getConvertedManaCost() >= permanent.getConvertedManaCost()) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
possibleTargets.add(permanent.getId());
|
if (firstTarget.getConvertedManaCost() >= permanent.getConvertedManaCost()) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,13 +82,15 @@ class ReciprocateTarget extends TargetPermanent {
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MageObject targetSource = game.getObject(sourceId);
|
MageObject targetSource = game.getObject(sourceId);
|
||||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId);
|
if(targetSource != null) {
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), sourceControllerId);
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
&& watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||||
count++;
|
&& watcher != null && watcher.hasSourceDoneDamage(permanent.getId(), game)) {
|
||||||
if (count >= remainingTargets) {
|
count++;
|
||||||
return true;
|
if (count >= remainingTargets) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,12 +119,14 @@ 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());
|
||||||
cardName = (String) game.getState().getValue(mageObject + "nameOfPermanent");
|
if(mageObject != null) {
|
||||||
if (controller != null
|
cardName = (String) game.getState().getValue(mageObject + "nameOfPermanent");
|
||||||
&& cardName != null) {
|
if (controller != null
|
||||||
FilterCard filterCard = new FilterCard("card named " + cardName);
|
&& cardName != null) {
|
||||||
filterCard.add(new NamePredicate(cardName));
|
FilterCard filterCard = new FilterCard("card named " + cardName);
|
||||||
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filterCard), true, true).apply(game, source);
|
filterCard.add(new NamePredicate(cardName));
|
||||||
|
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filterCard), true, true).apply(game, source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,15 +66,17 @@ 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());
|
||||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
if (player != null && sourceObject != null) {
|
||||||
if (player != null && player.choose(outcome, typeChoice, game)) {
|
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
if (player.choose(outcome, typeChoice, game)) {
|
||||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||||
creature.untap(game);
|
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
||||||
|
creature.untap(game);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
@ -47,7 +47,7 @@ public final class SatyrFiredancer extends CardImpl {
|
||||||
public SatyrFiredancer(final SatyrFiredancer card) {
|
public SatyrFiredancer(final SatyrFiredancer card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
public void adjustTargets(Ability ability, Game game) {
|
||||||
if (ability instanceof SatyrFiredancerTriggeredAbility) {
|
if (ability instanceof SatyrFiredancerTriggeredAbility) {
|
||||||
|
@ -59,7 +59,7 @@ public final class SatyrFiredancer extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SatyrFiredancer copy() {
|
public SatyrFiredancer copy() {
|
||||||
return new SatyrFiredancer(this);
|
return new SatyrFiredancer(this);
|
||||||
|
@ -97,15 +97,15 @@ class SatyrFiredancerTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (isControlledBy(game.getControllerId(event.getSourceId()))) {
|
if (isControlledBy(game.getControllerId(event.getSourceId()))) {
|
||||||
MageObject damageSource = game.getObject(event.getSourceId());
|
MageObject damageSource = game.getObject(event.getSourceId());
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ class SatyrFiredancerDamageEffect extends OneShotEffect {
|
||||||
if (targetCreature != null && controller != null) {
|
if (targetCreature != null && controller != null) {
|
||||||
int damage = (Integer) this.getValue("damage");
|
int damage = (Integer) this.getValue("damage");
|
||||||
if (damage > 0) {
|
if (damage > 0) {
|
||||||
targetCreature.damage(damage, source.getSourceId(), game, false, true);
|
targetCreature.damage(damage, source.getSourceId(), game, false, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,14 +72,16 @@ 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) {
|
||||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
for (CardType cardType :permanent.getCardType()) {
|
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
if (cardTypes.contains(cardType)) {
|
for (CardType cardType : permanent.getCardType()) {
|
||||||
return true;
|
if (cardTypes.contains(cardType)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
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,9 +78,11 @@ 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);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if(targetSource != null) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
possibleTargets.add(permanent.getId());
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
|
@ -126,10 +128,12 @@ 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);
|
||||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
if(targetSource != null) {
|
||||||
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if (firstTarget.getPower().getValue() >= permanent.getPower().getValue()) {
|
if (!targets.containsKey(permanent.getId()) && permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
possibleTargets.add(permanent.getId());
|
if (firstTarget.getPower().getValue() >= permanent.getPower().getValue()) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,10 +78,12 @@ 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) {
|
||||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
|
||||||
if(permanent.getPower().getValue() < game.getPlayer(sourceControllerId).getGraveyard().size()) {
|
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||||
return true;
|
if (permanent.getPower().getValue() < game.getPlayer(sourceControllerId).getGraveyard().size()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ class TobiasBeckettEffect extends OneShotEffect {
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
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,31 +64,33 @@ 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) {
|
||||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
if(sourceObject != null) {
|
||||||
if (!player.choose(outcome, typeChoice, game)) {
|
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||||
return false;
|
if (!player.choose(outcome, typeChoice, game)) {
|
||||||
}
|
return false;
|
||||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
|
||||||
targetPlayer.revealCards("hand of " + targetPlayer.getName(), targetPlayer.getHand(), game);
|
|
||||||
FilterCard filterCard = new FilterCard();
|
|
||||||
filterCard.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
|
||||||
List<Card> toDiscard = new ArrayList<>();
|
|
||||||
for (Card card : targetPlayer.getHand().getCards(game)) {
|
|
||||||
if (filterCard.match(card, game)) {
|
|
||||||
toDiscard.add(card);
|
|
||||||
}
|
}
|
||||||
}
|
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||||
for (Card card : toDiscard) {
|
targetPlayer.revealCards("hand of " + targetPlayer.getName(), targetPlayer.getHand(), game);
|
||||||
targetPlayer.discard(card, source, game);
|
FilterCard filterCard = new FilterCard();
|
||||||
}
|
filterCard.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||||
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
List<Card> toDiscard = new ArrayList<>();
|
||||||
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
for (Card card : targetPlayer.getHand().getCards(game)) {
|
||||||
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
if (filterCard.match(card, game)) {
|
||||||
if (creature.isControlledBy(targetPlayer.getId())) {
|
toDiscard.add(card);
|
||||||
creature.destroy(source.getSourceId(), game, true);
|
}
|
||||||
}
|
}
|
||||||
|
for (Card card : toDiscard) {
|
||||||
|
targetPlayer.discard(card, source, game);
|
||||||
|
}
|
||||||
|
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
|
||||||
|
filterCreaturePermanent.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||||
|
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
|
||||||
|
if (creature.isControlledBy(targetPlayer.getId())) {
|
||||||
|
creature.destroy(source.getSourceId(), game, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
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,21 +119,23 @@ 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());
|
||||||
permanent = (Permanent) game.getState().getValue("verdantSuccession" + mageObject);
|
if(mageObject != null) {
|
||||||
if (permanent != null) {
|
permanent = (Permanent) game.getState().getValue("verdantSuccession" + mageObject);
|
||||||
Player controller = game.getPlayer(permanent.getControllerId());
|
if (permanent != null) {
|
||||||
if (controller != null) {
|
Player controller = game.getPlayer(permanent.getControllerId());
|
||||||
FilterCard filterCard = new FilterCard("Card named " + permanent.getName());
|
if (controller != null) {
|
||||||
filterCard.add(new NamePredicate(permanent.getName()));
|
FilterCard filterCard = new FilterCard("Card named " + permanent.getName());
|
||||||
TargetCardInLibrary target = new TargetCardInLibrary(filterCard);
|
filterCard.add(new NamePredicate(permanent.getName()));
|
||||||
controller.searchLibrary(target, game);
|
TargetCardInLibrary target = new TargetCardInLibrary(filterCard);
|
||||||
if (!target.getTargets().isEmpty()) {
|
controller.searchLibrary(target, game);
|
||||||
Card card = game.getCard(target.getFirstTarget());
|
if (!target.getTargets().isEmpty()) {
|
||||||
if (card != null
|
Card card = game.getCard(target.getFirstTarget());
|
||||||
&& controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
if (card != null
|
||||||
controller.shuffleLibrary(source, game);
|
&& controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
||||||
|
controller.shuffleLibrary(source, game);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ class VillainousWealthEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
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,14 +64,18 @@ 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());
|
||||||
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
if (player != null) {
|
||||||
if (player != null && player.choose(outcome, typeChoice, game)) {
|
if (sourceObject != null) {
|
||||||
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
Choice typeChoice = new ChoiceCreatureType(sourceObject);
|
||||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
if (player.choose(outcome, typeChoice, game)) {
|
||||||
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
|
||||||
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
|
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||||
game.addEffect(effect, source);
|
filter.add(new SubtypePredicate(SubType.byDescription(typeChoice.getChoice())));
|
||||||
return true;
|
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
|
||||||
|
game.addEffect(effect, source);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue