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();
const PlayedRack &newRack =
helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_NEW);
helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_ALL);
setGameAndPlayersRack(newRack);
}

View file

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

View file

@ -179,6 +179,9 @@ Settings::Settings()
// ============== Arbitration mode options ==============
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
arbitration.add("default-penalty", Setting::TypeInt) = 5;
@ -198,6 +201,7 @@ Settings::Settings()
copySetting<int>(tmpConf, *m_conf, "duplicate.solo-value");
copySetting<bool>(tmpConf, *m_conf, "duplicate.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.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"
"Use a value of -1 to disable the alert.\n"
"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"
"The returned results will always be the best ones.\n"
"Use 0 to disable the limit (warning: searches yielding many "
"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());
// Auto-completion on the dictionary path
@ -115,6 +117,7 @@ PrefsDialog::PrefsDialog(QWidget *iParent)
// Arbitration settings
bool autoAssignMaster = qs.value(kARBIT_AUTO_MASTER, false).toBool();
checkBoxArbitAutoMaster->setChecked(autoAssignMaster);
checkBoxArbitFillRack->setChecked(Settings::Instance().getBool("arbitration.fill-rack"));
bool linkArbit7P1 = qs.value(kARBIT_LINK_7P1, false).toBool();
checkBoxArbitLink7P1->setChecked(linkArbit7P1);
spinBoxArbitSearchLimit->setValue(Settings::Instance().getInt("arbitration.search-limit"));
@ -204,6 +207,8 @@ void PrefsDialog::updateSettings()
// Arbitration settings
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())
{
// We need to (dis)connect the arbitration widget with the dictionary

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>443</width>
<height>761</height>
<height>789</height>
</rect>
</property>
<property name="windowTitle">
@ -323,14 +323,18 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<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">
<string>_(&quot;Choose a Master move automatically&quot;)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxArbitFillRack">
<property name="text">
<string>_(&quot;Propose a new rack automatically&quot;)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxArbitLink7P1">
<property name="toolTip">