Removed unnecessary battlefield.count methods not considering player range. Changed cards that used the removed methods.

This commit is contained in:
LevelX2 2013-02-12 17:14:20 +01:00
parent c375d80682
commit f504a543e1
28 changed files with 83 additions and 101 deletions

View file

@ -92,7 +92,7 @@ class FiligreeAngelEffect extends OneShotEffect<FiligreeAngelEffect> {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int life = game.getBattlefield().count(filter, source.getControllerId(), game) * 3;
int life = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) * 3;
player.gainLife(life, game);
}
return true;

View file

@ -106,7 +106,7 @@ class BudokaGardenerEffect extends OneShotEffect<BudokaGardenerEffect> {
if (c != null) {
c.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
}
if (game.getBattlefield().count(DokaiWeaverofLifeToken.filterLands, source.getControllerId(), game) >= 10) {
if (game.getBattlefield().count(DokaiWeaverofLifeToken.filterLands, source.getSourceId(), source.getControllerId(), game) >= 10) {
Permanent p = game.getPermanent(source.getSourceId());
if (p != null) {
p.flip(game);

View file

@ -96,7 +96,7 @@ class EmissaryOfHopeEffect extends OneShotEffect<EmissaryOfHopeEffect> {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
Player sourcePlayer = game.getPlayer(source.getControllerId());
if (targetPlayer != null && sourcePlayer != null) {
int amount = game.getBattlefield().count(filter, targetPlayer.getId(), game);
int amount = game.getBattlefield().count(filter, source.getSourceId(), targetPlayer.getId(), game);
if (amount > 0) {
sourcePlayer.gainLife(amount, game);
}

View file

@ -103,7 +103,7 @@ class ImmaculateMagistrateEffect extends OneShotEffect<ImmaculateMagistrateEffec
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
int count = game.getBattlefield().count(filter, source.getControllerId(), game);
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
if (count > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(count), game);
return true;

View file

@ -89,7 +89,7 @@ class CorruptEffect extends OneShotEffect<CorruptEffect> {
@Override
public boolean apply(Game game, Ability source) {
int amount = game.getBattlefield().count(filter, source.getControllerId(), game);
int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
if (amount > 0) {
int damageDealt = amount;
Permanent permanent = game.getPermanent(source.getFirstTarget());

View file

@ -98,7 +98,7 @@ class HarborSerpentEffect extends RestrictionEffect<HarborSerpentEffect> {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (game.getBattlefield().countAll(filter, game) < 5) {
if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 5) {
return true;
}
return false;

View file

@ -129,7 +129,7 @@ class LilianaOfTheDarkRealmsEffect extends ContinuousEffectImpl<LilianaOfTheDark
FilterLandPermanent filter = new FilterLandPermanent("Swamps");
filter.add(new SubtypePredicate("Swamp"));
filter.add(new ControllerPredicate(TargetController.YOU));
this.amount = game.getBattlefield().count(filter, source.getControllerId(), game);
this.amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
Player player = game.getPlayer(source.getControllerId());

View file

@ -96,7 +96,7 @@ public class TimberpackWolf extends CardImpl<TimberpackWolf> {
@Override
public boolean apply(Game game, Ability source) {
int count = game.getBattlefield().count(filter, source.getControllerId(), game) - 1;
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) - 1;
if (count > 0) {
Permanent target = (Permanent) game.getPermanent(source.getSourceId());
if (target != null) {

View file

@ -85,8 +85,8 @@ class WarReportEffect extends OneShotEffect<WarReportEffect> {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int lifeToGain = game.getBattlefield().countAll(new FilterCreaturePermanent(), game);
lifeToGain += game.getBattlefield().countAll(new FilterArtifactPermanent(), game);
int lifeToGain = game.getBattlefield().count(new FilterCreaturePermanent(), source.getSourceId(), source.getControllerId(), game);
lifeToGain += game.getBattlefield().count(new FilterArtifactPermanent(), source.getSourceId(), source.getControllerId(), game);
player.gainLife(lifeToGain, game);
}
return true;

View file

@ -104,7 +104,7 @@ class AxebaneGuardianManaEffect extends ManaEffect<AxebaneGuardianManaEffect> {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if(player != null){
int x = game.getBattlefield().count(filter, source.getControllerId(), game);
int x = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
Mana mana = new Mana();
for(int i = 0; i < x; i++){

View file

@ -86,7 +86,7 @@ class GlimmerpostEffect extends OneShotEffect<GlimmerpostEffect> {
@Override
public boolean apply(Game game, Ability source) {
int amount = game.getBattlefield().count(filter, source.getControllerId(), game);
int amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.gainLife(amount, game);

View file

@ -134,7 +134,7 @@ class SameNameAsExiledCountValue implements DynamicValue {
if (permanent != null && permanent.getImprinted().size() > 0) {
FilterPermanent filterPermanent = new FilterPermanent();
filterPermanent.add(new NamePredicate(game.getCard(permanent.getImprinted().get(0)).getName()));
value = game.getBattlefield().countAll(filterPermanent, game);
value = game.getBattlefield().count(filterPermanent, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
}
return value;
}

View file

@ -96,7 +96,7 @@ public class RelentlessRats extends CardImpl<RelentlessRats> {
@Override
public boolean apply(Game game, Ability source) {
int count = game.getBattlefield().count(filter, source.getControllerId(), game) - 1;
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) - 1;
if (count > 0) {
Permanent target = (Permanent) game.getPermanent(source.getSourceId());
if (target != null) {

View file

@ -75,7 +75,7 @@ public class ImpendingDisaster extends CardImpl<ImpendingDisaster> {
@Override
public boolean apply(Game game, Ability source) {
return game.getBattlefield().countAll(new FilterLandPermanent(), game) >= 7;
return game.getBattlefield().count(new FilterLandPermanent(), source.getSourceId(), source.getControllerId(), game) >= 7;
}
}
}

View file

@ -75,7 +75,7 @@ public class PlanarCollapse extends CardImpl<PlanarCollapse> {
@Override
public boolean apply(Game game, Ability source) {
return game.getBattlefield().countAll(new FilterCreaturePermanent(), game) >= 4;
return game.getBattlefield().count(new FilterCreaturePermanent(), source.getSourceId(), source.getControllerId(), game) >= 4;
}
}
}

View file

@ -104,7 +104,7 @@ public class RadiantArchangel extends CardImpl<RadiantArchangel> {
@Override
public boolean apply(Game game, Ability source) {
int count = game.getBattlefield().count(filter, source.getControllerId(), game) - 1;
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) - 1;
if (count > 0) {
Permanent target = (Permanent) game.getPermanent(source.getSourceId());
if (target != null) {

View file

@ -99,19 +99,18 @@ class BravadoBoostEnchantedEffect extends ContinuousEffectImpl<BravadoBoostEncha
@Override
public boolean apply(Game game, Ability source) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
int count = game.getBattlefield().count(filter, source.getControllerId(), game) - 1;
if (count > 0) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
creature.addPower(count);
creature.addToughness(count);
return true;
}
}
}
return false;
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) - 1;
if (count > 0) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
creature.addPower(count);
creature.addToughness(count);
return true;
}
}
}
return false;
}
}

View file

@ -164,7 +164,7 @@ class CarpetOfFlowersEffect extends ManaEffect<CarpetOfFlowersEffect> {
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
Player player = game.getPlayer(source.getControllerId());
if(player != null){
int countMax = game.getBattlefield().count(filter, source.getTargets().getFirstTarget(), game);
int countMax = game.getBattlefield().count(filter, source.getSourceId(), source.getTargets().getFirstTarget(), game);
ChoiceImpl choiceCount = new ChoiceImpl(true);
LinkedHashSet<String> set = new LinkedHashSet<String>();
for(int i = 0; i <= countMax; i++)

View file

@ -95,7 +95,7 @@ class WorshipReplacementEffect extends ReplacementEffectImpl<WorshipReplacementE
if (controller != null
&& (controller.getLife() - event.getAmount()) < 1
&& event.getPlayerId().equals(controller.getId())
&& game.getBattlefield().count(new FilterControlledCreaturePermanent(), event.getPlayerId(), game) > 0
&& game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getSourceId(), event.getPlayerId(), game) > 0
) {
event.setAmount(controller.getLife() - 1);
}

View file

@ -109,7 +109,7 @@ class HarabazDruidManaEffect extends ManaEffect<HarabazDruidManaEffect> {
public boolean apply(Game game, Ability source) {
ChoiceColor choice = (ChoiceColor) source.getChoices().get(0);
Player player = game.getPlayer(source.getControllerId());
int count = game.getBattlefield().count(filter, source.getControllerId(), game);
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
if (choice.getColor().isBlack()) {
player.getManaPool().addMana(new Mana(0, 0, 0, 0, count, 0, 0), game, source);
return true;

View file

@ -101,7 +101,7 @@ class MiresTollEffect extends OneShotEffect<MiresTollEffect> {
@Override
public boolean apply(Game game, Ability source) {
int swamps = game.getBattlefield().count(filter, source.getControllerId(), game);
int swamps = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (swamps > 0 && targetPlayer != null) {
Cards revealedCards = new CardsImpl(Constants.Zone.PICK);

View file

@ -153,7 +153,7 @@ class TuktukScrapperEffect extends OneShotEffect<TuktukScrapperEffect> {
Player controller = game.getPlayer(targetedArtifact.getControllerId());
targetedArtifact.destroy(id, game, true);
if (controller.getGraveyard().contains(artifact.getId())) {
int alliesControlled = game.getBattlefield().count(filter, source.getControllerId(), game);
int alliesControlled = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
controller.damage(alliesControlled, id, game, false, true);
return true;
}

View file

@ -114,7 +114,7 @@ class NissaRevaneGainLifeEffect extends OneShotEffect<NissaRevaneGainLifeEffect>
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
int life = 2 * game.getBattlefield().countAll(filter, game);
int life = 2 * game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
if (player != null) {
player.gainLife(life, game);
}

View file

@ -61,8 +61,12 @@ public class ValakutTheMoltenPinnacle extends CardImpl<ValakutTheMoltenPinnacle>
public ValakutTheMoltenPinnacle(UUID ownerId) {
super(ownerId, 228, "Valakut, the Molten Pinnacle", Rarity.RARE, new CardType[]{CardType.LAND}, null);
this.expansionSetCode = "ZEN";
// Valakut, the Molten Pinnacle enters the battlefield tapped.
this.addAbility(new EntersBattlefieldTappedAbility());
// Whenever a Mountain enters the battlefield under your control, if you control at least five other Mountains, you may have Valakut, the Molten Pinnacle deal 3 damage to target creature or player.
this.addAbility(new ValakutTheMoltenPinnacleTriggeredAbility());
// {T}: Add {R} to your mana pool.
this.addAbility(new RedManaAbility());
}
@ -93,11 +97,9 @@ class ValakutTheMoltenPinnacleTriggeredAbility extends TriggeredAbilityImpl<Vala
if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.BATTLEFIELD) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent.getCardType().contains(CardType.LAND) && permanent.getControllerId().equals(this.controllerId)) {
if (permanent.getCardType().contains(CardType.LAND) && permanent.getControllerId().equals(this.getControllerId())) {
if(permanent.hasSubtype("Mountain")){
int count = game.getBattlefield().count(ValakutTheMoltenPinnacle.filter, permanent.getControllerId(), game);
int count = game.getBattlefield().count(ValakutTheMoltenPinnacle.filter, getSourceId(), getControllerId(), game);
if(count > 5){
return true;
}