Implemented Inniaz, the Gale Force

This commit is contained in:
Evan Kranzler 2020-06-25 21:11:56 -04:00
parent f4896710d8
commit cb918253c8
2 changed files with 164 additions and 0 deletions

View file

@ -0,0 +1,163 @@
package mage.cards.i;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksWithCreaturesTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.common.FilterNonlandPermanent;
import mage.filter.predicate.mageobject.AbilityPredicate;
import mage.filter.predicate.permanent.AttackingPredicate;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.players.PlayerList;
import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class InniazTheGaleForce extends CardImpl {
private static final FilterCreaturePermanent filter
= new FilterCreaturePermanent("attacking creatures with flying");
private static final FilterCreaturePermanent filter2
= new FilterCreaturePermanent("creatures you control with flying");
static {
filter.add(AttackingPredicate.instance);
filter.add(new AbilityPredicate(FlyingAbility.class));
filter2.add(new AbilityPredicate(FlyingAbility.class));
}
public InniazTheGaleForce(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{U}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.DJINN);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// Flying
this.addAbility(FlyingAbility.getInstance());
// {2}{W/U}: Attacking creatures with flying get +1/+1 until end of turn.
this.addAbility(new SimpleActivatedAbility(new BoostAllEffect(
1, 1, Duration.EndOfTurn, filter, false
), new ManaCostsImpl("{2}{W/U}")));
// Whenever three or more creatures you control with flying attack, each player gains control of a nonland permanent of your choice controlled by the player to their right.
this.addAbility(new AttacksWithCreaturesTriggeredAbility(
new InniazTheGaleForceEffect(), 3, filter2
));
}
private InniazTheGaleForce(final InniazTheGaleForce card) {
super(card);
}
@Override
public InniazTheGaleForce copy() {
return new InniazTheGaleForce(this);
}
}
class InniazTheGaleForceEffect extends OneShotEffect {
private static final class PlayerPair {
private final Player leftPlayer;
private final Player rightPlayer;
private final FilterPermanent filter;
private final TargetPermanent target;
private PlayerPair(Player leftPlayer, Player rightPlayer) {
this.leftPlayer = leftPlayer;
this.rightPlayer = rightPlayer;
this.filter = this.makeFilter();
this.target = this.makeTarget();
}
private FilterPermanent makeFilter() {
FilterPermanent filter = new FilterNonlandPermanent(
"nonland permanent controlled by " + rightPlayer.getName()
+ " to give to " + leftPlayer.getName()
);
filter.add(new ControllerIdPredicate(rightPlayer.getId()));
return filter;
}
private TargetPermanent makeTarget() {
return new TargetPermanent(1, this.filter);
}
private void chooseTargets(Player controller, Game game, Ability source) {
if (game.getBattlefield().count(this.filter, source.getSourceId(), source.getControllerId(), game) > 0) {
controller.choose(Outcome.Neutral, this.target, source.getSourceId(), game);
}
}
private void createEffect(Game game, Ability source) {
if (this.target.getFirstTarget() == null) {
return;
}
game.addEffect(new GainControlTargetEffect(
Duration.Custom, true, leftPlayer.getId()
).setTargetPointer(new FixedTarget(target.getFirstTarget(), game)), source);
}
}
InniazTheGaleForceEffect() {
super(Outcome.Benefit);
staticText = "each player gains control of a nonland permanent of your choice controlled by the player to their right.";
}
private InniazTheGaleForceEffect(final InniazTheGaleForceEffect effect) {
super(effect);
}
@Override
public InniazTheGaleForceEffect copy() {
return new InniazTheGaleForceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
PlayerList playerList = game.getState().getPlayersInRange(source.getControllerId(), game);
List<PlayerPair> playerPairList = new ArrayList<>();
for (int i = 0; i < playerList.size() - 1; i++) {
playerPairList.add(new PlayerPair(
game.getPlayer(playerList.get(i)),
game.getPlayer(playerList.get(i + 1))
));
}
playerPairList.add(new PlayerPair(
game.getPlayer(playerList.get(playerPairList.size() - 1)),
game.getPlayer(playerList.get(0))
));
for (PlayerPair playerPair : playerPairList) {
playerPair.chooseTargets(controller, game, source);
}
for (PlayerPair playerPair : playerPairList) {
playerPair.createEffect(game, source);
}
return true;
}
}

View file

@ -221,6 +221,7 @@ public final class Jumpstart extends ExpansionSet {
cards.add(new SetCardInfo("Indomitable Will", 109, Rarity.COMMON, mage.cards.i.IndomitableWill.class)); cards.add(new SetCardInfo("Indomitable Will", 109, Rarity.COMMON, mage.cards.i.IndomitableWill.class));
cards.add(new SetCardInfo("Inferno Hellion", 337, Rarity.UNCOMMON, mage.cards.i.InfernoHellion.class)); cards.add(new SetCardInfo("Inferno Hellion", 337, Rarity.UNCOMMON, mage.cards.i.InfernoHellion.class));
cards.add(new SetCardInfo("Initiate's Companion", 403, Rarity.COMMON, mage.cards.i.InitiatesCompanion.class)); cards.add(new SetCardInfo("Initiate's Companion", 403, Rarity.COMMON, mage.cards.i.InitiatesCompanion.class));
cards.add(new SetCardInfo("Inniaz, the Gale Force", 12, Rarity.RARE, mage.cards.i.InniazTheGaleForce.class));
cards.add(new SetCardInfo("Innocent Blood", 244, Rarity.COMMON, mage.cards.i.InnocentBlood.class)); cards.add(new SetCardInfo("Innocent Blood", 244, Rarity.COMMON, mage.cards.i.InnocentBlood.class));
cards.add(new SetCardInfo("Inspired Charge", 110, Rarity.COMMON, mage.cards.i.InspiredCharge.class)); cards.add(new SetCardInfo("Inspired Charge", 110, Rarity.COMMON, mage.cards.i.InspiredCharge.class));
cards.add(new SetCardInfo("Inspiring Call", 404, Rarity.UNCOMMON, mage.cards.i.InspiringCall.class)); cards.add(new SetCardInfo("Inspiring Call", 404, Rarity.UNCOMMON, mage.cards.i.InspiringCall.class));