mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-15 06:23:14 -08:00
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)
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user