mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
[TLA] Implement Destined Confrontation
This commit is contained in:
parent
4e2c4ec1f0
commit
6b5fb2d4c2
2 changed files with 123 additions and 0 deletions
122
Mage.Sets/src/mage/cards/d/DestinedConfrontation.java
Normal file
122
Mage.Sets/src/mage/cards/d/DestinedConfrontation.java
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class DestinedConfrontation extends CardImpl {
|
||||
|
||||
public DestinedConfrontation(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{W}{W}");
|
||||
|
||||
// Each player chooses any number of creatures they control with total power 4 or less, then sacrifices all other creatures they control.
|
||||
this.getSpellAbility().addEffect(new DestinedConfrontationEffect());
|
||||
}
|
||||
|
||||
private DestinedConfrontation(final DestinedConfrontation card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestinedConfrontation copy() {
|
||||
return new DestinedConfrontation(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DestinedConfrontationEffect extends OneShotEffect {
|
||||
|
||||
DestinedConfrontationEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "each player chooses any number of creatures they control " +
|
||||
"with total power 4 or less, then sacrifices all other creatures they control";
|
||||
}
|
||||
|
||||
private DestinedConfrontationEffect(final DestinedConfrontationEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestinedConfrontationEffect copy() {
|
||||
return new DestinedConfrontationEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Set<UUID> permanents = new HashSet<>();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
TargetPermanent target = new DestinedConfrontationTarget();
|
||||
player.choose(outcome, target, source, game);
|
||||
permanents.addAll(target.getTargets());
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(
|
||||
StaticFilters.FILTER_PERMANENT_CREATURE, source.getSourceId(), source, game
|
||||
)) {
|
||||
if (!permanents.contains(permanent.getId())) {
|
||||
permanent.sacrifice(source, game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class DestinedConfrontationTarget extends TargetPermanent {
|
||||
|
||||
private static final FilterPermanent filter
|
||||
= new FilterControlledCreaturePermanent("creatures you control with total power 4 or less");
|
||||
|
||||
DestinedConfrontationTarget() {
|
||||
super(0, Integer.MAX_VALUE, filter, true);
|
||||
}
|
||||
|
||||
private DestinedConfrontationTarget(final DestinedConfrontationTarget target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestinedConfrontationTarget copy() {
|
||||
return new DestinedConfrontationTarget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID playerId, UUID id, Ability source, Game game) {
|
||||
if (!super.canTarget(playerId, id, source, game)) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return this
|
||||
.getTargets()
|
||||
.stream()
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.map(MageObject::getPower)
|
||||
.mapToInt(MageInt::getValue)
|
||||
.sum() + permanent.getPower().getValue() <= 4;
|
||||
}
|
||||
}
|
||||
|
|
@ -115,6 +115,7 @@ public final class AvatarTheLastAirbender extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Day of Black Sun", 94, Rarity.RARE, mage.cards.d.DayOfBlackSun.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Deadly Precision", 95, Rarity.COMMON, mage.cards.d.DeadlyPrecision.class));
|
||||
cards.add(new SetCardInfo("Deserter's Disciple", 131, Rarity.COMMON, mage.cards.d.DesertersDisciple.class));
|
||||
cards.add(new SetCardInfo("Destined Confrontation", 15, Rarity.UNCOMMON, mage.cards.d.DestinedConfrontation.class));
|
||||
cards.add(new SetCardInfo("Diligent Zookeeper", 171, Rarity.RARE, mage.cards.d.DiligentZookeeper.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Diligent Zookeeper", 327, Rarity.RARE, mage.cards.d.DiligentZookeeper.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Dragonfly Swarm", 215, Rarity.UNCOMMON, mage.cards.d.DragonflySwarm.class));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue