TargetSelection fix

This commit is contained in:
tool4EvEr
2022-10-12 18:22:40 +02:00
parent 9d64718805
commit 5673ea329e
3 changed files with 10 additions and 7 deletions

View File

@@ -4,8 +4,8 @@ Types:Legendary Planeswalker Ashiok
Loyalty:3
A:AB$ Dig | Cost$ AddCounter<2/LOYALTY> | Planeswalker$ True | ValidTgts$ Opponent | DigNum$ 3 | ChangeNum$ All | DestinationZone$ Exile | RememberChanged$ True | SpellDescription$ Exile the top three cards of target opponent's library.
A:AB$ ChooseCard | Cost$ SubCounter<X/LOYALTY> | Choices$ Creature.cmcEQX+IsRemembered+ExiledWithSource | ChoiceZone$ Exile | Planeswalker$ True | SubAbility$ DBChangeZone | AILogic$ Ashiok | SpellDescription$ Put a creature card with mana value X exiled with CARDNAME onto the battlefield under your control. That creature is a Nightmare in addition to its other types.
SVar:DBChangeZone:DB$ ChangeZone | Defined$ ChosenCard | Origin$ Exile | Destination$ Battlefield | ChangeType$ Creature.cmcEQX+IsRemembered+ExiledWithSource | GainControl$ True | SubAbility$ DBAnimate
SVar:DBAnimate:DB$ Animate | Defined$ ChosenCard | Types$ Nightmare | Duration$ Permanent | SubAbility$ DBCleanMinus
SVar:DBChangeZone:DB$ ChangeZone | Defined$ ChosenCard | Origin$ Exile | Destination$ Battlefield | ChangeType$ Creature.cmcEQX+IsRemembered+ExiledWithSource | GainControl$ True | AnimateSubAbility$ DBAnimate | SubAbility$ DBCleanMinus
SVar:DBAnimate:DB$ Animate | Defined$ ChosenCard | Types$ Nightmare | Duration$ Permanent
SVar:DBCleanMinus:DB$ Cleanup | ForgetDefined$ ChosenCard | ClearChosenCard$ True
SVar:X:Count$xPaid
A:AB$ ChangeZoneAll | Cost$ SubCounter<10/LOYALTY> | ChangeType$ Card.OppCtrl | Origin$ Graveyard,Hand | Destination$ Exile | RememberChanged$ True | Planeswalker$ True | Ultimate$ True | SpellDescription$ Exile all cards from all opponents' hands and graveyards.

View File

@@ -2,6 +2,6 @@ Name:Electropotence
ManaCost:2 R
Types:Enchantment
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Creature.YouCtrl | TriggerZones$ Battlefield | Execute$ TrigDamage | TriggerDescription$ Whenever a creature enters the battlefield under your control, you may pay {2}{R}. If you do, that creature deals damage equal to its power to any target.
SVar:TrigDamage:AB$DealDamage | Cost$ 2 R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | DamageSource$ TriggeredCard | NumDmg$ Damage
SVar:TrigDamage:AB$ DealDamage | Cost$ 2 R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | DamageSource$ TriggeredCard | NumDmg$ Damage
SVar:Damage:TriggeredCard$CardPower
Oracle:Whenever a creature enters the battlefield under your control, you may pay {2}{R}. If you do, that creature deals damage equal to its power to any target.

View File

@@ -103,7 +103,8 @@ public class TargetSelection {
return true;
}
final boolean hasCandidates = tgt.hasCandidates(this.ability);
List<GameEntity> candidates = tgt.getAllCandidates(this.ability, true);
final boolean hasCandidates = candidates.size() >= minTargets;
if (!hasCandidates && !hasEnoughTargets) {
// Cancel ability if there aren't any valid Candidates
return false;
@@ -118,7 +119,6 @@ public class TargetSelection {
final boolean choiceResult;
if (tgt.isRandomTarget() && numTargets == null) {
List<GameEntity> candidates = tgt.getAllCandidates(this.ability, true);
List<GameEntity> choices = new ArrayList<>();
// currently, only cards that target randomly use a random number of targets
int top = Math.min(candidates.size(), maxTargets); // prevents choosing more targets than possible
@@ -136,7 +136,7 @@ public class TargetSelection {
else if (zones.size() == 1 && zones.get(0) == ZoneType.Stack) {
// If Zone is Stack, the choices are handled slightly differently.
// Handle everything inside function due to interaction with StackInstance
return this.chooseCardFromStack(mandatory);
return chooseCardFromStack(mandatory);
}
else {
List<Card> validTargets = CardUtil.getValidCardsToTarget(tgt, ability);
@@ -173,11 +173,14 @@ public class TargetSelection {
if (nonCardTargets.size() == 1 && minTargets != 0) {
return ability.getTargets().add(nonCardTargets.get(0));
}
if (nonCardTargets.isEmpty()) {
return false;
}
}
else if (validTargets.size() == 1 && minTargets != 0 && ability.isTrigger() && !tgt.canTgtPlayer()) {
//if only one valid target card for triggered ability, auto-target that card
//only do this for triggered abilities to prevent auto-targeting when user chooses
//to play a spell or activat an ability
//to play a spell or activate an ability
if (ability.isDividedAsYouChoose()) {
ability.addDividedAllocation(validTargets.get(0), ability.getStillToDivide());
}