From f10f9ada3a34a22a6766bd788f3ebf788e15d903 Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Sun, 30 Jun 2019 18:08:07 +0200 Subject: [PATCH] properly capitalize set types like Duel Deck and From the Vault (#3770) * properly capitalize set types like Duel Deck and From the Vault * add more tiny words * update macos for travis (slower build times) --- .travis.yml | 1 + oracle/src/oracleimporter.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9a0d3ce8..36eafae3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -96,6 +96,7 @@ matrix: - protobuf - qt - xz + update: true script: bash ./.ci/travis-compile.sh --server --install --debug - name: macOS (Release) diff --git a/oracle/src/oracleimporter.cpp b/oracle/src/oracleimporter.cpp index 898adf9a..32310268 100644 --- a/oracle/src/oracleimporter.cpp +++ b/oracle/src/oracleimporter.cpp @@ -47,7 +47,20 @@ bool OracleImporter::readSetsFromByteArray(const QByteArray &data) setType = map.value("type").toString(); // capitalize set type if (setType.length() > 0) { - setType[0] = setType[0].toUpper(); + // basic grammar for words that aren't capitalized, like in "From the Vault" + const QStringList noCapitalize = {"the", "a", "an", "on", "to", "for", "of", "in", "and", "with", "or"}; + QStringList words = setType.split("_"); + setType.clear(); + bool first = false; + for (auto &item : words) { + if (first && noCapitalize.contains(item)) { + setType += item + QString(" "); + } else { + setType += item[0].toUpper() + item.mid(1, -1) + QString(" "); + first = true; + } + } + setType = setType.trimmed(); } if (!nonEnglishSets.contains(shortName)) { releaseDate = map.value("releaseDate").toDate();