Arbitration: new option to deactivate the automatic random rack

This commit is contained in:
Olivier Teulière 2012-04-16 23:02:11 +02:00
parent c891671588
commit c4fad05ffd
5 changed files with 31 additions and 12 deletions

View file

@ -49,7 +49,7 @@ void Arbitration::setRackRandom()
undoCurrentRack(); undoCurrentRack();
const PlayedRack &newRack = const PlayedRack &newRack =
helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_NEW); helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_ALL);
setGameAndPlayersRack(newRack); setGameAndPlayersRack(newRack);
} }

View file

@ -129,14 +129,21 @@ void Duplicate::start()
m_currPlayer = 0; m_currPlayer = 0;
// Complete the racks // Complete the racks
bool isArbitration = getParams().getMode() == GameParams::kARBITRATION;
try try
{ {
// Reset the master move // Reset the master move
setMasterMove(Move()); setMasterMove(Move());
const PlayedRack &newRack = bool fillRacks = Settings::Instance().getBool("arbitration.fill-rack");
helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_NEW); if (isArbitration && !fillRacks)
setGameAndPlayersRack(newRack); setGameAndPlayersRack(getHistory().getCurrentRack());
else
{
const PlayedRack &newRack =
helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_NEW);
setGameAndPlayersRack(newRack);
}
} }
catch (EndGameException &e) catch (EndGameException &e)
{ {
@ -144,7 +151,6 @@ void Duplicate::start()
return; return;
} }
bool isArbitration = getParams().getMode() == GameParams::kARBITRATION;
if (!isArbitration) if (!isArbitration)
{ {
// Little hack to handle duplicate games with only AI players. // Little hack to handle duplicate games with only AI players.

View file

@ -179,6 +179,9 @@ Settings::Settings()
// ============== Arbitration mode options ============== // ============== Arbitration mode options ==============
Setting &arbitration = m_conf->getRoot().add("arbitration", Setting::TypeGroup); Setting &arbitration = m_conf->getRoot().add("arbitration", Setting::TypeGroup);
// If true, a random rack is defined, otherwise the rack is left untouched
arbitration.add("fill-rack", Setting::TypeBoolean) = true;
// Default value of a penalty // Default value of a penalty
arbitration.add("default-penalty", Setting::TypeInt) = 5; arbitration.add("default-penalty", Setting::TypeInt) = 5;
@ -198,6 +201,7 @@ Settings::Settings()
copySetting<int>(tmpConf, *m_conf, "duplicate.solo-value"); copySetting<int>(tmpConf, *m_conf, "duplicate.solo-value");
copySetting<bool>(tmpConf, *m_conf, "duplicate.reject-invalid"); copySetting<bool>(tmpConf, *m_conf, "duplicate.reject-invalid");
copySetting<bool>(tmpConf, *m_conf, "freegame.reject-invalid"); copySetting<bool>(tmpConf, *m_conf, "freegame.reject-invalid");
copySetting<bool>(tmpConf, *m_conf, "arbitration.fill-rack");
copySetting<int>(tmpConf, *m_conf, "arbitration.search-limit"); copySetting<int>(tmpConf, *m_conf, "arbitration.search-limit");
copySetting<int>(tmpConf, *m_conf, "arbitration.default-penalty"); copySetting<int>(tmpConf, *m_conf, "arbitration.default-penalty");
} }

View file

@ -66,13 +66,15 @@ PrefsDialog::PrefsDialog(QWidget *iParent)
spinBoxTimerAlert->setToolTip(_q("Number of remaining seconds when an alert is triggered.\n" spinBoxTimerAlert->setToolTip(_q("Number of remaining seconds when an alert is triggered.\n"
"Use a value of -1 to disable the alert.\n" "Use a value of -1 to disable the alert.\n"
"Changing this value will reset the timer.")); "Changing this value will reset the timer."));
checkBoxArbitAutoMaster->setToolTip(_q("If checked, a Master move will be selected "
"by default when searching the results.\n"
"It is still possible to change the Master move afterwards."));
spinBoxTrainSearchLimit->setToolTip(_q("Maximum number of results returned by a search.\n" spinBoxTrainSearchLimit->setToolTip(_q("Maximum number of results returned by a search.\n"
"The returned results will always be the best ones.\n" "The returned results will always be the best ones.\n"
"Use 0 to disable the limit (warning: searches yielding many " "Use 0 to disable the limit (warning: searches yielding many "
"results could be very slow in this case!).")); "results could be very slow in this case!)."));
checkBoxArbitAutoMaster->setToolTip(_q("If checked, a Master move will be selected "
"by default when searching the results.\n"
"It is still possible to change the Master move afterwards."));
checkBoxArbitFillRack->setToolTip(_q("If checked, the rack will be completed with random letters. \n"
"Uncheck this option if you prefer to choose the letters yourself."));
spinBoxArbitSearchLimit->setToolTip(spinBoxTrainSearchLimit->toolTip()); spinBoxArbitSearchLimit->setToolTip(spinBoxTrainSearchLimit->toolTip());
// Auto-completion on the dictionary path // Auto-completion on the dictionary path
@ -115,6 +117,7 @@ PrefsDialog::PrefsDialog(QWidget *iParent)
// Arbitration settings // Arbitration settings
bool autoAssignMaster = qs.value(kARBIT_AUTO_MASTER, false).toBool(); bool autoAssignMaster = qs.value(kARBIT_AUTO_MASTER, false).toBool();
checkBoxArbitAutoMaster->setChecked(autoAssignMaster); checkBoxArbitAutoMaster->setChecked(autoAssignMaster);
checkBoxArbitFillRack->setChecked(Settings::Instance().getBool("arbitration.fill-rack"));
bool linkArbit7P1 = qs.value(kARBIT_LINK_7P1, false).toBool(); bool linkArbit7P1 = qs.value(kARBIT_LINK_7P1, false).toBool();
checkBoxArbitLink7P1->setChecked(linkArbit7P1); checkBoxArbitLink7P1->setChecked(linkArbit7P1);
spinBoxArbitSearchLimit->setValue(Settings::Instance().getInt("arbitration.search-limit")); spinBoxArbitSearchLimit->setValue(Settings::Instance().getInt("arbitration.search-limit"));
@ -204,6 +207,8 @@ void PrefsDialog::updateSettings()
// Arbitration settings // Arbitration settings
qs.setValue(kARBIT_AUTO_MASTER, checkBoxArbitAutoMaster->isChecked()); qs.setValue(kARBIT_AUTO_MASTER, checkBoxArbitAutoMaster->isChecked());
Settings::Instance().setBool("arbitration.fill-rack",
checkBoxArbitFillRack->isChecked());
if (qs.value(kARBIT_LINK_7P1, false).toBool() != checkBoxArbitLink7P1->isChecked()) if (qs.value(kARBIT_LINK_7P1, false).toBool() != checkBoxArbitLink7P1->isChecked())
{ {
// We need to (dis)connect the arbitration widget with the dictionary // We need to (dis)connect the arbitration widget with the dictionary

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>443</width> <width>443</width>
<height>761</height> <height>789</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -323,14 +323,18 @@
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QCheckBox" name="checkBoxArbitAutoMaster"> <widget class="QCheckBox" name="checkBoxArbitAutoMaster">
<property name="toolTip">
<string>_(&quot;If checked, a Master move will be selected by default when searching the results. It is still possible to change the Master move afterwards.&quot;)</string>
</property>
<property name="text"> <property name="text">
<string>_(&quot;Choose a Master move automatically&quot;)</string> <string>_(&quot;Choose a Master move automatically&quot;)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBoxArbitFillRack">
<property name="text">
<string>_(&quot;Propose a new rack automatically&quot;)</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="checkBoxArbitLink7P1"> <widget class="QCheckBox" name="checkBoxArbitLink7P1">
<property name="toolTip"> <property name="toolTip">