Merge branch 'master' into 'master'

Some additional logic for Return from Extinction.

See merge request core-developers/forge!1803
This commit is contained in:
Michael Kamensky
2019-06-07 16:00:38 +00:00
2 changed files with 33 additions and 1 deletions

View File

@@ -71,6 +71,29 @@ public class ChangeZoneAi extends SpellAbilityAi {
return false;
}
}
} else if (aiLogic.equals("NoSameCreatureType")) {
final List<ZoneType> origin = Lists.newArrayList();
if (sa.hasParam("Origin")) {
origin.addAll(ZoneType.listValueOf(sa.getParam("Origin")));
} else if (sa.hasParam("TgtZone")) {
origin.addAll(ZoneType.listValueOf(sa.getParam("TgtZone")));
}
CardCollection list = CardLists.getValidCards(ai.getGame().getCardsIn(origin),
sa.getTargetRestrictions().getValidTgts(), ai, sa.getHostCard(), sa);
final List<String> creatureTypes = Lists.newArrayList();
for (Card c : list) {
creatureTypes.addAll(c.getType().getCreatureTypes());
}
for (String type : creatureTypes) {
int freq = Collections.frequency(creatureTypes, type);
if (freq > 1) {
return false;
}
}
return true;
}
return super.checkAiLogic(ai, sa, aiLogic);
@@ -1194,6 +1217,15 @@ public class ChangeZoneAi extends SpellAbilityAi {
}
}
// honor the Same Creature Type restriction
if (sa.hasParam("TargetsWithSameCreatureType")) {
Card firstTarget = sa.getTargetCard();
if (firstTarget != null && !choice.sharesCreatureTypeWith(firstTarget)) {
list.remove(choice);
continue;
}
}
list.remove(choice);
sa.getTargets().add(choice);
}

View File

@@ -2,6 +2,6 @@ Name:Return from Extinction
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:DBChangeZone1:DB$ ChangeZone | Origin$ Graveyard | Destination$ Hand | Mandatory$ True | TgtPrompt$ Select target creature card in your graveyard | ValidTgts$ Creature.YouOwn | AILogic$ NoSameCreatureType | SpellDescription$ Return target creature card from your graveyard to your hand.
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.