-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.h
71 lines (47 loc) · 1.99 KB
/
Board.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
//
// Created by orjie on 28/03/2023.
//
#ifndef BUG_PROJECT_BOARD_H
#define BUG_PROJECT_BOARD_H
#include "Bug.h"
#include <vector>
#include "Direction.h"
#include <iostream>
#include <SFML/Graphics/Sprite.hpp>
class Board {
//private members
static const int BOARD_SIZE = 10;
//initializing the board to be a vector of bug cells
std::vector <Bug*> cells[100];
std::vector <Bug*> bugs;
// to keep track of the number of rounds played
int rounds = 0;
public:
//default constructor
Board();
bool initialiseBoard(const std::string& filename);
bool isValidBugData(const std::string& bugType, const std::string& bugIdStr, const std::string& bugXStr, const std::string& bugYStr, const std::string& directionStr, const std::string& sizeStr, const std::string& hopLengthStr, const std::string& bishopLengthStr) const;
void createHopperBug(int bugId, int bugX, int bugY, int direction, int size, int hopLength);
void createCrawlerBug(int bugId, int bugX, int bugY, int direction, int size);
void createBishopBug(int bugId, int bugX, int bugY, int direction, int size, int bisLength);
void displayAllBugs() const;
bool isBoardEmpty() const;
void findBugById() const;
void tapBoard();
int countAliveBugs() const;
Bug* findLastAliveBug() const;
//to simulate the fight between bugs in the same cell this is without graphics
void simulate();
//was done this way so that the method could be reused in the writeLifeHistoryOfAllBugsToFile() method
void displayLifeHistoryOfAllBugs(std::ostream& out = std::cout) const;
void writeLifeHistoryOfAllBugsToFile() const;
void displayAllCells() const;
//to draw the board with the SFML library
//this is the simulation of the board with graphics and superbug
void drawBoard();
void rotate(Bug *const &bug, sf::Sprite &sprite, float &offsetX, float &offsetY) const;
bool isCellEmpty(int x, int y);
//destructor
~Board();
};
#endif //BUG_PROJECT_BOARD_H