mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 06:52:02 -08:00
Lousy fix for #4138
This commit is contained in:
parent
9423c30245
commit
896bcc504c
1 changed files with 69 additions and 12 deletions
|
|
@ -31,16 +31,22 @@ import java.util.UUID;
|
|||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ChooseColorEffect;
|
||||
import mage.abilities.effects.common.continuous.GainProtectionFromColorTargetEffect;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.choices.ChoiceColor;
|
||||
import mage.constants.AbilityWord;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.FilterObject;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -49,7 +55,7 @@ import mage.target.targetpointer.FixedTarget;
|
|||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
* @author LevelX2 & L_J
|
||||
*/
|
||||
public class BatheInLight extends CardImpl {
|
||||
|
||||
|
|
@ -57,7 +63,6 @@ public class BatheInLight extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}");
|
||||
|
||||
// Radiance - Choose a color. Target creature and each other creature that shares a color with it gain protection from the chosen color until end of turn.
|
||||
this.getSpellAbility().addEffect(new ChooseColorEffect(Outcome.Benefit));
|
||||
this.getSpellAbility().addEffect(new BatheInLightEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
|
||||
this.getSpellAbility().setAbilityWord(AbilityWord.RADIANCE);
|
||||
|
|
@ -95,19 +100,71 @@ class BatheInLightEffect extends OneShotEffect {
|
|||
if (controller != null) {
|
||||
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (target != null) {
|
||||
ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color");
|
||||
if (protectColor != null) {
|
||||
ObjectColor color = target.getColor(game);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (permanent.getColor(game).shares(color)) {
|
||||
ContinuousEffect effect = new GainProtectionFromColorTargetEffect(Duration.EndOfTurn, protectColor);
|
||||
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||
game.addEffect(effect, source);
|
||||
ChoiceColor colorChoice = new ChoiceColor();
|
||||
if (controller.choose(Outcome.Benefit, colorChoice, game)) {
|
||||
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice());
|
||||
game.getState().setValue(target.getId() + "_color", colorChoice.getColor());
|
||||
|
||||
ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color");
|
||||
if (protectColor != null) {
|
||||
ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
|
||||
game.addEffect(effect, source);
|
||||
ObjectColor color = target.getColor(game);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
|
||||
if (permanent != target && permanent.getColor(game).shares(color)) {
|
||||
game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
|
||||
effect.setTargetPointer(new FixedTarget(permanent, game));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class ProtectionChosenColorTargetEffect extends ContinuousEffectImpl {
|
||||
|
||||
protected ObjectColor chosenColor;
|
||||
protected ProtectionAbility protectionAbility;
|
||||
|
||||
public ProtectionChosenColorTargetEffect() {
|
||||
super(Duration.EndOfTurn, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
}
|
||||
|
||||
public ProtectionChosenColorTargetEffect(final ProtectionChosenColorTargetEffect effect) {
|
||||
super(effect);
|
||||
if (effect.chosenColor != null) {
|
||||
this.chosenColor = effect.chosenColor.copy();
|
||||
}
|
||||
if (effect.protectionAbility != null) {
|
||||
this.protectionAbility = effect.protectionAbility.copy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtectionChosenColorTargetEffect copy() {
|
||||
return new ProtectionChosenColorTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent != null) {
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
|
||||
if (color != null && (protectionAbility == null || !color.equals(chosenColor))) {
|
||||
chosenColor = color;
|
||||
FilterObject protectionFilter = new FilterObject(chosenColor.getDescription());
|
||||
protectionFilter.add(new ColorPredicate(chosenColor));
|
||||
protectionAbility = new ProtectionAbility(protectionFilter);
|
||||
}
|
||||
if (protectionAbility != null) {
|
||||
permanent.addAbility(protectionAbility, source.getSourceId(), game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue