mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Merge branch 'master' into Zzooouhh-rat
This commit is contained in:
commit
5ecb34453d
53 changed files with 5054 additions and 47 deletions
|
|
@ -9,9 +9,11 @@ import java.util.UUID;
|
|||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -23,11 +25,15 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
|
|||
private int minAttackers;
|
||||
|
||||
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers) {
|
||||
this(effect, minAttackers, new FilterCreaturePermanent("creatures"));
|
||||
this(effect, minAttackers, StaticFilters.FILTER_PERMANENT_CREATURES);
|
||||
}
|
||||
|
||||
public AttacksWithCreaturesTriggeredAbility(Effect effect, int minAttackers, FilterCreaturePermanent filter) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
this(Zone.BATTLEFIELD, effect, minAttackers, filter);
|
||||
}
|
||||
|
||||
public AttacksWithCreaturesTriggeredAbility(Zone zone, Effect effect, int minAttackers, FilterCreaturePermanent filter) {
|
||||
super(zone, effect);
|
||||
this.filter = filter;
|
||||
this.minAttackers = minAttackers;
|
||||
}
|
||||
|
|
@ -50,13 +56,17 @@ public class AttacksWithCreaturesTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
int attackerCount = 0;
|
||||
for (UUID attacker : game.getCombat().getAttackers()) {
|
||||
if (filter.match(game.getPermanent(attacker), game)) {
|
||||
attackerCount++;
|
||||
if (game.getCombat().getAttackingPlayerId().equals(getControllerId())) {
|
||||
int attackerCount = 0;
|
||||
for (UUID attackerId : game.getCombat().getAttackers()) {
|
||||
Permanent permanent = game.getPermanent(attackerId);
|
||||
if (permanent != null && filter.match(game.getPermanent(attackerId), game)) {
|
||||
attackerCount++;
|
||||
}
|
||||
}
|
||||
return attackerCount >= minAttackers;
|
||||
}
|
||||
return attackerCount >= minAttackers && game.getCombat().getAttackingPlayerId().equals(getControllerId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class BlocksOrBecomesBlockedTriggeredAbility extends TriggeredAbilityImpl
|
|||
Permanent blocked = game.getPermanent(event.getTargetId());
|
||||
if (blocked != null && filter.match(blocked, game)) {
|
||||
if (setTargetPointer) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
this.getEffects().setTargetPointer(new FixedTarget(blocked, game));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ public class BlocksOrBecomesBlockedTriggeredAbility extends TriggeredAbilityImpl
|
|||
Permanent blocker = game.getPermanent(event.getSourceId());
|
||||
if (blocker != null && filter.match(blocker, game)) {
|
||||
if (setTargetPointer) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(event.getSourceId()));
|
||||
this.getEffects().setTargetPointer(new FixedTarget(blocker, game));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,13 +25,12 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
@ -41,10 +40,10 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class DamageAllControlledTargetEffect extends OneShotEffect {
|
||||
|
||||
private FilterCreaturePermanent filter;
|
||||
private FilterPermanent filter;
|
||||
private int amount;
|
||||
|
||||
public DamageAllControlledTargetEffect(int amount, FilterCreaturePermanent filter) {
|
||||
public DamageAllControlledTargetEffect(int amount, FilterPermanent filter) {
|
||||
super(Outcome.Damage);
|
||||
this.amount = amount;
|
||||
this.filter = filter;
|
||||
|
|
@ -64,7 +63,7 @@ public class DamageAllControlledTargetEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getFirstTarget(), game)) {
|
||||
permanent.damage(amount, source.getSourceId(), game, false, true);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import mage.game.Game;
|
|||
public class ReturnToBattlefieldUnderOwnerControlSourceEffect extends OneShotEffect {
|
||||
|
||||
private boolean tapped;
|
||||
private boolean attacking;
|
||||
private int zoneChangeCounter;
|
||||
|
||||
public ReturnToBattlefieldUnderOwnerControlSourceEffect() {
|
||||
|
|
@ -52,16 +53,25 @@ public class ReturnToBattlefieldUnderOwnerControlSourceEffect extends OneShotEff
|
|||
}
|
||||
|
||||
public ReturnToBattlefieldUnderOwnerControlSourceEffect(boolean tapped, int zoneChangeCounter) {
|
||||
this(tapped, false, zoneChangeCounter);
|
||||
}
|
||||
|
||||
public ReturnToBattlefieldUnderOwnerControlSourceEffect(boolean tapped, boolean attacking, int zoneChangeCounter) {
|
||||
super(Outcome.Benefit);
|
||||
this.tapped = tapped;
|
||||
this.attacking = attacking;
|
||||
this.zoneChangeCounter = zoneChangeCounter;
|
||||
staticText = new StringBuilder("return that card to the battlefield").append(tapped ? " tapped" : "").append(" under its owner's control").toString();
|
||||
staticText = "return that card to the battlefield"
|
||||
+ (tapped ? " tapped" : "")
|
||||
+ (attacking ? " attacking" : "")
|
||||
+ " under its owner's control";
|
||||
}
|
||||
|
||||
public ReturnToBattlefieldUnderOwnerControlSourceEffect(final ReturnToBattlefieldUnderOwnerControlSourceEffect effect) {
|
||||
super(effect);
|
||||
this.tapped = effect.tapped;
|
||||
this.zoneChangeCounter = effect.zoneChangeCounter;
|
||||
this.attacking = effect.attacking;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -80,7 +90,11 @@ public class ReturnToBattlefieldUnderOwnerControlSourceEffect extends OneShotEff
|
|||
case GRAVEYARD:
|
||||
if (zoneChangeCounter < 0 || game.getState().getZoneChangeCounter(card.getId()) == zoneChangeCounter) {
|
||||
Zone currentZone = game.getState().getZone(card.getId());
|
||||
card.putOntoBattlefield(game, currentZone, source.getSourceId(), card.getOwnerId(), tapped);
|
||||
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), card.getOwnerId(), tapped)) {
|
||||
if (attacking) {
|
||||
game.getCombat().addAttackingCreature(card.getId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public abstract class ExpansionSet implements Serializable {
|
|||
return this.cardNumber;
|
||||
}
|
||||
|
||||
public int getCardNumberAsInt(){
|
||||
public int getCardNumberAsInt() {
|
||||
return CardUtil.parseCardNumberAsInt(this.cardNumber);
|
||||
}
|
||||
|
||||
|
|
@ -121,6 +121,7 @@ public abstract class ExpansionSet implements Serializable {
|
|||
protected int numBoosterRare;
|
||||
protected int numBoosterDoubleFaced; // -1 = include normally 0 = exclude 1-n = include explicit
|
||||
protected int ratioBoosterMythic;
|
||||
protected boolean needsLegends = false;
|
||||
|
||||
protected int maxCardNumberInBooster; // used to omit cards with collector numbers beyond the regular cards in a set for boosters
|
||||
|
||||
|
|
@ -210,6 +211,20 @@ public abstract class ExpansionSet implements Serializable {
|
|||
}
|
||||
|
||||
public List<Card> createBooster() {
|
||||
if (needsLegends) {
|
||||
for (int i = 0; i < 100000; i++) {//don't want to somehow loop forever
|
||||
List<Card> booster = tryBooster();
|
||||
for (Card card : booster) {
|
||||
if (card.isLegendary() && card.isCreature()) {// Dominaria packs must contain at least one legendary creature.
|
||||
return booster;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tryBooster();
|
||||
}
|
||||
|
||||
public List<Card> tryBooster() {
|
||||
List<Card> booster = new ArrayList<>();
|
||||
if (!hasBoosters) {
|
||||
return booster;
|
||||
|
|
@ -436,6 +451,8 @@ public abstract class ExpansionSet implements Serializable {
|
|||
savedCards.clear();
|
||||
}
|
||||
|
||||
public int getMaxCardNumberInBooster() { return maxCardNumberInBooster; }
|
||||
public int getMaxCardNumberInBooster() {
|
||||
return maxCardNumberInBooster;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.filter.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageItem;
|
||||
import mage.filter.FilterImpl;
|
||||
import mage.filter.FilterInPlay;
|
||||
import mage.filter.FilterPlayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class FilterPlayerOrPlaneswalker extends FilterImpl<MageItem> implements FilterInPlay<MageItem> {
|
||||
|
||||
protected FilterPlaneswalkerPermanent planeswalkerFilter;
|
||||
protected final FilterPlayer playerFilter;
|
||||
|
||||
public FilterPlayerOrPlaneswalker() {
|
||||
this("player or planeswalker");
|
||||
}
|
||||
|
||||
public FilterPlayerOrPlaneswalker(String name) {
|
||||
super(name);
|
||||
planeswalkerFilter = new FilterPlaneswalkerPermanent();
|
||||
playerFilter = new FilterPlayer();
|
||||
}
|
||||
|
||||
public FilterPlayerOrPlaneswalker(final FilterPlayerOrPlaneswalker filter) {
|
||||
super(filter);
|
||||
this.planeswalkerFilter = filter.planeswalkerFilter.copy();
|
||||
this.playerFilter = filter.playerFilter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObjectClass(Object object) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(MageItem o, Game game) {
|
||||
if (o instanceof Player) {
|
||||
return playerFilter.match((Player) o, game);
|
||||
} else if (o instanceof Permanent) {
|
||||
return planeswalkerFilter.match((Permanent) o, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(MageItem o, UUID sourceId, UUID playerId, Game game) {
|
||||
if (o instanceof Player) {
|
||||
return playerFilter.match((Player) o, sourceId, playerId, game);
|
||||
} else if (o instanceof Permanent) {
|
||||
return planeswalkerFilter.match((Permanent) o, sourceId, playerId, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public FilterPlaneswalkerPermanent getPlaneswalkerFilter() {
|
||||
return this.planeswalkerFilter;
|
||||
}
|
||||
|
||||
public FilterPlayer getPlayerFilter() {
|
||||
return this.playerFilter;
|
||||
}
|
||||
|
||||
public void setPlaneswalkerFilter(FilterPlaneswalkerPermanent planeswalkerFilter) {
|
||||
this.planeswalkerFilter = planeswalkerFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterPlayerOrPlaneswalker copy() {
|
||||
return new FilterPlayerOrPlaneswalker(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
*/
|
||||
public class BelzenlokClericToken extends TokenImpl {
|
||||
|
||||
public BelzenlokClericToken() {
|
||||
super("Cleric", "0/1 black Cleric creature token");
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add(SubType.CLERIC);
|
||||
color.setBlack(true);
|
||||
power = new MageInt(0);
|
||||
toughness = new MageInt(1);
|
||||
}
|
||||
|
||||
public BelzenlokClericToken(final BelzenlokClericToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
public BelzenlokClericToken copy() {
|
||||
return new BelzenlokClericToken(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.SacrificeControllerEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class BelzenlokDemonToken extends TokenImpl {
|
||||
|
||||
public BelzenlokDemonToken() {
|
||||
super("Demon", "6/6 black Demon creature token with flying, trample, and "
|
||||
+ "\"At the beginning of your upkeep, sacrifice another creature. If you can't, this creature deals 6 damage to you.\"");
|
||||
cardType.add(CardType.CREATURE);
|
||||
color.setBlack(true);
|
||||
subtype.add(SubType.DEMON);
|
||||
power = new MageInt(6);
|
||||
toughness = new MageInt(6);
|
||||
addAbility(FlyingAbility.getInstance());
|
||||
addAbility(TrampleAbility.getInstance());
|
||||
addAbility(new BeginningOfUpkeepTriggeredAbility(new BelzenlokDemonTokenEffect(), TargetController.YOU, false));
|
||||
}
|
||||
|
||||
public BelzenlokDemonToken(final BelzenlokDemonToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BelzenlokDemonToken copy() {
|
||||
return new BelzenlokDemonToken(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpansionSetCodeForImage(String code) {
|
||||
super.setExpansionSetCodeForImage(code);
|
||||
if (getOriginalExpansionSetCode().equals("C14")) {
|
||||
this.setTokenType(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BelzenlokDemonTokenEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("another creature");
|
||||
|
||||
static {
|
||||
filter.add(new CardTypePredicate(CardType.CREATURE));
|
||||
filter.add(new AnotherPredicate());
|
||||
}
|
||||
|
||||
BelzenlokDemonTokenEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "sacrifice another creature. If you can't, this creature deals 6 damage to you.";
|
||||
}
|
||||
|
||||
BelzenlokDemonTokenEffect(final BelzenlokDemonTokenEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BelzenlokDemonTokenEffect copy() {
|
||||
return new BelzenlokDemonTokenEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int otherCreatures = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
|
||||
if (otherCreatures > 0) {
|
||||
new SacrificeControllerEffect(filter, 1, "").apply(game, source);
|
||||
} else {
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
permanent.damage(6, permanent.getId(), game, false, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com AS IS AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.game.permanent.token;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.MageInt;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
*/
|
||||
public class ChainersTormentNightmareToken extends TokenImpl {
|
||||
|
||||
public ChainersTormentNightmareToken(int xValue) {
|
||||
super("Nightmare", "X/X black Nightmare artifact creature token");
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add(SubType.NIGHTMARE);
|
||||
power = new MageInt(xValue);
|
||||
toughness = new MageInt(xValue);
|
||||
}
|
||||
|
||||
public ChainersTormentNightmareToken(final ChainersTormentNightmareToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
public ChainersTormentNightmareToken copy() {
|
||||
return new ChainersTormentNightmareToken(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com AS IS AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.game.permanent.token;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.keyword.HasteAbility;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author spjspj
|
||||
*/
|
||||
public class ValdukElementalToken extends TokenImpl {
|
||||
|
||||
public ValdukElementalToken() {
|
||||
this("DOM");
|
||||
}
|
||||
|
||||
public ValdukElementalToken(String setCode) {
|
||||
super("Elemental", "3/1 red Elemental creature token with trample and haste");
|
||||
cardType.add(CardType.CREATURE);
|
||||
color.setRed(true);
|
||||
subtype.add(SubType.ELEMENTAL);
|
||||
power = new MageInt(3);
|
||||
toughness = new MageInt(1);
|
||||
this.addAbility(TrampleAbility.getInstance());
|
||||
this.addAbility(HasteAbility.getInstance());
|
||||
this.setOriginalExpansionSetCode("DOM");
|
||||
this.setTokenType(1);
|
||||
}
|
||||
|
||||
public ValdukElementalToken(final ValdukElementalToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
public ValdukElementalToken copy() {
|
||||
return new ValdukElementalToken(this);
|
||||
}
|
||||
}
|
||||
218
Mage/src/main/java/mage/target/common/TargetAnyTargetAmount.java
Normal file
218
Mage/src/main/java/mage/target/common/TargetAnyTargetAmount.java
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.target.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterCreaturePlayerOrPlaneswalker;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetAmount;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TargetAnyTargetAmount extends TargetAmount {
|
||||
|
||||
protected final FilterCreaturePlayerOrPlaneswalker filter;
|
||||
|
||||
public TargetAnyTargetAmount(int amount) {
|
||||
// 107.1c If a rule or ability instructs a player to choose “any number,” that player may choose
|
||||
// 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;
|
||||
}
|
||||
|
||||
public TargetAnyTargetAmount(DynamicValue amount) {
|
||||
super(amount);
|
||||
this.zone = Zone.ALL;
|
||||
this.filter = new FilterCreaturePlayerOrPlaneswalker("targets");
|
||||
this.targetName = filter.getMessage();
|
||||
}
|
||||
|
||||
public TargetAnyTargetAmount(final TargetAnyTargetAmount target) {
|
||||
super(target);
|
||||
this.filter = target.filter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return this.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID objectId, Game game) {
|
||||
Permanent permanent = game.getPermanent(objectId);
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
Player player = game.getPlayer(objectId);
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID objectId, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(objectId);
|
||||
Player player = game.getPlayer(objectId);
|
||||
|
||||
if (source != null) {
|
||||
MageObject targetSource = source.getSourceObject(game);
|
||||
if (permanent != null) {
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
if (player != null) {
|
||||
return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game);
|
||||
}
|
||||
}
|
||||
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID playerId, UUID objectId, Ability source, Game game) {
|
||||
return canTarget(objectId, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, sourceControllerId, game)) {
|
||||
if (filter.match(permanent, null, sourceControllerId, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, sourceControllerId, game)) {
|
||||
if (filter.match(permanent, null, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetedName(Game game) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (UUID targetId : getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
sb.append(permanent.getLogName()).append('(').append(getTargetAmount(targetId)).append(") ");
|
||||
} else {
|
||||
Player player = game.getPlayer(targetId);
|
||||
sb.append(player.getLogName()).append('(').append(getTargetAmount(targetId)).append(") ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetAnyTargetAmount copy() {
|
||||
return new TargetAnyTargetAmount(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.target.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.common.FilterPlayerOrPlaneswalker;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class TargetPlayerOrPlaneswalker extends TargetImpl {
|
||||
|
||||
protected FilterPlayerOrPlaneswalker filter;
|
||||
|
||||
public TargetPlayerOrPlaneswalker() {
|
||||
this(1, 1, new FilterPlayerOrPlaneswalker());
|
||||
}
|
||||
|
||||
public TargetPlayerOrPlaneswalker(int numTargets) {
|
||||
this(numTargets, numTargets, new FilterPlayerOrPlaneswalker());
|
||||
}
|
||||
|
||||
public TargetPlayerOrPlaneswalker(FilterPlayerOrPlaneswalker filter) {
|
||||
this(1, 1, filter);
|
||||
}
|
||||
|
||||
public TargetPlayerOrPlaneswalker(int minNumTargets, int maxNumTargets, FilterPlayerOrPlaneswalker filter) {
|
||||
this.minNumberOfTargets = minNumTargets;
|
||||
this.maxNumberOfTargets = maxNumTargets;
|
||||
this.zone = Zone.ALL;
|
||||
this.filter = filter;
|
||||
this.targetName = filter.getMessage();
|
||||
}
|
||||
|
||||
public TargetPlayerOrPlaneswalker(final TargetPlayerOrPlaneswalker target) {
|
||||
super(target);
|
||||
this.filter = target.filter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
return this.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
Player player = game.getPlayer(id);
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
return canTarget(source.getControllerId(), id, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
Player player = game.getPlayer(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 (player != null) {
|
||||
return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game);
|
||||
}
|
||||
}
|
||||
|
||||
if (permanent != null) {
|
||||
return filter.match(permanent, game);
|
||||
}
|
||||
return player != null && filter.match(player, game);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are enough {@link Permanent} or {@link Player} that can
|
||||
* be chosen. Should only be used for Ability targets since this checks for
|
||||
* protection, shroud etc.
|
||||
*
|
||||
* @param sourceId - the target event source
|
||||
* @param sourceControllerId - controller of the target event source
|
||||
* @param game
|
||||
* @return - true if enough valid {@link Permanent} or {@link Player} exist
|
||||
*/
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPlaneswalkerFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are enough {@link Permanent} or {@link Player} that can
|
||||
* be selected. Should not be used for Ability targets since this does not
|
||||
* check for protection, shroud etc.
|
||||
*
|
||||
* @param sourceControllerId - controller of the select event
|
||||
* @param game
|
||||
* @return - true if enough valid {@link Permanent} or {@link Player} exist
|
||||
*/
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPlaneswalkerFilter(), sourceControllerId, game)) {
|
||||
if (filter.match(permanent, null, sourceControllerId, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null
|
||||
&& player.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||
&& filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPlaneswalkerFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||
&& filter.getPlaneswalkerFilter().match(permanent, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.getPlayerFilter().match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPlaneswalkerFilter(), sourceControllerId, game)) {
|
||||
if (filter.getPlaneswalkerFilter().match(permanent, null, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetedName(Game game) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (UUID targetId : getTargets()) {
|
||||
Permanent permanent = game.getPermanent(targetId);
|
||||
if (permanent != null) {
|
||||
sb.append(permanent.getLogName()).append(' ');
|
||||
} else {
|
||||
Player player = game.getPlayer(targetId);
|
||||
if (player != null) {
|
||||
sb.append(player.getLogName()).append(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPlayerOrPlaneswalker copy() {
|
||||
return new TargetPlayerOrPlaneswalker(this);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue