- QLabel *label = new QLabel(this);
- layout()->addWidget(label);
- players[device] = label;
+ players[device] = new Player(this);
+ }
+ players[device]->handleKey(string);
+
+ if (gameStarted) { // ingame
+ qDebug() << players[device]->getCurrentLine();
+ qDebug() << mainLabel->text();
+ if (players[device]->getCurrentLine() == mainLabel->text()) {
+ players[device]->score += typingPlayers;
+ QString readyString = QString("READY: %1 points").arg(typingPlayers);
+ players[device]->setWaiting(readyString);
+ qDebug() << "typingPlayers " << typingPlayers;
+ typingPlayers--;
+ qDebug() << "typingPlayers " << typingPlayers;
+ if (typingPlayers <= 0) {
+ nextWord();
+ }
+ }
+ } else { // name entering phase
+ bool allHaveNames = true;
+ for (QMap<int, Player*>::Iterator it = players.begin(); it != players.end(); ++it) {
+ if (! it.value()->hasName()) {
+ allHaveNames = false;
+ break;
+ }
+ }
+ if (!players.empty() && allHaveNames) {
+ gameStarted = true;
+ nextWord();
+ }