mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 20:59:14 -08:00
updated copy implementation to work with stack objects
This commit is contained in:
parent
1352beee9f
commit
92007f0132
14 changed files with 206 additions and 218 deletions
|
|
@ -24,10 +24,11 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.functions.SpellCopyApplier;
|
||||
import mage.util.functions.StackObjectCopyApplier;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -192,7 +193,7 @@ class BeamsplitterMagePredicate implements Predicate<Permanent> {
|
|||
}
|
||||
}
|
||||
|
||||
class BeamsplitterMageApplier implements SpellCopyApplier {
|
||||
class BeamsplitterMageApplier implements StackObjectCopyApplier {
|
||||
|
||||
private final Iterator<MageObjectReferencePredicate> predicate;
|
||||
|
||||
|
|
@ -203,7 +204,7 @@ class BeamsplitterMageApplier implements SpellCopyApplier {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void modifySpell(Spell spell, Game game) {
|
||||
public void modifySpell(StackObject stackObject, Game game) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ import mage.filter.StaticFilters;
|
|||
import mage.filter.predicate.mageobject.MageObjectReferencePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.target.TargetSpell;
|
||||
import mage.util.functions.SpellCopyApplier;
|
||||
import mage.util.functions.StackObjectCopyApplier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -69,12 +70,12 @@ class DoubleMajorEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
|
||||
enum DoubleMajorApplier implements SpellCopyApplier {
|
||||
enum DoubleMajorApplier implements StackObjectCopyApplier {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public void modifySpell(Spell spell, Game game) {
|
||||
spell.getSuperType().remove(SuperType.LEGENDARY);
|
||||
public void modifySpell(StackObject stackObject, Game game) {
|
||||
stackObject.getSuperType().remove(SuperType.LEGENDARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ import mage.filter.StaticFilters;
|
|||
import mage.filter.predicate.mageobject.MageObjectReferencePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.target.TargetSpell;
|
||||
import mage.util.functions.SpellCopyApplier;
|
||||
import mage.util.functions.StackObjectCopyApplier;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -70,12 +71,12 @@ class ForkEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
|
||||
enum ForkApplier implements SpellCopyApplier {
|
||||
enum ForkApplier implements StackObjectCopyApplier {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public void modifySpell(Spell spell, Game game) {
|
||||
spell.getColor(game).setColor(ObjectColor.RED);
|
||||
public void modifySpell(StackObject stackObject, Game game) {
|
||||
stackObject.getColor(game).setColor(ObjectColor.RED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.util.TargetAddress;
|
||||
|
|
@ -132,7 +133,7 @@ class InkTreaderNephilimEffect extends CopySpellForEachItCouldTargetEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(Spell spell, Player player, Ability source, Game game) {
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(StackObject stackObject, Player player, Ability source, Game game) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
return game.getBattlefield()
|
||||
.getActivePermanents(
|
||||
|
|
@ -141,14 +142,14 @@ class InkTreaderNephilimEffect extends CopySpellForEachItCouldTargetEffect {
|
|||
).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> !p.equals(permanent))
|
||||
.filter(p -> spell.canTarget(game, p.getId()))
|
||||
.filter(p -> stackObject.canTarget(game, p.getId()))
|
||||
.map(p -> new MageObjectReference(p, game))
|
||||
.map(MageObjectReferencePredicate::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Spell getSpell(Game game, Ability source) {
|
||||
protected Spell getStackObject(Game game, Ability source) {
|
||||
return (Spell) getValue("triggeringSpell");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.util.TargetAddress;
|
||||
|
|
@ -133,7 +134,7 @@ class MirrorwingDragonCopySpellEffect extends CopySpellForEachItCouldTargetEffec
|
|||
|
||||
@Override
|
||||
protected Player getPlayer(Game game, Ability source) {
|
||||
Spell spell = getSpell(game, source);
|
||||
Spell spell = getStackObject(game, source);
|
||||
if (spell == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -141,7 +142,7 @@ class MirrorwingDragonCopySpellEffect extends CopySpellForEachItCouldTargetEffec
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(Spell spell, Player player, Ability source, Game game) {
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(StackObject stackObject, Player player, Ability source, Game game) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
return game.getBattlefield()
|
||||
.getActivePermanents(
|
||||
|
|
@ -150,14 +151,14 @@ class MirrorwingDragonCopySpellEffect extends CopySpellForEachItCouldTargetEffec
|
|||
).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> !p.equals(permanent))
|
||||
.filter(p -> spell.canTarget(game, p.getId()))
|
||||
.filter(p -> stackObject.canTarget(game, p.getId()))
|
||||
.map(p -> new MageObjectReference(p, game))
|
||||
.map(MageObjectReferencePredicate::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Spell getSpell(Game game, Ability source) {
|
||||
protected Spell getStackObject(Game game, Ability source) {
|
||||
return (Spell) getValue("triggeringSpell");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.GolemToken;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.util.TargetAddress;
|
||||
|
|
@ -131,7 +132,7 @@ class PrecursorGolemCopySpellEffect extends CopySpellForEachItCouldTargetEffect
|
|||
|
||||
@Override
|
||||
protected Player getPlayer(Game game, Ability source) {
|
||||
Spell spell = getSpell(game, source);
|
||||
Spell spell = getStackObject(game, source);
|
||||
if (spell == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -139,7 +140,7 @@ class PrecursorGolemCopySpellEffect extends CopySpellForEachItCouldTargetEffect
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(Spell spell, Player player, Ability source, Game game) {
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(StackObject stackObject, Player player, Ability source, Game game) {
|
||||
Permanent permanent = (Permanent) getValue("targetedGolem");
|
||||
return game.getBattlefield()
|
||||
.getActivePermanents(
|
||||
|
|
@ -147,14 +148,14 @@ class PrecursorGolemCopySpellEffect extends CopySpellForEachItCouldTargetEffect
|
|||
).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> !p.equals(permanent))
|
||||
.filter(p -> spell.canTarget(game, p.getId()))
|
||||
.filter(p -> stackObject.canTarget(game, p.getId()))
|
||||
.map(p -> new MageObjectReference(p, game))
|
||||
.map(MageObjectReferencePredicate::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Spell getSpell(Game game, Ability source) {
|
||||
protected Spell getStackObject(Game game, Ability source) {
|
||||
return (Spell) getValue("triggeringSpell");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import mage.filter.predicate.ObjectPlayerPredicate;
|
|||
import mage.filter.predicate.mageobject.MageObjectReferencePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetSpell;
|
||||
|
|
@ -119,9 +120,9 @@ class RadiateEffect extends CopySpellForEachItCouldTargetEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(Spell spell, Player player, Ability source, Game game) {
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(StackObject stackObject, Player player, Ability source, Game game) {
|
||||
List<MageObjectReferencePredicate> predicates = new ArrayList<>();
|
||||
UUID targeted = spell
|
||||
UUID targeted = ((Spell) stackObject)
|
||||
.getSpellAbilities()
|
||||
.stream()
|
||||
.map(AbilityImpl::getTargets)
|
||||
|
|
@ -137,7 +138,7 @@ class RadiateEffect extends CopySpellForEachItCouldTargetEffect {
|
|||
).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> !p.equals(game.getPermanent(targeted)))
|
||||
.filter(p -> spell.canTarget(game, p.getId()))
|
||||
.filter(p -> stackObject.canTarget(game, p.getId()))
|
||||
.map(p -> new MageObjectReference(p, game))
|
||||
.map(MageObjectReferencePredicate::new)
|
||||
.forEach(predicates::add);
|
||||
|
|
@ -145,7 +146,7 @@ class RadiateEffect extends CopySpellForEachItCouldTargetEffect {
|
|||
.getPlayersInRange(source.getControllerId(), game)
|
||||
.stream()
|
||||
.filter(uuid -> !uuid.equals(targeted))
|
||||
.filter(uuid -> spell.canTarget(game, uuid))
|
||||
.filter(uuid -> stackObject.canTarget(game, uuid))
|
||||
.map(MageObjectReference::new)
|
||||
.map(MageObjectReferencePredicate::new)
|
||||
.forEach(predicates::add);
|
||||
|
|
@ -153,7 +154,7 @@ class RadiateEffect extends CopySpellForEachItCouldTargetEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Spell getSpell(Game game, Ability source) {
|
||||
protected Spell getStackObject(Game game, Ability source) {
|
||||
return game.getSpell(source.getFirstTarget());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.util.TargetAddress;
|
||||
|
|
@ -134,7 +135,7 @@ class ZadaHedronGrinderCopySpellEffect extends CopySpellForEachItCouldTargetEffe
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(Spell spell, Player player, Ability source, Game game) {
|
||||
protected List<MageObjectReferencePredicate> getPossibleTargets(StackObject stackObject, Player player, Ability source, Game game) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
return game.getBattlefield()
|
||||
.getActivePermanents(
|
||||
|
|
@ -143,14 +144,14 @@ class ZadaHedronGrinderCopySpellEffect extends CopySpellForEachItCouldTargetEffe
|
|||
).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(p -> !p.equals(permanent))
|
||||
.filter(p -> spell.canTarget(game, p.getId()))
|
||||
.filter(p -> stackObject.canTarget(game, p.getId()))
|
||||
.map(p -> new MageObjectReference(p, game))
|
||||
.map(MageObjectReferencePredicate::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Spell getSpell(Game game, Ability source) {
|
||||
protected Spell getStackObject(Game game, Ability source) {
|
||||
return (Spell) getValue("triggeringSpell");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue