* Turned SpriteObject into a member of JokerObject and CardObject and expiremented with casting * Extracted shop code to use generic `SpriteObject` * Extracted shop joker generation to a function * Renamed object -> item * Added setters and getters for `SpriteObject` members and updated all accesses to use them with casting (AI used for tedious work and reviewed - model Raptor mini) * Added sprite_object_set_vx() because sprite_object_set_vy() exists and reordered the function order to have x,y parameters first, then targets * Added Item object to act as a purchasable interface for the shop - AI used (model Raptor mini) * Added -fms-extensions and switched to anonymous inheritance * Fixed anonymous inheritance for joker and added direct access for that too * fix build error from previous commit + clang-format * Fixed build errors + clang-format for real this time (I hope...) * clang-format one last time, I don't understand it anymore * clang-format is annoying * Added uses of CHECK_NULL_ARG macros * Merged item_defs.h into item.h and fixed build error from previous commit * clang-format...? * Changed sprite_object_new() into sprite_object_init() and made it accept a parameter instead of returning one to make it less awkward * Updated sprite_object_init() documentation * Updated sprite_object_destroy documentation * More clang-format * Renamed add_to_inventory to acquire and updated documentation * Added function documentations * Update documentation + swap order of consumable and playing card types * Added documentation for new files (+ small addition to button.h) * clang-format * Used typedef * A bit more documentation * Changed sho pcode to use generic Item instead of SpriteObject * clang-format + fixed NULL-check error * Revert weird clang-format...? * clang-format for real * Fixed errors from rebase on log_function_name * Fixed build errors from rebase on main * Added some more documentation about first member struct inheritance * typo fix * typo fix for real * Removed SpriteObject field getters/setters (AI used - model Raptor mini) * Renamed item_acquire -> item_on_acquired * Added item_can_acquire() * clang-format * Fixed some sprite issues but not all... * Fixed some more issues * Cleanup JokerObject some more JokerObjects in the shop * Added `item_destroy()` * Added item_set_available_to_shop, CHECK_ITEM_TYPE macros + small documentation updates * Another small JokerObject->Item replacement * Removed item_set_available_to_shop and replaced with item_roll_new() and item_dispose(), also changed "available_to_shop" semantics to "rollable" * Re-applied changes from game.c to round.c after rebase on main * Added partial implementations of item functions for playing cards * Line endings fix... * Macro renames, function documentations * Updated documentations * Apply fixes from Copilot review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Fix card_object_get_buy_price type checking Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Avoid double pointer cast on dispose Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Apply suggestions from @ricfehr3's code review Co-authored-by: Rickey <ric@rf3.xyz> * Remove redundant comments * Moved error checking before joker_get_random_rarity Co-authored-by: Rickey <ric@rf3.xyz> * Fixed build error from rebase * clang-format * Added doxygen documentation for Item explaining inheritance * Removed unnecessary comment --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Rickey <ric@rf3.xyz>
90 lines
2.1 KiB
C
90 lines
2.1 KiB
C
#ifndef CARD_H
|
|
#define CARD_H
|
|
|
|
#include "deck_types.h"
|
|
#include "item.h"
|
|
|
|
#include <maxmod.h>
|
|
#include <tonc.h>
|
|
|
|
#define MAX_CARDS 128 // Arbitrary high value so we don't have issues
|
|
#define MAX_CARDS_ON_SCREEN 16
|
|
|
|
#define CARD_TID 0
|
|
#define CARD_SPRITE_OFFSET 16
|
|
#define CARD_PB 0
|
|
#define CARD_STARTING_LAYER 0
|
|
|
|
// Card suits
|
|
#define DIAMONDS 0
|
|
#define CLUBS 1
|
|
#define HEARTS 2
|
|
#define SPADES 3
|
|
#define NUM_SUITS 4
|
|
|
|
// Card ranks
|
|
#define TWO 0
|
|
#define THREE 1
|
|
#define FOUR 2
|
|
#define FIVE 3
|
|
#define SIX 4
|
|
#define SEVEN 5
|
|
#define EIGHT 6
|
|
#define NINE 7
|
|
#define TEN 8
|
|
#define JACK 9
|
|
#define QUEEN 10
|
|
#define KING 11
|
|
#define ACE 12
|
|
#define NUM_RANKS 13
|
|
#define RANK_OFFSET 2 // Because the first rank is 2 and ranks start at 0
|
|
|
|
#define IMPOSSIBLY_HIGH_CARD_VALUE 100
|
|
|
|
// Card sprites
|
|
#define DEFAULT_HIGH_CONTRAST false
|
|
#define DEFAULT_MORE_READABLE false
|
|
|
|
// Card types
|
|
typedef struct Card
|
|
{
|
|
u8 suit;
|
|
u8 rank;
|
|
} Card;
|
|
|
|
typedef struct CardObject
|
|
{
|
|
Item; // First member struct inheritance
|
|
Card* card;
|
|
bool selected;
|
|
} CardObject;
|
|
|
|
void card_init(void);
|
|
|
|
// Card sprites accessibility functions
|
|
void set_cards_high_contrast(bool enable);
|
|
void set_cards_more_readable(bool enable);
|
|
bool get_cards_high_contrast(void);
|
|
bool get_cards_more_readable(void);
|
|
|
|
// Card methods
|
|
Card* card_new(u8 suit, u8 rank);
|
|
void card_destroy(Card** card);
|
|
u8 card_get_value(Card* card);
|
|
|
|
// CardObject methods
|
|
CardObject* card_object_new(Card* card);
|
|
void card_object_destroy(CardObject** card_object);
|
|
void card_object_set_sprite(CardObject* card_object, int layer);
|
|
void card_object_set_sprite_face_down(CardObject* card_object, enum DeckType deck, int layer);
|
|
void card_object_shake(CardObject* card_object, mm_word sound_id);
|
|
|
|
void card_object_set_selected(CardObject* card_object, bool selected);
|
|
bool card_object_is_selected(CardObject* card_object);
|
|
Sprite* card_object_get_sprite(CardObject* card_object);
|
|
|
|
int card_object_get_buy_price(Item* card_object);
|
|
void card_object_dispose(Item** card_object);
|
|
|
|
#endif // CARD_H
|