mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Implement Flash Foliage
This commit is contained in:
parent
dcb1affb9d
commit
687c7a2b26
2 changed files with 102 additions and 0 deletions
101
Mage.Sets/src/mage/cards/f/FlashFoliage.java
Normal file
101
Mage.Sets/src/mage/cards/f/FlashFoliage.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
package mage.cards.f;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
|
||||
import mage.abilities.condition.common.AfterBlockersAreDeclaredCondition;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.game.Game;
|
||||
import mage.game.combat.CombatGroup;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.SaprolingToken;
|
||||
import mage.game.permanent.token.Token;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.FilterCreatureAttackingYou;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author noahg
|
||||
*/
|
||||
public final class FlashFoliage extends CardImpl {
|
||||
|
||||
public FlashFoliage(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{G}");
|
||||
|
||||
|
||||
// Cast Flash Foliage only during combat after blockers are declared.
|
||||
this.addAbility(new CastOnlyDuringPhaseStepSourceAbility(TurnPhase.COMBAT, AfterBlockersAreDeclaredCondition.instance));
|
||||
|
||||
// Create a 1/1 green Saproling creature token that’s blocking target creature attacking you.
|
||||
this.getSpellAbility().addEffect(new FlashFoliageEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(new FilterCreatureAttackingYou()));
|
||||
|
||||
// Draw a card.
|
||||
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
|
||||
}
|
||||
|
||||
public FlashFoliage(final FlashFoliage card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlashFoliage copy() {
|
||||
return new FlashFoliage(this);
|
||||
}
|
||||
}
|
||||
|
||||
class FlashFoliageEffect extends OneShotEffect {
|
||||
|
||||
public FlashFoliageEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "create a 1/1 green Saproling creature token that’s blocking target creature attacking you";
|
||||
}
|
||||
|
||||
public FlashFoliageEffect(final FlashFoliageEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlashFoliageEffect copy() {
|
||||
return new FlashFoliageEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
||||
if (controller != null) {
|
||||
Token token = new SaprolingToken();
|
||||
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
|
||||
Permanent attackingCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (attackingCreature != null && game.getState().getCombat() != null) {
|
||||
// Possible ruling (see Aetherplasm)
|
||||
// The token you created is blocking the attacking creature,
|
||||
// even if the block couldn't legally be declared (for example, if that creature
|
||||
// enters the battlefield tapped, or it can't block, or the attacking creature
|
||||
// has protection from it)
|
||||
CombatGroup combatGroup = game.getState().getCombat().findGroup(attackingCreature.getId());
|
||||
if (combatGroup != null) {
|
||||
for (UUID tokenId : token.getLastAddedTokenIds()) {
|
||||
Permanent saprolingToken = game.getPermanent(tokenId);
|
||||
if (saprolingToken != null) {
|
||||
combatGroup.addBlocker(tokenId, source.getControllerId(), game);
|
||||
game.getCombat().addBlockingGroup(tokenId, attackingCreature.getId(), controller.getId(), game);
|
||||
}
|
||||
}
|
||||
combatGroup.pickBlockerOrder(attackingCreature.getControllerId(), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -75,6 +75,7 @@ public final class Dissension extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Experiment Kraj", 110, Rarity.RARE, mage.cards.e.ExperimentKraj.class));
|
||||
cards.add(new SetCardInfo("Flame-Kin War Scout", 61, Rarity.UNCOMMON, mage.cards.f.FlameKinWarScout.class));
|
||||
cards.add(new SetCardInfo("Flaring Flame-Kin", 62, Rarity.UNCOMMON, mage.cards.f.FlaringFlameKin.class));
|
||||
cards.add(new SetCardInfo("Flash Foliage", 85, Rarity.UNCOMMON, mage.cards.f.FlashFoliage.class));
|
||||
cards.add(new SetCardInfo("Freewind Equenaut", 9, Rarity.COMMON, mage.cards.f.FreewindEquenaut.class));
|
||||
cards.add(new SetCardInfo("Ghost Quarter", 173, Rarity.UNCOMMON, mage.cards.g.GhostQuarter.class));
|
||||
cards.add(new SetCardInfo("Gnat Alley Creeper", 63, Rarity.UNCOMMON, mage.cards.g.GnatAlleyCreeper.class));
|
||||
|
|
Loading…
Reference in a new issue