1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-03 01:08:59 -09:00

[MOM] Implement Drana and Linvala

This commit is contained in:
theelk801 2023-04-17 19:53:32 -04:00
parent 8c2ee477fa
commit fbf874fdc5
4 changed files with 187 additions and 2 deletions
Mage.Sets/src/mage
Mage/src/main/java/mage/game/permanent

View file

@ -0,0 +1,182 @@
package mage.cards.d;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.AsThoughManaEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.RestrictionEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.ManaPoolItem;
import mage.util.CardUtil;
import java.util.Collection;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author TheElk801
*/
public final class DranaAndLinvala extends CardImpl {
public DranaAndLinvala(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{W}{B}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.VAMPIRE);
this.subtype.add(SubType.ANGEL);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Vigilance
this.addAbility(VigilanceAbility.getInstance());
// Activated abilities of creatures your opponents control can't be activated.
this.addAbility(new SimpleStaticAbility(new DranaAndLinvalaCantActivateEffect()));
// Drana and Linvala has all activated abilities of all creatures your opponents control. You may spend mana as though it were mana of any color to activate those abilities.
Ability ability = new SimpleStaticAbility(new DranaAndLinvalaGainAbilitiesEffect());
ability.addEffect(new DranaAndLinvalaManaEffect());
this.addAbility(ability);
}
private DranaAndLinvala(final DranaAndLinvala card) {
super(card);
}
@Override
public DranaAndLinvala copy() {
return new DranaAndLinvala(this);
}
}
class DranaAndLinvalaCantActivateEffect extends RestrictionEffect {
DranaAndLinvalaCantActivateEffect() {
super(Duration.WhileOnBattlefield);
staticText = "activated abilities of creatures your opponents control can't be activated";
}
private DranaAndLinvalaCantActivateEffect(final DranaAndLinvalaCantActivateEffect effect) {
super(effect);
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return permanent.isCreature(game)
&& game
.getOpponents(source.getControllerId())
.contains(permanent.getControllerId());
}
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
return false;
}
@Override
public DranaAndLinvalaCantActivateEffect copy() {
return new DranaAndLinvalaCantActivateEffect(this);
}
}
class DranaAndLinvalaGainAbilitiesEffect extends ContinuousEffectImpl {
DranaAndLinvalaGainAbilitiesEffect() {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
staticText = "{this} has all activated abilities of all creatures your opponents control";
this.addDependencyType(DependencyType.AddingAbility);
}
private DranaAndLinvalaGainAbilitiesEffect(final DranaAndLinvalaGainAbilitiesEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent perm = source.getSourcePermanentIfItStillExists(game);
if (perm == null) {
return false;
}
for (Ability ability : game
.getBattlefield()
.getActivePermanents(
StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE,
source.getControllerId(), source, game
)
.stream()
.map(permanent -> permanent.getAbilities(game))
.flatMap(Collection::stream)
.filter(Objects::nonNull)
.filter(ability -> ability.getAbilityType() == AbilityType.ACTIVATED
|| ability.getAbilityType() == AbilityType.MANA)
.collect(Collectors.toList())) {
Ability addedAbility = perm.addAbility(ability, source.getSourceId(), game);
addedAbility.getEffects().setValue("dranaLinvalaFlag", true);
}
return true;
}
@Override
public DranaAndLinvalaGainAbilitiesEffect copy() {
return new DranaAndLinvalaGainAbilitiesEffect(this);
}
}
class DranaAndLinvalaManaEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
DranaAndLinvalaManaEffect() {
super(AsThoughEffectType.SPEND_OTHER_MANA, Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "You may spend mana as though it were mana of any color to activate those abilities";
}
private DranaAndLinvalaManaEffect(final DranaAndLinvalaManaEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public DranaAndLinvalaManaEffect copy() {
return new DranaAndLinvalaManaEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) {
return CardUtil
.getMainCardId(game, objectId)
.equals(source.getSourceId())
&& affectedAbility
.getEffects()
.stream()
.map(effect -> effect.getValue("dranaLinvalaFlag"))
.filter(Boolean.class::isInstance)
.anyMatch(Boolean.class::cast)
&& source.isControlledBy(playerId);
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
return false;
}
@Override
public ManaType getAsThoughManaType(ManaType manaType, ManaPoolItem mana, UUID affectedControllerId, Ability source, Game game) {
return mana.getFirstAvailable();
}
}

View file

@ -97,6 +97,7 @@ public final class MarchOfTheMachine extends ExpansionSet {
cards.add(new SetCardInfo("Disturbing Conversion", 54, Rarity.COMMON, mage.cards.d.DisturbingConversion.class));
cards.add(new SetCardInfo("Djeru and Hazoret", 221, Rarity.RARE, mage.cards.d.DjeruAndHazoret.class));
cards.add(new SetCardInfo("Doomskar Warrior", 185, Rarity.RARE, mage.cards.d.DoomskarWarrior.class));
cards.add(new SetCardInfo("Drana and Linvala", 222, Rarity.RARE, mage.cards.d.DranaAndLinvala.class));
cards.add(new SetCardInfo("Dreg Recycler", 100, Rarity.COMMON, mage.cards.d.DregRecycler.class));
cards.add(new SetCardInfo("Dusk Legion Duelist", 11, Rarity.RARE, mage.cards.d.DuskLegionDuelist.class));
cards.add(new SetCardInfo("Elesh Norn", 12, Rarity.MYTHIC, mage.cards.e.EleshNorn.class));

View file

@ -212,7 +212,7 @@ public interface Permanent extends Card, Controllable {
* @param sourceId
* @param game
*/
void addAbility(Ability ability, UUID sourceId, Game game);
Ability addAbility(Ability ability, UUID sourceId, Game game);
void removeAllAbilities(UUID sourceId, Game game);

View file

@ -381,7 +381,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
}
@Override
public void addAbility(Ability ability, UUID sourceId, Game game) {
public Ability addAbility(Ability ability, UUID sourceId, Game game) {
// singleton abilities -- only one instance
// other abilities -- any amount of instances
if (!abilities.containsKey(ability.getId())) {
@ -397,7 +397,9 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
}
abilities.add(copyAbility);
abilities.addAll(ability.getSubAbilities());
return copyAbility;
}
return null;
}
@Override