|
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
|
Implementation of ItemExchangeModel. More...
#include "./itemexchangemodel.h"#include <QCollator>#include <QSet>#include <algorithm>#include <pse-savefile/expanded/fragments/itemstoragebox.h>#include <pse-savefile/expanded/player/playerbasics.h>#include <pse-db/itemsdb.h>#include <pse-db/entries/itemdbentry.h>Go to the source code of this file.
Implementation of ItemExchangeModel.
See itemexchangemodel.h.
The exchange is one net axis m_net (like the money<->coins converter's coin axis). Positive net = gained-A steps, negative = gained-B. The WHOLE net is priced as a single trade (giveFor/refundFor): the total value being bought is rounded up to a whole number of the given item, and only that one leftover comes back as money. Rounding the total – not each step – is what makes an even trade free of change: 3 Fresh Water (₽600) costs exactly 2 Potions (₽600) and refunds nothing.
The after-counts and money for any candidate net are pure functions (aAfterFor/bAfterFor/ moneyAfterFor), which the "+" gating and the preview both use; checkout() writes exactly that net via the box add/remove helpers (bag first, then PC storage).
Definition in file itemexchangemodel.cpp.