forked from External/mage
Fix Alloy Golem color set duration (#10195)
This commit is contained in:
parent
68b3fc80e9
commit
ba461d9af0
3 changed files with 102 additions and 8 deletions
|
|
@ -0,0 +1,44 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
|
||||
public class SetChosenColorEffect extends ContinuousEffectImpl {
|
||||
|
||||
public SetChosenColorEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.ColorChangingEffects_5, SubLayer.NA, Outcome.Neutral);
|
||||
staticText = "{this} is the chosen color.";
|
||||
}
|
||||
|
||||
public SetChosenColorEffect(final SetChosenColorEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetChosenColorEffect copy() {
|
||||
return new SetChosenColorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color") ;
|
||||
if (permanent != null && color != null) {
|
||||
permanent.getColor().setColor(color);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package mage.abilities.effects.common.enterAttribute;
|
||||
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* IMPORTANT: This only sets the chosen color while the source permanent is entering the battlefield.
|
||||
* You should also use @link{mage.abilities.effects.common.continuous.SetChosenColorEffect} so that the color persists.
|
||||
*
|
||||
* @author xenohedron
|
||||
*/
|
||||
|
||||
public class EnterAttributeSetChosenColorEffect extends OneShotEffect {
|
||||
|
||||
|
||||
public EnterAttributeSetChosenColorEffect() {
|
||||
super(Outcome.Neutral);
|
||||
}
|
||||
|
||||
public EnterAttributeSetChosenColorEffect(final EnterAttributeSetChosenColorEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnterAttributeSetChosenColorEffect copy() {
|
||||
return new EnterAttributeSetChosenColorEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color") ;
|
||||
if (permanent != null && color != null) {
|
||||
permanent.getColor().setColor(color);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue