mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
fix #10403 (Maestros Ascendancy)
This commit is contained in:
parent
6820aa5ee1
commit
0d5ae6b704
2 changed files with 14 additions and 10 deletions
|
|
@ -18,6 +18,7 @@ import mage.filter.StaticFilters;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
|
import mage.game.stack.Spell;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
|
|
||||||
|
|
@ -83,7 +84,7 @@ class MaestrosAscendancyCastEffect extends AsThoughEffectImpl {
|
||||||
|| !card.isOwnedBy(affectedControllerId)
|
|| !card.isOwnedBy(affectedControllerId)
|
||||||
|| !card.isInstantOrSorcery(game)
|
|| !card.isInstantOrSorcery(game)
|
||||||
|| !game.getState().getZone(objectId).match(Zone.GRAVEYARD)
|
|| !game.getState().getZone(objectId).match(Zone.GRAVEYARD)
|
||||||
|| !MaestrosAscendancyWatcher.checkPlayer(source, game)) {
|
|| MaestrosAscendancyWatcher.checkPlayer(source, game)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Costs<Cost> newCosts = new CostsImpl<>();
|
Costs<Cost> newCosts = new CostsImpl<>();
|
||||||
|
|
@ -115,10 +116,8 @@ class MaestrosAscendancyExileEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
((ZoneChangeEvent) event).setToZone(Zone.EXILED);
|
||||||
Card card = game.getCard(event.getTargetId());
|
return false;
|
||||||
return controller != null && card != null
|
|
||||||
&& controller.moveCards(card, Zone.EXILED, source, game);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -129,8 +128,10 @@ class MaestrosAscendancyExileEffect extends ReplacementEffectImpl {
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||||
|
Spell spell = game.getSpellOrLKIStack(zEvent.getTargetId());
|
||||||
return zEvent.getToZone() == Zone.GRAVEYARD
|
return zEvent.getToZone() == Zone.GRAVEYARD
|
||||||
&& MaestrosAscendancyWatcher.checkSpell(zEvent.getTargetId(), source, game);
|
&& spell != null
|
||||||
|
&& MaestrosAscendancyWatcher.checkSpell(spell, source, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,6 +147,7 @@ class MaestrosAscendancyWatcher extends Watcher {
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.SPELL_CAST
|
if (event.getType() == GameEvent.EventType.SPELL_CAST
|
||||||
|
&& event.hasApprovingIdentifier(MageIdentifier.MaestrosAscendencyAlternateCast)
|
||||||
&& event.getAdditionalReference() != null) {
|
&& event.getAdditionalReference() != null) {
|
||||||
playerMap.computeIfAbsent(
|
playerMap.computeIfAbsent(
|
||||||
event.getAdditionalReference()
|
event.getAdditionalReference()
|
||||||
|
|
@ -172,16 +174,16 @@ class MaestrosAscendancyWatcher extends Watcher {
|
||||||
.getState()
|
.getState()
|
||||||
.getWatcher(MaestrosAscendancyWatcher.class)
|
.getWatcher(MaestrosAscendancyWatcher.class)
|
||||||
.playerMap
|
.playerMap
|
||||||
.getOrDefault(new MageObjectReference(source), Collections.emptySet())
|
.getOrDefault(new MageObjectReference(source.getSourcePermanentIfItStillExists(game), game), Collections.emptySet())
|
||||||
.contains(source.getControllerId());
|
.contains(source.getControllerId());
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean checkSpell(UUID id, Ability source, Game game) {
|
static boolean checkSpell(Spell spell, Ability source, Game game) {
|
||||||
return game
|
return game
|
||||||
.getState()
|
.getState()
|
||||||
.getWatcher(MaestrosAscendancyWatcher.class)
|
.getWatcher(MaestrosAscendancyWatcher.class)
|
||||||
.spellMap
|
.spellMap
|
||||||
.getOrDefault(new MageObjectReference(source), Collections.emptySet())
|
.getOrDefault(new MageObjectReference(source.getSourcePermanentOrLKI(game), game), Collections.emptySet())
|
||||||
.contains(new MageObjectReference(id, game));
|
.contains(new MageObjectReference(spell, game));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,10 +57,12 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
|
||||||
this.zoneChangeCounter = -1;
|
this.zoneChangeCounter = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated // cause of many bugs, see issue #10479
|
||||||
public MageObjectReference(Ability source) {
|
public MageObjectReference(Ability source) {
|
||||||
this(source, 0);
|
this(source, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated // cause of many bugs, see issue #10479
|
||||||
public MageObjectReference(Ability source, int modifier) {
|
public MageObjectReference(Ability source, int modifier) {
|
||||||
this.sourceId = source.getSourceId();
|
this.sourceId = source.getSourceId();
|
||||||
this.zoneChangeCounter = source.getSourceObjectZoneChangeCounter() + modifier;
|
this.zoneChangeCounter = source.getSourceObjectZoneChangeCounter() + modifier;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue