mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Added support for TargetUnique for cards like Arc Trail, where subabilities can't target something any parent ability has targeted.
This commit is contained in:
@@ -3,7 +3,7 @@ ManaCost:1 R
|
|||||||
Types:Sorcery
|
Types:Sorcery
|
||||||
Text:no text
|
Text:no text
|
||||||
A:SP$ DealDamage | Cost$ 1 R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select target creature or player (2 damage) | NumDmg$ 2 | SubAbility$ SVar=DBDealDamage | SpellDescription$ CARDNAME deals 2 damage to target creature or player and 1 damage to another target creature or player.
|
A:SP$ DealDamage | Cost$ 1 R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select target creature or player (2 damage) | NumDmg$ 2 | SubAbility$ SVar=DBDealDamage | SpellDescription$ CARDNAME deals 2 damage to target creature or player and 1 damage to another target creature or player.
|
||||||
SVar:DBDealDamage:DB$DealDamage | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select target creature or player (1 damage) | NumDmg$ 1
|
SVar:DBDealDamage:DB$ DealDamage | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select target creature or player (1 damage) | TargetUnique$ True | NumDmg$ 1
|
||||||
SVar:Rarity:Uncommon
|
SVar:Rarity:Uncommon
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/arc_trail.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/arc_trail.jpg
|
||||||
SetInfo:SOM|Uncommon|http://magiccards.info/scans/en/som/81.jpg
|
SetInfo:SOM|Uncommon|http://magiccards.info/scans/en/som/81.jpg
|
||||||
|
|||||||
@@ -264,6 +264,10 @@ public class AbilityFactory {
|
|||||||
// TargetValidTargeting most for Counter: e.g. target spell that targets X.
|
// TargetValidTargeting most for Counter: e.g. target spell that targets X.
|
||||||
if (mapParams.containsKey("TargetValidTargeting"))
|
if (mapParams.containsKey("TargetValidTargeting"))
|
||||||
abTgt.setSAValidTargeting(mapParams.get("TargetValidTargeting"));
|
abTgt.setSAValidTargeting(mapParams.get("TargetValidTargeting"));
|
||||||
|
|
||||||
|
if (mapParams.containsKey("TargetUnique")){
|
||||||
|
abTgt.setUniqueTargets(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasSubAb = mapParams.containsKey("SubAbility");
|
hasSubAb = mapParams.containsKey("SubAbility");
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class Target {
|
|||||||
// Targeting restrictions (Creature, Min/Maxm etc) which are true for this whole Target
|
// Targeting restrictions (Creature, Min/Maxm etc) which are true for this whole Target
|
||||||
// Target Choices (which is specific for the StackInstance)
|
// Target Choices (which is specific for the StackInstance)
|
||||||
private Card srcCard;
|
private Card srcCard;
|
||||||
|
private boolean uniqueTargets = false;
|
||||||
private Target_Choices choice = null;
|
private Target_Choices choice = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -491,4 +491,12 @@ public class Target {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUniqueTargets() {
|
||||||
|
return uniqueTargets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUniqueTargets(boolean unique) {
|
||||||
|
this.uniqueTargets = unique;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,6 +158,17 @@ public class Target_Selection {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<Object> getUniqueTargets(SpellAbility ability){
|
||||||
|
ArrayList<Object> targets = new ArrayList<Object>();
|
||||||
|
SpellAbility child = ability;
|
||||||
|
while(child instanceof Ability_Sub){
|
||||||
|
child = ((Ability_Sub)child).getParent();
|
||||||
|
targets.addAll(child.getTarget().getTargets());
|
||||||
|
}
|
||||||
|
|
||||||
|
return targets;
|
||||||
|
}
|
||||||
|
|
||||||
// these have been copied over from CardFactoryUtil as they need two extra parameters for target selection.
|
// these have been copied over from CardFactoryUtil as they need two extra parameters for target selection.
|
||||||
// however, due to the changes necessary for SA_Requirements this is much different than the original
|
// however, due to the changes necessary for SA_Requirements this is much different than the original
|
||||||
|
|
||||||
@@ -177,17 +188,29 @@ public class Target_Selection {
|
|||||||
|
|
||||||
CardList choices = AllZoneUtil.getCardsInZone(zone).getValidCards(target.getValidTgts(), ability.getActivatingPlayer(), ability.getSourceCard());
|
CardList choices = AllZoneUtil.getCardsInZone(zone).getValidCards(target.getValidTgts(), ability.getActivatingPlayer(), ability.getSourceCard());
|
||||||
|
|
||||||
|
ArrayList<Object> objects = new ArrayList<Object>();
|
||||||
|
if (tgt.isUniqueTargets()){
|
||||||
|
objects = getUniqueTargets(ability);
|
||||||
|
for (Object o : objects) {
|
||||||
|
if (o instanceof Card && objects.contains(o)){
|
||||||
|
choices.remove((Card)o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove cards already targeted
|
// Remove cards already targeted
|
||||||
ArrayList<Card> targeted = tgt.getTargetCards();
|
ArrayList<Card> targeted = tgt.getTargetCards();
|
||||||
for (Card c : targeted) {
|
for (Card c : targeted) {
|
||||||
if (choices.contains(c))
|
if (choices.contains(c)){
|
||||||
choices.remove(c);
|
choices.remove(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zone.equals(Constant.Zone.Battlefield)) {
|
if (zone.equals(Constant.Zone.Battlefield)) {
|
||||||
AllZone.getInputControl().setInput(input_targetSpecific(choices, true, mandatory));
|
AllZone.getInputControl().setInput(input_targetSpecific(choices, true, mandatory, objects));
|
||||||
} else
|
} else{
|
||||||
chooseCardFromList(choices, true, mandatory);
|
chooseCardFromList(choices, true, mandatory);
|
||||||
|
}
|
||||||
}//input_targetValid
|
}//input_targetValid
|
||||||
|
|
||||||
//CardList choices are the only cards the user can successful select
|
//CardList choices are the only cards the user can successful select
|
||||||
@@ -197,9 +220,10 @@ public class Target_Selection {
|
|||||||
* @param choices a {@link forge.CardList} object.
|
* @param choices a {@link forge.CardList} object.
|
||||||
* @param targeted a boolean.
|
* @param targeted a boolean.
|
||||||
* @param mandatory a boolean.
|
* @param mandatory a boolean.
|
||||||
|
* @param objects TODO
|
||||||
* @return a {@link forge.gui.input.Input} object.
|
* @return a {@link forge.gui.input.Input} object.
|
||||||
*/
|
*/
|
||||||
public Input input_targetSpecific(final CardList choices, final boolean targeted, final boolean mandatory) {
|
public Input input_targetSpecific(final CardList choices, final boolean targeted, final boolean mandatory, final ArrayList<Object> alreadyTargeted) {
|
||||||
final SpellAbility sa = this.ability;
|
final SpellAbility sa = this.ability;
|
||||||
final Target_Selection select = this;
|
final Target_Selection select = this;
|
||||||
final Target tgt = this.target;
|
final Target tgt = this.target;
|
||||||
@@ -212,6 +236,9 @@ public class Target_Selection {
|
|||||||
public void showMessage() {
|
public void showMessage() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Targeted: ");
|
sb.append("Targeted: ");
|
||||||
|
for(Object o : alreadyTargeted){
|
||||||
|
sb.append(o).append(" ");
|
||||||
|
}
|
||||||
sb.append(tgt.getTargetedString());
|
sb.append(tgt.getTargetedString());
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
sb.append(tgt.getVTSelection());
|
sb.append(tgt.getVTSelection());
|
||||||
@@ -254,6 +281,10 @@ public class Target_Selection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectPlayer(Player player) {
|
public void selectPlayer(Player player) {
|
||||||
|
if (alreadyTargeted.contains(player)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((tgt.canTgtPlayer() || (tgt.canOnlyTgtOpponent() && player.equals(sa.getActivatingPlayer().getOpponent()))) &&
|
if ((tgt.canTgtPlayer() || (tgt.canOnlyTgtOpponent() && player.equals(sa.getActivatingPlayer().getOpponent()))) &&
|
||||||
player.canTarget(sa)) {
|
player.canTarget(sa)) {
|
||||||
tgt.addTarget(player);
|
tgt.addTarget(player);
|
||||||
|
|||||||
Reference in New Issue
Block a user