45 load(saveFile, offset);
50 for(
auto item :
items)
63 for(
auto el :
items) {
84 if(dest->items.size() >= dest->itemsMax())
92 if(ind >=
items.size())
104 for(
var8 i = 0; i < count; i++) {
138 if(giveSuperPotion) {
139 items.append(
new Item(
"SUPER POTION", 1));
153 for(
var8 i = 0; i < count; i++) {
160 if(
items.size() <= 0 ||
162 from >=
items.size() ||
164 to >=
items.size() ||
169 auto eFrom =
items.at(from);
170 items.removeAt(from);
173 items.insert(to, eFrom);
183 if(
items.size() <= 0 ||
188 items.at(ind)->deleteLater();
196 for(
auto el :
items) {
210 for(
auto el :
items) {
225 if(entry->getGlitch() || entry->getOnce())
231 pool.append(entry->getInd());
238 return pool.at(
Random::inst()->rangeExclusive(0, pool.size()));
264 while(
items.size() > 0 && dest->items.size() < dest->itemsMax()) {
276 if(
items.size() <= 0 ||
278 ind >=
items.size() ||
279 dest->items.size() >= dest->itemsMax())
282 auto el =
items.at(ind);
283 beforeItemRelocate(el);
289 dest->items.append(el);
290 dest->itemInsertChange();
291 dest->itemsChanged();
298 if(
items.size() <= 0)
303 collator.setNumericMode(
true);
304 collator.setIgnorePunctuation(
true);
309 [&collator](
Item* item1,
Item* item2)
311 if(item1->toItem() == nullptr || item2->toItem() == nullptr)
312 return collator.compare(
"",
"") < 0;
314 return collator.compare(item1->toItem()->getReadable(), item2->toItem()->getReadable()) < 0;
325 this->
file = saveFile;
327 if(saveFile ==
nullptr)
330 auto toolset = saveFile->
toolset;
334 for (
var8 i = 0; i < toolset->getByte(offset) && i <
maxSize; i++) {
335 auto item =
new Item(it);
353 it->setByte(
items.at(i)->ind);
354 it->setByte(
items.at(i)->amount);
363 ?
file->dataExpanded->storage->items
364 :
file->dataExpanded->player->items;
371 for(
auto el :
items) {
372 ret += el->buyPriceAllMoney();
382 for(
auto el :
items) {
383 ret += el->buyPriceAllCoins();
393 for(
auto el :
items) {
394 ret += el->sellPriceAllMoney();
404 for(
auto el :
items) {
405 ret += el->sellPriceAllCoins();
413 for(
auto item :
items) {
void sort()
Sort the box contents.
QVector< Item * > items
The stored items.
void save(SaveFile *saveFile, int offset)
Flatten the box to the save.
void reset()
Empty the box.
bool getIsBag()
Is this the bag?
void itemsResetChange()
The box was reset.
void randomizeBag()
Randomizer path for the bag.
bool isBag
Bag vs PC (set at construction; treat as read-only).
void load(SaveFile *saveFile=nullptr, int offset=0)
Expand the box from the save.
ItemStorageBox * destBox()
The paired box for relocation.
virtual ~ItemStorageBox()
int maxSize
Capacity (set at construction; treat as read-only).
void itemNew()
Add a fresh random item (never a duplicate of one already here).
ItemStorageBox(bool isBag, int maxSize, SaveFile *saveFile=nullptr, int offset=0)
How many items are there.
int itemsCountBulk()
Item count including stack amounts.
void itemInsertChange()
An item was inserted.
void itemMoveChange(int from, int to)
An item moved slot.
bool relocateAll()
Move every item to the paired box.
int randomUniqueInd()
A random non-glitch/non-once item index absent from this box, or -1 if none remain.
bool itemMove(int from, int to)
Reorder an item.
bool relocateOne(int ind)
Move one item to the paired box.
void randomizeStorage()
Randomizer path for a PC item box.
bool relocateFull()
Is relocation blocked because the paired box is full?
Item * itemAt(int ind)
Item slot ind (GC-protected return).
bool hasItemInd(int ind)
Does this box already contain an item with index ind? (Q_INVOKABLE: the SelectItem dropdown greys out...
void randomize()
Randomize (dispatches to bag/storage path); sorts afterward.
SaveFile * file
Owning save.
int amountOfInd(int ind)
Total amount of item ind across all rows in this box (Q_INVOKABLE: the SelectItem dropdown shows the ...
int itemsCount()
Distinct item count.
void itemRemoveChange(int ind)
An item was removed.
void itemsChanged()
Box contents changed.
void itemRemove(int ind)
Remove item ind.
One inventory slot: an item index and an amount, with live pricing.
static ItemsDB * inst()
< Number of items.
bool chanceSuccess(const int percent) const
Did a percent chance succeed?
int rangeInclusive(const int start, const int end) const
Random integer in the closed interval [start, end].
static Random * inst()
< Convenience 50% coin flip (integer path), readable from QML.
void setByte(var8 val, var16 padding=0)
Write a byte at the cursor; advances.
SaveFileIterator * offsetTo(var16 val)
Move the cursor to an absolute offset. Returns this for chaining.
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
SaveFileToolset * toolset
Tools to operate directly on the raw sav file data.
SaveFileIterator * iterator()
Returns a unique iterator that's setup to iterate over the raw sav file data.
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
qmlCppOwned() – protect Q_INVOKABLE QObject returns from QML's GC.
static T * qmlCppOwned(T *obj)
Hand QML CppOwnership of a C++-owned QObject returned from a Q_INVOKABLE.