diff --git a/game.c b/game.c index 65060c7..1737c17 100644 --- a/game.c +++ b/game.c @@ -6,6 +6,7 @@ #include "teyaku.h" #include "dekiyaku.h" #include "field_multiplier.h" +#include "play.h" Vector2 mouse_pos; char teyaku_calculation[400]; @@ -118,6 +119,33 @@ void handle_input(Game *g) { } } } + + 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; + } + } + + for (int i = 0; i < g->field.count; i++) { + if (point_within_card(g->field.cards[i], mouse_pos)) { + if (selected_card == NULL) printf("No card selected, whoops"); + if (valid_play(&g->field, selected_card, g->field.cards[i])) { + printf("Valid\n"); + } else { + printf("Invalid\n"); + } + } + } + + if (CheckCollisionPointRec(mouse_pos, next_card_position(&g->field))) { + if (valid_play(&g->field, selected_card, NULL)) { + printf("Valid\n"); + } else { + printf("Invalid\n"); + } + } } break; default: diff --git a/play.c b/play.c index 4d777eb..d12c362 100644 --- a/play.c +++ b/play.c @@ -6,7 +6,7 @@ bool valid_play(Hand *field, Card *played, Card *target) { if (target == NULL) { bool matching_month_in_field = false; for (int i = 0; i < field->count; i++) { - if (field->cards[i]->month == target->month) { + if (field->cards[i]->month == played->month) { matching_month_in_field = true; break; }