本文整理汇总了C++中Items::first方法的典型用法代码示例。如果您正苦于以下问题:C++ Items::first方法的具体用法?C++ Items::first怎么用?C++ Items::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Items
的用法示例。
在下文中一共展示了Items::first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
QList<ShopTemplateManager::ShopTemplateSection> ShopTemplateManager::FetchFromItemsKey(const QString &key, const Items &items, QHash<QString, QString> *options) {
QList<ShopTemplateManager::ShopTemplateSection> result;
if (items.size() > 0){
Items matchingItems;
bool includeNoBuyouts = options->contains("include.ignored");
ShopTemplateContainType containType = CONTAIN_TYPE_NONE;
if (key == "everything") {
matchingItems = items;
}
else if (key.startsWith("stash:")) {
int index = key.indexOf(":");
QString name = (index + 1 >= key.length()) ? "" : key.mid(index + 1);
if (!name.isEmpty()) {
for (const std::shared_ptr<Item> &item : items) {
if (QString::fromStdString(item->location().GetLabel()).compare(name, Qt::CaseInsensitive) == 0) {
matchingItems.push_back(item);
}
}
}
}
else {
Items pool = items;
QStringList keyParts = key.split("+", QString::SkipEmptyParts);
for (QString part : keyParts) {
if (templateMatchers.contains(part)) {
matchingItems = FindMatchingItems(pool, part);
}
else {
// todo(novynn): phase these out? Prefer {Normal+Helmet} over {NormalHelmet}
bool matchedRarity = false;
const QStringList rarities = {"normal", "magic", "rare", "unique"};
for (QString rarity : rarities) {
if (part.startsWith(rarity)) {
QString type = part.mid(rarity.length());
matchingItems = FindMatchingItems(pool, rarity);
matchingItems = FindMatchingItems(matchingItems, type);
matchedRarity = true;
}
}
if (matchedRarity) continue;
if (part.endsWith("gems")) {
if (part == "gems" || part == "allgems") {
matchingItems = FindMatchingItems(pool, "gems");
}
else {
const QStringList gemTypes = {"AoE", "Attack", "Aura", "Bow", "Cast", "Chaining", "Chaos",
"Cold", "Curse", "Duration", "Fire", "Lightning", "Melee", "Mine", "Minion",
"Movement", "Projectile", "Spell", "Totem", "Trap", "Support"};
for (QString gemType : gemTypes) {
if (!part.startsWith(gemType, Qt::CaseInsensitive)) continue;
// This will never just be first key (?)
QString firstKey = gemType.toLower() + "gems";
matchingItems = FindMatchingItems(pool, firstKey);
if (part != firstKey) {
// supportlightninggems
QString secondKey = part.mid(gemType.length());
matchingItems = FindMatchingItems(matchingItems, secondKey);
}
}
}
}
}
pool = matchingItems;
}
}
// Only select items from your stash unless specified
if (!options->contains("include.character")) {
matchingItems = Items::fromStdVector(
from(matchingItems.toStdVector())
.where([](const std::shared_ptr<Item> item) { return item->location().type() == ItemLocationType::STASH; })
.toVector()
);
}
if (matchingItems.size() == 0)
return result;
if (containType == CONTAIN_TYPE_NONE && options->contains("wrap")) containType = CONTAIN_TYPE_WRAP;
if (containType == CONTAIN_TYPE_NONE && options->contains("group")) containType = CONTAIN_TYPE_GROUP;
switch (containType) {
case (CONTAIN_TYPE_WRAP): {
QString header = "Items";
Buyout buyout = {};
if (options->contains("header")) {
header = options->value("header");
}
const std::shared_ptr<Item> first = matchingItems.first();
if (parent_->buyout_manager().Exists(*first)) buyout = parent_->buyout_manager().Get(*first);
//.........这里部分代码省略.........