mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
* Vindictive Lich - Fixed cross mode target handling.
This commit is contained in:
parent
7b1ba214e2
commit
2880b32444
4 changed files with 216 additions and 166 deletions
|
@ -1,106 +1,105 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
package mage.cards.v;
|
package mage.cards.v;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
import mage.abilities.common.DiesTriggeredAbility;
|
import mage.abilities.common.DiesTriggeredAbility;
|
||||||
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
||||||
import mage.abilities.effects.common.SacrificeEffect;
|
import mage.abilities.effects.common.SacrificeEffect;
|
||||||
import mage.abilities.effects.common.discard.DiscardTargetEffect;
|
import mage.abilities.effects.common.discard.DiscardTargetEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.filter.FilterOpponent;
|
import mage.constants.SubType;
|
||||||
import mage.filter.StaticFilters;
|
import mage.filter.FilterOpponent;
|
||||||
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
|
import mage.filter.StaticFilters;
|
||||||
import mage.target.Target;
|
import mage.filter.predicate.mageobject.AnotherTargetPredicate;
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.target.Target;
|
||||||
|
import mage.target.common.TargetOpponent;
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
* @author anonymous
|
*
|
||||||
*/
|
* @author anonymous
|
||||||
|
*/
|
||||||
|
public class VindictiveLich extends CardImpl {
|
||||||
public class VindictiveLich extends CardImpl {
|
|
||||||
|
public VindictiveLich(UUID ownerId, CardSetInfo setInfo) {
|
||||||
public VindictiveLich(UUID ownerId, CardSetInfo setInfo) {
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}");
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}");
|
|
||||||
|
this.subtype.add(SubType.ZOMBIE, SubType.WIZARD);
|
||||||
this.subtype.add("Zombie");
|
this.power = new MageInt(4);
|
||||||
this.subtype.add("Wizard");
|
this.toughness = new MageInt(1);
|
||||||
this.power = new MageInt(4);
|
|
||||||
this.toughness = new MageInt(1);
|
// When Vindictive Lich dies, choose one or more. Each mode must target a different player.
|
||||||
|
// *Target opponent sacrifices a creature.
|
||||||
// When Vindictive Lich dies, choose one or more. Each mode must target a different player.
|
Ability ability = new DiesTriggeredAbility(new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, "target opponent"));
|
||||||
// *Target opponent sacrifices a creature.
|
ability.getModes().setMinModes(1);
|
||||||
Ability ability = new DiesTriggeredAbility(new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, "target opponent"));
|
ability.getModes().setMaxModes(3);
|
||||||
ability.getModes().setMinModes(1);
|
ability.getModes().setMaxModesFilter(new FilterOpponent("a different player"));
|
||||||
ability.getModes().setMaxModes(3);
|
|
||||||
|
FilterOpponent filter = new FilterOpponent("opponent (sacrifice)");
|
||||||
FilterOpponent filter = new FilterOpponent();
|
filter.add(new AnotherTargetPredicate(1, true));
|
||||||
filter.add(new AnotherTargetPredicate(1));
|
Target target = new TargetOpponent(filter, false);
|
||||||
Target target = new TargetOpponent(filter, false);
|
target.setTargetTag(1);
|
||||||
target.setTargetTag(1);
|
ability.addTarget(target);
|
||||||
ability.addTarget(target);
|
|
||||||
|
// *Target opponent discards two cards.
|
||||||
// *Target opponent discards two cards.
|
Mode mode = new Mode();
|
||||||
Mode mode = new Mode();
|
mode.getEffects().add(new DiscardTargetEffect(2, false));
|
||||||
mode.getEffects().add(new DiscardTargetEffect(2, false));
|
filter = new FilterOpponent("opponent (discard)");
|
||||||
filter = new FilterOpponent();
|
filter.add(new AnotherTargetPredicate(2, true));
|
||||||
filter.add(new AnotherTargetPredicate(2));
|
target = new TargetOpponent(filter, false);
|
||||||
target = new TargetOpponent(filter, false);
|
target.setTargetTag(2);
|
||||||
target.setTargetTag(2);
|
mode.getTargets().add(target);
|
||||||
mode.getTargets().add(target);
|
ability.addMode(mode);
|
||||||
ability.addMode(mode);
|
|
||||||
|
// *Target opponent loses 5 life.
|
||||||
// *Target opponent loses 5 life.
|
mode = new Mode();
|
||||||
mode = new Mode();
|
mode.getEffects().add(new LoseLifeTargetEffect(2));
|
||||||
mode.getEffects().add(new LoseLifeTargetEffect(2));
|
filter = new FilterOpponent("opponent (life loss)");
|
||||||
filter = new FilterOpponent();
|
filter.add(new AnotherTargetPredicate(3, true));
|
||||||
filter.add(new AnotherTargetPredicate(2));
|
target = new TargetOpponent(filter, false);
|
||||||
target = new TargetOpponent(filter, false);
|
target.setTargetTag(3);
|
||||||
target.setTargetTag(3);
|
mode.getTargets().add(target);
|
||||||
mode.getTargets().add(target);
|
ability.addMode(mode);
|
||||||
ability.addMode(mode);
|
this.addAbility(ability);
|
||||||
this.addAbility(ability);
|
}
|
||||||
}
|
|
||||||
|
public VindictiveLich(final VindictiveLich card) {
|
||||||
public VindictiveLich(final VindictiveLich card) {
|
super(card);
|
||||||
super(card);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public VindictiveLich copy() {
|
||||||
public VindictiveLich copy() {
|
return new VindictiveLich(this);
|
||||||
return new VindictiveLich(this);
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ import mage.abilities.costs.OptionalAdditionalModeSourceCosts;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
|
import mage.filter.Filter;
|
||||||
|
import mage.filter.FilterPlayer;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.target.common.TargetOpponent;
|
||||||
|
@ -57,6 +59,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
private boolean eachModeOnlyOnce; // state if each mode can be chosen only once as long as the source object exists
|
private boolean eachModeOnlyOnce; // state if each mode can be chosen only once as long as the source object exists
|
||||||
private final LinkedHashMap<UUID, Mode> duplicateModes = new LinkedHashMap<>();
|
private final LinkedHashMap<UUID, Mode> duplicateModes = new LinkedHashMap<>();
|
||||||
private OptionalAdditionalModeSourceCosts optionalAdditionalModeSourceCosts = null; // only set if costs have to be paid
|
private OptionalAdditionalModeSourceCosts optionalAdditionalModeSourceCosts = null; // only set if costs have to be paid
|
||||||
|
private Filter maxModesFilter = null; // calculates the max number of available modes
|
||||||
|
|
||||||
public Modes() {
|
public Modes() {
|
||||||
this.currentMode = new Mode();
|
this.currentMode = new Mode();
|
||||||
|
@ -89,6 +92,7 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
this.eachModeOnlyOnce = modes.eachModeOnlyOnce;
|
this.eachModeOnlyOnce = modes.eachModeOnlyOnce;
|
||||||
this.eachModeMoreThanOnce = modes.eachModeMoreThanOnce;
|
this.eachModeMoreThanOnce = modes.eachModeMoreThanOnce;
|
||||||
this.optionalAdditionalModeSourceCosts = modes.optionalAdditionalModeSourceCosts;
|
this.optionalAdditionalModeSourceCosts = modes.optionalAdditionalModeSourceCosts;
|
||||||
|
this.maxModesFilter = modes.maxModesFilter; // can't change so no copy needed
|
||||||
}
|
}
|
||||||
|
|
||||||
public Modes copy() {
|
public Modes copy() {
|
||||||
|
@ -151,6 +155,14 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
this.maxModes = maxModes;
|
this.maxModes = maxModes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Filter getMaxModesFilter() {
|
||||||
|
return maxModesFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxModesFilter(Filter maxModesFilter) {
|
||||||
|
this.maxModesFilter = maxModesFilter;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxModes() {
|
public int getMaxModes() {
|
||||||
return this.maxModes;
|
return this.maxModes;
|
||||||
}
|
}
|
||||||
|
@ -230,7 +242,19 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
|
|
||||||
// player chooses modes manually
|
// player chooses modes manually
|
||||||
this.currentMode = null;
|
this.currentMode = null;
|
||||||
while (this.selectedModes.size() < this.getMaxModes()) {
|
int currentMaxModes = this.getMaxModes();
|
||||||
|
if (getMaxModesFilter() != null) {
|
||||||
|
if (maxModesFilter instanceof FilterPlayer) {
|
||||||
|
currentMaxModes = 0;
|
||||||
|
for (UUID targetPlayerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||||
|
Player targetPlayer = game.getPlayer(targetPlayerId);
|
||||||
|
if (((FilterPlayer) maxModesFilter).match(targetPlayer, source.getSourceId(), source.getControllerId(), game)) {
|
||||||
|
currentMaxModes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (this.selectedModes.size() < currentMaxModes) {
|
||||||
Mode choice = player.chooseMode(this, source, game);
|
Mode choice = player.chooseMode(this, source, game);
|
||||||
if (choice == null) {
|
if (choice == null) {
|
||||||
if (isEachModeOnlyOnce()) {
|
if (isEachModeOnlyOnce()) {
|
||||||
|
@ -337,7 +361,9 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
|
||||||
return this.getMode().getEffects().getText(this.getMode());
|
return this.getMode().getEffects().getText(this.getMode());
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (this.getMinModes() == 1 && this.getMaxModes() == 3) {
|
if (this.getMaxModesFilter() != null) {
|
||||||
|
sb.append("choose one or more. Each mode must target ").append(getMaxModesFilter().getMessage());
|
||||||
|
} else if (this.getMinModes() == 1 && this.getMaxModes() == 3) {
|
||||||
sb.append("choose one or more ");
|
sb.append("choose one or more ");
|
||||||
} else if (this.getMinModes() == 1 && this.getMaxModes() == 2) {
|
} else if (this.getMinModes() == 1 && this.getMaxModes() == 2) {
|
||||||
sb.append("choose one or both ");
|
sb.append("choose one or both ");
|
||||||
|
|
|
@ -1,53 +1,57 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
package mage.filter;
|
package mage.filter;
|
||||||
|
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
import mage.filter.predicate.other.PlayerPredicate;
|
import mage.filter.predicate.other.PlayerPredicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class FilterOpponent extends FilterPlayer{
|
public class FilterOpponent extends FilterPlayer {
|
||||||
|
|
||||||
public FilterOpponent() {
|
public FilterOpponent() {
|
||||||
super("opponent");
|
this("opponent");
|
||||||
add(new PlayerPredicate(TargetController.OPPONENT));
|
}
|
||||||
}
|
|
||||||
|
public FilterOpponent(String text) {
|
||||||
|
super(text);
|
||||||
public FilterOpponent(final FilterOpponent filter) {
|
add(new PlayerPredicate(TargetController.OPPONENT));
|
||||||
super(filter);
|
}
|
||||||
|
|
||||||
}
|
public FilterOpponent(final FilterOpponent filter) {
|
||||||
@Override
|
super(filter);
|
||||||
public FilterOpponent copy() {
|
|
||||||
return new FilterOpponent(this);
|
}
|
||||||
}
|
|
||||||
}
|
@Override
|
||||||
|
public FilterOpponent copy() {
|
||||||
|
return new FilterOpponent(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -27,7 +27,9 @@
|
||||||
*/
|
*/
|
||||||
package mage.filter.predicate.mageobject;
|
package mage.filter.predicate.mageobject;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
import mage.MageItem;
|
import mage.MageItem;
|
||||||
|
import mage.abilities.Mode;
|
||||||
import mage.filter.predicate.ObjectSourcePlayer;
|
import mage.filter.predicate.ObjectSourcePlayer;
|
||||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -45,24 +47,43 @@ import mage.target.Target;
|
||||||
public class AnotherTargetPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<MageItem>> {
|
public class AnotherTargetPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<MageItem>> {
|
||||||
|
|
||||||
private final int targetTag;
|
private final int targetTag;
|
||||||
|
private final boolean crossModalCheck;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param targetTag tag of the target the filter belongs to
|
* @param targetTag tag of the target the filter belongs to
|
||||||
*/
|
*/
|
||||||
public AnotherTargetPredicate(int targetTag) {
|
public AnotherTargetPredicate(int targetTag) {
|
||||||
|
this(targetTag, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnotherTargetPredicate(int targetTag, boolean crossModalCheck) {
|
||||||
this.targetTag = targetTag;
|
this.targetTag = targetTag;
|
||||||
|
this.crossModalCheck = crossModalCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(ObjectSourcePlayer<MageItem> input, Game game) {
|
public boolean apply(ObjectSourcePlayer<MageItem> input, Game game) {
|
||||||
StackObject source = game.getStack().getStackObject(input.getSourceId());
|
StackObject source = game.getStack().getStackObject(input.getSourceId());
|
||||||
if (source != null && source.getStackAbility().getTargets() != null) {
|
if (source != null && source.getStackAbility().getTargets() != null) {
|
||||||
for (Target target : source.getStackAbility().getTargets()) {
|
if (crossModalCheck) {
|
||||||
if (target.getTargetTag() > 0 // target is included in the target group to check
|
for (UUID modeId : source.getStackAbility().getModes().getSelectedModes()) {
|
||||||
&& target.getTargetTag() != targetTag // it's not the target of this predicate
|
Mode mode = source.getStackAbility().getModes().get(modeId);
|
||||||
&& target.getTargets().contains(input.getObject().getId())) { // if the uuid already is used for another target in the group it's not allowed here
|
for (Target target : mode.getTargets()) {
|
||||||
return false;
|
if (target.getTargetTag() > 0 // target is included in the target group to check
|
||||||
|
&& target.getTargetTag() != targetTag // it's not the target of this predicate
|
||||||
|
&& target.getTargets().contains(input.getObject().getId())) { // if the uuid already is used for another target in the group it's not allowed here
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (Target target : source.getStackAbility().getTargets()) {
|
||||||
|
if (target.getTargetTag() > 0 // target is included in the target group to check
|
||||||
|
&& target.getTargetTag() != targetTag // it's not the target of this predicate
|
||||||
|
&& target.getTargets().contains(input.getObject().getId())) { // if the uuid already is used for another target in the group it's not allowed here
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue