[AFR] Implemented Split the Party

This commit is contained in:
Daniel Bomar 2021-07-06 20:17:18 -05:00
parent f6b9c64c55
commit 700560442d
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,89 @@
package mage.cards.s;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author weirddan455
*/
public final class SplitTheParty extends CardImpl {
public SplitTheParty(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}{U}");
// Choose target player. Return half the creatures they control to their owner's hand, rounded up.
this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new SplitThePartyEffect());
}
private SplitTheParty(final SplitTheParty card) {
super(card);
}
@Override
public SplitTheParty copy() {
return new SplitTheParty(this);
}
}
class SplitThePartyEffect extends OneShotEffect {
public SplitThePartyEffect() {
super(Outcome.ReturnToHand);
this.staticText = "Choose target player. Return half the creatures they control to their owner's hand, rounded up";
}
private SplitThePartyEffect(final SplitThePartyEffect effect) {
super(effect);
}
@Override
public SplitThePartyEffect copy() {
return new SplitThePartyEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (controller == null || targetPlayer == null) {
return false;
}
int numCreatures = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, targetPlayer.getId(), game);
if (numCreatures > 0) {
int halfCreatures = (numCreatures / 2) + (numCreatures % 2);
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures controlled by " + targetPlayer.getName());
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
TargetCreaturePermanent target = new TargetCreaturePermanent(halfCreatures, halfCreatures, filter, true);
if (controller.chooseTarget(outcome, target, source, game)) {
Set<Card> cardsToHand = new HashSet<>();
for (UUID creatureId : target.getTargets()) {
Card card = game.getPermanent(creatureId);
if (card != null) {
cardsToHand.add(card);
}
}
controller.moveCards(cardsToHand, Zone.HAND, source, game);
}
}
return true;
}
}

View file

@ -157,6 +157,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
cards.add(new SetCardInfo("Skullport Merchant", 120, Rarity.UNCOMMON, mage.cards.s.SkullportMerchant.class));
cards.add(new SetCardInfo("Soulknife Spy", 75, Rarity.COMMON, mage.cards.s.SoulknifeSpy.class));
cards.add(new SetCardInfo("Spike Pit Trap", 251, Rarity.COMMON, mage.cards.s.SpikePitTrap.class));
cards.add(new SetCardInfo("Split the Party", 76, Rarity.UNCOMMON, mage.cards.s.SplitTheParty.class));
cards.add(new SetCardInfo("Steadfast Paladin", 38, Rarity.COMMON, mage.cards.s.SteadfastPaladin.class));
cards.add(new SetCardInfo("Sudden Insight", 77, Rarity.UNCOMMON, mage.cards.s.SuddenInsight.class));
cards.add(new SetCardInfo("Swamp", 270, Rarity.LAND, mage.cards.basiclands.Swamp.class, NON_FULL_USE_VARIOUS));