-
Notifications
You must be signed in to change notification settings - Fork 0
/
serwer.h
98 lines (80 loc) · 1.81 KB
/
serwer.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
#ifndef _serwer_h_
#define _serwer_h_
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
#include <vector>
#include <pthread.h>
#include <ncurses.h>
#include "player.h"
#include "map.h"
class Ds
{
public:
Point position;
int value;
char charUnder;
Ds(int x, int y, int valueToAssign, char charUnderToAssign)
{
position.x = x;
position.y = y;
value = valueToAssign;
charUnder = charUnderToAssign;
}
};
class Beast
{
public:
pthread_t th;
bool inBush;
char charUnder;
Point position;
enum direction dir;
char pieceOfMap[MAP_SIZE][MAP_SIZE+3];
Beast(int x, int y)
{
inBush = false;
charUnder = ' ';
position.x = x;
position.y = y;
}
static void *makeARequestToMoveThread(void *beastIGuess);
};
class Serwer
{
public:
char **map;
std::vector<Beast> beasts;
std::vector<Player> players;
std::vector<Ds> ds;
std::vector<Semaphore> semaphors;
std::vector<Player *> shmPointers;
pid_t PID;
long roundNumber;
Serwer()
{
beasts.clear();
players.clear();
ds.clear();
roundNumber=0;
PID = getpid();
}
void createPieceOfMap(Point position, char pieceOfMap[MAP_SIZE][MAP_SIZE+3]);
void mapGenerate();
void mapDisplay();
void addBeast();
void drawBeastOnMap(Beast toput);
void colisionWithBeast(Beast &beast, Player &toReset);
void actualMoveBeast(Beast &toMove);
void addPlayer(int number);
void drawPlayerOnMap(Player toput);
void colisionWithPlayer(Player &toReset1, Player &toReset2);
void actualMovePlayer(Player &toMove, enum direction dir);
void addTresure(char tres);
void gameRestart();
void endGame();
};
#endif