mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Refactored and fixed AvengerofZendikar
Fixed adding counters effects. Fixed getDynamicText for CreateTokenEffect
This commit is contained in:
parent
4d05d71aa3
commit
ea0bf9e313
5 changed files with 20 additions and 60 deletions
|
@ -30,48 +30,45 @@ package mage.sets.worldwake;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.TargetController;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.LandfallAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.Filter.ComparisonScope;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.game.permanent.token.PlantToken;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Loki, nantuko, North
|
||||
*/
|
||||
public class AvengerofZendikar extends CardImpl<AvengerofZendikar> {
|
||||
private static final FilterPermanent filter = new FilterPermanent("Plant creature you control");
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Plant creature you control");
|
||||
private static final FilterControlledPermanent filterLand = new FilterControlledPermanent("land you control");
|
||||
|
||||
static {
|
||||
filter.getCardType().add(CardType.CREATURE);
|
||||
filter.setScopeCardType(ComparisonScope.Any);
|
||||
filter.getSubtype().add("Plant");
|
||||
filter.setScopeSubtype(ComparisonScope.Any);
|
||||
filter.setTargetController(TargetController.YOU);
|
||||
|
||||
filterLand.getCardType().add(CardType.LAND);
|
||||
}
|
||||
|
||||
public AvengerofZendikar (UUID ownerId) {
|
||||
super(ownerId, 96, "Avenger of Zendikar", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{5}{G}{G}");
|
||||
this.expansionSetCode = "WWK";
|
||||
this.subtype.add("Elemental");
|
||||
|
||||
this.color.setGreen(true);
|
||||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(5);
|
||||
this.addAbility(new EntersBattlefieldAbility(new AvengerofZendikarTokensCreateEffect(), "put a 0/1 green Plant creature token onto the battlefield for each land you control"));
|
||||
this.addAbility(new LandfallAbility(new AddCountersAllEffect(CounterType.P1P1.createInstance(), filter), false));
|
||||
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new PlantToken(), new PermanentsOnBattlefieldCount(filterLand)), false));
|
||||
this.addAbility(new LandfallAbility(new AddCountersAllEffect(CounterType.P1P1.createInstance(), filter), true));
|
||||
}
|
||||
|
||||
public AvengerofZendikar (final AvengerofZendikar card) {
|
||||
|
@ -83,34 +80,3 @@ public class AvengerofZendikar extends CardImpl<AvengerofZendikar> {
|
|||
return new AvengerofZendikar(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AvengerofZendikarTokensCreateEffect extends OneShotEffect<AvengerofZendikarTokensCreateEffect> {
|
||||
private static final FilterPermanent filter = new FilterPermanent();
|
||||
private Token token = new PlantToken();
|
||||
|
||||
static {
|
||||
filter.getCardType().add(CardType.LAND);
|
||||
filter.setScopeCardType(ComparisonScope.Any);
|
||||
}
|
||||
|
||||
public AvengerofZendikarTokensCreateEffect() {
|
||||
super(Constants.Outcome.PutCreatureInPlay);
|
||||
}
|
||||
|
||||
public AvengerofZendikarTokensCreateEffect(final AvengerofZendikarTokensCreateEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (int i = 0; i < game.getBattlefield().countAll(filter, source.getControllerId()); i++) {
|
||||
token.putOntoBattlefield(game, source.getId(), source.getControllerId());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AvengerofZendikarTokensCreateEffect copy() {
|
||||
return new AvengerofZendikarTokensCreateEffect(this);
|
||||
}
|
||||
}
|
|
@ -73,9 +73,6 @@ public class CreateTokenEffect extends OneShotEffect<CreateTokenEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (int i = 0; i < amount.calculate(game, source); i++) {
|
||||
// we need to specify source.getSourceId(), not source.getId()
|
||||
// as we most interested in the game object that created effect,
|
||||
// not in ability uuid
|
||||
token.putOntoBattlefield(game, source.getSourceId(), source.getControllerId());
|
||||
}
|
||||
return true;
|
||||
|
@ -83,14 +80,11 @@ public class CreateTokenEffect extends OneShotEffect<CreateTokenEffect> {
|
|||
|
||||
@Override
|
||||
public String getDynamicText(Ability source) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (amount instanceof StaticValue) {
|
||||
int count = amount.calculate(null, null);
|
||||
if (count == 1)
|
||||
sb.append("put a");
|
||||
else sb.append("put ").append(Integer.toString(count));
|
||||
StringBuilder sb = new StringBuilder("put ");
|
||||
if (amount.toString().equals("1")) {
|
||||
sb.append("a");
|
||||
} else {
|
||||
sb.append("put ").append(amount);
|
||||
sb.append(amount.toString());
|
||||
}
|
||||
sb.append(" ").append(token.getDescription()).append(" onto the battlefield");
|
||||
String message = amount.getMessage();
|
||||
|
|
|
@ -66,7 +66,7 @@ public class AddCountersAllEffect extends OneShotEffect<AddCountersAllEffect> {
|
|||
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents();
|
||||
for (Permanent permanent : permanents) {
|
||||
if (filter.match(permanent, controllerId, game)) {
|
||||
permanent.addCounters(counter);
|
||||
permanent.addCounters(counter.copy());
|
||||
applied = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class AddCountersSourceEffect extends OneShotEffect<AddCountersSourceEffe
|
|||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (counter != null) {
|
||||
permanent.addCounters(counter);
|
||||
permanent.addCounters(counter.copy());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -63,13 +63,13 @@ public class AddCountersTargetEffect extends OneShotEffect<AddCountersTargetEffe
|
|||
Permanent permanent = game.getPermanent(uuid);
|
||||
if (permanent != null) {
|
||||
if (counter != null) {
|
||||
permanent.addCounters(counter);
|
||||
permanent.addCounters(counter.copy());
|
||||
affectedTargets ++;
|
||||
}
|
||||
} else {
|
||||
Player player = game.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
player.getCounters().addCounter(counter);
|
||||
player.getCounters().addCounter(counter.copy());
|
||||
affectedTargets ++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue