mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
[SPM] Implement With Great Power...
This commit is contained in:
parent
8e0a222f9b
commit
49a3b1176e
5 changed files with 174 additions and 83 deletions
|
|
@ -4,7 +4,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostEnchantedEffect;
|
||||
|
|
@ -15,8 +15,10 @@ import mage.constants.Outcome;
|
|||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterPermanentCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.AttachedToAttachedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -34,14 +36,22 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public final class MantleOfTheAncients extends CardImpl {
|
||||
private static final FilterCard filter = new FilterPermanentCard();
|
||||
private static final FilterPermanent filter2 = new FilterPermanent("Aura and Equipment attached to it");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(
|
||||
SubType.AURA.getPredicate(),
|
||||
SubType.EQUIPMENT.getPredicate()
|
||||
));
|
||||
filter2.add(Predicates.or(
|
||||
SubType.AURA.getPredicate(),
|
||||
SubType.EQUIPMENT.getPredicate()
|
||||
));
|
||||
filter2.add(AttachedToAttachedPredicate.instance);
|
||||
}
|
||||
|
||||
private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter2);
|
||||
|
||||
public MantleOfTheAncients(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}{W}");
|
||||
|
||||
|
|
@ -59,9 +69,7 @@ public final class MantleOfTheAncients extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// Enchanted creature gets +1/+1 for each Aura and Equipment attached to it.
|
||||
this.addAbility(new SimpleStaticAbility(new BoostEnchantedEffect(
|
||||
MantleOfTheAncientsValue.instance, MantleOfTheAncientsValue.instance
|
||||
)));
|
||||
this.addAbility(new SimpleStaticAbility(new BoostEnchantedEffect(xValue, xValue)));
|
||||
}
|
||||
|
||||
private MantleOfTheAncients(final MantleOfTheAncients card) {
|
||||
|
|
@ -116,39 +124,3 @@ class MantleOfTheAncientsEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
enum MantleOfTheAncientsValue implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
Permanent sourcePermanent = sourceAbility.getSourcePermanentOrLKI(game);
|
||||
if (sourcePermanent == null) {
|
||||
return 0;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(sourcePermanent.getAttachedTo());
|
||||
return permanent == null ? 0 : permanent
|
||||
.getAttachments()
|
||||
.stream()
|
||||
.map(game::getPermanentOrLKIBattlefield)
|
||||
.filter(Objects::nonNull)
|
||||
.map(p -> p.hasSubtype(SubType.EQUIPMENT, game) || p.hasSubtype(SubType.AURA, game))
|
||||
.mapToInt(b -> b ? 1 : 0)
|
||||
.sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MantleOfTheAncientsValue copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "Aura and Equipment attached to it";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
|
|
@ -14,10 +14,10 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.AttachmentType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.AttachedToAttachedPredicate;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -25,15 +25,25 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class ThranPowerSuit extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterPermanent("Aura and Equipment attached to it");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(
|
||||
SubType.AURA.getPredicate(),
|
||||
SubType.EQUIPMENT.getPredicate()
|
||||
));
|
||||
filter.add(AttachedToAttachedPredicate.instance);
|
||||
}
|
||||
|
||||
private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter, 2);
|
||||
|
||||
public ThranPowerSuit(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||
|
||||
this.subtype.add(SubType.EQUIPMENT);
|
||||
|
||||
// Equipped creature gets +1/+1 for each Aura and Equipment attached to it and has ward {2}.
|
||||
Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(
|
||||
ThranPowerSuitValue.instance, ThranPowerSuitValue.instance
|
||||
));
|
||||
Ability ability = new SimpleStaticAbility(new BoostEquippedEffect(xValue, xValue));
|
||||
ability.addEffect(new GainAbilityAttachedEffect(new WardAbility(
|
||||
new GenericManaCost(2), false
|
||||
), AttachmentType.EQUIPMENT).setText("and has ward {2}. <i>(Whenever equipped creature becomes the target of a spell or ability an opponent controls, counter it unless that player pays {2}.)</i>"));
|
||||
|
|
@ -52,39 +62,3 @@ public final class ThranPowerSuit extends CardImpl {
|
|||
return new ThranPowerSuit(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum ThranPowerSuitValue implements DynamicValue {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
Permanent sourcePermanent = sourceAbility.getSourcePermanentOrLKI(game);
|
||||
if (sourcePermanent == null) {
|
||||
return 0;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(sourcePermanent.getAttachedTo());
|
||||
return permanent == null ? 0 : permanent
|
||||
.getAttachments()
|
||||
.stream()
|
||||
.map(game::getPermanentOrLKIBattlefield)
|
||||
.filter(Objects::nonNull)
|
||||
.map(p -> p.hasSubtype(SubType.EQUIPMENT, game) || p.hasSubtype(SubType.AURA, game))
|
||||
.mapToInt(b -> b ? 1 : 0)
|
||||
.sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThranPowerSuitValue copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "Aura and Equipment attached to it";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "1";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
114
Mage.Sets/src/mage/cards/w/WithGreatPower.java
Normal file
114
Mage.Sets/src/mage/cards/w/WithGreatPower.java
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
package mage.cards.w;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.permanent.AttachedToAttachedPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.DamagePlayerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class WithGreatPower extends CardImpl {
|
||||
|
||||
private static final FilterPermanent filter = new FilterPermanent("Aura and Equipment attached to it");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(
|
||||
SubType.AURA.getPredicate(),
|
||||
SubType.EQUIPMENT.getPredicate()
|
||||
));
|
||||
filter.add(AttachedToAttachedPredicate.instance);
|
||||
}
|
||||
|
||||
private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter, 2);
|
||||
|
||||
public WithGreatPower(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}");
|
||||
|
||||
this.subtype.add(SubType.AURA);
|
||||
|
||||
// Enchant creature you control
|
||||
TargetPermanent auraTarget = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_CREATURE);
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
|
||||
this.addAbility(new EnchantAbility(auraTarget));
|
||||
|
||||
// Enchanted creature gets +2/+2 for each Aura and Equipment attached to it.
|
||||
this.addAbility(new SimpleStaticAbility(new BoostEquippedEffect(xValue, xValue)));
|
||||
|
||||
// All damage that would be dealt to you is dealt to enchanted creature instead.
|
||||
this.addAbility(new SimpleStaticAbility(new WithGreatPowerEffect()));
|
||||
}
|
||||
|
||||
private WithGreatPower(final WithGreatPower card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WithGreatPower copy() {
|
||||
return new WithGreatPower(this);
|
||||
}
|
||||
}
|
||||
|
||||
class WithGreatPowerEffect extends ReplacementEffectImpl {
|
||||
WithGreatPowerEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.RedirectDamage);
|
||||
staticText = "all damage that would be dealt to you is dealt to enchanted creature instead";
|
||||
}
|
||||
|
||||
private WithGreatPowerEffect(final WithGreatPowerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
DamagePlayerEvent damageEvent = (DamagePlayerEvent) event;
|
||||
Optional.ofNullable(event)
|
||||
.map(GameEvent::getSourceId)
|
||||
.map(game::getPermanent)
|
||||
.map(Permanent::getAttachedTo)
|
||||
.map(game::getPermanent)
|
||||
.ifPresent(permanent -> permanent.damage(
|
||||
damageEvent.getAmount(), event.getSourceId(), source,
|
||||
game, damageEvent.isCombatDamage(), damageEvent.isPreventable()
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DAMAGE_PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return source.isControlledBy(event.getPlayerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WithGreatPowerEffect copy() {
|
||||
return new WithGreatPowerEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -134,5 +134,6 @@ public final class MarvelsSpiderMan extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Web-Warriors", 203, Rarity.UNCOMMON, mage.cards.w.WebWarriors.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Whoosh!", 48, Rarity.COMMON, mage.cards.w.Whoosh.class));
|
||||
cards.add(new SetCardInfo("Wild Pack Squad", 23, Rarity.COMMON, mage.cards.w.WildPackSquad.class));
|
||||
cards.add(new SetCardInfo("With Great Power...", 24, Rarity.RARE, mage.cards.w.WithGreatPower.class));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package mage.filter.predicate.permanent;
|
||||
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum AttachedToAttachedPredicate implements ObjectSourcePlayerPredicate<Permanent> {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
|
||||
return Optional
|
||||
.ofNullable(input.getSource().getSourcePermanentOrLKI(game))
|
||||
.map(Permanent::getAttachedTo)
|
||||
.filter(input.getObject()::isAttachedTo)
|
||||
.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "attached to attached permanent";
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue