mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Champion ability - Fixed that it did not work for non champion permanents with the according subtype.
This commit is contained in:
parent
0122937fbc
commit
4b683619e3
2 changed files with 18 additions and 16 deletions
|
@ -34,7 +34,6 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
|
|
@ -29,9 +29,6 @@ package mage.abilities.keyword;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.StaticAbility;
|
import mage.abilities.StaticAbility;
|
||||||
|
@ -41,14 +38,17 @@ import mage.abilities.costs.CostImpl;
|
||||||
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
|
import mage.abilities.effects.common.ReturnFromExileForSourceEffect;
|
||||||
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
|
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
import mage.filter.predicate.Predicate;
|
import mage.filter.predicate.Predicate;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.common.TargetControlledCreaturePermanent;
|
import mage.players.Player;
|
||||||
|
import mage.target.common.TargetControlledPermanent;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
|
@ -96,13 +96,13 @@ public class ChampionAbility extends StaticAbility {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
this.objectDescription = sb.toString();
|
this.objectDescription = sb.toString();
|
||||||
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(objectDescription);
|
FilterControlledPermanent filter = new FilterControlledPermanent(objectDescription);
|
||||||
filter.add(Predicates.or(subtypesPredicates));
|
filter.add(Predicates.or(subtypesPredicates));
|
||||||
filter.add(new AnotherPredicate());
|
filter.add(new AnotherPredicate());
|
||||||
|
|
||||||
// When this permanent enters the battlefield, sacrifice it unless you exile another [object] you control.
|
// When this permanent enters the battlefield, sacrifice it unless you exile another [object] you control.
|
||||||
Ability ability1 = new EntersBattlefieldTriggeredAbility(
|
Ability ability1 = new EntersBattlefieldTriggeredAbility(
|
||||||
new SacrificeSourceUnlessPaysEffect(new ChampionExileCost(filter, new StringBuilder(card.getName()).append(" championed creatures").toString())),false);
|
new SacrificeSourceUnlessPaysEffect(new ChampionExileCost(filter, new StringBuilder(card.getName()).append(" championed permanents").toString())),false);
|
||||||
ability1.setRuleVisible(false);
|
ability1.setRuleVisible(false);
|
||||||
card.addAbility(ability1);
|
card.addAbility(ability1);
|
||||||
|
|
||||||
|
@ -137,8 +137,8 @@ class ChampionExileCost extends CostImpl {
|
||||||
|
|
||||||
private String exileZone = null;
|
private String exileZone = null;
|
||||||
|
|
||||||
public ChampionExileCost(FilterControlledCreaturePermanent filter, String exileZone) {
|
public ChampionExileCost(FilterControlledPermanent filter, String exileZone) {
|
||||||
this.addTarget(new TargetControlledCreaturePermanent(1,1,filter, true));
|
this.addTarget(new TargetControlledPermanent(1,1,filter, true));
|
||||||
this.text = "exile " + filter.getMessage() + " you control";
|
this.text = "exile " + filter.getMessage() + " you control";
|
||||||
this.exileZone = exileZone;
|
this.exileZone = exileZone;
|
||||||
}
|
}
|
||||||
|
@ -150,13 +150,16 @@ class ChampionExileCost extends CostImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||||
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
|
Player controller = game.getPlayer(controllerId);
|
||||||
for (UUID targetId: targets.get(0).getTargets()) {
|
if (controller != null) {
|
||||||
Permanent permanent = game.getPermanent(targetId);
|
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
|
||||||
if (permanent == null) {
|
for (UUID targetId: targets.get(0).getTargets()) {
|
||||||
return false;
|
Permanent permanent = game.getPermanent(targetId);
|
||||||
|
if (permanent == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
paid |= controller.moveCardToExileWithInfo(permanent, sourceId, exileZone, sourceId, game, Zone.BATTLEFIELD);
|
||||||
}
|
}
|
||||||
paid |= permanent.moveToExile(sourceId, exileZone, sourceId, game);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return paid;
|
return paid;
|
||||||
|
|
Loading…
Reference in a new issue