Fixed stack top bugs in joker_effects.c - e.g. Blackboard activated if just the first card in hand was not spades/clubs

This commit is contained in:
MeirGavish
2025-08-08 00:01:36 +03:00
parent 4492176df2
commit 5e6d28c663
3 changed files with 15 additions and 11 deletions
+9 -6
View File
@@ -1,3 +1,4 @@
#include "game.h"
#include "joker.h"
#include "util.h"
#include "hand_analysis.h"
@@ -178,7 +179,8 @@ static JokerEffect half_joker_effect(Joker *joker, Card *scored_card) {
if (scored_card != NULL)
return effect; // if card != null, we are not at the end-phase of scoring yet
if (get_played_top() + 1 <= 3) // game.c has hand_get_size() but it's not accesible here
int played_size = get_played_top() + 1;
if (played_size <= 3)
effect.mult = 20;
return effect;
@@ -190,12 +192,13 @@ static JokerEffect joker_stencil_effect(Joker *joker, Card *scored_card) {
return effect; // if card != null, we are not at the end-phase of scoring yet
// +1 xmult per empty joker slot...
int jokers_top = get_jokers_top();
effect.xmult = (MAX_JOKERS_HELD_SIZE-1) - jokers_top;
int num_jokers = get_jokers_top() + 1;
effect.xmult = (MAX_JOKERS_HELD_SIZE) - num_jokers;
// ...and also each stencil_joker adds +1 xmult
JokerObject** jokers = get_jokers();
for (int i = 0; i < jokers_top; i++ )
for (int i = 0; i < num_jokers; i++ )
{
if (jokers[i]->joker->id == JOKER_STENCIL_ID)
effect.xmult++;
@@ -271,8 +274,8 @@ static JokerEffect blackboard_joker_effect(Joker *joker, Card *scored_card) {
bool all_cards_are_spades_or_clubs = true;
CardObject** hand = get_hand_array();
int hand_top = get_hand_top();
for (int i = 0; i < hand_top; i++ )
int hand_size = hand_get_size();
for (int i = 0; i < hand_size; i++ )
{
u8 suit = hand[i]->card->suit;
if (suit == HEARTS || suit == DIAMONDS) {