mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Removed unnecessary battlefield.count methods not considering player range. Changed cards that used the removed methods.
This commit is contained in:
parent
c375d80682
commit
f504a543e1
28 changed files with 83 additions and 101 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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++){
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,6 @@ public class NoCreatureCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getBattlefield().countAll(filter, game) == 0;
|
||||
return game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) == 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,11 @@ public class AffinityEffect extends CostModificationEffectImpl<AffinityEffect> {
|
|||
SpellAbility spellAbility = (SpellAbility)abilityToModify;
|
||||
Mana mana = spellAbility.getManaCostsToPay().getMana();
|
||||
if (mana.getColorless() > 0) {
|
||||
int count = game.getBattlefield().count(filter, source.getControllerId(), game);
|
||||
int count = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
|
||||
int newCount = mana.getColorless() - count;
|
||||
if (newCount < 0) newCount = 0;
|
||||
if (newCount < 0) {
|
||||
newCount = 0;
|
||||
}
|
||||
mana.setColorless(newCount);
|
||||
spellAbility.getManaCostsToPay().load(mana.toString());
|
||||
return true;
|
||||
|
|
|
@ -147,7 +147,7 @@ class OfferingAsThoughEffect extends AsThoughEffectImpl<OfferingAsThoughEffect>
|
|||
game.getState().setValue("offering_Id_" + card.getId(), null);
|
||||
}
|
||||
|
||||
if (game.getBattlefield().count(((OfferingAbility) source).getFilter(), source.getControllerId(), game) > 0) {
|
||||
if (game.getBattlefield().count(((OfferingAbility) source).getFilter(), source.getSourceId(), source.getControllerId(), game) > 0) {
|
||||
|
||||
FilterControlledCreaturePermanent filter = ((OfferingAbility) source).getFilter();
|
||||
Card spellToCast = game.getCard(source.getSourceId());
|
||||
|
|
|
@ -28,15 +28,15 @@
|
|||
|
||||
package mage.game.permanent;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.RangeOfInfluence;
|
||||
import mage.abilities.keyword.PhasingAbility;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -68,27 +68,9 @@ public class Battlefield implements Serializable {
|
|||
field.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a count of all {@link Permanent} that match the filter.
|
||||
* This method ignores the range of influence.
|
||||
*
|
||||
* @param filter
|
||||
* @return count
|
||||
*/
|
||||
public int countAll(FilterPermanent filter, Game game) {
|
||||
int count = 0;
|
||||
for (Permanent permanent: field.values()) {
|
||||
if (filter.match(permanent, game)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a count of all {@link Permanent} that match the filter and are controlled by controllerId.
|
||||
* This method ignores the range of influence.
|
||||
*
|
||||
*
|
||||
* @param filter
|
||||
* @param controllerId
|
||||
* @return count
|
||||
|
@ -108,29 +90,11 @@ public class Battlefield implements Serializable {
|
|||
* and that match the supplied filter.
|
||||
*
|
||||
* @param filter
|
||||
* @param sourceId - sourceId of the MageObject the calling effect/ability belongs to
|
||||
* @param sourcePlayerId
|
||||
* @param game
|
||||
* @return count
|
||||
*/
|
||||
public int count(FilterPermanent filter, UUID sourcePlayerId, Game game) {
|
||||
int count = 0;
|
||||
if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) {
|
||||
for (Permanent permanent: field.values()) {
|
||||
if (filter.match(permanent, null, sourcePlayerId, game)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
||||
for (Permanent permanent: field.values()) {
|
||||
if (range.contains(permanent.getControllerId()) && filter.match(permanent, null, sourcePlayerId, game)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int count(FilterPermanent filter, UUID sourceId, UUID sourcePlayerId, Game game) {
|
||||
int count = 0;
|
||||
|
@ -165,8 +129,9 @@ public class Battlefield implements Serializable {
|
|||
for (Permanent permanent: field.values()) {
|
||||
if (filter.match(permanent, game)) {
|
||||
count++;
|
||||
if (num == count)
|
||||
if (num == count) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -186,8 +151,9 @@ public class Battlefield implements Serializable {
|
|||
for (Permanent permanent: field.values()) {
|
||||
if (permanent.getControllerId().equals(controllerId) && filter.match(permanent, game)) {
|
||||
count++;
|
||||
if (num == count)
|
||||
if (num == count) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -209,8 +175,9 @@ public class Battlefield implements Serializable {
|
|||
for (Permanent permanent: field.values()) {
|
||||
if (filter.match(permanent, null, sourcePlayerId, game)) {
|
||||
count++;
|
||||
if (num == count)
|
||||
if (num == count) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,8 +186,9 @@ public class Battlefield implements Serializable {
|
|||
for (Permanent permanent: field.values()) {
|
||||
if (range.contains(permanent.getControllerId()) && filter.match(permanent, null, sourcePlayerId, game)) {
|
||||
count++;
|
||||
if (num == count)
|
||||
if (num == count) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,8 +234,9 @@ public class Battlefield implements Serializable {
|
|||
public List<Permanent> getAllActivePermanents() {
|
||||
List<Permanent> active = new ArrayList<Permanent>();
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.isPhasedIn())
|
||||
if (perm.isPhasedIn()) {
|
||||
active.add(perm);
|
||||
}
|
||||
}
|
||||
return active;
|
||||
}
|
||||
|
@ -283,8 +252,9 @@ public class Battlefield implements Serializable {
|
|||
public List<Permanent> getAllActivePermanents(UUID controllerId) {
|
||||
List<Permanent> active = new ArrayList<Permanent>();
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.isPhasedIn() && perm.getControllerId().equals(controllerId))
|
||||
if (perm.isPhasedIn() && perm.getControllerId().equals(controllerId)) {
|
||||
active.add(perm);
|
||||
}
|
||||
}
|
||||
return active;
|
||||
}
|
||||
|
@ -300,8 +270,9 @@ public class Battlefield implements Serializable {
|
|||
public List<Permanent> getAllActivePermanents(CardType type) {
|
||||
List<Permanent> active = new ArrayList<Permanent>();
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.isPhasedIn() && perm.getCardType().contains(type))
|
||||
if (perm.isPhasedIn() && perm.getCardType().contains(type)) {
|
||||
active.add(perm);
|
||||
}
|
||||
}
|
||||
return active;
|
||||
}
|
||||
|
@ -318,8 +289,9 @@ public class Battlefield implements Serializable {
|
|||
public List<Permanent> getAllActivePermanents(FilterPermanent filter, Game game) {
|
||||
List<Permanent> active = new ArrayList<Permanent>();
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.isPhasedIn() && filter.match(perm, game))
|
||||
if (perm.isPhasedIn() && filter.match(perm, game)) {
|
||||
active.add(perm);
|
||||
}
|
||||
}
|
||||
return active;
|
||||
}
|
||||
|
@ -336,8 +308,9 @@ public class Battlefield implements Serializable {
|
|||
public List<Permanent> getAllActivePermanents(FilterPermanent filter, UUID controllerId, Game game) {
|
||||
List<Permanent> active = new ArrayList<Permanent>();
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.isPhasedIn() && perm.getControllerId().equals(controllerId) && filter.match(perm, game))
|
||||
if (perm.isPhasedIn() && perm.getControllerId().equals(controllerId) && filter.match(perm, game)) {
|
||||
active.add(perm);
|
||||
}
|
||||
}
|
||||
return active;
|
||||
}
|
||||
|
@ -360,15 +333,17 @@ public class Battlefield implements Serializable {
|
|||
List<Permanent> active = new ArrayList<Permanent>();
|
||||
if (game.getRangeOfInfluence() == RangeOfInfluence.ALL) {
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.isPhasedIn() && filter.match(perm, sourceId, sourcePlayerId, game))
|
||||
if (perm.isPhasedIn() && filter.match(perm, sourceId, sourcePlayerId, game)) {
|
||||
active.add(perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.isPhasedIn() && range.contains(perm.getControllerId()) && filter.match(perm, sourceId, sourcePlayerId, game))
|
||||
if (perm.isPhasedIn() && range.contains(perm.getControllerId()) && filter.match(perm, sourceId, sourcePlayerId, game)) {
|
||||
active.add(perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
return active;
|
||||
|
@ -390,8 +365,9 @@ public class Battlefield implements Serializable {
|
|||
List<Permanent> active = new ArrayList<Permanent>();
|
||||
Set<UUID> range = game.getPlayer(sourcePlayerId).getInRange();
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.isPhasedIn() && range.contains(perm.getControllerId()))
|
||||
if (perm.isPhasedIn() && range.contains(perm.getControllerId())) {
|
||||
active.add(perm);
|
||||
}
|
||||
}
|
||||
return active;
|
||||
}
|
||||
|
@ -400,8 +376,9 @@ public class Battlefield implements Serializable {
|
|||
public List<Permanent> getPhasedIn(UUID controllerId) {
|
||||
List<Permanent> phasedIn = new ArrayList<Permanent>();
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.getAbilities().containsKey(PhasingAbility.getInstance().getId()) && perm.isPhasedIn() && perm.getControllerId().equals(controllerId))
|
||||
if (perm.getAbilities().containsKey(PhasingAbility.getInstance().getId()) && perm.isPhasedIn() && perm.getControllerId().equals(controllerId)) {
|
||||
phasedIn.add(perm);
|
||||
}
|
||||
}
|
||||
return phasedIn;
|
||||
}
|
||||
|
@ -409,8 +386,9 @@ public class Battlefield implements Serializable {
|
|||
public List<Permanent> getPhasedOut(UUID controllerId) {
|
||||
List<Permanent> phasedOut = new ArrayList<Permanent>();
|
||||
for (Permanent perm: field.values()) {
|
||||
if (!perm.isPhasedIn() && perm.getControllerId().equals(controllerId))
|
||||
if (!perm.isPhasedIn() && perm.getControllerId().equals(controllerId)) {
|
||||
phasedOut.add(perm);
|
||||
}
|
||||
}
|
||||
return phasedOut;
|
||||
}
|
||||
|
@ -423,8 +401,9 @@ public class Battlefield implements Serializable {
|
|||
*/
|
||||
public void fireControlChangeEvents(Game game) {
|
||||
for (Permanent perm: field.values()) {
|
||||
if (perm.isPhasedIn())
|
||||
if (perm.isPhasedIn()) {
|
||||
perm.checkControlChanged(game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue