This commit is contained in:
Jeff 2019-02-07 17:09:51 -06:00
parent faf9b96a54
commit 1092552425

View file

@ -65,7 +65,11 @@ class ThousandYearStormEffect extends OneShotEffect {
if (spell != null) { if (spell != null) {
ThousandYearWatcher watcher = game.getState().getWatcher(ThousandYearWatcher.class); ThousandYearWatcher watcher = game.getState().getWatcher(ThousandYearWatcher.class);
if (watcher != null) { if (watcher != null) {
int numberOfCopies = watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) - 1; // recall only the spells cast before it
int numberOfCopies = 0;
if (game.getState().getValue(spell.getId().toString()) != null) {
numberOfCopies = (int) game.getState().getValue(spell.getId().toString()) - 1;
}
if (numberOfCopies > 0) { if (numberOfCopies > 0) {
for (int i = 0; i < numberOfCopies; i++) { for (int i = 0; i < numberOfCopies; i++) {
spell.createCopyOnStack(game, source, source.getControllerId(), true); spell.createCopyOnStack(game, source, source.getControllerId(), true);
@ -95,13 +99,19 @@ class ThousandYearWatcher 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
&& !game.getStack().contains(game.getSpell(sourceId))) {
Spell spell = game.getSpellOrLKIStack(event.getTargetId()); Spell spell = game.getSpellOrLKIStack(event.getTargetId());
if (spell != null && spell.isInstantOrSorcery()) { if (spell != null
&& spell.isInstantOrSorcery()) {
UUID playerId = event.getPlayerId(); UUID playerId = event.getPlayerId();
if (playerId != null) { if (playerId != null) {
amountOfInstantSorcerySpellsCastOnCurrentTurn.putIfAbsent(playerId, 0); amountOfInstantSorcerySpellsCastOnCurrentTurn.putIfAbsent(playerId, 0);
amountOfInstantSorcerySpellsCastOnCurrentTurn.compute(playerId, (k, a) -> a + 1); amountOfInstantSorcerySpellsCastOnCurrentTurn.compute(playerId, (k, a) -> a + 1);
// remember only the spells cast before it
game.getState().setValue(spell.getId().toString(), amountOfInstantSorcerySpellsCastOnCurrentTurn.get(playerId));
} }
} }
} }