Merge pull request #855 from FenrisulfrX/fix_dragonlord

Fix Dragonloard Atarka
This commit is contained in:
LevelX2 2015-03-30 10:29:06 +02:00
commit 4d2ff7b607
2 changed files with 27 additions and 25 deletions

View file

@ -31,6 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.DamageMultiEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.TrampleAbility;
@ -47,11 +48,11 @@ import mage.target.common.TargetCreatureOrPlaneswalkerAmount;
* @author fireshoes
*/
public class DragonlordAtarka extends CardImpl {
private static final FilterCreatureOrPlaneswalkerPermanent filter = new FilterCreatureOrPlaneswalkerPermanent("creatures and/or planeswalkers your opponents control");
static {
filter.add(new ControllerPredicate(TargetController.NOT_YOU));
filter.add(new ControllerPredicate(TargetController.OPPONENT));
}
public DragonlordAtarka(UUID ownerId) {
@ -65,13 +66,13 @@ public class DragonlordAtarka extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Trample
this.addAbility(TrampleAbility.getInstance());
// When Dragonlord Atarka enters the battlefield, it deals 5 damage divided as you choose among any number of target creatures and/or planeswalkers your opponents control.
Ability ability = new EntersBattlefieldTriggeredAbility(new DamageMultiEffect(5), false);
ability.addTarget(new TargetCreatureOrPlaneswalkerAmount(5));
ability.addTarget(new TargetCreatureOrPlaneswalkerAmount(5, filter));
this.addAbility(ability);
}

View file

@ -35,11 +35,8 @@
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.constants.TargetController;
import mage.filter.Filter;
import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetAmount;
@ -57,15 +54,21 @@ import mage.filter.predicate.permanent.ControllerPredicate;
// any positive number or zero, unless something (such as damage or counters) is being divided
// or distributed among any number of players and/or objects. In that case, a nonzero number
// of players and/or objects must be chosen if possible.
this(new StaticValue(amount));
this.minNumberOfTargets = 1;
this(amount, new FilterCreatureOrPlaneswalkerPermanent());
}
public TargetCreatureOrPlaneswalkerAmount(DynamicValue amount) {
this(amount, new FilterCreatureOrPlaneswalkerPermanent());
}
public TargetCreatureOrPlaneswalkerAmount(int amount, FilterCreatureOrPlaneswalkerPermanent filter) {
this(new StaticValue(amount), filter);
}
public TargetCreatureOrPlaneswalkerAmount(DynamicValue amount, FilterCreatureOrPlaneswalkerPermanent filter) {
super(amount);
this.zone = Zone.ALL;
this.filter = new FilterCreatureOrPlaneswalkerPermanent();
this.filter.add(new ControllerPredicate(TargetController.OPPONENT));
this.filter = filter;
this.targetName = filter.getMessage();
}
@ -91,15 +94,13 @@ import mage.filter.predicate.permanent.ControllerPredicate;
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
Permanent permanent = game.getPermanent(id);
if (source != null) {
MageObject targetSource = game.getObject(source.getSourceId());
if (permanent != null) {
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
}
}
if (permanent != null) {
return filter.match(permanent, game);
if (source != null) {
MageObject targetSource = game.getObject(source.getSourceId());
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
} else {
return filter.match(permanent, game);
}
}
return false;
}
@ -113,7 +114,7 @@ import mage.filter.predicate.permanent.ControllerPredicate;
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
int count = 0;
MageObject targetSource = game.getObject(sourceId);
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), sourceControllerId, game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreatureOrPlaneswalkerPermanent(), sourceControllerId, game)) {
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
count++;
if (count >= this.minNumberOfTargets) {
@ -127,7 +128,7 @@ import mage.filter.predicate.permanent.ControllerPredicate;
@Override
public boolean canChoose(UUID sourceControllerId, Game game) {
int count = 0;
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), sourceControllerId, game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreatureOrPlaneswalkerPermanent(), sourceControllerId, game)) {
if (filter.match(permanent, null, sourceControllerId, game)) {
count++;
if (count >= this.minNumberOfTargets) {
@ -142,7 +143,7 @@ import mage.filter.predicate.permanent.ControllerPredicate;
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<>();
MageObject targetSource = game.getObject(sourceId);
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), sourceControllerId, game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreatureOrPlaneswalkerPermanent(), sourceControllerId, game)) {
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
possibleTargets.add(permanent.getId());
}
@ -153,7 +154,7 @@ import mage.filter.predicate.permanent.ControllerPredicate;
@Override
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<>();
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), sourceControllerId, game)) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreatureOrPlaneswalkerPermanent(), sourceControllerId, game)) {
if (filter.match(permanent, null, sourceControllerId, game)) {
possibleTargets.add(permanent.getId());
}