diff --git a/game/settings.cpp b/game/settings.cpp index bdc45b2..689ae85 100644 --- a/game/settings.cpp +++ b/game/settings.cpp @@ -252,6 +252,11 @@ Settings::Settings() // Number of search results kept in a search arbitration.add("search-limit", Setting::TypeInt) = 100; + // ============== Topping mode options ============== + Setting &topping = m_conf->getRoot().add("topping", Setting::TypeGroup); + + topping.add("timeout-penalty", Setting::TypeInt) = 60; + // Try to read the values from the configuration file try { @@ -272,6 +277,7 @@ Settings::Settings() copySetting(tmpConf, *m_conf, "arbitration.solo-value"); copySetting(tmpConf, *m_conf, "arbitration.penalty-value"); copySetting(tmpConf, *m_conf, "arbitration.warnings-limit"); + copySetting(tmpConf, *m_conf, "topping.timeout-penalty"); } catch (const std::exception &e) { @@ -365,6 +371,8 @@ int Settings::getInt(const string &iName) const return 5; else if (iName == "arbitration.warnings-limit") return 3; + else if (iName == "arbitration.timeout-penalty") + return 60; return 0; #endif } diff --git a/game/topping.cpp b/game/topping.cpp index 1054b7b..fd7a04a 100644 --- a/game/topping.cpp +++ b/game/topping.cpp @@ -131,8 +131,9 @@ void Topping::turnTimeOut() // Give a penalty to the player // XXX: should we give the penalty directly in the NO_MOVE move? - // TODO: get the value from the preferences instead of hard-coding - addPenalty(180); + int penalty = Settings::Instance().getInt("topping.timeout-penalty"); + if (penalty > 0) + addPenalty(penalty); // Next turn endTurn(); diff --git a/qt/prefs_dialog.cpp b/qt/prefs_dialog.cpp index 95430a0..cb389ac 100644 --- a/qt/prefs_dialog.cpp +++ b/qt/prefs_dialog.cpp @@ -101,6 +101,8 @@ PrefsDialog::PrefsDialog(QWidget *iParent) spinBoxArbitSearchLimit->setToolTip(spinBoxTrainSearchLimit->toolTip()); spinBoxArbitWarnLimit->setToolTip(_q("Maximal number of \"acceptable\" warnings.\n" "Any additional warning will give a penalty to the player.")); + spinBoxToppingExpPenalty->setToolTip(_q("Number of points added to the player score when the timer expires.\n" + "Set it to 0 if you don't want any penalty.")); // Auto-completion on the dictionary path QCompleter *completer = new QCompleter(this); @@ -159,6 +161,9 @@ PrefsDialog::PrefsDialog(QWidget *iParent) spinBoxArbitWarnLimit->setValue(Settings::Instance().getInt("arbitration.warnings-limit")); spinBoxArbitSearchLimit->setValue(Settings::Instance().getInt("arbitration.search-limit")); + // Topping settings + spinBoxToppingExpPenalty->setValue(Settings::Instance().getInt("topping.timeout-penalty")); + // Confirmations bool confoStartGame = qs.value(kCONFO_START_GAME, true).toBool(); checkBoxConfoStartGame->setChecked(confoStartGame); @@ -291,6 +296,11 @@ void PrefsDialog::updateSettings() Settings::Instance().setInt("arbitration.warnings-limit", spinBoxArbitWarnLimit->value()); + // Topping settings + Settings::Instance().setInt("topping.timeout-penalty", + spinBoxToppingExpPenalty->value()); + + // Confirmations settings qs.setValue(kCONFO_START_GAME, checkBoxConfoStartGame->isChecked()); qs.setValue(kCONFO_LOAD_GAME, checkBoxConfoLoadGame->isChecked()); diff --git a/qt/ui/prefs_dialog.ui b/qt/ui/prefs_dialog.ui index df68566..f4b4a12 100644 --- a/qt/ui/prefs_dialog.ui +++ b/qt/ui/prefs_dialog.ui @@ -7,7 +7,7 @@ 0 0 474 - 630 + 699 @@ -489,6 +489,45 @@ + + + + _("Topping mode") + + + + + + _("Additional penalty given when the timer expires:" + + + + + + + 9999 + + + 60 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + +