changes to support multiplayer

This commit is contained in:
BetaSteward 2010-05-17 03:19:45 +00:00
parent 55cbfc53df
commit d91c00d002
12 changed files with 66 additions and 115 deletions

View file

@ -68,7 +68,7 @@ class MartialCoupEffect extends OneShotEffect {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
if (amount > 4) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter)) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, this.source.getControllerId(), game)) {
permanent.destroy(this.source.getSourceId(), game, false);
}
}

View file

@ -31,13 +31,12 @@ package mage.sets.magic2010;
import java.util.UUID;
import mage.Constants.CardType;
import mage.abilities.common.EntersBattlefieldStaticAbility;
import mage.abilities.effects.common.EntersBattlefieldTappedEffect;
import mage.abilities.effects.common.EntersBattlefieldTappedUnlessControlsEffect;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.RedManaAbility;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.filter.Filter.ComparisonScope;
import mage.filter.common.FilterLandPermanent;
import mage.sets.Magic2010;
/**
@ -46,32 +45,21 @@ import mage.sets.Magic2010;
*/
public class DragonskullSummit extends CardImpl {
private static FilterLandPermanent filter = new FilterLandPermanent();
static {
filter.getSubtype().add("Swamp");
filter.getSubtype().add("Mountain");
filter.setScopeSubtype(ComparisonScope.Any);
filter.setMessage("Swamp or a Mountain");
}
public DragonskullSummit(UUID ownerId) {
super(ownerId, "Dragonskull Summit", new CardType[]{CardType.LAND}, null);
this.expansionSetId = Magic2010.getInstance().getId();
this.art = "121671_typ_reg_sty_010.jpg";
this.addAbility(new EntersBattlefieldStaticAbility(new DragonskullSummitEffect()));
this.addAbility(new EntersBattlefieldStaticAbility(new EntersBattlefieldTappedUnlessControlsEffect(filter)));
this.addAbility(new BlackManaAbility());
this.addAbility(new RedManaAbility());
}
}
class DragonskullSummitEffect extends EntersBattlefieldTappedEffect {
@Override
public boolean replaceEvent(GameEvent event, Game game) {
FilterPermanent filter = new FilterPermanent();
filter.getName().add("Swamp");
filter.getName().add("Mountain");
filter.getControllerId().add(this.source.getControllerId());
if (game.getBattlefield().count(filter) == 0)
return apply(game);
return false;
}
@Override
public String getText() {
return super.getText() + " unless you control a Mountain or a Swamp";
}
}

View file

@ -68,11 +68,13 @@ class EarthquakeEffect extends OneShotEffect {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.getAbilities().add(FlyingAbility.getInstance());
filter.setNotAbilities(true);
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter)) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, this.source.getControllerId(), game)) {
permanent.damage(amount, source.getId(), game);
}
for (Player player: game.getPlayers().values()) {
player.damage(amount, source.getId(), game);
for (UUID playerId: game.getPlayer(this.source.getControllerId()).getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null)
player.damage(amount, source.getId(), game);
}
return true;
}

View file

@ -31,13 +31,12 @@ package mage.sets.magic2010;
import java.util.UUID;
import mage.Constants.CardType;
import mage.abilities.common.EntersBattlefieldStaticAbility;
import mage.abilities.effects.common.EntersBattlefieldTappedEffect;
import mage.abilities.effects.common.EntersBattlefieldTappedUnlessControlsEffect;
import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.filter.Filter.ComparisonScope;
import mage.filter.common.FilterLandPermanent;
import mage.sets.Magic2010;
/**
@ -46,32 +45,21 @@ import mage.sets.Magic2010;
*/
public class GlacialFortress extends CardImpl {
private static FilterLandPermanent filter = new FilterLandPermanent();
static {
filter.getSubtype().add("Plains");
filter.getSubtype().add("Island");
filter.setScopeSubtype(ComparisonScope.Any);
filter.setMessage("Plains or an Island");
}
public GlacialFortress(UUID ownerId) {
super(ownerId, "Glacial Fortress", new CardType[]{CardType.LAND}, null);
this.expansionSetId = Magic2010.getInstance().getId();
this.art = "121634_typ_reg_sty_010.jpg";
this.addAbility(new EntersBattlefieldStaticAbility(new GlacialFortressEffect()));
this.addAbility(new EntersBattlefieldStaticAbility(new EntersBattlefieldTappedUnlessControlsEffect(filter)));
this.addAbility(new BlueManaAbility());
this.addAbility(new WhiteManaAbility());
}
}
class GlacialFortressEffect extends EntersBattlefieldTappedEffect {
@Override
public boolean replaceEvent(GameEvent event, Game game) {
FilterPermanent filter = new FilterPermanent();
filter.getName().add("Plains");
filter.getName().add("Island");
filter.getControllerId().add(this.source.getControllerId());
if (game.getBattlefield().count(filter) == 0)
return apply(game);
return false;
}
@Override
public String getText() {
return super.getText() + " unless you control a Plains or an Island";
}
}

View file

@ -87,13 +87,12 @@ class MasterOfTheWildHuntEffect extends OneShotEffect {
filter.setUseTapped(true);
}
@Override
public boolean apply(Game game) {
filter.getControllerId().clear();
filter.getControllerId().add(this.source.getControllerId());
List<UUID> wolves = new ArrayList<UUID>();
Permanent target = game.getPermanent(this.source.getFirstTarget());
if (target != null) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter)) {
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, this.source.getControllerId())) {
permanent.tap(game);
target.damage(permanent.getToughness().getValue(), permanent.getId(), game);
}

View file

@ -31,13 +31,12 @@ package mage.sets.magic2010;
import java.util.UUID;
import mage.Constants.CardType;
import mage.abilities.common.EntersBattlefieldStaticAbility;
import mage.abilities.effects.common.EntersBattlefieldTappedEffect;
import mage.abilities.effects.common.EntersBattlefieldTappedUnlessControlsEffect;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.filter.Filter.ComparisonScope;
import mage.filter.common.FilterLandPermanent;
import mage.sets.Magic2010;
/**
@ -46,32 +45,21 @@ import mage.sets.Magic2010;
*/
public class RootboundCrag extends CardImpl {
private static FilterLandPermanent filter = new FilterLandPermanent();
static {
filter.getSubtype().add("Mountain");
filter.getSubtype().add("Forest");
filter.setScopeSubtype(ComparisonScope.Any);
filter.setMessage("Mountain or a Forest");
}
public RootboundCrag(UUID ownerId) {
super(ownerId, "Rootbound Crag", new CardType[]{CardType.LAND}, null);
this.expansionSetId = Magic2010.getInstance().getId();
this.art = "121648_typ_reg_sty_010.jpg";
this.addAbility(new EntersBattlefieldStaticAbility(new RootboundCragEffect()));
this.addAbility(new EntersBattlefieldStaticAbility(new EntersBattlefieldTappedUnlessControlsEffect(filter)));
this.addAbility(new RedManaAbility());
this.addAbility(new GreenManaAbility());
}
}
class RootboundCragEffect extends EntersBattlefieldTappedEffect {
@Override
public boolean replaceEvent(GameEvent event, Game game) {
FilterPermanent filter = new FilterPermanent();
filter.getName().add("Mountain");
filter.getName().add("Forest");
filter.getControllerId().add(this.source.getControllerId());
if (game.getBattlefield().count(filter) == 0)
return apply(game);
return false;
}
@Override
public String getText() {
return super.getText() + " unless you control a Mountain or a Forest";
}
}

View file

@ -32,10 +32,13 @@ import java.util.UUID;
import mage.Constants.CardType;
import mage.abilities.common.EntersBattlefieldStaticAbility;
import mage.abilities.effects.common.EntersBattlefieldTappedEffect;
import mage.abilities.effects.common.EntersBattlefieldTappedUnlessControlsEffect;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.filter.Filter.ComparisonScope;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.sets.Magic2010;
@ -46,32 +49,21 @@ import mage.sets.Magic2010;
*/
public class SunpetalGrove extends CardImpl {
private static FilterLandPermanent filter = new FilterLandPermanent();
static {
filter.getSubtype().add("Swamp");
filter.getSubtype().add("Mountain");
filter.setScopeSubtype(ComparisonScope.Any);
filter.setMessage("Swamp or a Mountain");
}
public SunpetalGrove(UUID ownerId) {
super(ownerId, "Sunpetal Grove", new CardType[]{CardType.LAND}, null);
this.expansionSetId = Magic2010.getInstance().getId();
this.art = "121679_typ_reg_sty_010.jpg";
this.addAbility(new EntersBattlefieldStaticAbility(new SunpetalGroveEffect()));
this.addAbility(new EntersBattlefieldStaticAbility(new EntersBattlefieldTappedUnlessControlsEffect(filter)));
this.addAbility(new GreenManaAbility());
this.addAbility(new WhiteManaAbility());
}
}
class SunpetalGroveEffect extends EntersBattlefieldTappedEffect {
@Override
public boolean replaceEvent(GameEvent event, Game game) {
FilterPermanent filter = new FilterPermanent();
filter.getName().add("Plains");
filter.getName().add("Forest");
filter.getControllerId().add(this.source.getControllerId());
if (game.getBattlefield().count(filter) == 0)
return apply(game);
return false;
}
@Override
public String getText() {
return super.getText() + " unless you control a Plains or a Forest";
}
}

View file

@ -93,13 +93,11 @@ class KnightOfTheWhiteOrchidAbility extends EntersBattlefieldTriggeredAbility {
@Override
public boolean checkIfClause(Game game) {
FilterLandPermanent filter = new FilterLandPermanent();
filter.getControllerId().clear();
filter.getControllerId().add(this.controllerId);
int numLands = game.getBattlefield().count(filter);
int numLands = game.getBattlefield().countAll(filter, this.controllerId);
for (UUID opponentId: game.getOpponents(this.controllerId)) {
filter.getControllerId().clear();
filter.getControllerId().add(opponentId);
if (numLands < game.getBattlefield().count(filter)) {
if (numLands < game.getBattlefield().countAll(filter, opponentId)) {
return true;
}
}

View file

@ -83,7 +83,7 @@ class TectonicEdgeCost extends CostImpl {
for (UUID opponentId: game.getOpponents(playerId)) {
filter.getControllerId().clear();
filter.getControllerId().add(opponentId);
if (game.getBattlefield().count(filter) > 3) {
if (game.getBattlefield().countAll(filter, opponentId) > 3) {
return true;
}
}

View file

@ -76,9 +76,7 @@ class BraveTheElementsEffect extends GainAbilityControlledEffect {
ChoiceColor choice = (ChoiceColor) this.source.getChoices().get(0);
filter2.setColor(choice.getColor());
filter2.setMessage(choice.getChoice());
filter1.getControllerId().clear();
filter1.getControllerId().add(source.getControllerId());
for (Permanent perm: game.getBattlefield().getActivePermanents(filter1)) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter1, source.getControllerId())) {
perm.addAbility(ability);
}
return true;

View file

@ -73,7 +73,7 @@ class OranRiefTheVastwoodEffect extends OneShotEffect {
FilterPermanent filter = new FilterPermanent();
filter.getCardType().add(CardType.CREATURE);
filter.getColor().setGreen(true);
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter)) {
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, this.source.getControllerId(), game)) {
if (permanent.getTurnsOnBattlefield() == 0) {
permanent.getCounters().addCounter(new PlusOneCounter());
}

View file

@ -79,9 +79,7 @@ class ScuteMobAbility extends TriggeredAbilityImpl {
@Override
public boolean checkIfClause(Game game) {
filter.getControllerId().clear();
filter.getControllerId().add(this.controllerId);
return game.getBattlefield().count(filter) >= 5;
return game.getBattlefield().countAll(filter, this.controllerId) >= 5;
}
@Override