summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2016-07-03 01:55:20 -0500
committerJohn Fultz <jfultz@wolfram.com>2016-07-03 01:55:20 -0500
commit0cda99549250c87ab9c9b20044767a7615e279c6 (patch)
treea53d4b1002ff6ae29f63e16aab25dab3082ba9ea
parent63e3348ace58bb8cc990d418269df61f640fc234 (diff)
Add a scoring option preference.
A checkbox in the preferences dialog now allows you to configure Quackle so that plays with illegal words which are left unchallenged score zero. Obviously, off by default. But useful for entering games as part of the Marty Gabriel/Scott Garner world record scoring attempt. This is apparently what the Guinness folks are looking for.
-rw-r--r--quacker/configpages.cpp4
-rw-r--r--quacker/configpages.h1
-rw-r--r--quacker/quacker.cpp8
-rw-r--r--quacker/quackersettings.cpp2
-rw-r--r--quackleio/util.cpp2
-rw-r--r--quackleio/util.h1
6 files changed, 16 insertions, 2 deletions
diff --git a/quacker/configpages.cpp b/quacker/configpages.cpp
index c246797..ee807fd 100644
--- a/quacker/configpages.cpp
+++ b/quacker/configpages.cpp
@@ -96,10 +96,12 @@ InterfacePage::InterfacePage(QWidget *parent)
QGroupBox *miscellanyGroup = new QGroupBox(tr("Miscellany"));
m_vowelFirstCheck = new QCheckBox(tr("&Vowel-first alphabetizing"));
m_octothorpCheck = new QCheckBox(tr("&Octothorp British words"));
+ m_scoreInvalidAsZero = new QCheckBox(tr("&Score 0 for plays with illegal words"));
QGridLayout *miscellanyLayout = new QGridLayout;
miscellanyLayout->addWidget(m_vowelFirstCheck, 0, 0);
miscellanyLayout->addWidget(m_octothorpCheck, 1, 0);
+ miscellanyLayout->addWidget(m_scoreInvalidAsZero, 2, 0);
miscellanyGroup->setLayout(miscellanyLayout);
QVBoxLayout *mainLayout = new QVBoxLayout;
@@ -116,6 +118,7 @@ void InterfacePage::readConfig()
m_verboseLabelsCheck->setChecked(QuackerSettings::self()->verboseLabels);
m_scoreLabelsCheck->setChecked(QuackerSettings::self()->scoreLabels);
m_octothorpCheck->setChecked(QuackleIO::UtilSettings::self()->octothorpBritish);
+ m_scoreInvalidAsZero->setChecked(QuackleIO::UtilSettings::self()->scoreInvalidAsZero);
}
void InterfacePage::writeConfig()
@@ -125,5 +128,6 @@ void InterfacePage::writeConfig()
QuackerSettings::self()->verboseLabels = m_verboseLabelsCheck->isChecked();
QuackerSettings::self()->scoreLabels = m_scoreLabelsCheck->isChecked();
QuackleIO::UtilSettings::self()->octothorpBritish = m_octothorpCheck->isChecked();
+ QuackleIO::UtilSettings::self()->scoreInvalidAsZero = m_scoreInvalidAsZero->isChecked();
}
diff --git a/quacker/configpages.h b/quacker/configpages.h
index 6d02ec0..6b61375 100644
--- a/quacker/configpages.h
+++ b/quacker/configpages.h
@@ -52,6 +52,7 @@ private:
QCheckBox *m_verboseLabelsCheck;
QCheckBox *m_scoreLabelsCheck;
QCheckBox *m_octothorpCheck;
+ QCheckBox *m_scoreInvalidAsZero;
QComboBox *m_britishColoringCombo;
};
diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp
index 69bf9f9..be70c14 100644
--- a/quacker/quacker.cpp
+++ b/quacker/quacker.cpp
@@ -297,6 +297,7 @@ void TopLevel::setCandidateMove(const Quackle::Move &move)
if (!m_game->hasPositions() || (move.action == Quackle::Move::Place && move.tiles().empty()))
return;
+ bool playHasIllegalWords = false;
Quackle::Move prettiedMove(move);
m_game->currentPosition().ensureMoveTilesDoNotIncludePlayThru(prettiedMove);
m_game->currentPosition().ensureMovePrettiness(prettiedMove);
@@ -367,6 +368,8 @@ void TopLevel::setCandidateMove(const Quackle::Move &move)
{
prettiedMove.setIsChallengedPhoney(true);
}
+ else
+ playHasIllegalWords = true;
}
validityFlags ^= Quackle::GamePosition::UnacceptableWord;
@@ -384,7 +387,10 @@ void TopLevel::setCandidateMove(const Quackle::Move &move)
if (!carryOn)
return;
- m_game->currentPosition().scoreMove(prettiedMove);
+ if (playHasIllegalWords && QuackleIO::UtilSettings::self()->scoreInvalidAsZero)
+ prettiedMove.score = 0;
+ else
+ m_game->currentPosition().scoreMove(prettiedMove);
m_game->currentPosition().addAndSetMoveMade(prettiedMove);
switchToTab(ChoicesTabIndex);
ensureUpToDateSimulatorMoveList();
diff --git a/quacker/quackersettings.cpp b/quacker/quackersettings.cpp
index 1889848..510e43a 100644
--- a/quacker/quackersettings.cpp
+++ b/quacker/quackersettings.cpp
@@ -45,6 +45,7 @@ void QuackerSettings::readSettings()
scoreLabels = settings.value("quackle/settings/score-labels", scoreLabels).toBool();
QuackleIO::UtilSettings::self()->vowelFirst = settings.value("quackle/settings/vowel-first", QuackleIO::UtilSettings::self()->vowelFirst).toBool();
QuackleIO::UtilSettings::self()->octothorpBritish = settings.value("quackle/settings/octothorp-british", QuackleIO::UtilSettings::self()->octothorpBritish).toBool();
+ QuackleIO::UtilSettings::self()->scoreInvalidAsZero = settings.value("quackle/settings/score-invalid-as-zero", QuackleIO::UtilSettings::self()->scoreInvalidAsZero).toBool();
m_letterboxSettings.readSettings();
}
@@ -57,6 +58,7 @@ void QuackerSettings::writeSettings()
settings.setValue("quackle/settings/score-labels", scoreLabels);
settings.setValue("quackle/settings/vowel-first", QuackleIO::UtilSettings::self()->vowelFirst);
settings.setValue("quackle/settings/octothorp-british", QuackleIO::UtilSettings::self()->octothorpBritish);
+ settings.setValue("quackle/settings/score-invalid-as-zero", QuackleIO::UtilSettings::self()->scoreInvalidAsZero);
m_letterboxSettings.writeSettings();
}
diff --git a/quackleio/util.cpp b/quackleio/util.cpp
index 817edac..5530f16 100644
--- a/quackleio/util.cpp
+++ b/quackleio/util.cpp
@@ -34,7 +34,7 @@ UtilSettings *UtilSettings::self()
}
UtilSettings::UtilSettings()
- : octothorpBritish(true), vowelFirst(false)
+ : octothorpBritish(true), vowelFirst(false), scoreInvalidAsZero(false)
{
m_self = this;
}
diff --git a/quackleio/util.h b/quackleio/util.h
index 10a57a2..62545bb 100644
--- a/quackleio/util.h
+++ b/quackleio/util.h
@@ -42,6 +42,7 @@ public:
bool octothorpBritish;
bool vowelFirst;
+ bool scoreInvalidAsZero;
private:
static UtilSettings *m_self;