mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
[BRO] Implemented Surge Engine
This commit is contained in:
parent
ae772f1f4e
commit
b8473bfb9d
2 changed files with 140 additions and 0 deletions
139
Mage.Sets/src/mage/cards/s/SurgeEngine.java
Normal file
139
Mage.Sets/src/mage/cards/s/SurgeEngine.java
Normal file
|
@ -0,0 +1,139 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.common.ActivateIfConditionActivatedAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.continuous.BecomesColorSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
|
||||
import mage.abilities.effects.common.continuous.LoseAbilitySourceEffect;
|
||||
import mage.abilities.effects.common.continuous.SetBasePowerToughnessSourceEffect;
|
||||
import mage.abilities.keyword.CantBeBlockedSourceAbility;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class SurgeEngine extends CardImpl {
|
||||
|
||||
public SurgeEngine(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{2}");
|
||||
|
||||
this.subtype.add(SubType.CONSTRUCT);
|
||||
this.power = new MageInt(3);
|
||||
this.toughness = new MageInt(2);
|
||||
|
||||
// Defender
|
||||
this.addAbility(DefenderAbility.getInstance());
|
||||
|
||||
// {U}: Surge Engine loses defender and gains "This creature can't be blocked."
|
||||
Ability ability = new SimpleActivatedAbility(new LoseAbilitySourceEffect(
|
||||
DefenderAbility.getInstance(), Duration.Custom
|
||||
), new ManaCostsImpl<>("{U}"));
|
||||
ability.addEffect(new GainAbilitySourceEffect(
|
||||
new CantBeBlockedSourceAbility(), Duration.Custom
|
||||
).setText("and gains \"This creature can't be blocked.\""));
|
||||
this.addAbility(ability);
|
||||
|
||||
// {2}{U}: Surge Engine becomes blue and has base power and toughness 5/4. Activate only if Surge Engine doesn't have defender.
|
||||
ability = new ActivateIfConditionActivatedAbility(
|
||||
Zone.BATTLEFIELD, new BecomesColorSourceEffect(ObjectColor.BLUE, Duration.Custom),
|
||||
new ManaCostsImpl<>("{2}{U}"), SurgeEngineCondition.instance
|
||||
);
|
||||
ability.addEffect(new SetBasePowerToughnessSourceEffect(
|
||||
5, 4, Duration.Custom, SubLayer.SetPT_7b
|
||||
).setText("and has base power and toughness 5/4"));
|
||||
this.addAbility(ability);
|
||||
|
||||
// {4}{U}{U}: Draw three cards. Activate only if Surge Engine is blue and only once.
|
||||
this.addAbility(new SurgeEngineAbility());
|
||||
}
|
||||
|
||||
private SurgeEngine(final SurgeEngine card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurgeEngine copy() {
|
||||
return new SurgeEngine(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum SurgeEngineCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return Optional
|
||||
.ofNullable(source.getSourcePermanentIfItStillExists(game))
|
||||
.filter(Objects::nonNull)
|
||||
.map(permanent -> permanent.hasAbility(DefenderAbility.getInstance(), game))
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "if {this} doesn't have defender";
|
||||
}
|
||||
}
|
||||
|
||||
class SurgeEngineAbility extends ActivatedAbilityImpl {
|
||||
|
||||
private static final Condition staticCondition = (game, source) -> Optional
|
||||
.ofNullable(source.getSourcePermanentIfItStillExists(game))
|
||||
.filter(Objects::nonNull)
|
||||
.map(permanent -> permanent.getColor(game))
|
||||
.map(ObjectColor::isBlue)
|
||||
.orElse(false);
|
||||
|
||||
SurgeEngineAbility() {
|
||||
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(3), new ManaCostsImpl<>("{4}{U}{U}"));
|
||||
this.condition = staticCondition;
|
||||
}
|
||||
|
||||
private SurgeEngineAbility(final SurgeEngineAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurgeEngineAbility copy() {
|
||||
return new SurgeEngineAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activate(Game game, boolean noMana) {
|
||||
if (!super.activate(game, noMana)) {
|
||||
return false;
|
||||
}
|
||||
game.getState().setValue(CardUtil.getCardZoneString("activationsAny" + originalId, sourceId, game), true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasMoreActivationsThisTurn(Game game) {
|
||||
if (!super.hasMoreActivationsThisTurn(game)) {
|
||||
return false;
|
||||
}
|
||||
Object value = game.getState().getValue(CardUtil.getCardZoneString("activationsAny" + originalId, sourceId, game));
|
||||
return value == null || ((Boolean) value) == false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "{4}{U}{U}: Draw three cards. Activate only if {this} is blue and only once.";
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ public final class TheBrothersWar extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Mountain", 284, Rarity.LAND, mage.cards.basiclands.Mountain.class, FULL_ART_BFZ_VARIOUS));
|
||||
cards.add(new SetCardInfo("Plains", 278, Rarity.LAND, mage.cards.basiclands.Plains.class, FULL_ART_BFZ_VARIOUS));
|
||||
cards.add(new SetCardInfo("Recruitment Officer", 23, Rarity.UNCOMMON, mage.cards.r.RecruitmentOfficer.class));
|
||||
cards.add(new SetCardInfo("Surge Engine", 81, Rarity.MYTHIC, mage.cards.s.SurgeEngine.class));
|
||||
cards.add(new SetCardInfo("Swamp", 282, Rarity.LAND, mage.cards.basiclands.Swamp.class, FULL_ART_BFZ_VARIOUS));
|
||||
cards.add(new SetCardInfo("The Mightstone and Weakstone", 238, Rarity.RARE, mage.cards.t.TheMightstoneAndWeakstone.class));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue