+void MultypoWindow::setLabel(QString text, QString color)
+{
+ mainLabel->setText(QString("<font color=%1>%2</span>").arg(color).arg(Qt::escape(text)));
+}
+
+void MultypoWindow::nextWord() {
+ 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;
+}
+