[ONS] Implemented Thoughtbound Primoc

This commit is contained in:
Alex W. Jackson 2022-09-29 08:43:29 -04:00
parent 6d3968df17
commit a66e455579
3 changed files with 159 additions and 50 deletions

View file

@ -12,12 +12,7 @@ import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.keyword.BushidoAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -31,16 +26,16 @@ public final class SokenzanRenegade extends CardImpl {
public SokenzanRenegade(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.subtype.add(SubType.OGRE);
this.subtype.add(SubType.SAMURAI);
this.subtype.add(SubType.MERCENARY);
this.subtype.add(SubType.OGRE, SubType.SAMURAI, SubType.MERCENARY);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Bushido 1
this.addAbility(new BushidoAbility(1));
// At the beginning of your upkeep, if a player has more cards in hand than each other player, the player who has the most cards in hand gains control of Sokenzan Renegade.
// At the beginning of your upkeep, if a player has more cards in hand than each other player,
// the player who has the most cards in hand gains control of Sokenzan Renegade.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new SokenzanRenegadeEffect(), TargetController.YOU, false),
OnePlayerHasTheMostCards.instance,
@ -77,34 +72,22 @@ class SokenzanRenegadeEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (controller != null
&& sourcePermanent != null) {
int max = Integer.MIN_VALUE;
Player newController = null;
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (player.getHand().size() > max) {
max = player.getHand().size();
newController = player;
}
}
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (sourcePermanent == null) {
return false;
}
Player newController = OnePlayerHasTheMostCards.getPlayerWithMostCards(game, source);
if (newController != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame, newController.getId());
effect.setTargetPointer(new FixedTarget(sourcePermanent.getId(), game));
effect.setTargetPointer(new FixedTarget(sourcePermanent, game));
game.addEffect(effect, source);
if (!source.isControlledBy(newController.getId())) {
game.informPlayers(newController.getLogName() + " got control of " + sourcePermanent.getLogName());
}
}
return true;
}
}
return false;
}
}
enum OnePlayerHasTheMostCards implements Condition {
@ -112,29 +95,29 @@ enum OnePlayerHasTheMostCards implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
return getPlayerWithMostCards(game, source) != null;
}
public static Player getPlayerWithMostCards(Game game, Ability source) {
int max = Integer.MIN_VALUE;
boolean onlyOnePlayer = false;
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player playerWithMost = null;
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (player.getHand().size() > max) {
max = player.getHand().size();
onlyOnePlayer = true;
} else if (player.getHand().size() == max) {
onlyOnePlayer = false;
int cards = player.getHand().size();
if (cards > max) {
max = cards;
playerWithMost = player;
} else if (cards == max) {
playerWithMost = null;
}
}
}
return onlyOnePlayer;
}
return false;
return playerWithMost;
}
@Override
public String toString() {
return "a player has more cards in hand than each other player";
}
}

View file

@ -0,0 +1,125 @@
package mage.cards.t;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
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.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author awjackson
*/
public final class ThoughtboundPrimoc extends CardImpl {
public ThoughtboundPrimoc(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.subtype.add(SubType.BIRD, SubType.BEAST);
this.power = new MageInt(2);
this.toughness = new MageInt(3);
// Flying
this.addAbility(FlyingAbility.getInstance());
// At the beginning of your upkeep, if a player controls more Wizards than each other player,
// the player who controls the most Wizards gains control of Thoughtbound Primoc.
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new ThoughtboundPrimocEffect(), TargetController.YOU, false),
OnePlayerHasTheMostWizards.instance,
"At the beginning of your upkeep, if a player controls more Wizards than each other player, the player who controls the most Wizards gains control of {this}"
));
}
private ThoughtboundPrimoc(final ThoughtboundPrimoc card) {
super(card);
}
@Override
public ThoughtboundPrimoc copy() {
return new ThoughtboundPrimoc(this);
}
}
class ThoughtboundPrimocEffect extends OneShotEffect {
public ThoughtboundPrimocEffect() {
super(Outcome.GainControl);
this.staticText = "the player who controls the most Wizards gains control of {this}";
}
public ThoughtboundPrimocEffect(final ThoughtboundPrimocEffect effect) {
super(effect);
}
@Override
public ThoughtboundPrimocEffect copy() {
return new ThoughtboundPrimocEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (sourcePermanent == null) {
return false;
}
Player newController = OnePlayerHasTheMostWizards.getPlayerWithMostWizards(game, source);
if (newController != null) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame, newController.getId());
effect.setTargetPointer(new FixedTarget(sourcePermanent, game));
game.addEffect(effect, source);
if (!source.isControlledBy(newController.getId())) {
game.informPlayers(newController.getLogName() + " got control of " + sourcePermanent.getLogName());
}
}
return true;
}
}
enum OnePlayerHasTheMostWizards implements Condition {
instance;
private static final FilterPermanent filter = new FilterPermanent(SubType.WIZARD, "Wizards");
@Override
public boolean apply(Game game, Ability source) {
return getPlayerWithMostWizards(game, source) != null;
}
public static Player getPlayerWithMostWizards(Game game, Ability source) {
int max = Integer.MIN_VALUE;
Player playerWithMost = null;
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int wizards = game.getBattlefield().countAll(filter, playerId, game);
if (wizards > max) {
max = wizards;
playerWithMost = player;
} else if (wizards == max) {
playerWithMost = null;
}
}
}
return playerWithMost;
}
@Override
public String toString() {
return "a player controls more Wizards than each other player";
}
}

View file

@ -328,6 +328,7 @@ public final class Onslaught extends ExpansionSet {
cards.add(new SetCardInfo("Taunting Elf", 290, Rarity.COMMON, mage.cards.t.TauntingElf.class));
cards.add(new SetCardInfo("Tempting Wurm", 291, Rarity.RARE, mage.cards.t.TemptingWurm.class));
cards.add(new SetCardInfo("Tephraderm", 239, Rarity.RARE, mage.cards.t.Tephraderm.class));
cards.add(new SetCardInfo("Thoughtbound Primoc", 240, Rarity.UNCOMMON, mage.cards.t.ThoughtboundPrimoc.class));
cards.add(new SetCardInfo("Thrashing Mudspawn", 177, Rarity.UNCOMMON, mage.cards.t.ThrashingMudspawn.class));
cards.add(new SetCardInfo("Threaten", 241, Rarity.UNCOMMON, mage.cards.t.Threaten.class));
cards.add(new SetCardInfo("Thunder of Hooves", 242, Rarity.UNCOMMON, mage.cards.t.ThunderOfHooves.class));