}
void MultypoWindow::nextWord() {
- QByteArray tmp = words.readLine();
+ QByteArray tmp = words.readLine().trimmed();
QString word = QString::fromUtf8(tmp);
mainLabel->setText(word);
+ typingPlayers = players.size();
}
void MultypoWindow::handleKeyPress(int device, QString string)
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);
+ }
} else { // name entering phase
bool allHaveNames = true;
for (QMap<int, Player*>::Iterator it = players.begin(); it != players.end(); ++it) {
Player::Player(QWidget* parent) {
theLabel = new QLabel (parent);
parent->layout()->addWidget(theLabel);
+ modifyable = true;
}
return currentLine;
}
+void Player::setWaiting(QString labeltext) {
+ theLabel->setText(labeltext);
+ modifyable = false;
+}
+
void Player::resetText() {
currentLine.clear();
theLabel->setText(currentLine);
+ modifyable = true;
}
void Player::handleKey(QString str) {
+ if (!modifyable)
+ return;
if (str.length() == 1) {
currentLine += str;
} else if (!hasName() && str == "Return") {