Target: TargetsWithSameCreatureType

This commit is contained in:
Hans Mackowiak
2019-06-06 12:27:49 +00:00
committed by Michael Kamensky
parent 9233f778c5
commit 9848775d70
5 changed files with 36 additions and 10 deletions

View File

@@ -349,6 +349,9 @@ public final class AbilityFactory {
if (mapParams.containsKey("TargetsWithoutSameCreatureType")) {
abTgt.setWithoutSameCreatureType(true);
}
if (mapParams.containsKey("TargetsWithSameCreatureType")) {
abTgt.setWithSameCreatureType(true);
}
if (mapParams.containsKey("TargetsWithSameController")) {
abTgt.setSameController(true);
}

View File

@@ -64,6 +64,7 @@ public class TargetRestrictions {
private boolean differentControllers = false;
private boolean sameController = false;
private boolean withoutSameCreatureType = false;
private boolean withSameCreatureType = false;
private boolean singleTarget = false;
private boolean randomTarget = false;
@@ -106,6 +107,7 @@ public class TargetRestrictions {
this.differentControllers = target.isDifferentControllers();
this.sameController = target.isSameController();
this.withoutSameCreatureType = target.isWithoutSameCreatureType();
this.withSameCreatureType = target.isWithSameCreatureType();
this.singleTarget = target.isSingleTarget();
this.randomTarget = target.isRandomTarget();
}
@@ -628,6 +630,20 @@ public class TargetRestrictions {
this.withoutSameCreatureType = b;
}
/**
* @return the withoutSameCreatureType
*/
public boolean isWithSameCreatureType() {
return withSameCreatureType;
}
/**
* @param b the withoutSameCreatureType to set
*/
public void setWithSameCreatureType(boolean b) {
this.withSameCreatureType = b;
}
/**
* <p>
* copy.

View File

@@ -3,8 +3,5 @@ ManaCost:1 B
Types:Sorcery
A:SP$ Charm | Cost$ 1 B | Choices$ DBChangeZone1,DBChangeZone2
SVar:DBChangeZone1:DB$ ChangeZone | Origin$ Graveyard | Destination$ Hand | Mandatory$ True | TgtPrompt$ Select target creature card in your graveyard | ValidTgts$ Creature.YouOwn | SpellDescription$ Return target creature card from your graveyard to your hand.
SVar:DBChangeZone2:DB$ Pump | RememberObjects$ Targeted | TgtZone$ Graveyard | ValidTgts$ Creature.YouOwn | TgtPrompt$ Select two target creature cards that share a creature type in your graveyard | SubAbility$ DBPump | SpellDescription$ Return two target creature cards that share a creature type from your graveyard to your hand.
SVar:DBPump:DB$ Pump | RememberObjects$ Targeted | TargetsWithRelatedProperty$ SharedCreatureType | TargetUnique$ True | TgtZone$ Graveyard | ValidTgts$ Creature.YouOwn | TgtPrompt$ Select two target creature cards that share a creature type in your graveyard | SubAbility$ DBChangeZoneAll
SVar:DBChangeZoneAll:DB$ ChangeZone | Defined$ Remembered | Origin$ Graveyard | Destination$ Hand | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:DBChangeZone2:DB$ ChangeZone | Origin$ Graveyard | Destination$ Hand | Mandatory$ True | TargetsWithSameCreatureType$ True | TargetMin$ 2 | TargetMax$ 2 | ValidTgts$ Creature.YouOwn | TgtPrompt$ Select two target creature cards that share a creature type in your graveyard | SpellDescription$ Return two target creature cards that share a creature type from your graveyard to your hand.
Oracle:Choose one -\n• Return target creature card from your graveyard to your hand.\n• Return two target creature cards that share a creature type from your graveyard to your hand.

View File

@@ -161,6 +161,11 @@ public final class InputSelectTargets extends InputSyncronizedBase {
showMessage(sa.getHostCard() + " - Cannot target this card (should not share a creature type)");
return false;
}
// If the cards share a creature type
if (tgt.isWithSameCreatureType() && lastTarget != null && !card.sharesCreatureTypeWith(lastTarget)) {
showMessage(sa.getHostCard() + " - Cannot target this card (should share a creature type)");
return false;
}
// If all cards must have different controllers
if (tgt.isDifferentControllers()) {

View File

@@ -17,14 +17,8 @@
*/
package forge.player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import forge.game.Game;
import forge.game.GameEntity;
import forge.game.GameObject;
@@ -41,6 +35,11 @@ import forge.game.zone.ZoneType;
import forge.match.input.InputSelectTargets;
import forge.util.Aggregates;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
* Target_Selection class.
@@ -182,6 +181,12 @@ public class TargetSelection {
for (final Card inZone : choices) {
Zone zz = game.getZoneOf(inZone);
CardView cardView = CardView.get(inZone);
if (this.ability.getTargetRestrictions() != null && this.ability.getTargetRestrictions().isWithSameCreatureType()) {
Card firstTgt = this.ability.getTargetCard();
if (firstTgt != null && !firstTgt.sharesCreatureTypeWith(inZone)) {
continue;
}
}
if (zz.is(ZoneType.Battlefield)) crdsBattle.add(cardView);
else if (zz.is(ZoneType.Exile)) crdsExile.add(cardView);
else if (zz.is(ZoneType.Graveyard)) crdsGrave.add(cardView);