[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/game navigation.cpp navigation.h training...
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot/game navigation.cpp navigation.h training... |
Date: |
Sun, 23 Nov 2008 17:08:12 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 08/11/23 17:08:12
Modified files:
game : navigation.cpp navigation.h training.cpp
Log message:
Do not allow navigating before the first turn, and do not count an
empty turn as a real one when navigating.
The navigation in the history is now more natural.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/navigation.cpp?cvsroot=eliot&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/eliot/game/navigation.h?cvsroot=eliot&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/eliot/game/training.cpp?cvsroot=eliot&r1=1.27&r2=1.28
Patches:
Index: navigation.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/navigation.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- navigation.cpp 23 Nov 2008 17:02:33 -0000 1.2
+++ navigation.cpp 23 Nov 2008 17:08:12 -0000 1.3
@@ -60,12 +60,32 @@
}
+bool Navigation::isFirstTurn() const
+{
+ return m_currTurn == 1 ||
+ (m_currTurn == 2 && m_turnCommands[1]->isEmpty());
+}
+
+
+bool Navigation::isLastTurn() const
+{
+ return m_currTurn == m_turnCommands.size();
+}
+
+
void Navigation::prevTurn()
{
- if (m_currTurn > 0)
+ if (m_currTurn > 1)
{
--m_currTurn;
m_turnCommands[m_currTurn]->undo();
+ // Special case: when the last turn is empty, automatically
+ // undo the previous turn as well
+ if (m_currTurn + 1 == m_turnCommands.size() &&
+ m_turnCommands[m_currTurn]->isEmpty())
+ {
+ prevTurn();
+ }
}
}
@@ -76,13 +96,20 @@
{
m_turnCommands[m_currTurn]->execute();
++m_currTurn;
+ // Special case: when the last turn is empty, automatically
+ // execute it
+ if (m_currTurn + 1 == m_turnCommands.size() &&
+ m_turnCommands[m_currTurn]->isEmpty())
+ {
+ nextTurn();
+ }
}
}
void Navigation::firstTurn()
{
- while (m_currTurn > 0)
+ while (m_currTurn > 1)
{
prevTurn();
}
Index: navigation.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/navigation.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- navigation.h 23 Nov 2008 17:02:33 -0000 1.2
+++ navigation.h 23 Nov 2008 17:08:12 -0000 1.3
@@ -39,8 +39,8 @@
void addAndExecute(Command *iCmd);
unsigned int getCurrTurn() const { return m_currTurn; }
- bool isFirstTurn() const { return m_currTurn == 0; }
- bool isLastTurn() const { return m_currTurn == m_turnCommands.size(); }
+ bool isFirstTurn() const;
+ bool isLastTurn() const;
void firstTurn();
void prevTurn();
Index: training.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/training.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- training.cpp 23 Nov 2008 17:04:40 -0000 1.27
+++ training.cpp 23 Nov 2008 17:08:12 -0000 1.28
@@ -136,10 +136,12 @@
void Training::start()
{
- if (getNPlayers() != 0)
- return;
-
- m_currPlayer = 0;
+ firstPlayer();
+ // Dummy new turn, because the navigation prevents undoing the first turn.
+ // Since in this mode the player can set the rack, we cannot do like in the
+ // duplicate and free game modes, where we change turn just before a move
+ // is played...
+ accessNavigation().newTurn();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot/game navigation.cpp navigation.h training...,
Olivier Teulière <=