mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
* Storm - Fixed a bug that the number of copies for storm were calculated wrong if a card was cast multiple times in one turn (e.g. by Yawgmoth's Will).
This commit is contained in:
parent
10657683af
commit
794c7c7d49
2 changed files with 15 additions and 10 deletions
|
@ -102,12 +102,16 @@ class StormEffect extends OneShotEffect {
|
|||
if (spell != null) {
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
|
||||
|
||||
for (int i = 0; i < watcher.getSpellOrder(spell) - 1; i++) {
|
||||
Spell copy = spell.copySpell();
|
||||
copy.setControllerId(source.getControllerId());
|
||||
copy.setCopiedSpell(true);
|
||||
game.getStack().push(copy);
|
||||
copy.chooseNewTargets(game, source.getControllerId());
|
||||
int stormCount = watcher.getSpellOrder(spell) - 1;
|
||||
if (stormCount > 0) {
|
||||
game.informPlayers("Storm: " + spell.getName() + " will be copied " + stormCount + " time" + (stormCount > 1 ?"s":""));
|
||||
for (int i = 0; i < stormCount; i++) {
|
||||
Spell copy = spell.copySpell();
|
||||
copy.setControllerId(source.getControllerId());
|
||||
copy.setCopiedSpell(true);
|
||||
game.getStack().push(copy);
|
||||
copy.chooseNewTargets(game, source.getControllerId());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -48,7 +49,7 @@ public class CastSpellLastTurnWatcher extends Watcher {
|
|||
|
||||
private final Map<UUID, Integer> amountOfSpellsCastOnPrevTurn = new HashMap<>();
|
||||
private final Map<UUID, Integer> amountOfSpellsCastOnCurrentTurn = new HashMap<>();
|
||||
private final List<UUID> spellsCastThisTurnInOrder = new ArrayList<>();
|
||||
private final List<MageObjectReference> spellsCastThisTurnInOrder = new ArrayList<>();
|
||||
|
||||
public CastSpellLastTurnWatcher() {
|
||||
super("CastSpellLastTurnWatcher", WatcherScope.GAME);
|
||||
|
@ -67,7 +68,7 @@ public class CastSpellLastTurnWatcher extends Watcher {
|
|||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||
spellsCastThisTurnInOrder.add(event.getTargetId());
|
||||
spellsCastThisTurnInOrder.add(new MageObjectReference(event.getSourceId(), game));
|
||||
UUID playerId = event.getPlayerId();
|
||||
if (playerId != null) {
|
||||
Integer amount = amountOfSpellsCastOnCurrentTurn.get(playerId);
|
||||
|
@ -116,9 +117,9 @@ public class CastSpellLastTurnWatcher extends Watcher {
|
|||
|
||||
public int getSpellOrder(Spell spell) {
|
||||
int index = 0;
|
||||
for (UUID uuid : spellsCastThisTurnInOrder) {
|
||||
for (MageObjectReference mor : spellsCastThisTurnInOrder) {
|
||||
index++;
|
||||
if (spell.getId().equals(uuid)) {
|
||||
if (mor.refersTo(spell)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue