mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
[CLB] Implemented Modify Memory
This commit is contained in:
parent
c91231b5eb
commit
e9a7df8665
2 changed files with 106 additions and 0 deletions
105
Mage.Sets/src/mage/cards/m/ModifyMemory.java
Normal file
105
Mage.Sets/src/mage/cards/m/ModifyMemory.java
Normal file
|
@ -0,0 +1,105 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.decorator.ConditionalOneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.continuous.ExchangeControlTargetEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Controllable;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetpointer.EachTargetPointer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class ModifyMemory extends CardImpl {
|
||||
|
||||
public ModifyMemory(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{U}");
|
||||
|
||||
// Exchange control of two target creatures controlled by different players. If you control neither creature, draw three cards.
|
||||
this.getSpellAbility().addEffect(new ExchangeControlTargetEffect(
|
||||
Duration.Custom, "exchange control of two target creatures controlled by different players"
|
||||
).setTargetPointer(new EachTargetPointer()));
|
||||
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
|
||||
new DrawCardSourceControllerEffect(3), ModifyMemoryCondition.instance,
|
||||
"If you control neither creature, draw three cards"
|
||||
));
|
||||
this.getSpellAbility().addTarget(new ModifyMemoryTarget());
|
||||
}
|
||||
|
||||
private ModifyMemory(final ModifyMemory card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModifyMemory copy() {
|
||||
return new ModifyMemory(this);
|
||||
}
|
||||
}
|
||||
|
||||
enum ModifyMemoryCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return source
|
||||
.getTargets()
|
||||
.stream()
|
||||
.map(Target::getTargets)
|
||||
.flatMap(Collection::stream)
|
||||
.map(game::getPermanentOrLKIBattlefield)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Controllable::getControllerId)
|
||||
.noneMatch(source::isControlledBy);
|
||||
}
|
||||
}
|
||||
|
||||
class ModifyMemoryTarget extends TargetCreaturePermanent {
|
||||
|
||||
private static final FilterCreaturePermanent filter
|
||||
= new FilterCreaturePermanent("creatures controlled by different players");
|
||||
|
||||
ModifyMemoryTarget() {
|
||||
super(2, 2, filter, false);
|
||||
}
|
||||
|
||||
private ModifyMemoryTarget(final ModifyMemoryTarget target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModifyMemoryTarget copy() {
|
||||
return new ModifyMemoryTarget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (!super.canTarget(controllerId, id, source, game)) {
|
||||
return false;
|
||||
}
|
||||
Permanent creature = game.getPermanent(id);
|
||||
if (creature == null) {
|
||||
return false;
|
||||
}
|
||||
return this.getTargets()
|
||||
.stream()
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.noneMatch(permanent -> !creature.getId().equals(permanent.getId())
|
||||
&& creature.isControlledBy(permanent.getControllerId())
|
||||
);
|
||||
}
|
||||
}
|
|
@ -360,6 +360,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Mirror Entity", 701, Rarity.RARE, mage.cards.m.MirrorEntity.class));
|
||||
cards.add(new SetCardInfo("Mizzium Mortars", 803, Rarity.RARE, mage.cards.m.MizziumMortars.class));
|
||||
cards.add(new SetCardInfo("Mocking Doppelganger", 667, Rarity.RARE, mage.cards.m.MockingDoppelganger.class));
|
||||
cards.add(new SetCardInfo("Modify Memory", 83, Rarity.UNCOMMON, mage.cards.m.ModifyMemory.class));
|
||||
cards.add(new SetCardInfo("Mold Folk", 133, Rarity.COMMON, mage.cards.m.MoldFolk.class));
|
||||
cards.add(new SetCardInfo("Monster Manual", 242, Rarity.RARE, mage.cards.m.MonsterManual.class));
|
||||
cards.add(new SetCardInfo("Moonshae Pixie", 84, Rarity.UNCOMMON, mage.cards.m.MoonshaePixie.class));
|
||||
|
|
Loading…
Reference in a new issue