mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
- Replaced the interface ITargetable with the class GameObject (which reflects the term used in the rules for players, cards and spell/abilities).
- Preparations for extending isValid and hasProperty functions for spell/abilities.
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -14510,7 +14510,7 @@ src/main/java/forge/GameLog.java -text
|
|||||||
src/main/java/forge/GameLogEntry.java -text
|
src/main/java/forge/GameLogEntry.java -text
|
||||||
src/main/java/forge/GameLogEntryType.java -text
|
src/main/java/forge/GameLogEntryType.java -text
|
||||||
src/main/java/forge/GameLogFormatter.java -text
|
src/main/java/forge/GameLogFormatter.java -text
|
||||||
src/main/java/forge/ITargetable.java -text
|
src/main/java/forge/GameObject.java -text
|
||||||
src/main/java/forge/ImageCache.java svneol=native#text/plain
|
src/main/java/forge/ImageCache.java svneol=native#text/plain
|
||||||
src/main/java/forge/ImageLoader.java -text
|
src/main/java/forge/ImageLoader.java -text
|
||||||
src/main/java/forge/Singletons.java svneol=native#text/plain
|
src/main/java/forge/Singletons.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.util.TreeMap;
|
|||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.event.GameEventCardAttachment;
|
import forge.game.event.GameEventCardAttachment;
|
||||||
import forge.game.event.GameEventCardAttachment.AttachMethod;
|
import forge.game.event.GameEventCardAttachment.AttachMethod;
|
||||||
import forge.game.player.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -34,7 +33,7 @@ import forge.game.player.Player;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id: Player.java 10091 2011-08-30 16:11:21Z Sloth $
|
* @version $Id: Player.java 10091 2011-08-30 16:11:21Z Sloth $
|
||||||
*/
|
*/
|
||||||
public abstract class GameEntity implements ITargetable {
|
public abstract class GameEntity extends GameObject {
|
||||||
private String name = "";
|
private String name = "";
|
||||||
private int preventNextDamage = 0;
|
private int preventNextDamage = 0;
|
||||||
private TreeMap<Card, Map<String, String>> preventionShieldsWithEffects = new TreeMap<Card, Map<String, String>>();
|
private TreeMap<Card, Map<String, String>> preventionShieldsWithEffects = new TreeMap<Card, Map<String, String>>();
|
||||||
@@ -342,58 +341,6 @@ public abstract class GameEntity implements ITargetable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is valid.
|
|
||||||
*
|
|
||||||
* @param restrictions
|
|
||||||
* the restrictions
|
|
||||||
* @param sourceController
|
|
||||||
* the source controller
|
|
||||||
* @param source
|
|
||||||
* the source
|
|
||||||
* @return true, if is valid
|
|
||||||
*/
|
|
||||||
public boolean isValid(final String[] restrictions, final Player sourceController, final Card source) {
|
|
||||||
|
|
||||||
for (final String restriction : restrictions) {
|
|
||||||
if (this.isValid(restriction, sourceController, source)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
} // isValid
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is valid.
|
|
||||||
*
|
|
||||||
* @param restriction
|
|
||||||
* the restriction
|
|
||||||
* @param sourceController
|
|
||||||
* the source controller
|
|
||||||
* @param source
|
|
||||||
* the source
|
|
||||||
* @return true, if is valid
|
|
||||||
*/
|
|
||||||
public boolean isValid(final String restriction, final Player sourceController, final Card source) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks for property.
|
|
||||||
*
|
|
||||||
* @param property
|
|
||||||
* the property
|
|
||||||
* @param sourceController
|
|
||||||
* the source controller
|
|
||||||
* @param source
|
|
||||||
* the source
|
|
||||||
* @return true, if successful
|
|
||||||
*/
|
|
||||||
public boolean hasProperty(final String property, final Player sourceController, final Card source) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GameEntities can now be Enchanted
|
// GameEntities can now be Enchanted
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
63
src/main/java/forge/GameObject.java
Normal file
63
src/main/java/forge/GameObject.java
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
package forge;
|
||||||
|
|
||||||
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.game.player.Player;
|
||||||
|
|
||||||
|
public abstract class GameObject {
|
||||||
|
|
||||||
|
public boolean canBeTargetedBy(final SpellAbility sa) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is valid.
|
||||||
|
*
|
||||||
|
* @param restrictions
|
||||||
|
* the restrictions
|
||||||
|
* @param sourceController
|
||||||
|
* the source controller
|
||||||
|
* @param source
|
||||||
|
* the source
|
||||||
|
* @return true, if is valid
|
||||||
|
*/
|
||||||
|
public boolean isValid(final String[] restrictions, final Player sourceController, final Card source) {
|
||||||
|
|
||||||
|
for (final String restriction : restrictions) {
|
||||||
|
if (this.isValid(restriction, sourceController, source)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
} // isValid
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is valid.
|
||||||
|
*
|
||||||
|
* @param restriction
|
||||||
|
* the restriction
|
||||||
|
* @param sourceController
|
||||||
|
* the source controller
|
||||||
|
* @param source
|
||||||
|
* the source
|
||||||
|
* @return true, if is valid
|
||||||
|
*/
|
||||||
|
public boolean isValid(final String restriction, final Player sourceController, final Card source) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for property.
|
||||||
|
*
|
||||||
|
* @param property
|
||||||
|
* the property
|
||||||
|
* @param sourceController
|
||||||
|
* the source controller
|
||||||
|
* @param source
|
||||||
|
* the source
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
|
public boolean hasProperty(final String property, final Player sourceController, final Card source) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package forge;
|
|
||||||
|
|
||||||
import forge.card.spellability.SpellAbility;
|
|
||||||
|
|
||||||
public interface ITargetable {
|
|
||||||
boolean canBeTargetedBy(final SpellAbility sa);
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,7 @@ import forge.Card;
|
|||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
@@ -469,7 +469,7 @@ public class AbilityUtils {
|
|||||||
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
return CardFactoryUtil.playerXCount(players, calcX[1], card) * multiplier;
|
||||||
}
|
}
|
||||||
if (calcX[0].startsWith("TargetedObjects")) {
|
if (calcX[0].startsWith("TargetedObjects")) {
|
||||||
final List<ITargetable> objects = new ArrayList<ITargetable>();
|
final List<GameObject> objects = new ArrayList<GameObject>();
|
||||||
// Make list of all targeted objects starting with the root SpellAbility
|
// Make list of all targeted objects starting with the root SpellAbility
|
||||||
SpellAbility loopSA = ability.getRootAbility();
|
SpellAbility loopSA = ability.getRootAbility();
|
||||||
while (loopSA != null) {
|
while (loopSA != null) {
|
||||||
@@ -603,8 +603,8 @@ public class AbilityUtils {
|
|||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
* a {@link forge.card.spellability.SpellAbility} object.
|
||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
public static List<ITargetable> getDefinedObjects(final Card card, final String def, final SpellAbility sa) {
|
public static List<GameObject> getDefinedObjects(final Card card, final String def, final SpellAbility sa) {
|
||||||
final ArrayList<ITargetable> objects = new ArrayList<ITargetable>();
|
final ArrayList<GameObject> objects = new ArrayList<GameObject>();
|
||||||
final String defined = (def == null) ? "Self" : def;
|
final String defined = (def == null) ? "Self" : def;
|
||||||
|
|
||||||
objects.addAll(AbilityUtils.getDefinedPlayers(card, defined, sa));
|
objects.addAll(AbilityUtils.getDefinedPlayers(card, defined, sa));
|
||||||
@@ -1194,7 +1194,7 @@ public class AbilityUtils {
|
|||||||
if (sa.hasParam("ForgetOtherTargets")) {
|
if (sa.hasParam("ForgetOtherTargets")) {
|
||||||
host.clearRemembered();
|
host.clearRemembered();
|
||||||
}
|
}
|
||||||
for (final ITargetable o : sa.getTargets().getTargets()) {
|
for (final GameObject o : sa.getTargets().getTargets()) {
|
||||||
host.addRemembered(o);
|
host.addRemembered(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
|
||||||
@@ -51,11 +51,11 @@ public class SaTargetRoutines {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Targets of unspecified type
|
// Targets of unspecified type
|
||||||
protected List<ITargetable> getTargets(SpellAbility sa) { return getTargetables(false, "Defined", sa); }
|
protected List<GameObject> getTargets(SpellAbility sa) { return getTargetables(false, "Defined", sa); }
|
||||||
protected List<ITargetable> getTargets(SpellAbility sa, String definedParam) { return getTargetables(false, definedParam, sa); }
|
protected List<GameObject> getTargets(SpellAbility sa, String definedParam) { return getTargetables(false, definedParam, sa); }
|
||||||
protected List<ITargetable> getDefinedOrTargeteded(SpellAbility sa, String definedParam) { return getTargetables(true, definedParam, sa); }
|
protected List<GameObject> getDefinedOrTargeteded(SpellAbility sa, String definedParam) { return getTargetables(true, definedParam, sa); }
|
||||||
|
|
||||||
private List<ITargetable> getTargetables(boolean definedFirst, String definedParam, SpellAbility sa) {
|
private List<GameObject> getTargetables(boolean definedFirst, String definedParam, SpellAbility sa) {
|
||||||
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||||
return useTargets ? Lists.newArrayList(sa.getTargets().getTargets())
|
return useTargets ? Lists.newArrayList(sa.getTargets().getTargets())
|
||||||
: AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam(definedParam), sa);
|
: AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam(definedParam), sa);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import forge.Card;
|
|||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.ability.SpellAbilityAi;
|
import forge.card.ability.SpellAbilityAi;
|
||||||
@@ -628,7 +628,7 @@ public class AttachAi extends SpellAbilityAi {
|
|||||||
protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
protected boolean doTriggerAINoCost(final Player ai, final SpellAbility sa, final boolean mandatory) {
|
||||||
final Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
// Check if there are any valid targets
|
// Check if there are any valid targets
|
||||||
List<ITargetable> targets = new ArrayList<ITargetable>();
|
List<GameObject> targets = new ArrayList<GameObject>();
|
||||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
targets = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
targets = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||||
@@ -703,7 +703,7 @@ public class AttachAi extends SpellAbilityAi {
|
|||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
private static boolean attachPreference(final SpellAbility sa, final TargetRestrictions tgt, final boolean mandatory) {
|
private static boolean attachPreference(final SpellAbility sa, final TargetRestrictions tgt, final boolean mandatory) {
|
||||||
ITargetable o;
|
GameObject o;
|
||||||
if (tgt.canTgtPlayer()) {
|
if (tgt.canTgtPlayer()) {
|
||||||
o = attachToPlayerAIPreferences(sa.getActivatingPlayer(), sa, mandatory);
|
o = attachToPlayerAIPreferences(sa.getActivatingPlayer(), sa, mandatory);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import forge.CardPredicates;
|
|||||||
import forge.CardPredicates.Presets;
|
import forge.CardPredicates.Presets;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.ability.SpellAbilityAi;
|
import forge.card.ability.SpellAbilityAi;
|
||||||
@@ -621,7 +621,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<ITargetable> objects = ComputerUtil.predictThreatenedObjects(ai, sa);
|
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(ai, sa);
|
||||||
boolean contains = false;
|
boolean contains = false;
|
||||||
for (final Card c : retrieval) {
|
for (final Card c : retrieval) {
|
||||||
if (objects.contains(c)) {
|
if (objects.contains(c)) {
|
||||||
@@ -743,7 +743,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
|
|||||||
// check stack for something on the stack that will kill
|
// check stack for something on the stack that will kill
|
||||||
// anything i control
|
// anything i control
|
||||||
if (!game.getStack().isEmpty()) {
|
if (!game.getStack().isEmpty()) {
|
||||||
final List<ITargetable> objects = ComputerUtil.predictThreatenedObjects(ai, sa);
|
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(ai, sa);
|
||||||
|
|
||||||
final List<Card> threatenedTargets = new ArrayList<Card>();
|
final List<Card> threatenedTargets = new ArrayList<Card>();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import com.google.common.base.Predicate;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.ability.SpellAbilityAi;
|
import forge.card.ability.SpellAbilityAi;
|
||||||
@@ -79,7 +79,7 @@ public class ChooseSourceAi extends SpellAbilityAi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Card threatSource = topStack.getSourceCard();
|
final Card threatSource = topStack.getSourceCard();
|
||||||
List<? extends ITargetable> objects = getTargets(sa);
|
List<? extends GameObject> objects = getTargets(sa);
|
||||||
|
|
||||||
if (!topStack.usesTargeting() && topStack.hasParam("ValidPlayers") && !topStack.hasParam("Defined")) {
|
if (!topStack.usesTargeting() && topStack.hasParam("ValidPlayers") && !topStack.hasParam("Defined")) {
|
||||||
objects = AbilityUtils.getDefinedPlayers(threatSource, topStack.getParam("ValidPlayers"), topStack);
|
objects = AbilityUtils.getDefinedPlayers(threatSource, topStack.getParam("ValidPlayers"), topStack);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.google.common.collect.Lists;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityAi;
|
import forge.card.ability.SpellAbilityAi;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
@@ -149,7 +149,7 @@ public class DamageDealAi extends DamageAiBase {
|
|||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
List<Card> hPlay = CardLists.getValidCards(pl.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, source);
|
List<Card> hPlay = CardLists.getValidCards(pl.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), ai, source);
|
||||||
|
|
||||||
final List<ITargetable> objects = Lists.newArrayList(sa.getTargets().getTargets());
|
final List<GameObject> objects = Lists.newArrayList(sa.getTargets().getTargets());
|
||||||
if (sa.hasParam("TargetUnique")) {
|
if (sa.hasParam("TargetUnique")) {
|
||||||
objects.addAll(sa.getUniqueTargets());
|
objects.addAll(sa.getUniqueTargets());
|
||||||
}
|
}
|
||||||
@@ -374,7 +374,7 @@ public class DamageDealAi extends DamageAiBase {
|
|||||||
*/
|
*/
|
||||||
private boolean damageChooseNontargeted(Player ai, final SpellAbility saMe, final int dmg) {
|
private boolean damageChooseNontargeted(Player ai, final SpellAbility saMe, final int dmg) {
|
||||||
// TODO: Improve circumstances where the Defined Damage is unwanted
|
// TODO: Improve circumstances where the Defined Damage is unwanted
|
||||||
final List<ITargetable> objects = AbilityUtils.getDefinedObjects(saMe.getSourceCard(), saMe.getParam("Defined"), saMe);
|
final List<GameObject> objects = AbilityUtils.getDefinedObjects(saMe.getSourceCard(), saMe.getParam("Defined"), saMe);
|
||||||
boolean urgent = false; // can it wait?
|
boolean urgent = false; // can it wait?
|
||||||
boolean positive = false;
|
boolean positive = false;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.util.List;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityAi;
|
import forge.card.ability.SpellAbilityAi;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
@@ -55,11 +55,11 @@ public class DamagePreventAi extends SpellAbilityAi {
|
|||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
// As far as I can tell these Defined Cards will only have one of
|
// As far as I can tell these Defined Cards will only have one of
|
||||||
// them
|
// them
|
||||||
final List<ITargetable> objects = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
final List<GameObject> objects = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||||
|
|
||||||
// react to threats on the stack
|
// react to threats on the stack
|
||||||
if (!game.getStack().isEmpty()) {
|
if (!game.getStack().isEmpty()) {
|
||||||
final List<ITargetable> threatenedObjects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
final List<GameObject> threatenedObjects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||||
for (final Object o : objects) {
|
for (final Object o : objects) {
|
||||||
if (threatenedObjects.contains(o)) {
|
if (threatenedObjects.contains(o)) {
|
||||||
chance = true;
|
chance = true;
|
||||||
@@ -94,7 +94,7 @@ public class DamagePreventAi extends SpellAbilityAi {
|
|||||||
else if (!game.getStack().isEmpty()) {
|
else if (!game.getStack().isEmpty()) {
|
||||||
sa.resetTargets();
|
sa.resetTargets();
|
||||||
// check stack for something on the stack will kill anything i control
|
// check stack for something on the stack will kill anything i control
|
||||||
final List<ITargetable> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||||
|
|
||||||
if (objects.contains(ai)) {
|
if (objects.contains(ai)) {
|
||||||
sa.getTargets().add(ai);
|
sa.getTargets().add(ai);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityAi;
|
import forge.card.ability.SpellAbilityAi;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
@@ -91,7 +91,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
|||||||
final List<Card> list = AbilityUtils.getDefinedCards(hostCard, sa.getParam("Defined"), sa);
|
final List<Card> list = AbilityUtils.getDefinedCards(hostCard, sa.getParam("Defined"), sa);
|
||||||
|
|
||||||
if (!game.getStack().isEmpty()) {
|
if (!game.getStack().isEmpty()) {
|
||||||
final List<ITargetable> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||||
|
|
||||||
for (final Card c : list) {
|
for (final Card c : list) {
|
||||||
if (objects.contains(c)) {
|
if (objects.contains(c)) {
|
||||||
@@ -127,7 +127,7 @@ public class RegenerateAi extends SpellAbilityAi {
|
|||||||
if (!game.getStack().isEmpty()) {
|
if (!game.getStack().isEmpty()) {
|
||||||
// check stack for something on the stack will kill anything i
|
// check stack for something on the stack will kill anything i
|
||||||
// control
|
// control
|
||||||
final List<ITargetable> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||||
|
|
||||||
final List<Card> threatenedTargets = new ArrayList<Card>();
|
final List<Card> threatenedTargets = new ArrayList<Card>();
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.SpellAbilityAi;
|
import forge.card.ability.SpellAbilityAi;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
@@ -58,7 +58,7 @@ public class RegenerateAllAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
int numSaved = 0;
|
int numSaved = 0;
|
||||||
if (!game.getStack().isEmpty()) {
|
if (!game.getStack().isEmpty()) {
|
||||||
final List<ITargetable> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa);
|
||||||
|
|
||||||
for (final Card c : list) {
|
for (final Card c : list) {
|
||||||
if (objects.contains(c) && c.getShield() == 0) {
|
if (objects.contains(c) && c.getShield() == 0) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityAi;
|
import forge.card.ability.SpellAbilityAi;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
@@ -68,7 +68,7 @@ public class UnattachAllAi extends SpellAbilityAi {
|
|||||||
final Card card = sa.getSourceCard();
|
final Card card = sa.getSourceCard();
|
||||||
final Player opp = ai.getOpponent();
|
final Player opp = ai.getOpponent();
|
||||||
// Check if there are any valid targets
|
// Check if there are any valid targets
|
||||||
List<ITargetable> targets = new ArrayList<ITargetable>();
|
List<GameObject> targets = new ArrayList<GameObject>();
|
||||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||||
if (tgt == null) {
|
if (tgt == null) {
|
||||||
targets = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
targets = AbilityUtils.getDefinedObjects(sa.getSourceCard(), sa.getParam("Defined"), sa);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import forge.Card;
|
|||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
@@ -39,7 +39,7 @@ public class AttachEffect extends SpellAbilityEffect {
|
|||||||
Card source = sa.getSourceCard();
|
Card source = sa.getSourceCard();
|
||||||
Card card = sa.getSourceCard();
|
Card card = sa.getSourceCard();
|
||||||
|
|
||||||
final List<ITargetable> targets = getTargets(sa);
|
final List<GameObject> targets = getTargets(sa);
|
||||||
|
|
||||||
if (sa.hasParam("Object")) {
|
if (sa.hasParam("Object")) {
|
||||||
card = AbilityUtils.getDefinedCards(source, sa.getParam("Object"), sa).get(0);
|
card = AbilityUtils.getDefinedCards(source, sa.getParam("Object"), sa).get(0);
|
||||||
@@ -66,7 +66,7 @@ public class AttachEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
sb.append(" Attach to ");
|
sb.append(" Attach to ");
|
||||||
|
|
||||||
final List<ITargetable> targets = getTargets(sa);
|
final List<GameObject> targets = getTargets(sa);
|
||||||
// Should never allow more than one Attachment per card
|
// Should never allow more than one Attachment per card
|
||||||
|
|
||||||
sb.append(Lang.joinHomogenous(targets));
|
sb.append(Lang.joinHomogenous(targets));
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.card.spellability.SpellAbilityStackInstance;
|
import forge.card.spellability.SpellAbilityStackInstance;
|
||||||
@@ -53,11 +53,11 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
if( changesOneTarget ) {
|
if( changesOneTarget ) {
|
||||||
// 1. choose a target of target spell
|
// 1. choose a target of target spell
|
||||||
List<Pair<SpellAbilityStackInstance, ITargetable>> allTargets = new ArrayList<>();
|
List<Pair<SpellAbilityStackInstance, GameObject>> allTargets = new ArrayList<>();
|
||||||
while(changingTgtSI != null) {
|
while(changingTgtSI != null) {
|
||||||
SpellAbility changedSa = changingTgtSI.getSpellAbility();
|
SpellAbility changedSa = changingTgtSI.getSpellAbility();
|
||||||
if(changedSa.usesTargeting()) {
|
if(changedSa.usesTargeting()) {
|
||||||
for(ITargetable it : changedSa.getTargets().getTargets())
|
for(GameObject it : changedSa.getTargets().getTargets())
|
||||||
allTargets.add(ImmutablePair.of(changingTgtSI, it));
|
allTargets.add(ImmutablePair.of(changingTgtSI, it));
|
||||||
}
|
}
|
||||||
changingTgtSI = changingTgtSI.getSubInstace();
|
changingTgtSI = changingTgtSI.getSubInstace();
|
||||||
@@ -68,16 +68,16 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pair<SpellAbilityStackInstance, ITargetable> chosenTarget = chooser.getController().chooseTarget(sa, allTargets);
|
Pair<SpellAbilityStackInstance, GameObject> chosenTarget = chooser.getController().chooseTarget(sa, allTargets);
|
||||||
// 2. prepare new target choices
|
// 2. prepare new target choices
|
||||||
SpellAbilityStackInstance replaceIn = chosenTarget.getKey();
|
SpellAbilityStackInstance replaceIn = chosenTarget.getKey();
|
||||||
ITargetable oldTarget = chosenTarget.getValue();
|
GameObject oldTarget = chosenTarget.getValue();
|
||||||
TargetChoices oldTargetBlock = replaceIn.getTargetChoices();
|
TargetChoices oldTargetBlock = replaceIn.getTargetChoices();
|
||||||
TargetChoices newTargetBlock = oldTargetBlock.clone();
|
TargetChoices newTargetBlock = oldTargetBlock.clone();
|
||||||
newTargetBlock.remove(oldTarget);
|
newTargetBlock.remove(oldTarget);
|
||||||
replaceIn.updateTarget(newTargetBlock);
|
replaceIn.updateTarget(newTargetBlock);
|
||||||
// 3. test if updated choices would be correct.
|
// 3. test if updated choices would be correct.
|
||||||
ITargetable newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa), null);
|
GameObject newTarget = Iterables.getFirst(getDefinedCardsOrTargeted(sa), null);
|
||||||
if(replaceIn.getSpellAbility().canTarget(newTarget)) {
|
if(replaceIn.getSpellAbility().canTarget(newTarget)) {
|
||||||
newTargetBlock.add(newTarget);
|
newTargetBlock.add(newTarget);
|
||||||
replaceIn.updateTarget(newTargetBlock);
|
replaceIn.updateTarget(newTargetBlock);
|
||||||
@@ -94,8 +94,8 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
changingTgtSA.resetTargets();
|
changingTgtSA.resetTargets();
|
||||||
List<ITargetable> candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true);
|
List<GameObject> candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true);
|
||||||
ITargetable choice = Aggregates.random(candidates);
|
GameObject choice = Aggregates.random(candidates);
|
||||||
changingTgtSA.getTargets().add(choice);
|
changingTgtSA.getTargets().add(choice);
|
||||||
changingTgtSI.updateTarget(changingTgtSA.getTargets());
|
changingTgtSI.updateTarget(changingTgtSA.getTargets());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
@@ -206,7 +206,7 @@ public class ChooseSourceEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<? extends ITargetable> objects = getTargets(abilityOnStack);
|
List<? extends GameObject> objects = getTargets(abilityOnStack);
|
||||||
|
|
||||||
if (!abilityOnStack.usesTargeting() && !abilityOnStack.hasParam("Defined") && abilityOnStack.hasParam("ValidPlayers"))
|
if (!abilityOnStack.usesTargeting() && !abilityOnStack.hasParam("Defined") && abilityOnStack.hasParam("ValidPlayers"))
|
||||||
objects = AbilityUtils.getDefinedPlayers(source, abilityOnStack.getParam("ValidPlayers"), abilityOnStack);
|
objects = AbilityUtils.getDefinedPlayers(source, abilityOnStack.getParam("ValidPlayers"), abilityOnStack);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.google.common.collect.Iterables;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
import forge.card.cardfactory.CardFactory;
|
import forge.card.cardfactory.CardFactory;
|
||||||
@@ -92,7 +92,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
targetedSA = targetedSA.getSubAbility();
|
targetedSA = targetedSA.getSubAbility();
|
||||||
}
|
}
|
||||||
List<ITargetable> candidates = targetedSA.getTargetRestrictions().getAllCandidates(targetedSA, true);
|
List<GameObject> candidates = targetedSA.getTargetRestrictions().getAllCandidates(targetedSA, true);
|
||||||
if (sa.hasParam("CanTargetPlayer")) {
|
if (sa.hasParam("CanTargetPlayer")) {
|
||||||
// Radiate
|
// Radiate
|
||||||
// Remove targeted players because getAllCandidates include all the valid players
|
// Remove targeted players because getAllCandidates include all the valid players
|
||||||
@@ -100,7 +100,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
|||||||
candidates.remove(p);
|
candidates.remove(p);
|
||||||
|
|
||||||
mayChoseNewTargets = false;
|
mayChoseNewTargets = false;
|
||||||
for (ITargetable o : candidates) {
|
for (GameObject o : candidates) {
|
||||||
SpellAbility copy = CardFactory.copySpellAbilityAndSrcCard(card, chosenSA.getSourceCard(), chosenSA, true);
|
SpellAbility copy = CardFactory.copySpellAbilityAndSrcCard(card, chosenSA.getSourceCard(), chosenSA, true);
|
||||||
copy.resetFirstTarget(o);
|
copy.resetFirstTarget(o);
|
||||||
copies.add(copy);
|
copies.add(copy);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
@@ -26,7 +26,7 @@ public class CountersPutOrRemoveEffect extends SpellAbilityEffect {
|
|||||||
sb.append(sa.getActivatingPlayer().getName());
|
sb.append(sa.getActivatingPlayer().getName());
|
||||||
sb.append(" removes a counter from or puts another of those counters on ");
|
sb.append(" removes a counter from or puts another of those counters on ");
|
||||||
|
|
||||||
final List<ITargetable> targets = getTargets(sa);
|
final List<GameObject> targets = getTargets(sa);
|
||||||
sb.append(Lang.joinHomogenous(targets));
|
sb.append(Lang.joinHomogenous(targets));
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
@@ -28,7 +28,7 @@ public class DamageDealEffect extends SpellAbilityEffect {
|
|||||||
final int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa);
|
final int dmg = AbilityUtils.calculateAmount(sa.getSourceCard(), damage, sa);
|
||||||
|
|
||||||
|
|
||||||
List<ITargetable> tgts = getTargets(sa);
|
List<GameObject> tgts = getTargets(sa);
|
||||||
if (tgts.isEmpty())
|
if (tgts.isEmpty())
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class DamageDealEffect extends SpellAbilityEffect {
|
|||||||
final boolean removeDamage = sa.hasParam("Remove");
|
final boolean removeDamage = sa.hasParam("Remove");
|
||||||
final boolean divideOnResolution = sa.hasParam("DividerOnResolution");
|
final boolean divideOnResolution = sa.hasParam("DividerOnResolution");
|
||||||
|
|
||||||
List<ITargetable> tgts = getTargets(sa);
|
List<GameObject> tgts = getTargets(sa);
|
||||||
|
|
||||||
// Right now for Fireball, maybe later for other stuff
|
// Right now for Fireball, maybe later for other stuff
|
||||||
if (sa.hasParam("DivideEvenly")) {
|
if (sa.hasParam("DivideEvenly")) {
|
||||||
@@ -121,7 +121,7 @@ public class DamageDealEffect extends SpellAbilityEffect {
|
|||||||
|
|
||||||
List<Card> assigneeCards = new ArrayList<Card>();
|
List<Card> assigneeCards = new ArrayList<Card>();
|
||||||
// Do we have a way of doing this in a better fashion?
|
// Do we have a way of doing this in a better fashion?
|
||||||
for(ITargetable obj : tgts) {
|
for(GameObject obj : tgts) {
|
||||||
if (obj instanceof Card) {
|
if (obj instanceof Card) {
|
||||||
assigneeCards.add((Card)obj);
|
assigneeCards.add((Card)obj);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
@@ -65,7 +65,7 @@ public class DamageEachEffect extends SpellAbilityEffect {
|
|||||||
sources = CardLists.getValidCards(sources, sa.getParam("ValidCards"), card.getController(), card);
|
sources = CardLists.getValidCards(sources, sa.getParam("ValidCards"), card.getController(), card);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<ITargetable> tgts = getTargets(sa, "DefinedPlayers");
|
final List<GameObject> tgts = getTargets(sa, "DefinedPlayers");
|
||||||
|
|
||||||
final boolean targeted = (sa.usesTargeting());
|
final boolean targeted = (sa.usesTargeting());
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
@@ -18,7 +18,7 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
|||||||
protected String getStackDescription(SpellAbility sa) {
|
protected String getStackDescription(SpellAbility sa) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
final List<ITargetable> tgts = getTargets(sa);
|
final List<GameObject> tgts = getTargets(sa);
|
||||||
|
|
||||||
sb.append("Prevent the next ");
|
sb.append("Prevent the next ");
|
||||||
sb.append(sa.getParam("Amount"));
|
sb.append(sa.getParam("Amount"));
|
||||||
@@ -67,7 +67,7 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
|||||||
Card host = sa.getSourceCard();
|
Card host = sa.getSourceCard();
|
||||||
int numDam = AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa);
|
int numDam = AbilityUtils.calculateAmount(host, sa.getParam("Amount"), sa);
|
||||||
|
|
||||||
final List<ITargetable> tgts = getTargets(sa);
|
final List<GameObject> tgts = getTargets(sa);
|
||||||
final ArrayList<Card> untargetedCards = new ArrayList<Card>();
|
final ArrayList<Card> untargetedCards = new ArrayList<Card>();
|
||||||
|
|
||||||
if (sa.hasParam("Radiance") && (sa.usesTargeting())) {
|
if (sa.hasParam("Radiance") && (sa.usesTargeting())) {
|
||||||
@@ -100,7 +100,7 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
|||||||
effectMap.put("ShieldAmount", String.valueOf(numDam));
|
effectMap.put("ShieldAmount", String.valueOf(numDam));
|
||||||
if (sa.hasParam("ShieldEffectTarget")) {
|
if (sa.hasParam("ShieldEffectTarget")) {
|
||||||
String effTgtString = "";
|
String effTgtString = "";
|
||||||
List<ITargetable> effTgts = new ArrayList<ITargetable>();
|
List<GameObject> effTgts = new ArrayList<GameObject>();
|
||||||
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
|
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
|
||||||
for (final Object effTgt : effTgts) {
|
for (final Object effTgt : effTgts) {
|
||||||
if (effTgt instanceof Card) {
|
if (effTgt instanceof Card) {
|
||||||
@@ -127,7 +127,7 @@ public class DamagePreventEffect extends SpellAbilityEffect {
|
|||||||
effectMap.put("ShieldAmount", String.valueOf(numDam));
|
effectMap.put("ShieldAmount", String.valueOf(numDam));
|
||||||
if (sa.hasParam("ShieldEffectTarget")) {
|
if (sa.hasParam("ShieldEffectTarget")) {
|
||||||
String effTgtString = "";
|
String effTgtString = "";
|
||||||
List<ITargetable> effTgts = new ArrayList<ITargetable>();
|
List<GameObject> effTgts = new ArrayList<GameObject>();
|
||||||
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
|
effTgts = AbilityUtils.getDefinedObjects(host, sa.getParam("ShieldEffectTarget"), sa);
|
||||||
for (final Object effTgt : effTgts) {
|
for (final Object effTgt : effTgts) {
|
||||||
if (effTgt instanceof Card) {
|
if (effTgt instanceof Card) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.SpellAbilityEffect;
|
import forge.card.ability.SpellAbilityEffect;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
@@ -143,7 +143,7 @@ public class UnattachAllEffect extends SpellAbilityEffect {
|
|||||||
protected String getStackDescription(SpellAbility sa) {
|
protected String getStackDescription(SpellAbility sa) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Unattach all valid Equipment and Auras from ");
|
sb.append("Unattach all valid Equipment and Auras from ");
|
||||||
final List<ITargetable> targets = getTargets(sa);
|
final List<GameObject> targets = getTargets(sa);
|
||||||
sb.append(StringUtils.join(targets, " "));
|
sb.append(StringUtils.join(targets, " "));
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,7 @@ public class UnattachAllEffect extends SpellAbilityEffect {
|
|||||||
public void resolve(SpellAbility sa) {
|
public void resolve(SpellAbility sa) {
|
||||||
Card source = sa.getSourceCard();
|
Card source = sa.getSourceCard();
|
||||||
final Game game = sa.getActivatingPlayer().getGame();
|
final Game game = sa.getActivatingPlayer().getGame();
|
||||||
final List<ITargetable> targets = getTargets(sa);
|
final List<GameObject> targets = getTargets(sa);
|
||||||
|
|
||||||
// If Cast Targets will be checked on the Stack
|
// If Cast Targets will be checked on the Stack
|
||||||
for (final Object o : targets) {
|
for (final Object o : targets) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.cost.CostPartMana;
|
import forge.card.cost.CostPartMana;
|
||||||
@@ -220,10 +220,10 @@ public class HumanPlaySpellAbility {
|
|||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
sb.append(ability.getSourceCard().getName());
|
sb.append(ability.getSourceCard().getName());
|
||||||
if (ability.getTargetRestrictions() != null) {
|
if (ability.getTargetRestrictions() != null) {
|
||||||
final Iterable<ITargetable> targets = ability.getTargets().getTargets();
|
final Iterable<GameObject> targets = ability.getTargets().getTargets();
|
||||||
if (!Iterables.isEmpty(targets)) {
|
if (!Iterables.isEmpty(targets)) {
|
||||||
sb.append(" - Targeting ");
|
sb.append(" - Targeting ");
|
||||||
for (final ITargetable o : targets) {
|
for (final GameObject o : targets) {
|
||||||
sb.append(o.toString()).append(" ");
|
sb.append(o.toString()).append(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
@@ -53,7 +53,7 @@ import forge.util.TextUtil;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public abstract class SpellAbility implements ISpellAbility, ITargetable {
|
public abstract class SpellAbility extends GameObject implements ISpellAbility {
|
||||||
|
|
||||||
// choices for constructor isPermanent argument
|
// choices for constructor isPermanent argument
|
||||||
private String description = "";
|
private String description = "";
|
||||||
@@ -1027,7 +1027,7 @@ public abstract class SpellAbility implements ISpellAbility, ITargetable {
|
|||||||
* a GameEntity
|
* a GameEntity
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean canTarget(final ITargetable entity) {
|
public final boolean canTarget(final GameObject entity) {
|
||||||
final TargetRestrictions tr = this.getTargetRestrictions();
|
final TargetRestrictions tr = this.getTargetRestrictions();
|
||||||
|
|
||||||
// Restriction related to this ability
|
// Restriction related to this ability
|
||||||
@@ -1364,7 +1364,7 @@ public abstract class SpellAbility implements ISpellAbility, ITargetable {
|
|||||||
* Reset the first target.
|
* Reset the first target.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void resetFirstTarget(ITargetable c) {
|
public void resetFirstTarget(GameObject c) {
|
||||||
SpellAbility sa = this;
|
SpellAbility sa = this;
|
||||||
while (sa != null) {
|
while (sa != null) {
|
||||||
if (sa.targetRestricions != null) {
|
if (sa.targetRestricions != null) {
|
||||||
@@ -1528,8 +1528,8 @@ public abstract class SpellAbility implements ISpellAbility, ITargetable {
|
|||||||
* the ability
|
* the ability
|
||||||
* @return the unique targets
|
* @return the unique targets
|
||||||
*/
|
*/
|
||||||
public final List<ITargetable> getUniqueTargets() {
|
public final List<GameObject> getUniqueTargets() {
|
||||||
final List<ITargetable> targets = new ArrayList<ITargetable>();
|
final List<GameObject> targets = new ArrayList<GameObject>();
|
||||||
SpellAbility child = this.getParent();
|
SpellAbility child = this.getParent();
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
if (child.getTargetRestrictions() != null) {
|
if (child.getTargetRestrictions() != null) {
|
||||||
@@ -1574,7 +1574,7 @@ public abstract class SpellAbility implements ISpellAbility, ITargetable {
|
|||||||
|
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
|
|
||||||
for (final ITargetable o : matchTgt.getTargets()) {
|
for (final GameObject o : matchTgt.getTargets()) {
|
||||||
if (matchesValid(o, splitTargetRestrictions.split(","))) {
|
if (matchesValid(o, splitTargetRestrictions.split(","))) {
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
@@ -1604,7 +1604,7 @@ public abstract class SpellAbility implements ISpellAbility, ITargetable {
|
|||||||
return topSA.getSourceCard().isValid(tgt.getValidTgts(), this.getActivatingPlayer(), this.getSourceCard());
|
return topSA.getSourceCard().isValid(tgt.getValidTgts(), this.getActivatingPlayer(), this.getSourceCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchesValid(final ITargetable o, final String[] valids) {
|
private boolean matchesValid(final GameObject o, final String[] valids) {
|
||||||
final Card srcCard = this.getSourceCard();
|
final Card srcCard = this.getSourceCard();
|
||||||
final Player activatingPlayer = this.getActivatingPlayer();
|
final Player activatingPlayer = this.getActivatingPlayer();
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
@@ -1622,6 +1622,61 @@ public abstract class SpellAbility implements ISpellAbility, ITargetable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Takes one argument like Permanent.Blue+withFlying
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* isValid.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param restriction
|
||||||
|
* a {@link java.lang.String} object.
|
||||||
|
* @param sourceController
|
||||||
|
* a {@link forge.game.player.Player} object.
|
||||||
|
* @param source
|
||||||
|
* a {@link forge.Card} object.
|
||||||
|
* @return a boolean.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final boolean isValid(final String restriction, final Player sourceController, final Card source) {
|
||||||
|
|
||||||
|
// Inclusive restrictions are Card types
|
||||||
|
final String[] incR = restriction.split("\\.", 2);
|
||||||
|
|
||||||
|
if (incR[0].equals("Spell") && !this.isSpell()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (incR.length > 1) {
|
||||||
|
final String excR = incR[1];
|
||||||
|
final String[] exR = excR.split("\\+"); // Exclusive Restrictions are ...
|
||||||
|
for (int j = 0; j < exR.length; j++) {
|
||||||
|
if (!this.hasProperty(exR[j], sourceController, source)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} // isValid(String Restriction)
|
||||||
|
|
||||||
|
// Takes arguments like Blue or withFlying
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* hasProperty.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param property
|
||||||
|
* a {@link java.lang.String} object.
|
||||||
|
* @param sourceController
|
||||||
|
* a {@link forge.game.player.Player} object.
|
||||||
|
* @param source
|
||||||
|
* a {@link forge.Card} object.
|
||||||
|
* @return a boolean.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean hasProperty(final String property, final Player sourceController, final Card source) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Methods enabling multiple instances of conspire
|
// Methods enabling multiple instances of conspire
|
||||||
public void addConspireInstance() {
|
public void addConspireInstance() {
|
||||||
this.conspireInstances++;
|
this.conspireInstances++;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +62,7 @@ public class TargetChoices implements Cloneable {
|
|||||||
* a {@link java.lang.Object} object.
|
* a {@link java.lang.Object} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean add(final ITargetable o) {
|
public final boolean add(final GameObject o) {
|
||||||
if (o instanceof Player) {
|
if (o instanceof Player) {
|
||||||
return this.addTarget((Player) o);
|
return this.addTarget((Player) o);
|
||||||
} else if (o instanceof Card) {
|
} else if (o instanceof Card) {
|
||||||
@@ -137,7 +137,7 @@ public class TargetChoices implements Cloneable {
|
|||||||
* a {@link forge.Card} object.
|
* a {@link forge.Card} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean remove(final ITargetable target) {
|
public final boolean remove(final GameObject target) {
|
||||||
// remove returns true if element was found in given list
|
// remove returns true if element was found in given list
|
||||||
if (this.targetCards.remove(target) || this.targetPlayers.remove(target) || this.targetSpells.remove(target)) {
|
if (this.targetCards.remove(target) || this.targetPlayers.remove(target) || this.targetSpells.remove(target)) {
|
||||||
this.numTargeted--;
|
this.numTargeted--;
|
||||||
@@ -186,8 +186,8 @@ public class TargetChoices implements Cloneable {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
*/
|
*/
|
||||||
public final List<ITargetable> getTargets() {
|
public final List<GameObject> getTargets() {
|
||||||
final ArrayList<ITargetable> tgts = new ArrayList<ITargetable>();
|
final ArrayList<GameObject> tgts = new ArrayList<GameObject>();
|
||||||
tgts.addAll(this.targetPlayers);
|
tgts.addAll(this.targetPlayers);
|
||||||
tgts.addAll(this.targetCards);
|
tgts.addAll(this.targetCards);
|
||||||
tgts.addAll(this.targetSpells);
|
tgts.addAll(this.targetSpells);
|
||||||
@@ -197,7 +197,7 @@ public class TargetChoices implements Cloneable {
|
|||||||
|
|
||||||
|
|
||||||
public final String getTargetedString() {
|
public final String getTargetedString() {
|
||||||
final List<ITargetable> tgts = this.getTargets();
|
final List<GameObject> tgts = this.getTargets();
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (final Object o : tgts) {
|
for (final Object o : tgts) {
|
||||||
if (o instanceof Player) {
|
if (o instanceof Player) {
|
||||||
@@ -231,7 +231,7 @@ public class TargetChoices implements Cloneable {
|
|||||||
return !targetSpells.isEmpty();
|
return !targetSpells.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isTargeting(ITargetable e) {
|
public final boolean isTargeting(GameObject e) {
|
||||||
return targetCards.contains(e) || targetSpells.contains(e) || targetPlayers.contains(e);
|
return targetCards.contains(e) || targetSpells.contains(e) || targetPlayers.contains(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.util.List;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
@@ -499,9 +499,9 @@ public class TargetRestrictions {
|
|||||||
* Check Valid Candidates and Targeting
|
* Check Valid Candidates and Targeting
|
||||||
* @return a List<Object>.
|
* @return a List<Object>.
|
||||||
*/
|
*/
|
||||||
public final List<ITargetable> getAllCandidates(final SpellAbility sa, final boolean isTargeted) {
|
public final List<GameObject> getAllCandidates(final SpellAbility sa, final boolean isTargeted) {
|
||||||
final Game game = sa.getActivatingPlayer().getGame();
|
final Game game = sa.getActivatingPlayer().getGame();
|
||||||
List<ITargetable> candidates = new ArrayList<ITargetable>();
|
List<GameObject> candidates = new ArrayList<GameObject>();
|
||||||
for (Player player : game.getPlayers()) {
|
for (Player player : game.getPlayers()) {
|
||||||
if (sa.canTarget(player)) {
|
if (sa.canTarget(player)) {
|
||||||
candidates.add(player);
|
candidates.add(player);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
@@ -97,8 +97,8 @@ public class TargetSelection {
|
|||||||
final boolean choiceResult;
|
final boolean choiceResult;
|
||||||
final boolean random = tgt.isRandomTarget();
|
final boolean random = tgt.isRandomTarget();
|
||||||
if (random) {
|
if (random) {
|
||||||
List<ITargetable> candidates = tgt.getAllCandidates(this.ability, true);
|
List<GameObject> candidates = tgt.getAllCandidates(this.ability, true);
|
||||||
ITargetable choice = Aggregates.random(candidates);
|
GameObject choice = Aggregates.random(candidates);
|
||||||
return ability.getTargets().add(choice);
|
return ability.getTargets().add(choice);
|
||||||
} else if (zone.size() == 1 && zone.get(0) == ZoneType.Stack) {
|
} else if (zone.size() == 1 && zone.get(0) == ZoneType.Stack) {
|
||||||
// If Zone is Stack, the choices are handled slightly differently.
|
// If Zone is Stack, the choices are handled slightly differently.
|
||||||
@@ -149,7 +149,7 @@ public class TargetSelection {
|
|||||||
choices.remove(ability.getSourceCard());
|
choices.remove(ability.getSourceCard());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<ITargetable> targetedObjects = this.ability.getUniqueTargets();
|
List<GameObject> targetedObjects = this.ability.getUniqueTargets();
|
||||||
|
|
||||||
if (tgt.isUniqueTargets()) {
|
if (tgt.isUniqueTargets()) {
|
||||||
for (final Object o : targetedObjects) {
|
for (final Object o : targetedObjects) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
@@ -183,7 +183,7 @@ public class WrappedAbility extends Ability implements ISpellAbility {
|
|||||||
final StringBuilder sb = new StringBuilder(regtrig.toString());
|
final StringBuilder sb = new StringBuilder(regtrig.toString());
|
||||||
if (this.getTargetRestrictions() != null) {
|
if (this.getTargetRestrictions() != null) {
|
||||||
sb.append(" (Targeting ");
|
sb.append(" (Targeting ");
|
||||||
for (final ITargetable o : this.getTargets().getTargets()) {
|
for (final GameObject o : this.getTargets().getTargets()) {
|
||||||
sb.append(o.toString());
|
sb.append(o.toString());
|
||||||
sb.append(", ");
|
sb.append(", ");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import forge.CounterType;
|
|||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.GameLogEntryType;
|
import forge.GameLogEntryType;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.CardDb;
|
import forge.card.CardDb;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
import forge.card.TriggerReplacementBase;
|
import forge.card.TriggerReplacementBase;
|
||||||
@@ -1420,7 +1420,7 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Delivers a message to all players. (use reveal to show Cards) */
|
/** Delivers a message to all players. (use reveal to show Cards) */
|
||||||
public void nofityOfValue(SpellAbility saSource, ITargetable relatedTarget, String value, Player playerExcept) {
|
public void nofityOfValue(SpellAbility saSource, GameObject relatedTarget, String value, Player playerExcept) {
|
||||||
for(Player p : game.getPlayers()) {
|
for(Player p : game.getPlayers()) {
|
||||||
if (playerExcept == p) continue;
|
if (playerExcept == p) continue;
|
||||||
p.getController().notifyOfValue(saSource, relatedTarget, value);
|
p.getController().notifyOfValue(saSource, relatedTarget, value);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import forge.Constant;
|
|||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.CardPredicates.Presets;
|
import forge.CardPredicates.Presets;
|
||||||
import forge.CardUtil;
|
import forge.CardUtil;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.CardType;
|
import forge.card.CardType;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.AbilityFactory;
|
import forge.card.ability.AbilityFactory;
|
||||||
@@ -1272,9 +1272,9 @@ public class ComputerUtil {
|
|||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public static List<ITargetable> predictThreatenedObjects(final Player aiPlayer, final SpellAbility sa) {
|
public static List<GameObject> predictThreatenedObjects(final Player aiPlayer, final SpellAbility sa) {
|
||||||
final Game game = aiPlayer.getGame();
|
final Game game = aiPlayer.getGame();
|
||||||
final List<ITargetable> objects = new ArrayList<ITargetable>();
|
final List<GameObject> objects = new ArrayList<GameObject>();
|
||||||
if (game.getStack().isEmpty()) {
|
if (game.getStack().isEmpty()) {
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
@@ -1298,10 +1298,10 @@ public class ComputerUtil {
|
|||||||
* @return a {@link java.util.ArrayList} object.
|
* @return a {@link java.util.ArrayList} object.
|
||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
private static Iterable<? extends ITargetable> predictThreatenedObjects(final Player aiPlayer, final SpellAbility saviour,
|
private static Iterable<? extends GameObject> predictThreatenedObjects(final Player aiPlayer, final SpellAbility saviour,
|
||||||
final SpellAbility topStack) {
|
final SpellAbility topStack) {
|
||||||
Iterable<? extends ITargetable> objects = new ArrayList<ITargetable>();
|
Iterable<? extends GameObject> objects = new ArrayList<GameObject>();
|
||||||
final List<ITargetable> threatened = new ArrayList<ITargetable>();
|
final List<GameObject> threatened = new ArrayList<GameObject>();
|
||||||
ApiType saviourApi = saviour == null ? null : saviour.getApi();
|
ApiType saviourApi = saviour == null ? null : saviour.getApi();
|
||||||
|
|
||||||
if (topStack == null) {
|
if (topStack == null) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.mana.Mana;
|
import forge.card.mana.Mana;
|
||||||
import forge.card.replacement.ReplacementEffect;
|
import forge.card.replacement.ReplacementEffect;
|
||||||
@@ -111,7 +111,7 @@ public abstract class PlayerController {
|
|||||||
public abstract TargetChoices chooseNewTargetsFor(SpellAbility ability);
|
public abstract TargetChoices chooseNewTargetsFor(SpellAbility ability);
|
||||||
|
|
||||||
// Specify a target of a spell (Spellskite)
|
// Specify a target of a spell (Spellskite)
|
||||||
public abstract Pair<SpellAbilityStackInstance, ITargetable> chooseTarget(SpellAbility sa, List<Pair<SpellAbilityStackInstance, ITargetable>> allTargets);
|
public abstract Pair<SpellAbilityStackInstance, GameObject> chooseTarget(SpellAbility sa, List<Pair<SpellAbilityStackInstance, GameObject>> allTargets);
|
||||||
|
|
||||||
public abstract List<Card> chooseCardsForEffect(List<Card> sourceList, SpellAbility sa, String title, int amount, boolean isOptional);
|
public abstract List<Card> chooseCardsForEffect(List<Card> sourceList, SpellAbility sa, String title, int amount, boolean isOptional);
|
||||||
public Card chooseSingleCardForEffect(Collection<Card> sourceList, SpellAbility sa, String title) { return chooseSingleCardForEffect(sourceList, sa, title, false); }
|
public Card chooseSingleCardForEffect(Collection<Card> sourceList, SpellAbility sa, String title) { return chooseSingleCardForEffect(sourceList, sa, title, false); }
|
||||||
@@ -129,7 +129,7 @@ public abstract class PlayerController {
|
|||||||
/** Shows the card to this player*/
|
/** Shows the card to this player*/
|
||||||
public abstract void reveal(String string, Collection<Card> cards, ZoneType zone, Player owner);
|
public abstract void reveal(String string, Collection<Card> cards, ZoneType zone, Player owner);
|
||||||
/** Shows message to player to reveal chosen cardName, creatureType, number etc. AI must analyze API to understand what that is */
|
/** Shows message to player to reveal chosen cardName, creatureType, number etc. AI must analyze API to understand what that is */
|
||||||
public abstract void notifyOfValue(SpellAbility saSource, ITargetable realtedTarget, String value);
|
public abstract void notifyOfValue(SpellAbility saSource, GameObject realtedTarget, String value);
|
||||||
public abstract ImmutablePair<List<Card>, List<Card>> arrangeForScry(List<Card> topN);
|
public abstract ImmutablePair<List<Card>, List<Card>> arrangeForScry(List<Card> topN);
|
||||||
public abstract boolean willPutCardOnTop(Card c);
|
public abstract boolean willPutCardOnTop(Card c);
|
||||||
public abstract List<Card> orderMoveToZoneList(List<Card> cards, ZoneType destinationZone);
|
public abstract List<Card> orderMoveToZoneList(List<Card> cards, ZoneType destinationZone);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import forge.CardLists;
|
|||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.ability.ai.CharmAi;
|
import forge.card.ability.ai.CharmAi;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
@@ -408,14 +408,14 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pair<SpellAbilityStackInstance, ITargetable> chooseTarget(SpellAbility saSrc, List<Pair<SpellAbilityStackInstance, ITargetable>> allTargets) {
|
public Pair<SpellAbilityStackInstance, GameObject> chooseTarget(SpellAbility saSrc, List<Pair<SpellAbilityStackInstance, GameObject>> allTargets) {
|
||||||
// TODO Teach AI how to use Spellskite
|
// TODO Teach AI how to use Spellskite
|
||||||
return allTargets.get(0);
|
return allTargets.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyOfValue(SpellAbility saSource, ITargetable realtedTarget, String value) {
|
public void notifyOfValue(SpellAbility saSource, GameObject realtedTarget, String value) {
|
||||||
// AI should take into consideration creature types, numbers and other information (mostly choices) arriving through this channel
|
// AI should take into consideration creature types, numbers and other information (mostly choices) arriving through this channel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import com.google.common.collect.Lists;
|
|||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CounterType;
|
import forge.CounterType;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.ability.effects.CharmEffect;
|
import forge.card.ability.effects.CharmEffect;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
@@ -697,30 +697,30 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pair<SpellAbilityStackInstance, ITargetable> chooseTarget(SpellAbility saSpellskite, List<Pair<SpellAbilityStackInstance, ITargetable>> allTargets) {
|
public Pair<SpellAbilityStackInstance, GameObject> chooseTarget(SpellAbility saSpellskite, List<Pair<SpellAbilityStackInstance, GameObject>> allTargets) {
|
||||||
if( allTargets.size() < 2)
|
if( allTargets.size() < 2)
|
||||||
return Iterables.getFirst(allTargets, null);
|
return Iterables.getFirst(allTargets, null);
|
||||||
|
|
||||||
final Function<Pair<SpellAbilityStackInstance, ITargetable>, String> fnToString = new Function<Pair<SpellAbilityStackInstance, ITargetable>, String>() {
|
final Function<Pair<SpellAbilityStackInstance, GameObject>, String> fnToString = new Function<Pair<SpellAbilityStackInstance, GameObject>, String>() {
|
||||||
@Override
|
@Override
|
||||||
public String apply(Pair<SpellAbilityStackInstance, ITargetable> targ) {
|
public String apply(Pair<SpellAbilityStackInstance, GameObject> targ) {
|
||||||
return targ.getRight().toString() + " - " + targ.getLeft().getStackDescription();
|
return targ.getRight().toString() + " - " + targ.getLeft().getStackDescription();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
List<Pair<SpellAbilityStackInstance, ITargetable>> chosen = GuiChoose.getChoices(saSpellskite.getSourceCard().getName(), 1, 1, allTargets, null, fnToString);
|
List<Pair<SpellAbilityStackInstance, GameObject>> chosen = GuiChoose.getChoices(saSpellskite.getSourceCard().getName(), 1, 1, allTargets, null, fnToString);
|
||||||
return Iterables.getFirst(chosen, null);
|
return Iterables.getFirst(chosen, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyOfValue(SpellAbility sa, ITargetable realtedTarget, String value) {
|
public void notifyOfValue(SpellAbility sa, GameObject realtedTarget, String value) {
|
||||||
String message = formatNotificationMessage(sa, realtedTarget, value);
|
String message = formatNotificationMessage(sa, realtedTarget, value);
|
||||||
GuiDialog.message(message, sa.getSourceCard().getName());
|
GuiDialog.message(message, sa.getSourceCard().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// These are not much related to PlayerController
|
// These are not much related to PlayerController
|
||||||
private String formatNotificationMessage(SpellAbility sa, ITargetable target, String value) {
|
private String formatNotificationMessage(SpellAbility sa, GameObject target, String value) {
|
||||||
if (sa.getApi() == null) {
|
if (sa.getApi() == null) {
|
||||||
return ("Result: " + value);
|
return ("Result: " + value);
|
||||||
}
|
}
|
||||||
@@ -741,7 +741,7 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String mayBeYou(ITargetable what, Player you) {
|
private String mayBeYou(GameObject what, Player you) {
|
||||||
return what == you ? "you" : what.toString();
|
return what == you ? "you" : what.toString();
|
||||||
}
|
}
|
||||||
// end of not related candidates for move.
|
// end of not related candidates for move.
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import forge.Card;
|
|||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.ITargetable;
|
import forge.GameObject;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.CardPredicates.Presets;
|
import forge.CardPredicates.Presets;
|
||||||
import forge.GameLogEntryType;
|
import forge.GameLogEntryType;
|
||||||
@@ -692,7 +692,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
|||||||
// With multi-targets, as long as one target is still legal,
|
// With multi-targets, as long as one target is still legal,
|
||||||
// we'll try to go through as much as possible
|
// we'll try to go through as much as possible
|
||||||
final TargetChoices choices = sa.getTargets();
|
final TargetChoices choices = sa.getTargets();
|
||||||
for (final ITargetable o : sa.getTargets().getTargets()) {
|
for (final GameObject o : sa.getTargets().getTargets()) {
|
||||||
boolean invalidTarget = false;
|
boolean invalidTarget = false;
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
final Card card = (Card) o;
|
final Card card = (Card) o;
|
||||||
|
|||||||
Reference in New Issue
Block a user