- QByteArray tmp = words.readLine();
- QString word = QString::fromUtf8(tmp);
- mainLabel->setText(word);
+ QByteArray tmp = words.readLine().trimmed();
+ currentWord = QString::fromUtf8(tmp);
+ qDebug() << "New word:" << currentWord;
+ if (currentWord.isEmpty()) { // game over
+ setLabel("GAME OVER", READY_COLOR);
+ for (QMap<int, Player*>::Iterator it = players.begin(); it != players.end(); ++it) {
+ it.value()->showScore();
+ }
+ state = Scoring;
+ } else {
+ for (QMap<int, Player*>::Iterator it = players.begin(); it != players.end(); ++it) {
+ it.value()->nextWord();
+ }
+ setLabel(currentWord, BASE_COLOR);
+ state = Playing;
+ }
+}
+
+bool MultypoWindow::allPlayersWaiting()
+{
+ for (QMap<int, Player*>::Iterator it = players.begin(); it != players.end(); ++it) {
+ if (it.value()->getState() != Player::Waiting) return false;
+ }
+ return true;
+}
+
+int MultypoWindow::typingPlayers()
+{
+ int n = 0;
+ for (QMap<int, Player*>::Iterator it = players.begin(); it != players.end(); ++it) {
+ if (it.value()->getState() == Player::Typing) ++n;
+ }
+ return n;