Changeset View
Changeset View
Standalone View
Standalone View
freecell.cpp
| Context not available. | |||||
| 98 | setNeededFutureMoves( 4 ); // reserve some | 98 | setNeededFutureMoves( 4 ); // reserve some | ||
|---|---|---|---|---|---|
| 99 | } | 99 | } | ||
| 100 | 100 | | |||
| 101 | int Freecell::moveCount() const | ||||
| 102 | { | ||||
| 103 | int count = 0; | ||||
| 104 | // For every move that was done so far, | ||||
| 105 | for (int i = 0; i< m_undoStack.size(); ++i) { | ||||
| 106 | // add the number of cards that were moved | ||||
| 107 | count += m_undoStack.at(i)->changes.size(); | ||||
| 108 | } | ||||
| 109 | // Do the same for the current state | ||||
| 110 | count += m_currentState ? m_currentState->changes.size() : 0; | ||||
| 111 | // Finally, add the number of moves from the save state. | ||||
| 112 | count += m_loadedMoveCount; | ||||
| 113 | // Setting up the initial game state creates a state with a run containing 8 changes | ||||
| 114 | // This initial setup should not be part of the moveCount, thus we subtract it | ||||
| 115 | count -= 8; | ||||
| 116 | return count; | ||||
| 117 | } | ||||
| 118 | | ||||
| 101 | 119 | | |||
| 102 | void Freecell::restart( const QList<KCard*> & cards ) | 120 | void Freecell::restart( const QList<KCard*> & cards ) | ||
| 103 | { | 121 | { | ||
| Context not available. | |||||