Topping: add a preference to set the penalty value in case of timeout

This commit is contained in:
Olivier Teulière 2013-01-13 22:52:52 +01:00
parent 7e9dab2e9b
commit ec0cfb47fa
4 changed files with 61 additions and 3 deletions

View file

@ -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<int>(tmpConf, *m_conf, "arbitration.solo-value");
copySetting<int>(tmpConf, *m_conf, "arbitration.penalty-value");
copySetting<int>(tmpConf, *m_conf, "arbitration.warnings-limit");
copySetting<int>(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
}

View file

@ -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();

View file

@ -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());

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>474</width>
<height>630</height>
<height>699</height>
</rect>
</property>
<property name="windowTitle">
@ -489,6 +489,45 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>_(&quot;Topping mode&quot;)</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>_(&quot;Additional penalty given when the timer expires:&quot;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBoxToppingExpPenalty">
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>60</number>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">