mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-26 19:58:44 +01:00
Display the total number of warnings of a player in the corresponding history tab title
This commit is contained in:
parent
a03eaab88a
commit
917c94fd5e
3 changed files with 29 additions and 0 deletions
|
@ -82,6 +82,16 @@ void Player::removeLastTurn()
|
|||
m_history.removeLastTurn();
|
||||
}
|
||||
|
||||
unsigned Player::getWarningsNb() const
|
||||
{
|
||||
unsigned total = 0;
|
||||
for (unsigned i = 0; i < m_history.getSize(); ++i)
|
||||
{
|
||||
total += m_history.getTurn(i).getWarningsNb();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
wstring Player::toString() const
|
||||
{
|
||||
wstring res = L"Player ";
|
||||
|
|
|
@ -79,6 +79,9 @@ public:
|
|||
/// Remove last turn
|
||||
void removeLastTurn();
|
||||
|
||||
/// Return the total number of warnings received
|
||||
unsigned getWarningsNb() const;
|
||||
|
||||
/**************************
|
||||
* Accessors for the score of the player
|
||||
**************************/
|
||||
|
|
|
@ -329,6 +329,22 @@ void HistoryTabWidget::setGame(const PublicGame *iGame)
|
|||
|
||||
void HistoryTabWidget::refresh()
|
||||
{
|
||||
// Display the number of warnings between parentheses
|
||||
// (only if the player got at least one warning)
|
||||
if (m_game != NULL)
|
||||
{
|
||||
for (unsigned int i = 0; i < m_game->getNbPlayers(); ++i)
|
||||
{
|
||||
const Player &player = m_game->getPlayer(i);
|
||||
unsigned count = player.getWarningsNb();
|
||||
if (count == 0)
|
||||
setTabText(i + 1, qfw(player.getName()));
|
||||
else
|
||||
setTabText(i + 1, QString("%1 (%2)").arg(qfw(player.getName())).arg(count));
|
||||
}
|
||||
}
|
||||
|
||||
// Propagate the refresh to the history widgets (i.e. to the tab contents)
|
||||
emit refreshSignal();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue