mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
support for RandomTarget and RandomTargetRestriction on CopySpellAbilityEffect
This commit is contained in:
@@ -21,6 +21,7 @@ import forge.game.player.Player;
|
||||
import forge.game.replacement.ReplacementType;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.CardTranslation;
|
||||
import forge.util.Localizer;
|
||||
|
||||
@@ -162,6 +163,14 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||
if (sa.hasParam("MayChooseTarget")) {
|
||||
copy.setMayChooseNewTargets(true);
|
||||
}
|
||||
if (sa.hasParam("RandomTarget")){
|
||||
List<GameEntity> candidates = copy.getTargetRestrictions().getAllCandidates(chosenSA, true);
|
||||
if (sa.hasParam("RandomTargetRestriction")) {
|
||||
candidates.removeIf(c -> !c.isValid(sa.getParam("RandomTargetRestriction").split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa));
|
||||
}
|
||||
GameEntity choice = Aggregates.random(candidates);
|
||||
resetFirstTargetOnCopy(copy, choice, chosenSA);
|
||||
}
|
||||
|
||||
// extra case for Epic to remove the keyword and the last part of the SpellAbility
|
||||
if (sa.hasParam("Epic")) {
|
||||
|
||||
Reference in New Issue
Block a user