Merge branch 'chefs_kiss' into 'master'

MH2: Chef's Kiss and support

See merge request core-developers/forge!4765
This commit is contained in:
Michael Kamensky
2021-05-27 04:25:33 +00:00
3 changed files with 19 additions and 0 deletions

View File

@@ -99,6 +99,9 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
int div = changingTgtSA.getTotalDividedValue(); int div = changingTgtSA.getTotalDividedValue();
changingTgtSA.resetTargets(); changingTgtSA.resetTargets();
List<GameEntity> candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true); List<GameEntity> candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true);
if (sa.hasParam("RandomTargetRestriction")) {
candidates.removeIf(c -> !c.isValid(sa.getParam("RandomTargetRestriction").split(","), sa.getActivatingPlayer(), sa.getHostCard(), sa));
}
GameEntity choice = Aggregates.random(candidates); GameEntity choice = Aggregates.random(candidates);
changingTgtSA.getTargets().add(choice); changingTgtSA.getTargets().add(choice);
if (changingTgtSA.isDividedAsYouChoose()) { if (changingTgtSA.isDividedAsYouChoose()) {

View File

@@ -21,6 +21,7 @@ import forge.game.player.Player;
import forge.game.replacement.ReplacementType; import forge.game.replacement.ReplacementType;
import forge.game.spellability.AbilitySub; import forge.game.spellability.AbilitySub;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.util.Aggregates;
import forge.util.CardTranslation; import forge.util.CardTranslation;
import forge.util.Localizer; import forge.util.Localizer;
@@ -162,6 +163,14 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
if (sa.hasParam("MayChooseTarget")) { if (sa.hasParam("MayChooseTarget")) {
copy.setMayChooseNewTargets(true); 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 // extra case for Epic to remove the keyword and the last part of the SpellAbility
if (sa.hasParam("Epic")) { if (sa.hasParam("Epic")) {

View File

@@ -0,0 +1,7 @@
Name:Chef's Kiss
ManaCost:1 R R
Types:Instant
A:SP$ ControlSpell | ValidTgts$ Card | TgtPrompt$ Select target spell that targets only a single permanent or player | TargetType$ Spell | Mode$ Gain | TargetsSingleTarget$ True | TargetValidTargeting$ Permanent,Player | SubAbility$ DBCopy | StackDescription$ SpellDescription | SpellDescription$ Gain control of target spell that targets only a single permanent or player. Copy it, then reselect the targets at random for the spell and the copy. The new targets can't be you or a permanent you control.
SVar:DBCopy:DB$ CopySpellAbility | Defined$ Targeted | RandomTarget$ True | RandomTargetRestriction$ Player.Other,Permanent.YouDontCtrl | SubAbility$ DBChangeTargets | StackDescription$ None
SVar:DBChangeTargets:DB$ ChangeTargets | Defined$ Targeted | RandomTarget$ True | RandomTargetRestriction$ Player.Other,Permanent.YouDontCtrl
Oracle:Gain control of target spell that targets only a single permanent or player. Copy it, then reselect the targets at random for the spell and the copy. The new targets can't be you or a permanent you control.