mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
Awesome bug fix (3h of debuging): 1. ReboundEffect was copied by Ascension. 2. Copied spells moved original spell to grave that caused later wrong changeZone event with from=GRAVEYARD to=GRAVEYARD instead of from=STACK to=GRAVEYARD.
This commit is contained in:
parent
e1aa3c0587
commit
267ae4f559
3 changed files with 33 additions and 10 deletions
|
|
@ -55,6 +55,7 @@ public class CopyTargetSpellEffect extends OneShotEffect<CopyTargetSpellEffect>
|
|||
if (spell != null) {
|
||||
Spell copy = spell.copySpell();
|
||||
copy.setControllerId(source.getControllerId());
|
||||
copy.setCopiedSpell(true);
|
||||
game.getStack().push(copy);
|
||||
copy.chooseNewTargets(game);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import mage.game.events.GameEvent.EventType;
|
|||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* This ability has no effect by default and will always return false on the call
|
||||
|
|
@ -103,7 +104,7 @@ public class ReboundAbility extends TriggeredAbilityImpl<ReboundAbility> {
|
|||
if ( event.getType() == EventType.SPELL_CAST && this.installReboundEffect ) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (spell != null && spell.getSourceId().equals(this.getSourceId())) {
|
||||
spell.getSpellAbility().addEffect(new ReboundEffect());
|
||||
spell.getSpellAbility().addEffect(new ReboundEffect(spell.getId()));
|
||||
this.installReboundEffect = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -131,16 +132,27 @@ public class ReboundAbility extends TriggeredAbilityImpl<ReboundAbility> {
|
|||
*/
|
||||
class ReboundEffect extends OneShotEffect<ReboundEffect> {
|
||||
|
||||
public ReboundEffect ( ) {
|
||||
private Logger log = Logger.getLogger(ReboundEffect.class);
|
||||
|
||||
private UUID originalId;
|
||||
|
||||
public ReboundEffect(UUID originalId) {
|
||||
super(Outcome.Benefit);
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
public ReboundEffect ( ReboundEffect effect ) {
|
||||
super(effect);
|
||||
this.originalId = effect.originalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (!originalId.equals(source.getId())) {
|
||||
log.warn("rebound was ignored. was it copied spell?");
|
||||
return false;
|
||||
}
|
||||
|
||||
Card sourceCard = (Card)game.getObject(source.getSourceId());
|
||||
ReboundEffectCastFromExileDelayedTrigger trigger = new ReboundEffectCastFromExileDelayedTrigger(sourceCard.getId(), sourceCard.getId());
|
||||
trigger.setControllerId(source.getControllerId());
|
||||
|
|
@ -276,6 +288,7 @@ class ReboundCastSpellFromExileEffect extends OneShotEffect<ReboundCastSpellFrom
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ExileZone zone = game.getExile().getExileZone(this.cardId);
|
||||
if (zone == null || zone.isEmpty()) return false;
|
||||
Card reboundCard = zone.get(this.cardId, game);
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
SpellAbility ability = reboundCard.getSpellAbility();
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
private Card card;
|
||||
private SpellAbility ability;
|
||||
private UUID controllerId;
|
||||
private boolean copiedSpell;
|
||||
|
||||
public Spell(Card card, SpellAbility ability, UUID controllerId) {
|
||||
this.card = card;
|
||||
|
|
@ -85,14 +86,18 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
else
|
||||
result = true;
|
||||
|
||||
if (ability.getEffects().contains(ExileSpellEffect.getInstance()))
|
||||
game.getExile().getPermanentExile().add(card);
|
||||
else if (ability.getEffects().contains(ShuffleSpellEffect.getInstance())) {
|
||||
card.moveToZone(Zone.LIBRARY, ability.getId(), game, false);
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null) player.shuffleLibrary(game);
|
||||
} else
|
||||
card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false);
|
||||
if (!copiedSpell) {
|
||||
if (ability.getEffects().contains(ExileSpellEffect.getInstance()))
|
||||
game.getExile().getPermanentExile().add(card);
|
||||
else if (ability.getEffects().contains(ShuffleSpellEffect.getInstance())) {
|
||||
card.moveToZone(Zone.LIBRARY, ability.getId(), game, false);
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null) player.shuffleLibrary(game);
|
||||
} else {
|
||||
card.moveToZone(Zone.GRAVEYARD, ability.getId(), game, false);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
//20091005 - 608.2b
|
||||
|
|
@ -344,5 +349,9 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
public void assignNewId() {
|
||||
throw new UnsupportedOperationException("Unsupported operation");
|
||||
}
|
||||
|
||||
public void setCopiedSpell(boolean isCopied) {
|
||||
this.copiedSpell = isCopied;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue