- When displaying an old turn, do not allow playing

- Turns start at 0 instead of 1, to indicate that nothing was played on the first turn
This commit is contained in:
Olivier Teulière 2008-11-30 21:08:29 +00:00
parent 06dd7dff71
commit 81b44a8050
3 changed files with 16 additions and 5 deletions

View file

@ -65,7 +65,7 @@ unsigned int Navigation::getCurrTurn() const
unsigned int currTurn = m_currTurn;
if (isLastTurn() && m_turnCommands.back()->isEmpty())
--currTurn;
return currTurn;
return currTurn - 1;
}
@ -74,7 +74,7 @@ unsigned int Navigation::getNbTurns() const
unsigned int count = m_turnCommands.size();
if (m_turnCommands.back()->isEmpty())
--count;
return count;
return count - 1;
}

View file

@ -134,9 +134,18 @@ void PlayerWidget::refresh()
lineEditCoords->clear();
lineEditChange->clear();
// Do not allow messing with AI players or with players who already played
setEnabled(!m_game->hasPlayed(m_player) &&
m_game->getPlayer(m_player).isHuman());
if (!m_game->isLastTurn())
{
// Do not allow entering a move when displaying an old turn
setEnabled(false);
}
else
{
// Do not allow messing with AI players or with players
// who already played
setEnabled(!m_game->hasPlayed(m_player) &&
m_game->getPlayer(m_player).isHuman());
}
}

View file

@ -117,6 +117,8 @@ void TrainingWidget::refresh()
pushButtonComplement->setEnabled(true);
pushButtonSearch->setEnabled(m_model->rowCount() == 0 &&
lineEditRack->text() != "");
// Do not allow entering a move when displaying an old turn
setEnabled(m_game->isLastTurn());
}
}