mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
[Mobile] add Experimental Rollback Phase
This commit is contained in:
@@ -39,6 +39,7 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
|
||||
private boolean processEventsQueued, needPhaseUpdate, needCombatUpdate, needStackUpdate, needPlayerControlUpdate, refreshFieldUpdate;
|
||||
private boolean gameOver, gameFinished;
|
||||
private boolean needSaveState = false;
|
||||
private PlayerView turnUpdate;
|
||||
|
||||
public FControlGameEventHandler(final PlayerControllerHuman humanController0) {
|
||||
@@ -81,7 +82,12 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
}
|
||||
if (needPhaseUpdate) {
|
||||
needPhaseUpdate = false;
|
||||
matchController.updatePhase();
|
||||
if (needSaveState) {
|
||||
needSaveState = false;
|
||||
matchController.updatePhase(true);
|
||||
} else {
|
||||
matchController.updatePhase(false);
|
||||
}
|
||||
}
|
||||
if (needCombatUpdate) {
|
||||
needCombatUpdate = false;
|
||||
@@ -173,6 +179,10 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
@Override
|
||||
public Void visit(final GameEventTurnPhase ev) {
|
||||
needPhaseUpdate = true;
|
||||
if (ev.phaseDesc == "dev")
|
||||
needSaveState = false;
|
||||
else
|
||||
needSaveState = true;
|
||||
return processEvent();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ public interface IDevModeCheats {
|
||||
|
||||
void generateMana();
|
||||
|
||||
void rollbackPhase();
|
||||
|
||||
void dumpGameState();
|
||||
|
||||
void setupGameState();
|
||||
@@ -95,6 +97,11 @@ public interface IDevModeCheats {
|
||||
@Override
|
||||
public void generateMana() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollbackPhase() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpGameState() {
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Map;
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.ai.GameState;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.CardPool;
|
||||
import forge.game.GameEntityView;
|
||||
@@ -42,7 +43,7 @@ public interface IGuiGame {
|
||||
void updateButtons(PlayerView owner, String label1, String label2, boolean enable1, boolean enable2, boolean focus1);
|
||||
void flashIncorrectAction();
|
||||
void alertUser();
|
||||
void updatePhase();
|
||||
void updatePhase(boolean saveState);
|
||||
void updateTurn(PlayerView player);
|
||||
void updatePlayerControl();
|
||||
void enableOverlay();
|
||||
@@ -61,6 +62,7 @@ public interface IGuiGame {
|
||||
void updateCards(Iterable<CardView> cards);
|
||||
void refreshCardDetails(Iterable<CardView> cards);
|
||||
void refreshField();
|
||||
GameState getGamestate();
|
||||
void updateManaPool(Iterable<PlayerView> manaPoolUpdate);
|
||||
void updateLives(Iterable<PlayerView> livesUpdate);
|
||||
void setPanelSelection(CardView hostCard);
|
||||
|
||||
@@ -418,7 +418,7 @@ public class HostedMatch {
|
||||
gui.openView(new TrackableCollection<>(p.getView()));
|
||||
gui.setGameView(null);
|
||||
gui.setGameView(gameView);
|
||||
gui.updatePhase();
|
||||
gui.updatePhase(true);
|
||||
gui.message(event.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.net.server;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.ai.GameState;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.CardPool;
|
||||
import forge.game.GameEntityView;
|
||||
@@ -93,7 +94,7 @@ public class NetGuiGame extends AbstractGuiGame {
|
||||
public void alertUser() { send(ProtocolMethod.alertUser); }
|
||||
|
||||
@Override
|
||||
public void updatePhase() {
|
||||
public void updatePhase(boolean saveState) {
|
||||
updateGameView();
|
||||
send(ProtocolMethod.updatePhase);
|
||||
}
|
||||
@@ -189,6 +190,11 @@ public class NetGuiGame extends AbstractGuiGame {
|
||||
send(ProtocolMethod.refreshField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameState getGamestate() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbilityView getAbilityToPlay(final CardView hostCard, final List<SpellAbilityView> abilities, final ITriggerEvent triggerEvent) {
|
||||
return sendAndWait(ProtocolMethod.getAbilityToPlay, hostCard, abilities, null/*triggerEvent*/); //someplatform don't have mousetriggerevent class or it will not allow them to click/tap
|
||||
|
||||
@@ -2140,6 +2140,17 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollbackPhase() {
|
||||
final Player pPriority = getGame().getPhaseHandler().getPriorityPlayer();
|
||||
if (pPriority == null) {
|
||||
getGui().message(localizer.getMessage("lblNoPlayerPriorityGameStateCannotBeSetup"));
|
||||
return;
|
||||
}
|
||||
if (getGui().getGamestate() != null)
|
||||
getGui().getGamestate().applyToGame(getGame());
|
||||
}
|
||||
|
||||
private GameState createGameStateObject() {
|
||||
return new GameState() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user