void MultypoWindow::nextWord() {
QByteArray tmp = words.readLine().trimmed();
QString word = QString::fromUtf8(tmp);
- mainLabel->setText(word);
- typingPlayers = players.size();
+ if (word.isEmpty()) { // game over
+ qDebug() << "TODO: implement gameover";
+ exit (0);
+ } else {
+ resetPlayerText();
+ mainLabel->setText(word);
+ typingPlayers = players.size();
+ }
}
void MultypoWindow::handleKeyPress(int device, QString string)
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 (int i = 0; i < ndevices; ++i) {
if (devices[i].use != XIMasterKeyboard) continue;
qDebug() << "Found master keyboard with ID" << devices[i].deviceid;
- //XISetFocus(dpy, devices[i].deviceid, winId(), CurrentTime);
+ XISetFocus(dpy, devices[i].deviceid, winId(), CurrentTime);
}
XIFreeDeviceInfo(devices);