Skip to content
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

Closed
simon33-2 opened this issue Jul 30, 2016 · 15 comments
Closed

Back button on place units phase #1025

simon33-2 opened this issue Jul 30, 2016 · 15 comments

Comments

@simon33-2
Copy link
Contributor

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 @@
}

// public abstract Class<?> getRemotePlayerType();
  • public boolean goBack()
  • {
  •   return false;
    
  • }
    }
    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;
  • private boolean m_goBack = false;

public MainGameFrame(final String name, final LocalPlayers players)
{
@@ -36,6 +37,16 @@
m_localPlayers = players;
setIconImage(GameRunner2.getGameIcon(this));
}
+

  • public boolean goBack()
  • {
  •   return m_goBack;
    
  • }
  • public void setGoBack(boolean b)
  • {
  •   m_goBack = b;
    
  • }

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 void goBack1Step()
  • {
  •   synchronized (m_currentStepMutex)
    
  •   {
    
  •       if (m_currentIndex > 0)
    
  •       {
    
  •           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;

  •   waitForPlayerToFinishStep();
    
  •   if( waitForPlayerToFinishStep() )
    
  •   {
    
  •       endStep();
    
  •       m_data.getSequence().goBack1Step();
    
  •       m_goneBack = true;
    
  •       return;
    
  •   }
    if (m_isGameOver)
        return;
    final boolean autoSaveAfterDelegateDone = endStep();
    

    @@ -565,6 +575,7 @@
    try
    {
    getCurrentStep().getDelegate().end();

  •       if( getCurrentStep().getDelegate() instanceof MoveDelegate ) m_endLastMove = getCurrentStep().getDelegate().saveState(); 
    } finally
    {
        m_delegateExecutionManager.leaveDelegateExecution();
    

    @@ -638,7 +649,15 @@
    {
    final IDelegate delegate = getCurrentStep().getDelegate();
    delegate.setDelegateBridgeAndPlayer(bridge);

  •       delegate.start();
    
  •       if( delegate instanceof MoveDelegate && m_goneBack )
    
  •       {
    
  •           ( (MoveDelegate) delegate).loadState( m_endLastMove );
    
  •           ( (MoveDelegate) delegate).clearNeedToInitialize();
    
  •           delegate.start();
    
  •           //delegate.
    
  •       }
    
  •       else delegate.start();
    
  •       m_goneBack = false;
    } finally
    {
        m_delegateExecutionManager.leaveDelegateExecution();
    

    @@ -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)

  •       return;
    
  •       return false;
    if (!getCurrentStep().getDelegate().delegateCurrentlyRequiresUserInput())
    
  •       return;
    
  •       return false;
    final IGamePlayer player = m_gamePlayers.get(playerID);
    if (player != 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);
    }*/

  •       player.clearGoBackFlag();
        player.start(getCurrentStep().getName());
    
  •       return player.goBack();
    }
    else
    {
    

    @@ -676,6 +697,7 @@
    }*/
    advancer.startPlayerStep(getCurrentStep().getName(), playerID);
    }

  •   return false;
    

    }

    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 @@

    • Called when the game is stopped (like if we are closing the window or leaving the game).
      */
      public void stopGame();
  • public boolean goBack();

  • public void clearGoBackFlag();

/*

  • (now in superclass)
  • @return the id of this player. This id is initialized by the initialize method in IGamePlayer.
    Index: src/games/strategy/triplea/TripleAPlayer.java

    --- src/games/strategy/triplea/TripleAPlayer.java (revision 4392)
    +++ 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;
  • private IMoveDelegate moveDel;

/** 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);

  •       move(nonCombat, name);
    
  •       try
    
  •       {
    
  •           if( !m_ui.goBack() )
    
  •           {
    
  •               // Don't clear data if user has gone back to here
    
  •               moveDel = (IMoveDelegate) getPlayerBridge().getRemoteDelegate();
    
  •           }
    
  •       } catch (final ClassCastException e)
    
  •       {
    
  •           final String errorContext = "PlayerBridge step name: " + getPlayerBridge().getStepName() + ", Remote class name: "
    
  •                       + getPlayerBridge().getRemoteDelegate().getClass();
    
  •           System.err.println(errorContext); // for some reason the client is not seeing or getting these errors, so print to err too
    
  •           e.printStackTrace();
    
  •           throw new IllegalStateException(errorContext, e);
    
  •       }
    
  •       move(nonCombat, name, moveDel);
        if (!nonCombat)
        {
            m_ui.waitForMoveForumPoster(getPlayerID(), getPlayerBridge());
    

    @@ -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;
    }

  •   final IMoveDelegate moveDel;
    
  •   try
    
  •   {
    
  •       moveDel = (IMoveDelegate) getPlayerBridge().getRemoteDelegate();
    
  •   } catch (final ClassCastException e)
    
  •   {
    
  •       final String errorContext = "PlayerBridge step name: " + getPlayerBridge().getStepName() + ", Remote class name: "
    
  •                   + getPlayerBridge().getRemoteDelegate().getClass();
    
  •       System.err.println(errorContext); // for some reason the client is not seeing or getting these errors, so print to err too
    
  •       e.printStackTrace();
    
  •       throw new IllegalStateException(errorContext, e);
    
  •   }
    
  •   /*
    
  •   if (!moveDel.stuffToDoInThisDelegate())
    
  •       return;
    
  •   */
    final PlayerID id = getPlayerID();
    // play a sound for this phase
    if (nonCombat && !m_soundPlayedAlreadyNonCombatMove)
    

    @@ -408,7 +408,7 @@
    {
    if (!canAirLand(true, id))
    {

  •               move(nonCombat, stepName);
    
  •               move(nonCombat, stepName, moveDel);
            }
        }
        if (!nonCombat)
    

    @@ -415,7 +415,7 @@
    {
    if (canUnitsFight())
    {

  •               move(nonCombat, stepName);
    
  •               move(nonCombat, stepName, moveDel);
            }
        }
        return;
    

    @@ -426,7 +426,7 @@
    {
    m_ui.notifyError(error);
    }

  •   move(nonCombat, stepName);
    
  •   move(nonCombat, stepName, moveDel);
    

    }

    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());

  •       if( m_ui.goBack() )
    
  •       {
    
  •           return;
    
  •       }
        if (placeData == null)
        {
            // this only happens in lhtr rules
    

    @@ -964,4 +968,14 @@
    }
    return m_ui.pickTerritoryAndUnits(this.getPlayerID(), territoryChoices, unitChoices, unitsPerPick);
    }
    +

  • public boolean goBack()

  • {

  •   return m_ui.goBack();
    
  • }

  • public void clearGoBackFlag()
  • {
  •   m_ui.setGoBack(false);
    
  • }
    }
    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;
    }
  • public boolean goBack()
  • {
  •   return false;
    
  • }
    }
    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);
    }
    };
  • public boolean goBack()
  • {
  •   return false;
    
  • }
    }
    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);
    }
    };
  • public boolean goBack()
  • {
  •   return false;
    
  • }
    }
    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 ";
  • public static String CLEANING_UP_DURING_MOVEMENT_PHASE = "Cleaning up during movement phase";
    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);
  •   resetUnitStateAndDelegateState();
    // can't collect unless you own your own capital
    if (!canPlayerCollectIncome(m_player, data))
    {
    
    @@ -644,6 +647,19 @@
    }
    };
    }
    +
  • private void resetUnitStateAndDelegateState()
  • {
  •   final Change change = MoveDelegate.getResetUnitStateChange(getData());
    
  •   if (!change.isEmpty())
    
  •   {
    
  •       // if no non-combat occurred, we may have cleanup left from combat
    
  •       // that we need to spawn an event for
    
  •       m_bridge.getHistoryWriter().startEvent(CLEANING_UP_DURING_MOVEMENT_PHASE);
    
  •       m_bridge.addChange(change);
    
  •   }
    
  • }

}

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))
{

  •       System.out.println("Abstract place");
        return "Not enough units";
    }
    return null;
    

    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
    {
  • public static String CLEANING_UP_DURING_MOVEMENT_PHASE = "Cleaning up during movement phase";
    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_PUsLost.clear();
    

+/* if (GameStepPropertiesHelper.isResetUnitStateAtStart(data))
+* {
+* resetUnitStateAndDelegateState();
+* }
+*/
m_needToInitialize = false;
}
}
@@ -236,11 +237,12 @@
m_needToDoRockets = false;
}
}

  •   // do at the end of the round, if we do it at the start of non combat, then we may do it in the middle of the round, while loading.
    
  •   if (GameStepPropertiesHelper.isResetUnitStateAtEnd(data))
    
  •   {
    
  •       resetUnitStateAndDelegateState();
    
  •   }
    
  •   // do at the end of the round, if we do it at the start of non combat, then we may do it in the middle of the round, while loading. _Don't reset unit data here any more because people can go back now_
    
  •   /_if (_/GameStepPropertiesHelper.isResetUnitStateAtEnd(data) ;
    
  •   /_)
    
    +_ {
    +* resetUnitStateAndDelegateState();
  •   }*/
    m_needToInitialize = true;
    m_needToDoRockets = true;
    
    }
    @@ -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()

  • {

  •   m_needToInitialize = false;
    
  • }

  • /*

    • Returns a list of the maximum number of each type of unit that can be loaded on the transports
    • If it can't succeed returns an empty Map.
      Index: src/games/strategy/triplea/ui/AbstractMovePanel.java

      --- src/games/strategy/triplea/ui/AbstractMovePanel.java (revision 4392)
      +++ 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;

  •   public void actionPerformed(final ActionEvent e)
    
  •   {
    
  •       if (backMoveAction())
    
  •       {
    
  •           for ( int i = m_undoableMoves.size() ; i>0 ; undoMove( --i ) );
    
  •           m_moveMessage = null;
    
  •           release();
    
  •           m_frame.setGoBack(true);
    
  •       }
    
  •   }
    
  • };

  • 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;

    • public void actionPerformed(final ActionEvent e)
      {
      if (doneMoveAction())
      @@ -74,6 +92,16 @@
      abstract protected boolean doneMoveAction();

    /*

  • * sub-classes method for back handling

  • */

  • abstract protected boolean backMoveAction();

  • protected void enableBackButton()

  • {

  •   m_BACK_MOVE_ACTION.setEnabled(true);
    
  •   m_backButton.setVisible(true);
    
  • };

  • /*

  • 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)));

  •           add(leftBox(m_backButton));
    
  •           m_BACK_MOVE_ACTION.setEnabled(false);
    
  •           m_backButton.setVisible(false);
            add(leftBox(new JButton(m_DONE_MOVE_ACTION)));
            addAdditionalButtons();
            add(Box.createVerticalStrut(s_entryPadding));
    

    @@ -303,4 +334,9 @@
    clearDependencies();
    return rVal;
    }

  • public final boolean goBack()

  • {

  •   return m_frame.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 ActionPanel m_current;
  • private ActionPanel m_current, m_previous, m_tmpPanel;
    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)
    {
  •   List<UndoableMove> tmpUndoableMoves = Collections.emptyList();
    m_battlePanel = new BattlePanel(data, map);
    
  •   m_movePanel = new MovePanel(data, map, parent);
    
  •   m_movePanel = new MovePanel(data, map, parent, tmpUndoableMoves );
    m_purchasePanel = new PurchasePanel(data, map);
    m_repairPanel = new RepairPanel(data, map);
    m_placePanel = new PlacePanel(data, map, parent);
    
    @@ -94,6 +98,7 @@
    add(m_repairPanel, m_repairPanel.toString());
    add(m_purchasePanel, m_purchasePanel.toString());
    add(m_placePanel, m_placePanel.toString());
  • // add(m_placePanel, "Back");
    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)
{

  •   List<UndoableMove> x;
    
  •   m_tmpPanel = m_previous;
    
  •   m_previous = m_current;
    m_current.setActive(false);
    
  •   m_current = newCurrent;
    
  •   m_current = m_previous instanceof MovePanel && ( (MovePanel) m_current).goBack() ? m_tmpPanel : newCurrent;
    
  •   if( m_current instanceof MovePanel ) {
    
  •       x = ( (MovePanel) m_current).getUndoableMoves();
    
  •       System.out.format( "Count of moves %d, first move already moved: %d  ", x.size(), x.size() > 0 ? ( (TripleAUnit) ( (List) x.get(0).getUnits()).get(0) ).getAlreadyMoved() : -1 );
    
  •   }
    // newCurrent might be null if we are shutting down
    if (m_current == null)
        return;
    

    @@ -219,6 +231,10 @@
    m_layout.show(ActionButtons.this, currentName);
    }
    });

  •   if( m_current instanceof MovePanel ) {
    
  •       x = ( (MovePanel) m_current).getUndoableMoves();
    
  •       System.out.format( " 2nd Count of moves %d , first move already moved: %d\n",x.size(), x.size() > 0 ? ( (TripleAUnit) ( (List) x.get(0).getUnits()).get(0) ).getAlreadyMoved() : -1 );
    
  •   }
    

    }

    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;

  •   m_undoableMoves = undoableMoves;
    
  •   m_undoableMovesPanel.setMoves( undoableMoves );
    

    }

  • public boolean backMoveAction()

  • {

  •   return false;
    
  • }

// 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 backMoveAction()
  • {
  •   System.out.println("checking back move");
    
  •   return true;
    
  • }

@OverRide
protected boolean setCancelButton()
@@ -262,8 +269,10 @@
@OverRide
final protected void addAdditionalButtons()
{

  •   System.out.println("adding buttons");
    add(leftBox(m_leftToPlaceLabel));
    add(m_unitsToPlace);
    
  •   enableBackButton();     // This appears to be thread safe if placed here
    updateUnits();
    
    }
    }
@DanVanAtta
Copy link
Member

Thanks @simon33-2 - this is perfect.
If anyone picks this up, please comment in this issue

@RoiEXLab
Copy link
Member

Yes this is messy, but I think I got what you wanted to achieve with this.

  1. Since this is GitHub tripleA is using git instead of SVN -> your code Base you are/were using is very likely outdated. (Version number is 1.9)
  2. In order to create a pull request you can fork the project (click fork in the upper right corner) and select your own branch on your fork which is supposed to be added to the game. (This way no write permission is Needed)
  3. Since you are using an Unix os (probably Linux) I'd recommend you installing Gitkraken or any comparable git-Ui application instead of using command line only.
    More detailed information can be found here

@RoiEXLab
Copy link
Member

Sorry if I misunderstood something. If you still happen to have any questions feel free to ask.

@simon33-2
Copy link
Contributor Author

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"?

@RoiEXLab
Copy link
Member

@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.
If you can't use the gui, I'd highly recommend to watch a git tutorial on YouTube or whatever...
If you still want to update your branch you have to rebase it onto the "updated" branch the command "git rebase" should help you there

@simon33-2
Copy link
Contributor Author

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 :)

@DanVanAtta
Copy link
Member

source tree is another nice GUI app for git. https://github.com/ndbroadbent/scm_breeze is a nice tool for command line enhancements.

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 :)

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:
git pull --rebase upstream master

This would then push a branch called master to my origin:
git push origin master

It is recommended you create a new branch for each project.

@simon33-2
Copy link
Contributor Author

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?

@DanVanAtta
Copy link
Member

Usually that can be autogenerated by your IDE, example: https://www.mkyong.com/java/how-to-generate-serialversionuid/

@RoiEXLab
Copy link
Member

This can be closed right?

@simon33-2
Copy link
Contributor Author

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.

@DanVanAtta
Copy link
Member

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.

@DanVanAtta
Copy link
Member

Backlogging. https://github.com/triplea-game/triplea/wiki/Feature-Back-Log/
I think this is a killer feature, i hope it is done soon! Games have ended with fights over mistaken end phase clicks (eg: click end phase, notice that something very key was not moved, opponent does not allow edit, you then lose game suddenly)

@simon33-2
Copy link
Contributor Author

I don't think it is as important now that you can reload the NonCombatMove autosave.

@DanVanAtta
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants