Refactor: replaced sourceId by source and introduced source param in some methods;

This commit is contained in:
Oleg Agafonov 2020-12-12 20:23:19 +04:00
parent 2bb472607b
commit db239a1055
3205 changed files with 7080 additions and 6795 deletions

View file

@ -6,6 +6,7 @@ import mage.constants.TurnPhase;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.PhaseChangedEvent;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
@ -121,14 +122,14 @@ public class Turn implements Serializable {
}
if (!isEndTurnRequested() || phase.getType() == TurnPhase.END) {
currentPhase = phase;
game.fireEvent(new GameEvent(GameEvent.EventType.PHASE_CHANGED, activePlayer.getId(), null, activePlayer.getId()));
game.fireEvent(new PhaseChangedEvent(activePlayer.getId(), null));
if (!game.getState().getTurnMods().skipPhase(activePlayer.getId(), currentPhase.getType())) {
if (phase.play(game, activePlayer.getId())) {
if (game.executingRollback()) {
return false;
}
//20091005 - 500.4/703.4n
game.emptyManaPools();
game.emptyManaPools(null);
game.saveState(false);
//20091005 - 500.8
@ -155,7 +156,7 @@ public class Turn implements Serializable {
} while (phase.type != phaseType);
if (phase.resumePlay(game, stepType, wasPaused)) {
//20091005 - 500.4/703.4n
game.emptyManaPools();
game.emptyManaPools(null);
//game.saveState();
//20091005 - 500.8
playExtraPhases(game, phase.getType());
@ -169,14 +170,14 @@ public class Turn implements Serializable {
if (!game.getState().getTurnMods().skipPhase(activePlayerId, currentPhase.getType())) {
if (phase.play(game, activePlayerId)) {
//20091005 - 500.4/703.4n
game.emptyManaPools();
game.emptyManaPools(null);
//game.saveState();
//20091005 - 500.8
playExtraPhases(game, phase.getType());
}
}
if (!currentPhase.equals(phase)) { // phase was changed from the card
game.fireEvent(new GameEvent(GameEvent.EventType.PHASE_CHANGED, activePlayerId, null, activePlayerId));
game.fireEvent(new PhaseChangedEvent(activePlayerId, null));
break;
}
}
@ -223,7 +224,7 @@ public class Turn implements Serializable {
phase = new EndPhase();
}
currentPhase = phase;
game.fireEvent(new GameEvent(GameEvent.EventType.PHASE_CHANGED, activePlayerId, extraPhaseTurnMod.getId(), activePlayerId));
game.fireEvent(new PhaseChangedEvent(activePlayerId, extraPhaseTurnMod));
Player activePlayer = game.getPlayer(activePlayerId);
if (activePlayer != null && !game.isSimulation()) {
game.informPlayers(activePlayer.getLogName() + " starts an additional " + phase.getType().toString() + " phase");
@ -256,7 +257,7 @@ public class Turn implements Serializable {
while (!game.hasEnded() && !game.getStack().isEmpty()) {
StackObject stackObject = game.getStack().peekFirst();
if (stackObject instanceof Spell) {
((Spell) stackObject).moveToExile(null, "", source.getSourceId(), game);
((Spell) stackObject).moveToExile(null, "", source, game);
} else {
game.getStack().remove(stackObject, game); // stack ability
}