Merge remote-tracking branch 'DolphyWind/tty-solitaire/auto_uncover_top'

This commit is contained in:
maride 2024-11-26 22:21:02 +01:00
commit 17cfae9c54
3 changed files with 13 additions and 1 deletions

View File

@ -141,7 +141,16 @@ void move_block(struct stack **origin, struct stack **destination,
if (stack_length(*destination) > 1) {
cursor->y += block_size;
}
stack_free(tmp);
}
void expose_top(struct stack **origin)
{
struct card *top;
if((top = stack_pop(origin)))
{
card_expose(top);
stack_push(origin, top);
}
}
static void fill_deck(struct deck *deck) {

View File

@ -43,6 +43,7 @@ bool stock_stack(struct stack *);
bool valid_move(struct stack *, struct stack *);
void move_card(struct stack **, struct stack **);
void move_block(struct stack **, struct stack **, int);
void expose_top(struct stack **);
void game_init(struct game *, int, int);
bool game_won();
void game_end();

View File

@ -158,6 +158,7 @@ static void handle_card_movement(struct cursor *cursor) {
;
if (valid_move(block, *destination)) {
move_block(origin, destination, _marked_cards_count);
expose_top(origin);
}
} else {
if (valid_move(*origin, *destination)) {
@ -165,6 +166,7 @@ static void handle_card_movement(struct cursor *cursor) {
cursor->y++;
}
move_card(origin, destination);
expose_top(origin);
}
}
draw_stack(*origin);