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:
@@ -1153,7 +1153,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
turn = cturn;
|
turn = cturn;
|
||||||
|
|
||||||
game.fireEvent(new GameEventTurnPhase(playerTurn, phase, ""));
|
game.fireEvent(new GameEventTurnPhase(playerTurn, phase, "dev"));
|
||||||
if (endCombat) {
|
if (endCombat) {
|
||||||
endCombat(); // not-null can be created only when declare attackers phase begins
|
endCombat(); // not-null can be created only when declare attackers phase begins
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import forge.ImageCache;
|
|||||||
import forge.LobbyPlayer;
|
import forge.LobbyPlayer;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.StaticData;
|
import forge.StaticData;
|
||||||
|
import forge.ai.GameState;
|
||||||
import forge.assets.FSkinProp;
|
import forge.assets.FSkinProp;
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
import forge.control.KeyboardShortcuts;
|
import forge.control.KeyboardShortcuts;
|
||||||
@@ -620,6 +621,11 @@ public final class CMatchUI
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameState getGamestate() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<JMenu> getMenus() {
|
public List<JMenu> getMenus() {
|
||||||
return menus.getMenus();
|
return menus.getMenus();
|
||||||
@@ -771,7 +777,7 @@ public final class CMatchUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePhase() {
|
public void updatePhase(boolean saveState) {
|
||||||
final PlayerView p = getGameView().getPlayerTurn();
|
final PlayerView p = getGameView().getPlayerTurn();
|
||||||
final PhaseType ph = getGameView().getPhase();
|
final PhaseType ph = getGameView().getPhase();
|
||||||
// this should never happen, but I've seen it periodically... so, need to get to the bottom of it
|
// this should never happen, but I've seen it periodically... so, need to get to the bottom of it
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
|
import forge.ai.GameState;
|
||||||
import forge.assets.FSkinImage;
|
import forge.assets.FSkinImage;
|
||||||
|
import forge.item.IPaperCard;
|
||||||
import forge.util.Localizer;
|
import forge.util.Localizer;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -71,6 +73,11 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
|
|
||||||
private static HostedMatch hostedMatch;
|
private static HostedMatch hostedMatch;
|
||||||
private static MatchScreen view;
|
private static MatchScreen view;
|
||||||
|
private static GameState phaseGameState;
|
||||||
|
|
||||||
|
private GameState getPhaseGameState() {
|
||||||
|
return phaseGameState;
|
||||||
|
}
|
||||||
|
|
||||||
private final Map<PlayerView, InfoTab> zonesToRestore = Maps.newHashMap();
|
private final Map<PlayerView, InfoTab> zonesToRestore = Maps.newHashMap();
|
||||||
|
|
||||||
@@ -122,6 +129,11 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
refreshCardDetails(null);
|
refreshCardDetails(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameState getGamestate() {
|
||||||
|
return getPhaseGameState();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hotSeatMode() {
|
public boolean hotSeatMode() {
|
||||||
return FModel.getPreferences().getPrefBoolean(FPref.MATCH_HOT_SEAT_MODE);
|
return FModel.getPreferences().getPrefBoolean(FPref.MATCH_HOT_SEAT_MODE);
|
||||||
}
|
}
|
||||||
@@ -199,7 +211,7 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePhase() {
|
public void updatePhase(boolean saveState) {
|
||||||
final PlayerView p = getGameView().getPlayerTurn();
|
final PlayerView p = getGameView().getPlayerTurn();
|
||||||
final PhaseType ph = getGameView().getPhase();
|
final PhaseType ph = getGameView().getPhase();
|
||||||
|
|
||||||
@@ -217,6 +229,20 @@ public class MatchController extends AbstractGuiGame {
|
|||||||
}
|
}
|
||||||
if(GuiBase.isNetworkplay())
|
if(GuiBase.isNetworkplay())
|
||||||
checkStack();
|
checkStack();
|
||||||
|
|
||||||
|
if (saveState) {
|
||||||
|
phaseGameState = new GameState() {
|
||||||
|
@Override //todo get specific card edition for this function?
|
||||||
|
public IPaperCard getPaperCard(final String cardName) {
|
||||||
|
return FModel.getMagicDb().getCommonCards().getCard(cardName);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
phaseGameState.initFromGame(getGameView().getGame());
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(phaseGameState);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -378,6 +378,9 @@ public class MatchScreen extends FScreen {
|
|||||||
devMenu.setEnabled(true);
|
devMenu.setEnabled(true);
|
||||||
else
|
else
|
||||||
devMenu.setEnabled(false);
|
devMenu.setEnabled(false);
|
||||||
|
|
||||||
|
//rollbackphase enable -- todo limit by gametype?
|
||||||
|
devMenu.getChildAt(2).setEnabled(game.getPlayers().size() == 2 && game.getStack().size() == 0 && !GuiBase.isNetworkplay());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,17 @@ public class VDevMenu extends FDropDownMenu {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
addItem(new FMenuItem(Localizer.getInstance().getMessage("lblRollbackPhase"), new FEventHandler() {
|
||||||
|
@Override
|
||||||
|
public void handleEvent(FEvent e) {
|
||||||
|
ThreadUtil.invokeInGameThread(new Runnable() { //must invoke all these in game thread since they may require synchronous user input
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MatchController.instance.getGameController().cheat().rollbackPhase();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}));
|
||||||
addItem(new FMenuItem(Localizer.getInstance().getMessage("lblCastSpellOrPlayLand"), new FEventHandler() {
|
addItem(new FMenuItem(Localizer.getInstance().getMessage("lblCastSpellOrPlayLand"), new FEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handleEvent(FEvent e) {
|
public void handleEvent(FEvent e) {
|
||||||
|
|||||||
@@ -1947,6 +1947,7 @@ lblViewAll=Zeige alle Karten
|
|||||||
lblSetupGame=Spielstand erstellen
|
lblSetupGame=Spielstand erstellen
|
||||||
lblDumpGame=Spielstand sichern
|
lblDumpGame=Spielstand sichern
|
||||||
lblTutor=Suche nach Karte
|
lblTutor=Suche nach Karte
|
||||||
|
lblRollbackPhase=Rollback Phase
|
||||||
lblAddCounterPermanent=Marken zu Karte hinzufügen
|
lblAddCounterPermanent=Marken zu Karte hinzufügen
|
||||||
lblSubCounterPermanent=Marken von Karte entfernen
|
lblSubCounterPermanent=Marken von Karte entfernen
|
||||||
lblTapPermanent=Bleibende Karte tappen
|
lblTapPermanent=Bleibende Karte tappen
|
||||||
|
|||||||
@@ -1947,6 +1947,7 @@ lblViewAll=View All Cards
|
|||||||
lblSetupGame=Setup Game State
|
lblSetupGame=Setup Game State
|
||||||
lblDumpGame=Dump Game State
|
lblDumpGame=Dump Game State
|
||||||
lblTutor=Tutor for Card
|
lblTutor=Tutor for Card
|
||||||
|
lblRollbackPhase=Rollback Phase
|
||||||
lblAddCounterPermanent=Add Counters to Card
|
lblAddCounterPermanent=Add Counters to Card
|
||||||
lblSubCounterPermanent=Sub Counters from Card
|
lblSubCounterPermanent=Sub Counters from Card
|
||||||
lblTapPermanent=Tap Permanents
|
lblTapPermanent=Tap Permanents
|
||||||
|
|||||||
@@ -1947,6 +1947,7 @@ lblViewAll=Ver todas las cartas
|
|||||||
lblSetupGame=Configurar el estado del juego
|
lblSetupGame=Configurar el estado del juego
|
||||||
lblDumpGame=Volcar el estado del juego
|
lblDumpGame=Volcar el estado del juego
|
||||||
lblTutor=Tutor para la carta
|
lblTutor=Tutor para la carta
|
||||||
|
lblRollbackPhase=Rollback Phase
|
||||||
lblAddCounterPermanent=Añadir contadores a la carta
|
lblAddCounterPermanent=Añadir contadores a la carta
|
||||||
lblSubCounterPermanent=Quitar contadores a la carta
|
lblSubCounterPermanent=Quitar contadores a la carta
|
||||||
lblTapPermanent=Girar permanentes
|
lblTapPermanent=Girar permanentes
|
||||||
|
|||||||
@@ -1947,6 +1947,7 @@ lblViewAll=View All Cards
|
|||||||
lblSetupGame=Setup Game State
|
lblSetupGame=Setup Game State
|
||||||
lblDumpGame=Dump Game State
|
lblDumpGame=Dump Game State
|
||||||
lblTutor=Tutor for Card
|
lblTutor=Tutor for Card
|
||||||
|
lblRollbackPhase=Rollback Phase
|
||||||
lblAddCounterPermanent=Add Counters to Card
|
lblAddCounterPermanent=Add Counters to Card
|
||||||
lblSubCounterPermanent=Sub Counters from Card
|
lblSubCounterPermanent=Sub Counters from Card
|
||||||
lblTapPermanent=Tap Permanents
|
lblTapPermanent=Tap Permanents
|
||||||
|
|||||||
@@ -1947,6 +1947,7 @@ lblViewAll=View All Cards
|
|||||||
lblSetupGame=Setup Game State
|
lblSetupGame=Setup Game State
|
||||||
lblDumpGame=Dump Game State
|
lblDumpGame=Dump Game State
|
||||||
lblTutor=Tutor for Card
|
lblTutor=Tutor for Card
|
||||||
|
lblRollbackPhase=Rollback Phase
|
||||||
lblAddCounterPermanent=Add Counters to Card
|
lblAddCounterPermanent=Add Counters to Card
|
||||||
lblSubCounterPermanent=Sub Counters from Card
|
lblSubCounterPermanent=Sub Counters from Card
|
||||||
lblTapPermanent=Tap Permanents
|
lblTapPermanent=Tap Permanents
|
||||||
|
|||||||
@@ -1947,6 +1947,7 @@ lblViewAll=查看所有牌
|
|||||||
lblSetupGame=设定游戏状态
|
lblSetupGame=设定游戏状态
|
||||||
lblDumpGame=转储游戏状态
|
lblDumpGame=转储游戏状态
|
||||||
lblTutor=导师牌
|
lblTutor=导师牌
|
||||||
|
lblRollbackPhase=Rollback Phase
|
||||||
lblAddCounterPermanent=向牌添加指示物
|
lblAddCounterPermanent=向牌添加指示物
|
||||||
lblSubCounterPermanent=从牌减少指示物
|
lblSubCounterPermanent=从牌减少指示物
|
||||||
lblTapPermanent=横置永久物
|
lblTapPermanent=横置永久物
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
|||||||
|
|
||||||
private boolean processEventsQueued, needPhaseUpdate, needCombatUpdate, needStackUpdate, needPlayerControlUpdate, refreshFieldUpdate;
|
private boolean processEventsQueued, needPhaseUpdate, needCombatUpdate, needStackUpdate, needPlayerControlUpdate, refreshFieldUpdate;
|
||||||
private boolean gameOver, gameFinished;
|
private boolean gameOver, gameFinished;
|
||||||
|
private boolean needSaveState = false;
|
||||||
private PlayerView turnUpdate;
|
private PlayerView turnUpdate;
|
||||||
|
|
||||||
public FControlGameEventHandler(final PlayerControllerHuman humanController0) {
|
public FControlGameEventHandler(final PlayerControllerHuman humanController0) {
|
||||||
@@ -81,7 +82,12 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
|||||||
}
|
}
|
||||||
if (needPhaseUpdate) {
|
if (needPhaseUpdate) {
|
||||||
needPhaseUpdate = false;
|
needPhaseUpdate = false;
|
||||||
matchController.updatePhase();
|
if (needSaveState) {
|
||||||
|
needSaveState = false;
|
||||||
|
matchController.updatePhase(true);
|
||||||
|
} else {
|
||||||
|
matchController.updatePhase(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (needCombatUpdate) {
|
if (needCombatUpdate) {
|
||||||
needCombatUpdate = false;
|
needCombatUpdate = false;
|
||||||
@@ -173,6 +179,10 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
|||||||
@Override
|
@Override
|
||||||
public Void visit(final GameEventTurnPhase ev) {
|
public Void visit(final GameEventTurnPhase ev) {
|
||||||
needPhaseUpdate = true;
|
needPhaseUpdate = true;
|
||||||
|
if (ev.phaseDesc == "dev")
|
||||||
|
needSaveState = false;
|
||||||
|
else
|
||||||
|
needSaveState = true;
|
||||||
return processEvent();
|
return processEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ public interface IDevModeCheats {
|
|||||||
|
|
||||||
void generateMana();
|
void generateMana();
|
||||||
|
|
||||||
|
void rollbackPhase();
|
||||||
|
|
||||||
void dumpGameState();
|
void dumpGameState();
|
||||||
|
|
||||||
void setupGameState();
|
void setupGameState();
|
||||||
@@ -95,6 +97,11 @@ public interface IDevModeCheats {
|
|||||||
@Override
|
@Override
|
||||||
public void generateMana() {
|
public void generateMana() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rollbackPhase() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dumpGameState() {
|
public void dumpGameState() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.Map;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
import forge.LobbyPlayer;
|
import forge.LobbyPlayer;
|
||||||
|
import forge.ai.GameState;
|
||||||
import forge.assets.FSkinProp;
|
import forge.assets.FSkinProp;
|
||||||
import forge.deck.CardPool;
|
import forge.deck.CardPool;
|
||||||
import forge.game.GameEntityView;
|
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 updateButtons(PlayerView owner, String label1, String label2, boolean enable1, boolean enable2, boolean focus1);
|
||||||
void flashIncorrectAction();
|
void flashIncorrectAction();
|
||||||
void alertUser();
|
void alertUser();
|
||||||
void updatePhase();
|
void updatePhase(boolean saveState);
|
||||||
void updateTurn(PlayerView player);
|
void updateTurn(PlayerView player);
|
||||||
void updatePlayerControl();
|
void updatePlayerControl();
|
||||||
void enableOverlay();
|
void enableOverlay();
|
||||||
@@ -61,6 +62,7 @@ public interface IGuiGame {
|
|||||||
void updateCards(Iterable<CardView> cards);
|
void updateCards(Iterable<CardView> cards);
|
||||||
void refreshCardDetails(Iterable<CardView> cards);
|
void refreshCardDetails(Iterable<CardView> cards);
|
||||||
void refreshField();
|
void refreshField();
|
||||||
|
GameState getGamestate();
|
||||||
void updateManaPool(Iterable<PlayerView> manaPoolUpdate);
|
void updateManaPool(Iterable<PlayerView> manaPoolUpdate);
|
||||||
void updateLives(Iterable<PlayerView> livesUpdate);
|
void updateLives(Iterable<PlayerView> livesUpdate);
|
||||||
void setPanelSelection(CardView hostCard);
|
void setPanelSelection(CardView hostCard);
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ public class HostedMatch {
|
|||||||
gui.openView(new TrackableCollection<>(p.getView()));
|
gui.openView(new TrackableCollection<>(p.getView()));
|
||||||
gui.setGameView(null);
|
gui.setGameView(null);
|
||||||
gui.setGameView(gameView);
|
gui.setGameView(gameView);
|
||||||
gui.updatePhase();
|
gui.updatePhase(true);
|
||||||
gui.message(event.message);
|
gui.message(event.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.net.server;
|
|||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import forge.LobbyPlayer;
|
import forge.LobbyPlayer;
|
||||||
|
import forge.ai.GameState;
|
||||||
import forge.assets.FSkinProp;
|
import forge.assets.FSkinProp;
|
||||||
import forge.deck.CardPool;
|
import forge.deck.CardPool;
|
||||||
import forge.game.GameEntityView;
|
import forge.game.GameEntityView;
|
||||||
@@ -93,7 +94,7 @@ public class NetGuiGame extends AbstractGuiGame {
|
|||||||
public void alertUser() { send(ProtocolMethod.alertUser); }
|
public void alertUser() { send(ProtocolMethod.alertUser); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePhase() {
|
public void updatePhase(boolean saveState) {
|
||||||
updateGameView();
|
updateGameView();
|
||||||
send(ProtocolMethod.updatePhase);
|
send(ProtocolMethod.updatePhase);
|
||||||
}
|
}
|
||||||
@@ -189,6 +190,11 @@ public class NetGuiGame extends AbstractGuiGame {
|
|||||||
send(ProtocolMethod.refreshField);
|
send(ProtocolMethod.refreshField);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameState getGamestate() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SpellAbilityView getAbilityToPlay(final CardView hostCard, final List<SpellAbilityView> abilities, final ITriggerEvent triggerEvent) {
|
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
|
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() {
|
private GameState createGameStateObject() {
|
||||||
return new GameState() {
|
return new GameState() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user