- 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) {
+ Player *player = players[device];
+ player->handleKey(string);
+
+ if (state == Naming) {
+ // someone's still naming (or nobody's there yet)
+ if (!players.empty() && allPlayersWaiting()) {
+ qDebug() << "Game starting";
+ nextWord();
+ }
+ }
+ else if (state == Playing) { // all players are waiting or typing
+ if (player->getState() == Player::Typing && player->getCurrentWord() == currentWord) {
+ int points = typingPlayers()+1;
+ player->wordComplete(points);
+ QString readyString = QString("READY: %1 points").arg(points);
+ if (allPlayersWaiting()) {