Files
balatro-gba/source/item_funcs.c
Geralt 0eb7042468
Some checks failed
Build and Deploy Doxygen Docs / docs (push) Has been cancelled
Deploy Nightly / Run Build ROM Workflow (push) Has been cancelled
Deploy Nightly / Deploy nightly (push) Has been cancelled
[Bug] Implement independent RNG sequences to avoid interferences (#599)
* Implement our own Xorshift32 RNG algo to manage independent number sequences

* Fix issues with seed 0

* adress @MeirGavish's review

* Apply suggestions from @MeirGavish's code review

Co-authored-by: MeirGavish <meir.gavish@gmail.com>

* adress the rest of @MeirGavish's review

* adress @MeirGavish's review

* Fix last issues

---------

Co-authored-by: MathisMartin31 <mathis.martin31@gmail.com>
Co-authored-by: MeirGavish <meir.gavish@gmail.com>
Co-authored-by: MonteCrysto <monte.crysto31@gmail.com>
2026-08-05 12:37:06 +03:00

65 lines
1.9 KiB
C

#include "item_funcs.h"
#include "card.h"
#include "game.h"
#include "game/shop.h"
#include "joker.h"
#include "util.h"
static Item* item_roll_new_unimplemented(enum RngSequence key);
static void item_acquire_unimplemented(Item* item);
static bool item_always_can_acquire(Item* item);
// clang-format off
ItemFuncs item_func_table[] = {
[ITEM_TYPE_JOKER] = {
.roll_new = joker_object_roll_new,
.get_buy_price = joker_object_get_buy_price,
.acquire = joker_object_add_to_owned,
.can_acquire = joker_object_can_acquire,
.dispose = joker_object_dispose
},
/* Currently playing cards have partial implementations since Magic Trick is not implemented
* and playing cards can't appear in the shop.
* If the Magic Trick voucher is implemented, these need to be completed.
* Playing cards must stay the only exception, the rest of the item types must implement
* all the basic functions to appear in the shop.
*/
[ITEM_TYPE_PLAYING_CARD] = {
.roll_new = item_roll_new_unimplemented,
.get_buy_price = card_object_get_buy_price,
.acquire = item_acquire_unimplemented,
.can_acquire = item_always_can_acquire,
.dispose = card_object_dispose
}
};
// clang-format on
ItemFuncs* get_item_type_funcs(enum ItemType type)
{
if ((int)type < 0 || type >= NUM_ELEM_IN_ARR(item_func_table))
{
MGBA_FUNC_ERROR("Invalid type %d", type);
return NULL;
}
return &item_func_table[type];
}
static Item* item_roll_new_unimplemented(enum RngSequence key)
{
MGBA_FUNC_ERROR("Unimplemented roll_new function called");
return NULL;
}
static void item_acquire_unimplemented(Item* item)
{
GBAL_RETURN_IF_NULL_VOID(item);
MGBA_FUNC_ERROR("Unimplemented acquire function called for item type type %d", (item)->type);
}
static bool item_always_can_acquire(Item* item)
{
return true;
}