Advertisement
Guest User

header

a guest
Dec 14th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. #pragma once
  2.  
  3. //Header file for the game
  4. //This contains declaration of function signatures and structs
  5.  
  6. struct Deck {
  7.     int* cards; //an array of cards
  8.     int deck_size;  //the size of the deck
  9.     int* cnt_top;   //the index to the top card;
  10. };
  11.  
  12. struct PlayPile {
  13.     int is_ascending; //true = ASCENDING false = DESCENDING pile
  14.     int pile_size; //the current size of the pile
  15.     int top_card;  //the value of the top card
  16. };
  17.  
  18. struct Player {
  19.     int cards[8];   //player's hand
  20.     int max_hand_size; //the maximum hand size of a player
  21.     int hand_size;  //the size of the current hand
  22. };
  23.  
  24. struct TheGame {
  25.     Deck draw_deck;     //the drawdeck
  26.     PlayPile play_piles[4]; //4 play piles
  27.     Player players[5];  //maximum 5 players
  28.     int num_players;    //number of players
  29.     int turns;          //the number of turns
  30. };
  31.  
  32. void swapInt(int* a, int* b);
  33.  
  34. void sortIntArray(int* array, int size);
  35.  
  36. //Deck related functions
  37. void initialise_deck(Deck* deck, int decksize);
  38.  
  39. void display_deck(const Deck* deck);
  40.  
  41. void cleanup_deck(Deck* deck);
  42.  
  43. void shuffle_deck(Deck* deck, int times);
  44.  
  45. //Game related functions
  46. TheGame* create_new_game(int num_players);
  47.  
  48. void initialise_game(TheGame* game, int num_players);
  49.  
  50. bool is_game_ended(const TheGame* game);
  51.  
  52. int calculate_game_score(const TheGame* game);
  53.  
  54. void display_game_state(const TheGame* game);
  55.  
  56. void cleanup_game(TheGame* game);
  57.  
  58. //Play pile related functions
  59. void initialise_play_pile(PlayPile* pile, bool ascending);
  60.  
  61. //Player related functions
  62. void initialise_player(Player* player, int hand_size, Deck* deck);
  63.  
  64. //check if the value of card can be played into the pile;
  65. bool is_play_valid(int card, PlayPile* pile);
  66.  
  67. void display_player_hand(const Player* player);
  68.  
  69. //The input player draws a number of card specified by count from the deck
  70. //The function returns the actual number of card drawn.
  71. int player_draw_cards_from_deck(Player* player, Deck* deck, int count);
  72.  
  73. bool player_play_card_to_pile(Player* player, int whichcard, PlayPile* pile);
  74.  
  75. //Player takes a game turn
  76. //This function returns the number cards the player
  77. //played in this turn.
  78. int player_process_turn(TheGame* game, Player* player);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement