Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
ItemMarketEntryMoney Class Reference

Market row representing the player's money/coins balance. More...

#include <itemmarketentrymoney.h>

Inheritance diagram for ItemMarketEntryMoney:
Collaboration diagram for ItemMarketEntryMoney:

Public Types

enum  { DirGlobal = -1 , DirToMoney = 0 , DirToCoins = 1 }
 Direction of a money row. More...
Public Types inherited from ItemMarketEntry
enum  { CompatNo = 0 , CompatYes , CompatEither }
 Three-state compatibility for the mode filters. More...
enum  {
  HashKeyName , HashKeyInStockCount , HashKeyCanSell , HashKeyItemWorth ,
  HashKeyWhichType
}
 Cache keys for the memoised mode-stable values. More...

Public Member Functions

 ItemMarketEntryMoney (int forceDir=DirGlobal)
virtual ~ItemMarketEntryMoney ()
virtual QString _name () override
 Subtype: compute the display name.
virtual int _inStockCount () override
 Subtype: compute the owned/sellable count.
virtual bool _canSell () override
 Subtype: compute sellability.
virtual int _itemWorth () override
 Subtype: compute the unit value.
virtual QString _whichType () override
 Subtype: report the type label.
virtual int onCartLeft () override
 Subtype: how many more may be added.
virtual int stackCount () override
 Subtype: new stack slots needed (see note above).
virtual bool canCheckout () override
 Exchange-aware affordability gate.
bool buying () const
 This row's effective direction: true = Money=>Coins (spend money), false = Coins=>Money (spend coins).
int moneyDelta () const
 Signed money change for this row's onCart (-cost buying, +gain selling).
int coinsDelta () const
 Signed coins change for this row's onCart (+buying, -selling).
virtual void checkout () override
 Apply the money/coins change.
Public Member Functions inherited from ItemMarketEntry
 ItemMarketEntry (int compatMoneyCurrency=CompatEither, int compatBuyMode=CompatEither)
virtual ~ItemMarketEntry ()
virtual void initOnce ()
 One-time setup for the first instance of a type.
void finishConstruction ()
 Finalise construction (register the instance).
QString name ()
 Cached display name.
int inStockCount ()
 Cached owned/sellable count.
bool canSell ()
 Cached sellable flag.
int itemWorth ()
 Cached unit value.
QString whichType ()
 Cached type label.
virtual QString infoText ()
 Detailed-tooltip body (default none).
bool requestFilter ()
 Helper: does this row pass the current mode filter?
int getCartCount ()
 Current cart quantity (backs onCart).
int cartWorth ()
 Value of the cart quantity.
int totalStackCount ()
 Stacks across all rows of this type.
int totalWorth ()
 Signed worth across ALL rows (sell +, buy -).
int moneyLeftover ()
 Money remaining if this checks out.
bool canAnyCheckout ()
 Can any row check out?
void setCartCount (int val)
 Set the cart quantity (backs onCart).
void reUpdateConstants ()
 Clear the cached mode-stable values.

Public Attributes

int forceDir = DirGlobal
 Fixed direction, or DirGlobal to follow the model.
Public Attributes inherited from ItemMarketEntry
int compatMoneyCurrency = CompatEither
 Money/coins compatibility.
int compatBuyMode = CompatEither
 Buy/sell compatibility.
int onCart = 0
 Backing cart quantity.
bool exclude = false
 Exclude from aggregate totals (see note).
int viewTag = -1
 Left-list view filter tag.
int cartSignVal = 1
 Net contribution sign (-1 buy / +1 sell).
QHash< int, QVariant > cache
 Memoised mode-stable values (see HashKey* enum).

Static Public Attributes

static constexpr const char * type = "money"
 This row's type key.
Static Public Attributes inherited from ItemMarketEntry
static bool * isMoneyCurrency = nullptr
 Shared: current currency mode.
static bool * isBuyMode = nullptr
 Shared: current buy/sell mode.
static PlayerBasicsplayer = nullptr
 Shared: player money/coins.
static QHash< QString, QVector< ItemMarketEntry * > * > instances
 All rows, grouped by type.
static QVector< ItemMarketEntry * > instancesCombined
 All rows, flat.
static QVector< ItemMarketEntry * > * activeList = nullptr
 Current model's live rows.

Additional Inherited Members

Protected Member Functions inherited from ItemMarketEntry
void doReUpdateConstants ()
 Force a refresh of the "mode-stable" values.
Protected Attributes inherited from ItemMarketEntry
 : void onCartChanged()
 < Quantity on the cart.

Detailed Description

Market row representing the player's money/coins balance.

An ItemMarketEntry subtype; the overrides implement the base's virtual table for a money/coins row. checkout() applies the balance change. See ItemMarketEntry.

Definition at line 25 of file itemmarketentrymoney.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Direction of a money row.

Enumerator
DirGlobal 

Follow the model's global buy/sell flag (legacy behaviour).

DirToMoney 

Coins => Money (the "sell" direction).

DirToCoins 

Money => Coins (the "buy" direction).

Definition at line 31 of file itemmarketentrymoney.h.

Constructor & Destructor Documentation

◆ ItemMarketEntryMoney()

ItemMarketEntryMoney::ItemMarketEntryMoney ( int forceDir = DirGlobal)
explicit
Parameters
forceDirfix this row's exchange direction (see Dir*); DirGlobal follows the model's buy/sell flag. The dedicated Exchange list builds one of each fixed direction so both swaps appear at once.

Definition at line 38 of file itemmarketentrymoney.cpp.

References ItemMarketEntry::CompatEither, ItemMarketEntry::exclude, ItemMarketEntry::finishConstruction(), forceDir, and ItemMarketEntry::ItemMarketEntry().

◆ ~ItemMarketEntryMoney()

ItemMarketEntryMoney::~ItemMarketEntryMoney ( )
virtual

Definition at line 46 of file itemmarketentrymoney.cpp.

Member Function Documentation

◆ _canSell()

bool ItemMarketEntryMoney::_canSell ( )
overridevirtual

Subtype: compute sellability.

Implements ItemMarketEntry.

Definition at line 73 of file itemmarketentrymoney.cpp.

◆ _inStockCount()

int ItemMarketEntryMoney::_inStockCount ( )
overridevirtual

Subtype: compute the owned/sellable count.

Implements ItemMarketEntry.

Definition at line 65 of file itemmarketentrymoney.cpp.

References buying(), and ItemMarketEntry::player.

◆ _itemWorth()

int ItemMarketEntryMoney::_itemWorth ( )
overridevirtual

Subtype: compute the unit value.

Implements ItemMarketEntry.

Definition at line 79 of file itemmarketentrymoney.cpp.

References buying(), GameCornerDB::getBuyPrice(), GameCornerDB::getSellPrice(), and GameCornerDB::inst().

◆ _name()

QString ItemMarketEntryMoney::_name ( )
overridevirtual

Subtype: compute the display name.

Implements ItemMarketEntry.

Definition at line 55 of file itemmarketentrymoney.cpp.

References buying().

◆ _whichType()

QString ItemMarketEntryMoney::_whichType ( )
overridevirtual

Subtype: report the type label.

Implements ItemMarketEntry.

Definition at line 87 of file itemmarketentrymoney.cpp.

References type.

◆ buying()

bool ItemMarketEntryMoney::buying ( ) const

This row's effective direction: true = Money=>Coins (spend money), false = Coins=>Money (spend coins).

Honours forceDir, else the global buy flag.

Definition at line 48 of file itemmarketentrymoney.cpp.

References DirGlobal, DirToCoins, forceDir, and ItemMarketEntry::isBuyMode.

Referenced by _inStockCount(), _itemWorth(), _name(), canCheckout(), coinsDelta(), moneyDelta(), and onCartLeft().

◆ canCheckout()

bool ItemMarketEntryMoney::canCheckout ( )
overridevirtual

Exchange-aware affordability gate.

Reimplemented from ItemMarketEntry.

Definition at line 136 of file itemmarketentrymoney.cpp.

References buying(), GameCornerDB::getBuyPrice(), GameCornerDB::inst(), ItemMarketEntry::onCart, onCartLeft(), and ItemMarketEntry::player.

Referenced by checkout().

◆ checkout()

void ItemMarketEntryMoney::checkout ( )
overridevirtual

Apply the money/coins change.

Implements ItemMarketEntry.

Definition at line 148 of file itemmarketentrymoney.cpp.

References canCheckout(), coinsDelta(), moneyDelta(), ItemMarketEntry::onCart, and ItemMarketEntry::player.

◆ coinsDelta()

int ItemMarketEntryMoney::coinsDelta ( ) const

Signed coins change for this row's onCart (+buying, -selling).

Definition at line 100 of file itemmarketentrymoney.cpp.

References buying(), and ItemMarketEntry::onCart.

Referenced by checkout().

◆ moneyDelta()

int ItemMarketEntryMoney::moneyDelta ( ) const

Signed money change for this row's onCart (-cost buying, +gain selling).

Definition at line 92 of file itemmarketentrymoney.cpp.

References buying(), GameCornerDB::getBuyPrice(), GameCornerDB::getSellPrice(), GameCornerDB::inst(), and ItemMarketEntry::onCart.

Referenced by checkout().

◆ onCartLeft()

int ItemMarketEntryMoney::onCartLeft ( )
overridevirtual

◆ stackCount()

int ItemMarketEntryMoney::stackCount ( )
overridevirtual

Subtype: new stack slots needed (see note above).

Implements ItemMarketEntry.

Definition at line 129 of file itemmarketentrymoney.cpp.

Member Data Documentation

◆ forceDir

int ItemMarketEntryMoney::forceDir = DirGlobal

Fixed direction, or DirGlobal to follow the model.

Definition at line 68 of file itemmarketentrymoney.h.

Referenced by buying(), and ItemMarketEntryMoney().

◆ type

const char* ItemMarketEntryMoney::type = "money"
staticconstexpr

This row's type key.

Definition at line 66 of file itemmarketentrymoney.h.

Referenced by _whichType().


The documentation for this class was generated from the following files: