-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameView.h
executable file
·130 lines (100 loc) · 5.22 KB
/
GameView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// GameView.h
// Official Interface for GameViewADT
// COMP1927 14s2
#ifndef GAME_VIEW_H
#define GAME_VIEW_H
#include "Globals.h"
#include "Game.h"
#include "Places.h"
typedef struct gameView *GameView;
// newGameView() creates a new game view to summarise the current state of
// the game.
//
// pastPlays is a string of all the plays made in the game so far by all
// players (including Dracula) from earliest to most recent.
//
// messages is an array containing a playerMessage for each play in the game
// so far. It will have exactly the same number of elements as there are plays
// in pastPlays. The message from the first play will be at index 0, and so on.
// The contents of each playerMessage will be exactly as provided by the player.
//
// The "PlayerMessage" type is defined in game.h.
// You are free to ignore messages if you wish.
GameView newGameView(char *pastPlays, PlayerMessage messages[]);
// disposeGameView() frees all memory previously allocated for the GameView
// toBeDeleted. toBeDeleted should not be accessed after the call.
void disposeGameView(GameView toBeDeleted);
// Functions to return simple information about the current state of the game
// Get the current round
Round getRound(GameView currentView);
// Get the id of current player - ie whose turn is it?
// Only returns a 'playerID' which is one of:
// LORD_GODALMING (0): Lord Godalming's turn
// DR_SEWARD (1): Dr. Seward's turn
// VAN_HELSING (2): Van Helsing's turn
// MINA_HARKER (3): Mina Harker's turn
// DRACULA (4): Dracula's turn
PlayerID getCurrentPlayer(GameView currentView);
// Get the current score
// Returns a positive integer [0...366]
int getScore(GameView currentView);
// Get the current health points for a given player
// 'player' specifies which players's life/blood points to return
// and must be a value in the interval [0...4] (see 'player' type)
int getHealth(GameView currentView, PlayerID player);
// Get the current location id of a given player
// May be UNKNOWN_LOCATION if the player has not had a turn yet
// (ie at the beginning of the game when the round is 0)
// otherwise for a hunter it should be an integer in the interval [0..70]
// The given roundNumber is >= 0 and <= the current round number
// 'whichHunter' specifies which hunter's location to return
// and must be a value in the interval [0...3] (see 'player' type)
// Or for dracula it should
// gets the location of Dracula at the start of a particular round
// Returns an integer:
// in the interval [0...70] if Dracula was known to be in a city or sea
// CITY_UNKNOWN if Dracula was in an unknown city
// SEA_UNKNOWN if Dracula was in an unknown sea
// HIDE if Dracula was known to have made a hide move
// DOUBLE_BACK_N where N is [0...5], if Dracula was known to have
// made a double back move N positions back in the trail
// e.g. DOUBLE_BACK_1 is the last place place he visited
// TELEPORT if Dracula apparated back to Castle Dracula
// LOCATION_UNKNOWN if the round number is 0
LocationID getLocation(GameView currentView, PlayerID player);
//// Functions that return information about the history of the game
// Fills the trail array with the location ids of the last 6 turns
// for the given player
// For Dracula this may include integers:
// in the interval [0...70] if Dracula was known to be in a city or sea
// CITY_UNKNOWN if Dracula was in an unknown city
// SEA_UNKNOWN if Dracula was in an unknown sea
// HIDE if Dracula was known to have made a hide move
// DOUBLE_BACK_N where N is [0...5], if Dracula was known to have
// made a double back move N positions back in the trail
// e.g. DOUBLE_BACK_1 is the last place place he visited
// TELEPORT if Dracula apparated back to Castle Dracula
//
// For any player if the move does not exist yet (i.e, the start of the game),
// the value should be UNKNOWN_LOCATION (-1)
// For example after 2 turns the array may have the contents
// {29, 12, -1, -1, -1, -1}
// This would mean in the first move the player started on location 12
// then moved to the current location of 29
void getHistory(GameView currentView, PlayerID player,
LocationID trail[TRAIL_SIZE]);
//// Functions that query the map to find information about connectivity
// connectedLocations() returns an array of LocationID that represent
// all locations that are connected to the given LocationID.
// road, rail and sea are connections should only be considered
// if the road, rail, sea parameters are TRUE.
// The size of the array is stored in the variable pointed to by numLocations
// The array can be in any order but must contain unique entries
// Your function must take into account the round and player id for rail travel
// Your function must take into account that Dracula can't move to
// the hospital or travel by rail but need not take into account Dracula's trail
// The destination 'from' should be included in the array
LocationID *connectedLocations(GameView currentView, int *numLocations,
LocationID from, PlayerID player, Round round,
int road, int rail, int sea);
#endif