Implemented Captive Audience

This commit is contained in:
Evan Kranzler 2019-01-09 21:50:52 -05:00
parent 46ef843586
commit 009ffbcadd
2 changed files with 139 additions and 0 deletions

View file

@ -0,0 +1,138 @@
package mage.cards.c;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.abilities.effects.common.SetPlayerLifeSourceEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.effects.common.discard.DiscardHandControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.game.Game;
import mage.game.permanent.token.ZombieToken;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetOpponent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
import static mage.constants.Outcome.Benefit;
/**
* @author TheElk801
*/
public final class CaptiveAudience extends CardImpl {
public CaptiveAudience(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{5}{B}{R}");
// Captive Audience enters the battlefield under the control of an opponent of your choice.
this.addAbility(new EntersBattlefieldAbility(new CaptiveAudienceETBEffect()));
// At the beginning of your upkeep, choose one that hasn't been chosen
// Your life total becomes 4.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new SetPlayerLifeSourceEffect(4), TargetController.YOU, false);
ability.getModes().setEachModeOnlyOnce(true);
// Discard your hand.
ability.addMode(new Mode(new DiscardHandControllerEffect()));
// Each opponent creates five 2/2 black Zombie creature tokens.
ability.addMode(new Mode(new CaptiveAudienceCreateTokensEffect()));
this.addAbility(ability);
}
private CaptiveAudience(final CaptiveAudience card) {
super(card);
}
@Override
public CaptiveAudience copy() {
return new CaptiveAudience(this);
}
}
class CaptiveAudienceETBEffect extends OneShotEffect {
CaptiveAudienceETBEffect() {
super(Benefit);
staticText = "under the control of an opponent of your choice";
}
private CaptiveAudienceETBEffect(final CaptiveAudienceETBEffect effect) {
super(effect);
}
@Override
public CaptiveAudienceETBEffect copy() {
return new CaptiveAudienceETBEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Target target = new TargetOpponent();
target.setNotTarget(true);
if (!controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
return false;
}
Player player = game.getPlayer(target.getFirstTarget());
if (player == null) {
return false;
}
ContinuousEffect continuousEffect = new GainControlTargetEffect(
Duration.WhileOnBattlefield, true, player.getId()
);
continuousEffect.setTargetPointer(
new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter() + 1)
);
game.addEffect(continuousEffect, source);
return true;
}
}
class CaptiveAudienceCreateTokensEffect extends OneShotEffect {
CaptiveAudienceCreateTokensEffect() {
super(Benefit);
staticText = "Each opponent creates five 2/2 black Zombie creature tokens.";
}
private CaptiveAudienceCreateTokensEffect(final CaptiveAudienceCreateTokensEffect effect) {
super(effect);
}
@Override
public CaptiveAudienceCreateTokensEffect copy() {
return new CaptiveAudienceCreateTokensEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
for (Player player : game.getPlayers().values()) {
if (player != null && controller.hasOpponent(player.getId(), game)) {
Effect effect = new CreateTokenTargetEffect(new ZombieToken(), 5);
effect.setTargetPointer(new FixedTarget(player.getId(), game));
effect.apply(game, source);
}
}
return true;
}
}

View file

@ -57,6 +57,7 @@ public final class RavnicaAllegiance extends ExpansionSet {
cards.add(new SetCardInfo("Breeding Pool", 246, Rarity.RARE, mage.cards.b.BreedingPool.class));
cards.add(new SetCardInfo("Burn Bright", 93, Rarity.COMMON, mage.cards.b.BurnBright.class));
cards.add(new SetCardInfo("Burning-Tree Vandal", 94, Rarity.COMMON, mage.cards.b.BurningTreeVandal.class));
cards.add(new SetCardInfo("Captive Audience", 160, Rarity.MYTHIC, mage.cards.c.CaptiveAudience.class));
cards.add(new SetCardInfo("Carnival // Carnage", 222, Rarity.UNCOMMON, mage.cards.c.CarnivalCarnage.class));
cards.add(new SetCardInfo("Clan Guildmage", 162, Rarity.UNCOMMON, mage.cards.c.ClanGuildmage.class));
cards.add(new SetCardInfo("Combine Guildmage", 163, Rarity.UNCOMMON, mage.cards.c.CombineGuildmage.class));