Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- //Header file for the game
- //This contains declaration of function signatures and structs
- struct Deck {
- int* cards; //an array of cards
- int deck_size; //the size of the deck
- int* cnt_top; //the index to the top card;
- };
- struct PlayPile {
- int is_ascending; //true = ASCENDING false = DESCENDING pile
- int pile_size; //the current size of the pile
- int top_card; //the value of the top card
- };
- struct Player {
- int cards[8]; //player's hand
- int max_hand_size; //the maximum hand size of a player
- int hand_size; //the size of the current hand
- };
- struct TheGame {
- Deck draw_deck; //the drawdeck
- PlayPile play_piles[4]; //4 play piles
- Player players[5]; //maximum 5 players
- int num_players; //number of players
- int turns; //the number of turns
- };
- void swapInt(int* a, int* b);
- void sortIntArray(int* array, int size);
- //Deck related functions
- void initialise_deck(Deck* deck, int decksize);
- void display_deck(const Deck* deck);
- void cleanup_deck(Deck* deck);
- void shuffle_deck(Deck* deck, int times);
- //Game related functions
- TheGame* create_new_game(int num_players);
- void initialise_game(TheGame* game, int num_players);
- bool is_game_ended(const TheGame* game);
- int calculate_game_score(const TheGame* game);
- void display_game_state(const TheGame* game);
- void cleanup_game(TheGame* game);
- //Play pile related functions
- void initialise_play_pile(PlayPile* pile, bool ascending);
- //Player related functions
- void initialise_player(Player* player, int hand_size, Deck* deck);
- //check if the value of card can be played into the pile;
- bool is_play_valid(int card, PlayPile* pile);
- void display_player_hand(const Player* player);
- //The input player draws a number of card specified by count from the deck
- //The function returns the actual number of card drawn.
- int player_draw_cards_from_deck(Player* player, Deck* deck, int count);
- bool player_play_card_to_pile(Player* player, int whichcard, PlayPile* pile);
- //Player takes a game turn
- //This function returns the number cards the player
- //played in this turn.
- int player_process_turn(TheGame* game, Player* player);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement