- 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) {
+ 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();
+ player->wordComplete(points);
+ QString readyString = QString("READY: %1 points").arg(points);
+ if (allPlayersWaiting()) {