New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Back button on place units phase #1025
Comments
Thanks @simon33-2 - this is perfect. |
Yes this is messy, but I think I got what you wanted to achieve with this.
|
Sorry if I misunderstood something. If you still happen to have any questions feel free to ask. |
Thanks Roi. I can't use Gitkraken on my laptop because it's 32 bit although I'll put it on my desktop. I've got the general idea now, which is to create a private repo (fork) and change that. What happens if someone else has a change merged, does the my private repo get updated so that I can update my checkout with "svn update"? |
@simon33-2 no, your fork is completely independent. I'd recommend to create a new branch based of the triplea-game/master (not your forks master) for every feature you want to implement and delete it after it's merged. |
I can use the gui on one computer but I'm having some trouble getting it to work. If I put my fork in the remote it doesn't accept it. I think the problem with this change is that it seems I checked the code out from sourceforge. Perhaps this project used to live there. I'm reapplying the changes now. Nearly done but it will still need a bit of testing. There must be something I'm missing. The idea of svn is that others can make changes and they are automatically merged in, unless the same lines are changed by both people with fingers then crossed. Perhaps github breaks all this but it would seem to be a retrograde step. Or the problem is that I can't commit to the master :) |
source tree is another nice GUI app for git. https://github.com/ndbroadbent/scm_breeze is a nice tool for command line enhancements.
Git actually makes this relatively easy, it's far smarter about resolving conflicts. Conflicts still do happen. The thing to keep in mind is that in Git every branch is a first class citizen. You actually have 3 key branches to worry about. The master in triplea-games, often called upstream, the master in your fork, often called origin, and then finally the master on your local dev machine. You can tell git to pull in changes from any branch to any other branch. This will for example update my local branch to be replayed on top of upstream's master: This would then push a branch called master to my origin: It is recommended you create a new branch for each project. |
Hi @DanVanAtta There's still one more thing I don't know how to do. Looks like I need to create a Serialization Version ID. "warning: [serial] serializable class <anonymous games.strategy.triplea.ui.AbstractMovePanel$2> has no definition of serialVersionUID" How do I do that - just make up a number, search all the source and make sure it's unique or is there a better/proper way? |
Usually that can be autogenerated by your IDE, example: https://www.mkyong.com/java/how-to-generate-serialversionuid/ |
This can be closed right? |
Well, the PR hasn't been logged. There's a couple of more important things around and I've realised that someone, somewhere will no doubt say that we don't want to use that. I need to add something to "Game Options". But I guess the added value of keeping it open can be argued is negligible. |
I dont' see the value in closing this as it has not been done. The code sample is a good starting point for anyone wanting to pick this feature up. I believe there is agreement that this should be done, help solve the debates of whether you can go back and edit stuff you forgot in the non-combat phase. IMO knowing that you can go back will make the game go faster, less need to double/triple check the map before hitting the done button. |
Backlogging. https://github.com/triplea-game/triplea/wiki/Feature-Back-Log/ |
I don't think it is as important now that you can reload the NonCombatMove autosave. |
The nuance is perhaps about strict edit vs non-strict edit rules. If playing strict, where you never edit unless to correct game bugs, then ending a phase too early due to misclick or oversight can be a disastrous mistake. If there is a game feature to go back, then we have basically baked in 'non-strict' rules, where you can undo a phase end and finish up some moves so long as dice have not been rolled. |
No doubt more experienced Java programmers than I are going to find this messy, but an svn diff produces this output. Note that I don't have commit access (unless I'm unaware of it) so I can't commit which means that I can't create a pull request. It's also still filled with debugs. But I'll post what I have to see if it is nearly suitable:
simon@gigabyte43:~/triplea-code/triplea$ svn diff
Index: build.gradle
--- build.gradle (revision 4392)
+++ build.gradle (working copy)
@@ -7,7 +7,7 @@
}
group = 'triplea'
-version = '1.8.0.5'
+version = '1.8.0.9'
description = 'TripleA is a free online turn based strategy game and board game engine, similar to such board games as Axis & Allies or Risk.'
mainClassName = "games.strategy.engine.framework.GameRunner"
Index: src/games/strategy/common/player/AbstractBasePlayer.java
--- src/games/strategy/common/player/AbstractBasePlayer.java (revision 4392)
+++ src/games/strategy/common/player/AbstractBasePlayer.java (working copy)
@@ -140,4 +140,9 @@
}
}
Index: src/games/strategy/common/ui/MainGameFrame.java
===================================================================
--- src/games/strategy/common/ui/MainGameFrame.java (revision 4392)
+++ src/games/strategy/common/ui/MainGameFrame.java (working copy)
@@ -29,6 +29,7 @@
{
private static final long serialVersionUID = 7433347393639606647L;
protected LocalPlayers m_localPlayers;
public MainGameFrame(final String name, final LocalPlayers players)
{
@@ -36,6 +37,16 @@
m_localPlayers = players;
setIconImage(GameRunner2.getGameIcon(this));
}
+
public abstract IGame getGame();
Index: src/games/strategy/engine/data/GameSequence.java
--- src/games/strategy/engine/data/GameSequence.java (revision 4392)
+++ src/games/strategy/engine/data/GameSequence.java (working copy)
@@ -191,6 +191,17 @@
return getStep(m_currentIndex);
}
}
+
public GameStep getStep(final int index)
{
Index: src/games/strategy/engine/framework/ServerGame.java
--- src/games/strategy/engine/framework/ServerGame.java (revision 4392)
+++ src/games/strategy/engine/framework/ServerGame.java (working copy)
@@ -53,6 +53,7 @@
import games.strategy.engine.random.RandomStats;
import games.strategy.net.INode;
import games.strategy.net.Messengers;
+import games.strategy.triplea.delegate.MoveDelegate;
import games.strategy.triplea.TripleAPlayer;
import games.strategy.triplea.ai.Dynamix_AI.CommandCenter.CachedInstanceCenter;
import games.strategy.triplea.ui.ErrorHandler;
@@ -62,6 +63,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
@@ -86,6 +88,8 @@
private final DelegateExecutionManager m_delegateExecutionManager = new DelegateExecutionManager();
private InGameLobbyWatcherWrapper m_inGameLobbyWatcher;
private boolean m_needToInitialize = true;
private boolean m_goneBack = false;
private Serializable m_endLastMove;
/**
When the delegate execution is stopped, we countdown on this latch to prevent the startgame(...) method from returning.
@@ -538,7 +542,13 @@ startStep(stepIsRestoredFromSavedGame); if (m_isGameOver) return;
@@ -565,6 +575,7 @@
try
{
getCurrentStep().getDelegate().end();
@@ -638,7 +649,15 @@
{
final IDelegate delegate = getCurrentStep().getDelegate();
delegate.setDelegateBridgeAndPlayer(bridge);
@@ -645,14 +664,14 @@
}
}
private void waitForPlayerToFinishStep()
private boolean waitForPlayerToFinishStep()
{
final PlayerID playerID = getCurrentStep().getPlayerID();
// no player specified for the given step
if (playerID == null)
@@ -662,7 +681,9 @@
System.out.println("Local Player step: " + getCurrentStep().getName() + " for PlayerID: " + playerID.getName() + ", player name: " + player.getName() + ", player type: "
+ player.getType() + ". All local players: " + m_gamePlayers + ". All players: " + m_playerManager);
}*/
@@ -676,6 +697,7 @@
}*/
advancer.startPlayerStep(getCurrentStep().getName(), playerID);
}
}
private void notifyGameStepChanged(final boolean loadedFromSavedGame)
Index: src/games/strategy/engine/gamePlayer/IGamePlayer.java
--- src/games/strategy/engine/gamePlayer/IGamePlayer.java (revision 4392)
+++ src/games/strategy/engine/gamePlayer/IGamePlayer.java (working copy)
@@ -61,7 +61,11 @@
*/
public void stopGame();
public boolean goBack();
/*
@return the id of this player. This id is initialized by the initialize method in IGamePlayer.
--- src/games/strategy/triplea/TripleAPlayer.java (revision 4392)Index: src/games/strategy/triplea/TripleAPlayer.java
+++ src/games/strategy/triplea/TripleAPlayer.java (working copy)
@@ -95,6 +95,7 @@
private boolean m_soundPlayedAlreadyBattle = false;
private boolean m_soundPlayedAlreadyEndTurn = false;
private boolean m_soundPlayedAlreadyPlacement = false;
/** Creates new TripleAPlayer */
public TripleAPlayer(final String name, final String type)
@@ -149,7 +150,22 @@
else if (name.endsWith("Move"))
{
final boolean nonCombat = GameStepPropertiesHelper.isNonCombatMove(getGameData(), false);
@@ -366,28 +382,12 @@
}
}
private void move(final boolean nonCombat, final String stepName)
private void move(final boolean nonCombat, final String stepName, final IMoveDelegate moveDel)
{
if (getPlayerBridge().isGameOver())
{
return;
}
@@ -408,7 +408,7 @@
{
if (!canAirLand(true, id))
{
@@ -415,7 +415,7 @@
{
if (canUnitsFight())
{
@@ -426,7 +426,7 @@
{
m_ui.notifyError(error);
}
}
private boolean canAirLand(final boolean movePhase, final PlayerID player)
@@ -672,6 +672,10 @@
m_soundPlayedAlreadyPlacement = true;
}
final PlaceData placeData = m_ui.waitForPlace(id, bid, getPlayerBridge());
@@ -964,4 +968,14 @@
}
return m_ui.pickTerritoryAndUnits(this.getPlayerID(), territoryChoices, unitChoices, unitsPerPick);
}
+
public boolean goBack()
{
}
}
Index: src/games/strategy/triplea/ai/Dynamix_AI/Dynamix_AI.java
===================================================================
--- src/games/strategy/triplea/ai/Dynamix_AI/Dynamix_AI.java (revision 4392)
+++ src/games/strategy/triplea/ai/Dynamix_AI/Dynamix_AI.java (working copy)
@@ -538,4 +538,9 @@
{
return null;
}
}
Index: src/games/strategy/triplea/ai/strongAI/StrongAI.java
===================================================================
--- src/games/strategy/triplea/ai/strongAI/StrongAI.java (revision 4392)
+++ src/games/strategy/triplea/ai/strongAI/StrongAI.java (working copy)
@@ -9977,4 +9977,9 @@
return (TripleAUnit.get(o).getTransporting().size() > 0);
}
};
}
Index: src/games/strategy/triplea/ai/weakAI/WeakAI.java
===================================================================
--- src/games/strategy/triplea/ai/weakAI/WeakAI.java (revision 4392)
+++ src/games/strategy/triplea/ai/weakAI/WeakAI.java (working copy)
@@ -1173,4 +1173,9 @@
return (TripleAUnit.get(o).getTransporting().size() > 0);
}
};
}
Index: src/games/strategy/triplea/delegate/AbstractEndTurnDelegate.java
===================================================================
--- src/games/strategy/triplea/delegate/AbstractEndTurnDelegate.java (revision 4392)
+++ src/games/strategy/triplea/delegate/AbstractEndTurnDelegate.java (working copy)
@@ -35,6 +35,7 @@
import games.strategy.engine.random.IRandomStats.DiceType;
import games.strategy.triplea.Constants;
import games.strategy.triplea.Properties;
+import games.strategy.triplea.TripleAUnit;
import games.strategy.triplea.attatchments.PlayerAttachment;
import games.strategy.triplea.attatchments.RelationshipTypeAttachment;
import games.strategy.triplea.attatchments.TechAbilityAttachment;
@@ -67,6 +68,7 @@
public abstract class AbstractEndTurnDelegate extends BaseTripleADelegate implements IAbstractForumPosterDelegate
{
public static final String END_TURN_REPORT_STRING = "End of Turn Report for ";
private boolean m_needToInitialize = true;
private boolean m_hasPostedTurnSummary = false;
private static int CONVOY_BLOCKADE_DICE_SIDES = 6;
@@ -99,6 +101,7 @@
final StringBuilder endTurnReport = new StringBuilder();
m_hasPostedTurnSummary = false;
final PlayerAttachment pa = PlayerAttachment.get(m_player);
}
};
}
+
}
Index: src/games/strategy/triplea/delegate/AbstractPlaceDelegate.java
--- src/games/strategy/triplea/delegate/AbstractPlaceDelegate.java (revision 4392)
+++ src/games/strategy/triplea/delegate/AbstractPlaceDelegate.java (working copy)
@@ -708,6 +708,7 @@
// make sure the player has enough units in hand to place
if (!player.getUnits().getUnits().containsAll(units))
{
Index: src/games/strategy/triplea/delegate/MoveDelegate.java
--- src/games/strategy/triplea/delegate/MoveDelegate.java (revision 4392)+++ src/games/strategy/triplea/delegate/MoveDelegate.java (working copy)
@@ -67,7 +67,6 @@
*/
public class MoveDelegate extends AbstractMoveDelegate implements IMoveDelegate
{
private boolean m_needToInitialize = true; // needToInitialize means we only do certain things once, so that if a game is saved then loaded, they aren't done again
private boolean m_needToDoRockets = true;
private IntegerMap m_PUsLost = new IntegerMap();
@@ -179,11 +178,13 @@
}
}
+/* if (GameStepPropertiesHelper.isResetUnitStateAtStart(data))
+* {
+* resetUnitStateAndDelegateState();
+* }
+*/
m_needToInitialize = false;
}
}
@@ -236,11 +237,12 @@
m_needToDoRockets = false;
}
}
+* resetUnitStateAndDelegateState();
@@ -311,7 +313,8 @@
}
return change;
}
private void resetUnitStateAndDelegateState()
{
m_PUsLost.clear(); // while not a 'unit state', this is fine here for now. since we only have one instance of this delegate, as long as it gets cleared once per player's turn block, we are fine.
@@ -324,6 +327,7 @@
m_bridge.addChange(change);
}
}
public static Change getResetUnitStateChange(final GameData data)
{
@@ -380,6 +384,7 @@
return change;
}
private void removeMovementFromAirOnDamagedAlliedCarriers(final IDelegateBridge aBridge, final PlayerID player)
{
final GameData data = aBridge.getData();
@@ -938,6 +943,11 @@
m_PUsLost.add(t, amt);
}
public void clearNeedToInitialize()
{
}
/*
If it can't succeed returns an empty Map.
--- src/games/strategy/triplea/ui/AbstractMovePanel.java (revision 4392)Index: src/games/strategy/triplea/ui/AbstractMovePanel.java
+++ src/games/strategy/triplea/ui/AbstractMovePanel.java (working copy)
@@ -40,10 +40,28 @@
private final JLabel m_actionLabel = new JLabel();
protected MoveDescription m_moveMessage;
protected List m_undoableMoves;
private JComponent m_backBox = null;
protected AbstractAction m_backMove = new AbstractAction("Back")
{
+// private static final long serialVersionUID = not sure;
};
private final Action m_BACK_MOVE_ACTION = new WeakAction("Back", m_backMove);
private final JButton m_backButton = new JButton(m_BACK_MOVE_ACTION);
protected AbstractAction m_doneMove = new AbstractAction("Done")
{
private static final long serialVersionUID = -6497408896615920650L;
{
if (doneMoveAction())
@@ -74,6 +92,16 @@
abstract protected boolean doneMoveAction();
/*
* sub-classes method for back handling
*/
abstract protected boolean backMoveAction();
protected void enableBackButton()
{
};
/*
sub-classes method for cancel handling
*/
abstract protected void cancelMoveAction();
@@ -234,6 +262,9 @@
add(leftBox(m_actionLabel));
if (setCancelButton())
add(leftBox(new JButton(m_CANCEL_MOVE_ACTION)));
@@ -303,4 +334,9 @@
clearDependencies();
return rVal;
}
public final boolean goBack()
{
}
}
Index: src/games/strategy/triplea/ui/ActionButtons.java
===================================================================
--- src/games/strategy/triplea/ui/ActionButtons.java (revision 4392)
+++ src/games/strategy/triplea/ui/ActionButtons.java (working copy)
@@ -34,6 +34,8 @@
import games.strategy.triplea.delegate.dataObjects.TechRoll;
import games.strategy.triplea.delegate.remote.IPoliticsDelegate;
import games.strategy.triplea.delegate.remote.IUserActionDelegate;
+import games.strategy.triplea.delegate.UndoableMove;
+import games.strategy.triplea.TripleAUnit;
import games.strategy.util.IntegerMap;
import games.strategy.util.Tuple;
@@ -40,6 +42,7 @@
import java.awt.CardLayout;
import java.awt.event.KeyEvent;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -67,7 +70,7 @@
private TechPanel m_techPanel;
private EndTurnPanel m_endTurnPanel;
private MoveForumPosterPanel m_moveForumPosterPanel;
private PoliticsPanel m_politicsPanel;
private UserActionPanel m_userActionPanel;
private PickTerritoryAndUnitsPanel m_pickTerritoryAndUnitsPanel;
@@ -75,8 +78,9 @@
/** Creates new ActionPanel */
public ActionButtons(final GameData data, final MapPanel map, final TripleAFrame parent)
{
add(m_repairPanel, m_repairPanel.toString());
add(m_purchasePanel, m_purchasePanel.toString());
add(m_placePanel, m_placePanel.toString());
add(m_techPanel, m_techPanel.toString());
add(m_endTurnPanel, m_endTurnPanel.toString());
add(m_moveForumPosterPanel, m_moveForumPosterPanel.toString());
@@ -204,8 +209,15 @@
private void changeTo(final PlayerID id, final ActionPanel newCurrent)
{
@@ -219,6 +231,10 @@
m_layout.show(ActionButtons.this, currentName);
}
});
}
public void changeToPickTerritoryAndUnits(final PlayerID id)
Index: src/games/strategy/triplea/ui/MovePanel.java
--- src/games/strategy/triplea/ui/MovePanel.java (revision 4392)
+++ src/games/strategy/triplea/ui/MovePanel.java (working copy)
@@ -36,6 +36,7 @@
import games.strategy.triplea.delegate.MoveDelegate;
import games.strategy.triplea.delegate.MoveValidator;
import games.strategy.triplea.delegate.TransportTracker;
+import games.strategy.triplea.delegate.UndoableMove;
import games.strategy.triplea.delegate.UnitComparator;
import games.strategy.triplea.delegate.dataObjects.MoveDescription;
import games.strategy.triplea.delegate.dataObjects.MoveValidationResult;
@@ -110,7 +111,7 @@
private MoveType m_moveType = MoveType.DEFAULT;
/** Creates new MovePanel */
public MovePanel(final GameData data, final MapPanel map, final TripleAFrame frame)
public MovePanel(final GameData data, final MapPanel map, final TripleAFrame frame, List undoableMoves)
{
super(data, map, frame);
m_undoableMovesPanel = new UndoableMovesPanel(data, this);
@@ -117,8 +118,15 @@
m_mouseCurrentTerritory = null;
m_unitsThatCanMoveOnRoute = Collections.emptyList();
m_currentCursorImage = null;
}
public boolean backMoveAction()
{
}
// TODO: oh my fucking god this code is awefull. only the local computer has access to the UI. why the fuck did someone think they could do this?
// The host has no access to the client's UI, and therefore does not know what dependent units there are.
// TODO: rewrite this fucking garbage! None of this s_dependentUnits shit should be in the move panel! (fixed by sending a copy of this with the move details)
Index: src/games/strategy/triplea/ui/PlacePanel.java
--- src/games/strategy/triplea/ui/PlacePanel.java (revision 4392)
+++ src/games/strategy/triplea/ui/PlacePanel.java (working copy)
@@ -252,6 +252,13 @@
m_placeData = null;
return true;
}
+
@OverRide
protected boolean setCancelButton()
@@ -262,8 +269,10 @@
@OverRide
final protected void addAdditionalButtons()
{
}
The text was updated successfully, but these errors were encountered: