-Player::Player(QWidget* parent) {
- theLabel = new QLabel (parent);
- parent->layout()->addWidget(theLabel);
+void Player::setLabel(QString body, QString color)
+{
+ QString text = QString("<font color=%1>").arg(color);
+ if (state >= Waiting) {
+ text += QString("<font size=-3>%1:</font><br>").arg(Qt::escape(name));
+ }
+ text += Qt::escape(body);
+ theLabel->setText(text);
+}
+
+void Player::wordComplete(int points)
+{
+ score += points;
+ state = Waiting;
+ setLabel(currentWord, READY_COLOR);
+}
+
+QString Player::getCurrentWord() {
+ Q_ASSERT(state == Typing);
+ return currentWord;
+}
+
+void Player::nextWord() {
+ Q_ASSERT(state == Waiting);
+ currentWord = "";
+ setLabel("<Warte auf Eingabe>", BASE_COLOR);
+ state = Typing;