Show selections

This commit is contained in:
Bill Rossi 2025-02-25 05:55:03 -05:00
parent ec0459e35b
commit 2b3dbc5fec

36
game.c
View File

@ -343,6 +343,7 @@ void run_frame_initializing(Game *g) {
for (int i = 0; i < 48; i++) {
Card *c = &g->cards[i];
c->visible = false;
c->selected = false;
add_to_hand(&g->deck, c, g->deal_speed);
}
@ -458,19 +459,24 @@ void run_frame_choosing_target(Game *g) {
return;
}
Card *selected_card = NULL;
bool no_cards_selected = true;
for (int i = 0; i < g->player.hand.count; i++) {
if (g->player.hand.cards[i]->selected) {
no_cards_selected = false;
selected_card = g->player.hand.cards[i];
break;
}
}
if (no_cards_selected) {
if (!selected_card) {
g->state = GAME_STATE_CHOOSING_FROM_HAND;
return;
}
for (int i = 0; i < g->field.count; i++) {
g->field.cards[i]->selected = g->field.cards[i]->month == selected_card->month;
}
if (g->current_play_from_hand) {
if (g->current_play_target) {
g->current_play_from_hand->selected = false;
@ -492,6 +498,9 @@ void run_frame_choosing_target(Game *g) {
add_to_hand(&g->field, g->current_play_from_hand, g->deal_speed);
g->current_play_from_hand = NULL;
}
for (int i = 0; i < g->player.scored.count; i++) {
g->player.scored.cards[i]->selected = false;
}
g->state = GAME_STATE_SHOWING_CARD_FROM_DECK;
}
}
@ -536,7 +545,14 @@ void run_frame_choosing_target_from_deck(Game *g) {
valid_targets(top_card, &g->field, &targets[0], &target_count);
if (is_player_turn(g)) {
for (int i = 0; i < target_count; i++) {
targets[i]->selected = true;
}
if (g->current_play_target) {
for (int i = 0; i < target_count; i++) {
targets[i]->selected = false;
}
capture_card_from_field(g, top_card, g->current_play_target, &g->deck, to_hand);
g->state = GAME_STATE_CHECKING_FOR_NEW_DEKIYAKU;
g->current_play_from_hand = NULL;
@ -923,7 +939,21 @@ void draw_frame(Game *g) {
break;
case GAME_STATE_CHOOSING_TARGET:
DrawText("Choose a target on the field", 60, 485, 20, BLACK);
DrawRectangleRec(next_card_position(&g->field), BLUE);
Card *selected_card = NULL;
for (int i = 0; i < g->player.hand.count; i++) {
if (g->player.hand.cards[i]->selected) {
selected_card = g->player.hand.cards[i];
break;
}
}
if (!selected_card) break;
bool draw_next_rec = true;
for (int i = 0; i < g->field.count; i++) {
if (g->field.cards[i]->month == selected_card->month) draw_next_rec = false;
}
if (draw_next_rec) DrawRectangleRec(next_card_position(&g->field), BLUE);
break;
default:
break;