- 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)
+ qDebug() << "checking for game started";
+ if (!players.empty() && allPlayersWaiting()) {
+ nextWord();
+ }
+ }
+ else if (state == Playing) { // all players are waiting or typing
+ qDebug() << "current player line" << player->getCurrentWord();
+ qDebug() << "current word" << currentWord;
+ 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()) {