Alchemy
Loading...
Searching...
No Matches

buy.c File Reference

Buying: the stock list, the money and party windows, quantities and prices. More...

Go to the source code of this file.

Macros

#define SHOP_INVENTORY_OFFSET   ((s32)offsetof(struct BattleUnit, inventory))
#define SHOP_ICON_DEPTH_OFFSET   ((s32)offsetof(struct RenderOutput, sentinel))
#define SHOP_STACK_LIMIT   30
 maximum quantity accepted by Inventory_AddItem
#define SHOP_QUANTITY_NUMBER_X   72
#define SHOP_QUANTITY_COIN_LABEL_X   136

Functions

s32 Shop_SelectBuy (void)
 Runs the Buy and Artifacts counters: the player browses the stock seven items a page, picks one, chooses who gets it and how many, and pays.
void Shop_DrawStock (struct UiWindow *window, s32 selected)
 Draws a page of seven stock items with their prices, the page arrows, and the chosen item lifted and pulsing.
void Shop_DrawMoney (void)
 Draws the party's coins in the coins window, in the edition's layout.
void Shop_DrawItemPrice (struct UiWindow *window, s32 itemId, s32 price, s32 priceKind)
 Draws the item's name and below it its price.
void Shop_DrawMsg (struct UiWindow *window, s32 message)
 Shows message, an item's description, in the help window; a NULL window is ignored.
void Shop_DrawParty (struct UiWindow *window, s32 selected, s32 itemId)
 Shows the chosen member walking and the others standing, and draws at four fifths of their size the members who cannot equip itemId.
void Shop_DrawEquipComparison (struct UiWindow *window, s32 unitId, s32 itemId)
 Shows how Attack, Defense and Agility would change if the member wore the item: equips it in place of what it would replace, recomputes, puts the slot back and recomputes again, then draws both values with an arrow and the name of the item it would replace.
void Shop_DrawUnitItem (struct UiWindow *window, s32 unitId, s32 itemId)
 Shows the quantity already carried and the member's inventory icons.
s32 Shop_SelectBuyNum (s32 unitId, s32 itemId)
 Asks how many to buy when the item stacks, limited by what the coins buy, the artifact's stock and a stack of 30 less what the member carries.
s32 Shop_SelectQuantity (s32 minimum, s32 maximum, s32 price)
 Chooses how many items to buy or sell, returning the quantity above minimum or -1 when cancelled.
void Shop_BuyDone (s32 unitId, s32 itemId, s32 quantity)
 Adds each item bought to the member, charging its price and adding it to the shop credit one at a time, then offers to equip it and, if equipped, to sell what it replaced.
s32 Shop_ConfirmEquip (s32 unitId, s32 slot)
 Offers to equip the item just bought, unless it is equipped already, the member cannot equip it, or what it would replace is cursed on.
s32 Shop_SellOld (s32 unitId, s32 slot)
 Offers to sell the item the new one replaced, unless there is none or it is a Psynergy item or indispensable.
s32 Shop_SalePrice (s32 inventoryEntry)
 Returns what the shops pay for an inventory entry: nothing for an indispensable item, half the price for a broken one, three quarters otherwise.

Detailed Description

Buying: the stock list, the money and party windows, quantities and prices.

Part of shop.c, the shop object, compiled only through it.

Definition in file buy.c.

Macro Definition Documentation

◆ SHOP_INVENTORY_OFFSET

#define SHOP_INVENTORY_OFFSET   ((s32)offsetof(struct BattleUnit, inventory))

Definition at line 9 of file buy.c.

Referenced by Shop_DrawUnitItem().

◆ SHOP_ICON_DEPTH_OFFSET

#define SHOP_ICON_DEPTH_OFFSET   ((s32)offsetof(struct RenderOutput, sentinel))

Definition at line 10 of file buy.c.

Referenced by Shop_DrawUnitItem().

◆ SHOP_STACK_LIMIT

#define SHOP_STACK_LIMIT   30

maximum quantity accepted by Inventory_AddItem

Definition at line 12 of file buy.c.

Referenced by Shop_SelectBuyNum(), and Shop_SelectQuantity().

◆ SHOP_QUANTITY_NUMBER_X

#define SHOP_QUANTITY_NUMBER_X   72

Definition at line 602 of file buy.c.

Referenced by Shop_SelectQuantity().

◆ SHOP_QUANTITY_COIN_LABEL_X

#define SHOP_QUANTITY_COIN_LABEL_X   136

Definition at line 603 of file buy.c.

Referenced by Shop_SelectQuantity().

Function Documentation

◆ Shop_SelectBuy()

s32 Shop_SelectBuy ( void )

Runs the Buy and Artifacts counters: the player browses the stock seven items a page, picks one, chooses who gets it and how many, and pays.

Checks room in the bag and coins first, and warns when the member cannot equip it. An artifact bought takes its stock counter down, and the list is rebuilt. Repeats until B. Called by Shop_Run.

Definition at line 19 of file buy.c.

Referenced by Shop_Run(), and Shop_SelectBuy().

◆ Shop_DrawStock()

void Shop_DrawStock ( struct UiWindow * window,
s32 selected )

Draws a page of seven stock items with their prices, the page arrows, and the chosen item lifted and pulsing.

Called by Shop_SelectBuy each time the cursor moves.

Definition at line 241 of file buy.c.

Referenced by Shop_DrawStock(), and Shop_SelectBuy().

◆ Shop_DrawMoney()

void Shop_DrawMoney ( void )

Draws the party's coins in the coins window, in the edition's layout.

Called when a counter opens and after each purchase, sale or repair.

Definition at line 305 of file buy.c.

Referenced by Inn_CheckIn(), Sanctum_RunPartyService(), Shop_BuyDone(), Shop_ConfirmAct(), Shop_DrawMoney(), Shop_PickUnit(), Shop_RepairItem(), Shop_SelectBuy(), and Shop_SellItem().

◆ Shop_DrawItemPrice()

void Shop_DrawItemPrice ( struct UiWindow * window,
s32 itemId,
s32 price,
s32 priceKind )

Draws the item's name and below it its price.

With a price of 0 it says instead that the shop does not buy it (priceKind 1) or that it is not broken (2). Called by the buy, sell and repair lists.

Definition at line 328 of file buy.c.

Referenced by Shop_DrawItemPrice(), Shop_SelectBuy(), Shop_SelectRepair(), and Shop_SelectSell().

◆ Shop_DrawMsg()

void Shop_DrawMsg ( struct UiWindow * window,
s32 message )

Shows message, an item's description, in the help window; a NULL window is ignored.

Called by the counters' lists each time the cursor moves.

Definition at line 367 of file buy.c.

Referenced by Shop_DrawMsg(), Shop_SelectBuy(), Shop_SelectRepair(), Shop_SelectSell(), and Shop_SelectUse().

◆ Shop_DrawParty()

void Shop_DrawParty ( struct UiWindow * window,
s32 selected,
s32 itemId )

Shows the chosen member walking and the others standing, and draws at four fifths of their size the members who cannot equip itemId.

Called by every counter's member choice.

Definition at line 382 of file buy.c.

Referenced by Shop_BuySpecialItem(), Shop_DrawParty(), Shop_PickUnit(), Shop_PickUnitItem(), and Shop_SelectBuy().

◆ Shop_DrawEquipComparison()

void Shop_DrawEquipComparison ( struct UiWindow * window,
s32 unitId,
s32 itemId )

Shows how Attack, Defense and Agility would change if the member wore the item: equips it in place of what it would replace, recomputes, puts the slot back and recomputes again, then draws both values with an arrow and the name of the item it would replace.

Called by Shop_SelectBuy for weapons and armor.

Definition at line 407 of file buy.c.

Referenced by Shop_DrawEquipComparison(), and Shop_SelectBuy().

◆ Shop_DrawUnitItem()

void Shop_DrawUnitItem ( struct UiWindow * window,
s32 unitId,
s32 itemId )

Shows the quantity already carried and the member's inventory icons.

Called by Shop_SelectBuy for items that are not equipment.

Definition at line 484 of file buy.c.

Referenced by Shop_BuySpecialItem(), Shop_DrawUnitItem(), and Shop_SelectBuy().

◆ Shop_SelectBuyNum()

s32 Shop_SelectBuyNum ( s32 unitId,
s32 itemId )

Asks how many to buy when the item stacks, limited by what the coins buy, the artifact's stock and a stack of 30 less what the member carries.

Returns the count (1 for other items), or -1 when cancelled. Called by Shop_SelectBuy.

Definition at line 547 of file buy.c.

Referenced by Shop_SelectBuy(), and Shop_SelectBuyNum().

◆ Shop_SelectQuantity()

s32 Shop_SelectQuantity ( s32 minimum,
s32 maximum,
s32 price )

Chooses how many items to buy or sell, returning the quantity above minimum or -1 when cancelled.

The bar's fixed prefix is minimum (items already carried when buying); maximum must exceed it so at least one can be chosen. Holds heap slot 14 for the bar's tiles. Called by the buy and sell quantity pickers.

Definition at line 611 of file buy.c.

Referenced by Shop_SelectBuyNum(), Shop_SelectQuantity(), and Shop_SelectSellNum().

◆ Shop_BuyDone()

void Shop_BuyDone ( s32 unitId,
s32 itemId,
s32 quantity )

Adds each item bought to the member, charging its price and adding it to the shop credit one at a time, then offers to equip it and, if equipped, to sell what it replaced.

Called by Shop_SelectBuy.

Definition at line 700 of file buy.c.

Referenced by Shop_BuyDone(), and Shop_SelectBuy().

◆ Shop_ConfirmEquip()

s32 Shop_ConfirmEquip ( s32 unitId,
s32 slot )

Offers to equip the item just bought, unless it is equipped already, the member cannot equip it, or what it would replace is cursed on.

Equips it on Yes, redraws the grid and warns of a curse. Returns 1 when it was equipped. Called by Shop_BuyDone.

Definition at line 732 of file buy.c.

Referenced by Shop_BuyDone(), Shop_ConfirmEquip(), and Shop_RepairItem().

◆ Shop_SellOld()

s32 Shop_SellOld ( s32 unitId,
s32 slot )

Offers to sell the item the new one replaced, unless there is none or it is a Psynergy item or indispensable.

Returns 1 when it offered. Called by Shop_BuyDone.

Definition at line 781 of file buy.c.

Referenced by Shop_BuyDone(), Shop_RepairItem(), and Shop_SellOld().

◆ Shop_SalePrice()

s32 Shop_SalePrice ( s32 inventoryEntry)

Returns what the shops pay for an inventory entry: nothing for an indispensable item, half the price for a broken one, three quarters otherwise.

Definition at line 803 of file buy.c.

Referenced by Shop_DrawUseItem(), Shop_SalePrice(), Shop_SelectSell(), Shop_SelectSellNum(), and Shop_SellItem().