Automatically expose the top card on a maneuvre after a move
This commit is contained in:
		
							parent
							
								
									14cd5e61bb
								
							
						
					
					
						commit
						7f459aa5b8
					
				
							
								
								
									
										11
									
								
								src/game.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/game.c
									
									
									
									
									
								
							| @ -141,7 +141,16 @@ void move_block(struct stack **origin, struct stack **destination, | |||||||
|   if (stack_length(*destination) > 1) { |   if (stack_length(*destination) > 1) { | ||||||
|     cursor->y += block_size; |     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) { | static void fill_deck(struct deck *deck) { | ||||||
|  | |||||||
| @ -43,6 +43,7 @@ bool stock_stack(struct stack *); | |||||||
| bool valid_move(struct stack *, struct stack *); | bool valid_move(struct stack *, struct stack *); | ||||||
| void move_card(struct stack **, struct stack **); | void move_card(struct stack **, struct stack **); | ||||||
| void move_block(struct stack **, struct stack **, int); | void move_block(struct stack **, struct stack **, int); | ||||||
|  | void expose_top(struct stack **); | ||||||
| void game_init(struct game *, int, int); | void game_init(struct game *, int, int); | ||||||
| bool game_won(); | bool game_won(); | ||||||
| void game_end(); | void game_end(); | ||||||
|  | |||||||
| @ -157,6 +157,7 @@ static void handle_card_movement(struct cursor *cursor) { | |||||||
|               ; |               ; | ||||||
|             if (valid_move(block, *destination)) { |             if (valid_move(block, *destination)) { | ||||||
|               move_block(origin, destination, _marked_cards_count); |               move_block(origin, destination, _marked_cards_count); | ||||||
|  |               expose_top(origin); | ||||||
|             } |             } | ||||||
|           } else { |           } else { | ||||||
|             if (valid_move(*origin, *destination)) { |             if (valid_move(*origin, *destination)) { | ||||||
| @ -164,6 +165,7 @@ static void handle_card_movement(struct cursor *cursor) { | |||||||
|                 cursor->y++; |                 cursor->y++; | ||||||
|               } |               } | ||||||
|               move_card(origin, destination); |               move_card(origin, destination); | ||||||
|  |               expose_top(origin); | ||||||
|             } |             } | ||||||
|           } |           } | ||||||
|           draw_stack(*origin); |           draw_stack(*origin); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user