- QLabel *label = new QLabel(this);
- layout()->addWidget(label);
- players[device] = label;
+ if (gameStarted)
+ return;
+ players[device] = new Player(this);
+ }
+ bool newChar = players[device]->handleKey(string);
+
+ if (gameStarted) { // ingame
+ qDebug() << "current player line" << players[device]->getCurrentLine();
+ qDebug() << "current word" << mainLabel->text();
+ if (newChar && 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
+ qDebug() << "checking for game started";
+ bool allHaveNames = true;
+ for (QMap<int, Player*>::Iterator it = players.begin(); it != players.end(); ++it) {
+ if (! it.value()->hasName()) {
+ allHaveNames = false;
+ break;
+ }
+ }
+ qDebug() << "Players empty?" << players.empty() << "All have names?" << allHaveNames;
+ if (!players.empty() && allHaveNames) {
+ gameStarted = true;
+ nextWord();
+ }