50 return (
data !=
nullptr) ?
data->getInfo() : QString();
70 int stackPartialBag = 0;
71 int stackPartialBox = 0;
74 Item* currentStackBag =
nullptr;
75 Item* currentStackBox =
nullptr;
79 for(
auto el :
toBag->items) {
80 if(el->ind ==
data->getInd() && el->amount < 99) {
86 for(
auto el :
toBox->items) {
87 if(el->ind ==
data->getInd() && el->amount < 99) {
95 if(currentStackBag !=
nullptr) {
97 int totalStackLeft = 99 - currentStackBag->
amount;
102 if(_onCart > totalStackLeft) {
103 stackPartialBag = totalStackLeft;
104 _onCart -= totalStackLeft;
110 stackPartialBag = _onCart;
118 if(currentStackBox !=
nullptr && _onCart > 0) {
119 int totalStackLeft = 99 - currentStackBox->
amount;
120 if(_onCart > totalStackLeft) {
121 stackPartialBox = totalStackLeft;
122 _onCart -= totalStackLeft;
125 stackPartialBox = _onCart;
164 return data->getReadable();
187 return data->buyPriceMoney();
189 return data->buyPriceCoins();
216 int combinedBoxSpace =
toBox->itemsMax() +
toBag->itemsMax();
217 int combinedBoxUsed =
toBox->itemsCount() +
toBag->itemsCount();
220 int stackSpaceBefore = combinedBoxSpace - combinedBoxUsed;
223 int stackSpaceLeftAfter = stackSpaceBefore - totalStackFromOthers - stk.full;
227 ret = stackSpaceLeftAfter * 99;
235 if(stk.partialElBag !=
nullptr) {
236 ret += 99 - stk.partialBag - stk.partialElBag->amount;
238 if((99 - stk.partialBag - stk.partialElBag->amount) < 0)
239 qDebug() <<
"Negative Amount" << (99 - stk.partialBag - stk.partialElBag->amount);
242 if(stk.partialElBox !=
nullptr) {
243 ret += 99 - stk.partialBox - stk.partialElBox->amount;
245 if((99 - stk.partialBox - stk.partialElBox->amount) < 0)
246 qDebug() <<
"Negative Amount" << (99 - stk.partialBox - stk.partialElBox->amount);
255 return qMin(ret, maxAmountFromMoney);
279 if(stk.partialElBag !=
nullptr) {
280 stk.partialElBag->amount += stk.partialBag;
281 stk.partialElBag->amountChanged();
284 if(stk.partialElBox !=
nullptr) {
285 stk.partialElBox->amount += stk.partialBox;
286 stk.partialElBox->amountChanged();
298 for(
int i = 0; i < stk.full &&
onCart > 0 && (
toBag->itemsCount() <
toBag->itemsMax()); i++) {
301 toBag->itemInsertChange();
302 toBag->itemsChanged();
307 toBag->itemInsertChange();
308 toBag->itemsChanged();
315 stk.full -= stkFullUsed;
320 for(
int i = 0; i < stk.full &&
onCart > 0 && (
toBox->itemsCount() <
toBox->itemsMax()); i++) {
323 toBox->itemInsertChange();
324 toBox->itemsChanged();
329 toBox->itemInsertChange();
330 toBox->itemsChanged();
337 player->money -= origCartWorth;
343 player->coins -= origCartWorth;
virtual void checkout() override
Buy the item (into bag/box).
virtual QString _whichType() override
Subtype: report the type label.
ItemStorageBox * toBox
Overflow PC item box.
static constexpr const char * type
This row's type key.
virtual bool _canSell() override
Subtype: compute sellability.
virtual ~ItemMarketEntryStoreItem()
virtual int _itemWorth() override
Subtype: compute the unit value.
ItemMarketEntryStoreItem(ItemDBEntry *data, ItemStorageBox *toBag, ItemStorageBox *toBox)
StackReturn calculateStacks()
Work out the full/partial bag-and-box landing for the cart qty.
ItemDBEntry * data
The item being sold.
virtual int _inStockCount() override
Subtype: compute the owned/sellable count.
ItemStorageBox * toBag
Destination bag.
virtual int stackCount() override
Subtype: new stack slots needed (see note above).
virtual QString infoText() override
Detailed-tooltip body (default none).
virtual QString _name() override
Subtype: compute the display name.
virtual int onCartLeft() override
Subtype: how many more may be added.
ItemMarketEntry(int compatMoneyCurrency=CompatEither, int compatBuyMode=CompatEither)
int totalStackCount()
Stacks across all rows of this type.
int cartSignVal
Net contribution sign (-1 buy / +1 sell).
int moneyLeftover()
Money remaining if this checks out.
bool requestFilter()
Helper: does this row pass the current mode filter?
static bool * isMoneyCurrency
Shared: current currency mode.
int itemWorth()
Cached unit value.
static PlayerBasics * player
Shared: player money/coins.
void finishConstruction()
Finalise construction (register the instance).
int onCart
Backing cart quantity.
int cartWorth()
Value of the cart quantity.
virtual bool canCheckout()
Can this row alone check out?
A container of Items – either the trainer's bag or a PC item box.
One inventory slot: an item index and an amount, with live pricing.
int amount
Item amount (max 99 in Gen 1; backs property).
One item's static data: name/flags, pricing, and where it's used.
Result of working out where a bought stack lands (full stacks + partial in bag/box).
Item * partialElBox
The PC-box item a partial merges into.
int partialBox
Remainder added to an existing PC-box stack.
int partialBag
Remainder added to an existing bag stack.
int full
Number of full new stacks.
Item * partialElBag
The bag item a partial merges into.