13 if ((
int)item_type < 0 || item_type >= ITEM_NUM_TYPES)
15 MGBA_FUNC_ERROR(
"Invalid type %d", item_type);
24 MGBA_FUNC_ERROR(
"Unimplemented 'roll_new' function called for item type %d", item_type);
40 if (item_funcs->get_buy_price == NULL)
43 "Unimplemented 'get_buy_price' function called for item type %d",
49 return item_funcs->get_buy_price(item);
58 if (item_funcs->get_sell_price == NULL)
61 "Unimplemented 'get_sell_price' function called for item type %d",
67 return item_funcs->get_sell_price(item);
76 if (item_funcs->get_name == NULL)
78 MGBA_FUNC_ERROR(
"Unimplemented 'get_name' function called for item type %d", item->
type);
83 const char* item_name = item_funcs->get_name(item);
97 if (item_funcs->get_subtype_info == NULL)
100 "Unimplemented 'get_subtype_info' function called for item type %d",
107 if (ret_info.name_str == NULL)
109 MGBA_FUNC_ERROR(
"Item of type %d returned NULL as description subtype name", item->
type);
123 if (item_funcs->acquire == NULL)
125 MGBA_FUNC_ERROR(
"Unimplemented 'acquire' function called for item type %d", item->
type);
129 item_funcs->acquire(item);
138 if (item_funcs->can_acquire == NULL)
140 MGBA_FUNC_ERROR(
"Unimplemented 'can_acquire' function called for item type %d", item->
type);
144 return item_funcs->can_acquire(item);
153 if (item_funcs->dispose == NULL)
155 MGBA_FUNC_ERROR(
"Unimplemented 'dispose' function called for item type %d", (*item)->type);
159 item_funcs->dispose(item);
167 if (item_funcs->print_description == NULL)
170 "Unimplemented 'print_description' function called for item type %d",
176 return item_funcs->print_description(item, dest_rect);
191 if (sell_price == UNDEFINED)
193 MGBA_FUNC_ERROR(
"Undefined sell price for item of type %d", item->
type);
197 g_game_vars.money += sell_price;
200 item_start_discard_animation(item);
Game global game variables struct definition.
The core structure for items in the shop and inventory. Provides a common API for the shop and invent...
bool item_is_owned(Item *item)
Returns whether or not the given Item is in the player's possession.
int item_get_sell_price(Item *item)
Returns the sell price of the item.
void item_dispose(Item **item)
Destroys an item, freeing underlying resources, and manages rollable items sets if needed....
#define ITEM_NAME_UNDEFINED
Default Item name, for the sake of consistency.
const char * item_get_name(Item *item)
Returns the name of the Item.
void item_print_buy_price_under(Item *item)
Prints the buy price under the item Relies on the fact item is a SpriteObject.
#define ITEM_SUBTYPE_INFO_DEFAULT
Default subtype info struct declaration.
Item * item_roll_new(enum ItemType item_type, enum RngSequence key)
Rolls a random item of type item_type and returns a newly created one. Manages rollable items set if ...
bool item_can_acquire(Item *item)
Returns true if the item can be acquired, i.e. added to inventory. Does not check if the player has e...
ItemDescSubtypeInfo item_get_subtype_info(Item *item)
Returns the colors and name of the Item's subtype.
void item_acquire(Item *item)
Acquires the item, adding to inventory if applicable. Called when it is purchased from the shop,...
void item_sell(Item *item)
Performs the item sell transaction, gaining its sell value and discarding it.
int item_print_description(Item *item, Rect dest_rect)
Prints the item's description inside the given rectangle.
int item_get_buy_price(Item *item)
Returns the buy price of the item.
An API for the item functions defined in item.h Separated module from item.c/.h so item_funcs....
ItemFuncs * get_item_type_funcs(enum ItemType type)
Returns the function table for a given item type.
Interface to interact with the mgba logger.
RngSequence
Keys to different independent RNG sequences.
void sprite_object_print_price_under(SpriteObject *sprite_object, int price)
Print the price string directly beneath a SpriteObject. More specialized version of sprite_object_pri...
void sprite_object_erase_text_under(SpriteObject *sprite_object)
Erase the text within the Rect directly beneath a SpriteObject. This is used only for Cards for now.
Structure containing the main and shadow colors, and the name string associated with an Item's subtyp...
The set of functions that each item type implements.
Item *(* roll_new)(enum RngSequence key)
A generic interface for all items that can appear in the shop or be in the inventory....
enum ItemType type
The item type - used to dispatch the function implementations for inheriting types.
bool is_owned
Whether the item is currently held - used in cases where a behaviour needs to be different for Items ...
A sprite object is a sprite that is focusable and movable in animation.
Utilities relating around number string representation and protected arithmatic helper functions.
#define GBAL_RETURN_IF_NULL(param, ret_val)
Returns ret_val and prints a default error message if param is equal to NULL. Useful for checking arg...
#define RET_NONE
An empty return value for RETURN_IF macros when used in void functions Expands to nothing because mac...