[M20] added Thunderkin Awakener

This commit is contained in:
Oleg Agafonov 2019-06-29 18:03:12 +04:00
parent 606c0ae61a
commit 46d030d37a
4 changed files with 181 additions and 17 deletions

View file

@ -1,14 +1,17 @@
package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class InfoEffect extends OneShotEffect {
@ -32,4 +35,11 @@ public class InfoEffect extends OneShotEffect {
return new InfoEffect(this);
}
public static void addInfoToPermanent(Game game, Ability source, Permanent permanent, String info) {
// add simple static info to permanent's rules
SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect(info));
GainAbilityTargetEffect gainAbilityEffect = new GainAbilityTargetEffect(ability, Duration.WhileOnBattlefield);
gainAbilityEffect.setTargetPointer(new FixedTarget(permanent.getId()));
game.addEffect(gainAbilityEffect, source);
}
}

View file

@ -1,7 +1,5 @@
package mage.abilities.effects.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -15,32 +13,52 @@ import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author noxx
*/
public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffect {
private boolean fromExileZone;
private boolean tapped;
private boolean attacking;
public ReturnToBattlefieldUnderYourControlTargetEffect() {
this(false);
}
/**
*
* @param fromExileZone - the card will only be returned if it's still in
* the source object specific exile zone
*/
public ReturnToBattlefieldUnderYourControlTargetEffect(boolean fromExileZone) {
this(fromExileZone, false, false);
}
/**
* @param fromExileZone - the card will only be returned if it's still in
* the source object specific exile zone
*/
public ReturnToBattlefieldUnderYourControlTargetEffect(boolean fromExileZone, boolean tapped, boolean attacking) {
super(Outcome.Benefit);
staticText = "return that card to the battlefield under your control";
this.fromExileZone = fromExileZone;
this.tapped = tapped;
this.attacking = attacking;
updateText();
}
public ReturnToBattlefieldUnderYourControlTargetEffect(final ReturnToBattlefieldUnderYourControlTargetEffect effect) {
super(effect);
this.fromExileZone = effect.fromExileZone;
this.tapped = effect.tapped;
this.attacking = effect.attacking;
updateText();
}
private void updateText() {
this.staticText = "return that card to the battlefield under your control"
+ (tapped ? " tapped" : "")
+ (tapped && attacking ? " and" : "")
+ (attacking ? " attacking" : "");
}
@Override
@ -61,8 +79,7 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
if (exileZone.contains(targetId)) {
cardsToBattlefield.add(targetId);
}
else {
} else {
Card card = game.getCard(targetId);
if (card instanceof MeldCard) {
MeldCard meldCard = (MeldCard) card;
@ -82,8 +99,13 @@ public class ReturnToBattlefieldUnderYourControlTargetEffect extends OneShotEffe
} else {
cardsToBattlefield.addAll(getTargetPointer().getTargets(game, source));
}
if (!cardsToBattlefield.isEmpty()) {
controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game);
for (Card card : cardsToBattlefield.getCards(game)) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game, tapped, false, false, null)) {
if (attacking) {
game.getCombat().addAttackingCreature(card.getId(), game);
}
}
}
return true;
}