Merge branch 'master' into refactor/multiple-names

This commit is contained in:
theelk801 2024-09-11 16:42:43 -04:00
commit a2b44bceac
67 changed files with 2801 additions and 295 deletions

View file

@ -0,0 +1,42 @@
package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.keyword.ManifestDreadEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
* @author TheElk801
*/
public class ManifestDreadThenAttachEffect extends OneShotEffect {
public ManifestDreadThenAttachEffect() {
super(Outcome.Benefit);
staticText = "manifest dread, then attach {this} to that creature";
}
private ManifestDreadThenAttachEffect(final ManifestDreadThenAttachEffect effect) {
super(effect);
}
@Override
public ManifestDreadThenAttachEffect copy() {
return new ManifestDreadThenAttachEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Permanent creature = ManifestDreadEffect.doManifestDread(player, source, game);
Permanent equipment = source.getSourcePermanentIfItStillExists(game);
return creature != null
&& equipment != null
&& creature.addAttachment(equipment.getId(), source, game);
}
}

View file

@ -24,19 +24,35 @@ public class AddCreatureSubTypeAllMultiZoneEffect extends ContinuousEffectImpl {
private final FilterControlledCreaturePermanent filterPermanent;
private final FilterControlledCreatureSpell filterSpell;
private final FilterOwnedCreatureCard filterCard;
private final SubType chosenType;
public AddCreatureSubTypeAllMultiZoneEffect(
FilterControlledCreaturePermanent filterPermanent,
FilterControlledCreatureSpell filterSpell,
FilterOwnedCreatureCard filterCard
) {
this(filterPermanent, filterSpell, filterCard, null);
}
public AddCreatureSubTypeAllMultiZoneEffect(
FilterControlledCreaturePermanent filterPermanent,
FilterControlledCreatureSpell filterSpell,
FilterOwnedCreatureCard filterCard,
SubType chosenType
) {
super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Benefit);
this.filterPermanent = filterPermanent;
this.filterSpell = filterSpell;
this.filterCard = filterCard;
this.chosenType = chosenType;
staticText = filterPermanent.getMessage() + " are the chosen type in addition to their other types. "
String typeMessage = "the chosen type";
if (chosenType != null) {
typeMessage = chosenType.getPluralName();
}
staticText = filterPermanent.getMessage() + " are " + typeMessage + " in addition to their other types. "
+ "The same is true for " + filterSpell.getMessage()
+ " and " + filterCard.getMessage() + " that aren't on the battlefield";
}
@ -46,6 +62,7 @@ public class AddCreatureSubTypeAllMultiZoneEffect extends ContinuousEffectImpl {
this.filterPermanent = effect.filterPermanent;
this.filterSpell = effect.filterSpell;
this.filterCard = effect.filterCard;
this.chosenType = effect.chosenType;
}
@Override
@ -57,7 +74,10 @@ public class AddCreatureSubTypeAllMultiZoneEffect extends ContinuousEffectImpl {
public boolean apply(Game game, Ability source) {
UUID controllerId = source.getControllerId();
Player controller = game.getPlayer(controllerId);
SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
SubType subType = this.chosenType;
if (subType == null) {
subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
}
if (controller == null || subType == null) {
return false;
}

View file

@ -1,18 +1,15 @@
package mage.abilities.effects.common.continuous;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.TargetController;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.Optional;
import java.util.UUID;
/**
* @author LevelX2
*/
@ -48,41 +45,47 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
switch (targetController) {
case YOU:
controller.setCanGainLife(false);
break;
case NOT_YOU:
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && !player.equals(controller)) {
player.setCanGainLife(false);
}
if (controller == null) {
return false;
}
switch (targetController) {
case YOU:
controller.setCanGainLife(false);
break;
case NOT_YOU:
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null && !player.equals(controller)) {
player.setCanGainLife(false);
}
break;
case OPPONENT:
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (controller.hasOpponent(playerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.setCanGainLife(false);
}
}
}
break;
case ANY:
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
}
break;
case OPPONENT:
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (controller.hasOpponent(playerId, game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.setCanGainLife(false);
}
}
break;
}
return true;
}
break;
case ANY:
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.setCanGainLife(false);
}
}
break;
case ENCHANTED:
Optional
.ofNullable(source.getSourcePermanentIfItStillExists(game))
.map(Permanent::getAttachedTo)
.map(game::getPlayer)
.ifPresent(player -> player.setCanGainLife(false));
}
return false;
return true;
}
private String setText() {
@ -100,6 +103,8 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
case ANY:
sb.append("Players");
break;
case ENCHANTED:
sb.append("enchanted player");
}
sb.append(" can't gain life");
if (!this.duration.toString().isEmpty()) {

View file

@ -8,6 +8,7 @@ import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.ManifestedDreadEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
@ -65,6 +66,8 @@ public class ManifestDreadEffect extends OneShotEffect {
}
cards.retainZone(Zone.LIBRARY, game);
player.moveCards(cards, Zone.GRAVEYARD, source, game);
cards.retainZone(Zone.GRAVEYARD, game);
game.fireEvent(new ManifestedDreadEvent(permanent, source, player.getId(), cards, game));
return permanent;
}
}

View file

@ -346,6 +346,27 @@ public final class StaticFilters {
FILTER_PERMANENT_ARTIFACT_OR_CREATURE.setLockedFilter(true);
}
public static final FilterPermanent FILTER_PERMANENT_CREATURE_OR_ENCHANTMENT = new FilterPermanent("creature or enchantment");
static {
FILTER_PERMANENT_CREATURE_OR_ENCHANTMENT.add(Predicates.or(
CardType.CREATURE.getPredicate(),
CardType.ENCHANTMENT.getPredicate()
));
FILTER_PERMANENT_CREATURE_OR_ENCHANTMENT.setLockedFilter(true);
}
public static final FilterPermanent FILTER_PERMANENT_ANOTHER_CREATURE_OR_ENCHANTMENT = new FilterPermanent("another creature or enchantment");
static {
FILTER_PERMANENT_ANOTHER_CREATURE_OR_ENCHANTMENT.add(Predicates.or(
CardType.CREATURE.getPredicate(),
CardType.ENCHANTMENT.getPredicate()
));
FILTER_PERMANENT_ANOTHER_CREATURE_OR_ENCHANTMENT.setLockedFilter(true);
}
public static final FilterPermanent FILTER_PERMANENT_ARTIFACT_CREATURE_OR_ENCHANTMENT = new FilterPermanent("artifact, creature, or enchantment");
static {

View file

@ -478,6 +478,7 @@ public class GameEvent implements Serializable {
PHASE_IN, PHASED_IN,
TURN_FACE_UP, TURNED_FACE_UP,
TURN_FACE_DOWN, TURNED_FACE_DOWN,
MANIFESTED_DREAD,
/* OPTION_USED
targetId originalId of the ability that triggered the event
sourceId sourceId of the ability that triggered the event

View file

@ -0,0 +1,31 @@
package mage.game.events;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.cards.Cards;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* @author TheElk801
*/
public class ManifestedDreadEvent extends GameEvent {
private final List<MageObjectReference> graveyardCards = new ArrayList<>();
public ManifestedDreadEvent(Permanent permanent, Ability source, UUID playerId, Cards cards, Game game) {
super(EventType.MANIFESTED_DREAD, permanent == null ? null : permanent.getId(), source, playerId);
cards.getCards(game)
.stream()
.map(card -> new MageObjectReference(card, game))
.forEach(graveyardCards::add);
}
public List<MageObjectReference> getGraveyardCards() {
return graveyardCards;
}
}