77 connect(
this, &ItemMarketModel::isBuyModeChanged,
this, &ItemMarketModel::isAnyChanged);
78 connect(
this, &ItemMarketModel::isMoneyCurrencyChanged,
this, &ItemMarketModel::isAnyChanged);
79 connect(
this, &ItemMarketModel::isExchangeModeChanged,
this, &ItemMarketModel::isAnyChanged);
104 if (!index.isValid())
126 return item->inStockCount();
128 return item->canSell();
130 return item->itemWorth();
132 return item->whichType();
134 return item->stackCount();
136 return item->onCartLeft();
138 return item->getCartCount();
140 return item->cartWorth();
142 return item->totalStackCount();
144 return item->totalWorth();
146 return item->canCheckout();
148 return item->requestFilter();
150 return item->exclude;
152 return item->moneyLeftover();
158 return item->viewTag;
160 return item->cartSignVal;
162 auto money = qobject_cast<ItemMarketEntryMoney*>(item);
163 return money ? money->forceDir : -1;
166 return item->infoText();
173 QHash<int, QByteArray> roles;
215 item->setCartCount(value.toInt());
216 dataChanged(index, index);
291 if(el->onCartLeft() < 0) {
326 auto money = qobject_cast<ItemMarketEntryMoney*>(el);
328 m += money->moneyDelta();
339 auto money = qobject_cast<ItemMarketEntryMoney*>(el);
341 c += money->coinsDelta();
363 auto money = qobject_cast<ItemMarketEntryMoney*>(el);
366 net += money->buying() ? money->onCart : -money->onCart;
376 auto money = qobject_cast<ItemMarketEntryMoney*>(el);
379 if(money->buying()) buyRow = money;
else sellRow = money;
381 if(buyRow ==
nullptr || sellRow ==
nullptr)
386 int want = net + deltaCoins;
394 }
else if(want < 0) {
398 buyRow->onCartChanged();
399 sellRow->onCartChanged();
430 static const QSet<int> kBuyable = {
481 return kBuyable.contains(el->
getInd());
490 const int i = el->
getInd();
491 return i == 60 || i == 61 || i == 62;
590 collator.setNumericMode(
true);
591 collator.setIgnorePunctuation(
true);
593 auto sortByName = [&collator](QVector<ItemDBEntry*>& v)
595 std::sort(v.begin(), v.end(),
598 return collator.compare(a->getReadable(), b->getReadable()) < 0;
602 auto appendItems = [
this](
const QVector<ItemDBEntry*>& v)
608 QVector<ItemDBEntry*> tmp;
617 if(el->isGameCornerExclusive())
625 if(el->getType() ==
"pokemon")
643 QVector<ItemDBEntry*> normalItems;
644 QVector<ItemDBEntry*> vendingItems;
645 QVector<ItemDBEntry*> specialItems;
651 vendingItems.append(el);
653 normalItems.append(el);
655 specialItems.append(el);
659 sortByName(normalItems);
660 appendItems(normalItems);
663 sortByName(vendingItems);
664 appendItems(vendingItems);
667 sortByName(specialItems);
668 appendItems(specialItems);
696 if(path !=
"qrc:/ui/app/screens/non-modal/Pokemart.qml")
int getBuyPrice() const
The buy rate (backs getBuyPrice).
static GameCornerDB * inst()
< Number of prize entries.
int getSellPrice() const
The sell rate (half the buy rate).
Market row for a Game Corner Pokemon prize (bought with coins).
Market row that just shows a message (e.g.
Market row representing the player's money/coins balance.
@ DirToMoney
Coins => Money (the "sell" direction).
@ DirToCoins
Money => Coins (the "buy" direction).
virtual int onCartLeft() override
Subtype: how many more may be added.
Market row for one of the player's own items being sold.
Market row for an item the player can buy from the store.
static QVector< ItemMarketEntry * > * activeList
Current model's live rows.
static bool * isMoneyCurrency
Shared: current currency mode.
static PlayerBasics * player
Shared: player money/coins.
int onCart
Backing cart quantity.
static bool * isBuyMode
Shared: current buy/sell mode.
Storage * storage
PC storage (for received Pokemon).
void buildExchangeList()
Build the money<->coins exchange rows (both directions).
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Edit a row (cart count).
ItemStorageBox * itemStorage
The PC item box.
bool buyableInGame(ItemDBEntry *el) const
Is el sold by a reachable Gen-1 vendor (Normal vs Special)?
virtual QHash< int, QByteArray > roleNames() const override
Role -> QML name.
PlayerBasics * basics
Player money/coins.
void exchangeAdjust(int deltaCoins)
Nudge the net (+Coins = +1, +Money = -1).
void clearList()
Empty the row cache.
bool vendorListItem(ItemDBEntry *el)
Should el appear in the store list (has a price here)?
virtual int rowCount(const QModelIndex &parent) const override
Row count.
bool isVendingItem(ItemDBEntry *el) const
Is el a Celadon vending-machine drink (its own group)?
void checkout()
Apply the cart transaction to the save.
virtual QVariant data(const QModelIndex &index, int role) const override
Row+role value.
ItemStorageBox * itemBag
The player's bag.
void buildPlayerItemList()
Build rows from the player's items.
ItemMarketModel(ItemStorageBox *itemBag, ItemStorageBox *itemStorage, PlayerBasics *basics, Router *router, PlayerPokemon *playerPokemon, Storage *storage, SaveFile *file)
void buildList()
Build the rows for the current mode.
void pageOpening(QString path)
Hook when the market page opens.
void reUpdateAll()
Rebuild + recompute everything.
Router * router
For page hooks.
void onReUpdateValues()
Recompute the derived totals.
QVector< ItemMarketEntry * > itemListCache
The current market rows.
void buildMartItemList()
Build rows from the store stock.
PlayerPokemon * playerPokemon
Party (for received Pokemon).
int exchangeNet()
+N buying N coins / -N selling N coins.
SaveFile * file
The live save.
A container of Items – either the trainer's bag or a PC item box.
static ItemsDB * inst()
< Number of items.
The trainer's headline values: name, ID, money, coins, badges, starter.
The player's active party – a specialized PokemonStorageBox.
Screen navigation for the UI – the QML StackView's controller.
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
void dataExpandedChanged(SaveFileExpanded *expanded)
SAV file has changed but the old expansion has not been replaced with exxpansion of new data.
The PC: the item storage box and all 12 Pokemon boxes.
One item's static data: name/flags, pricing, and where it's used.
bool isGameCornerExclusive() const
int buyPriceMoney() const
int buyPriceCoins() const