-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAllShips.cpp
64 lines (50 loc) · 1.45 KB
/
AllShips.cpp
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
#include "AllShips.h"
#include<iostream>
using namespace std;
AllShips::AllShips() {
for (int i = 0; i < amountToPlace; i++)
this->allShips.emplace_back(theirSize[i],i); //Konstruktor clasy AllShips, która przechowuje statki.
}
vector<Ship> AllShips::returnShips() {
return this->allShips;//zwraca wektor przechowuj¹cy objekty statków
}
int AllShips::returnAmountToPlace() {
return this->amountToPlace; //
}
map<Ship, vector<string>> AllShips::zwrocPozycje() {
return this->wszystkiePozycje; //
}
void AllShips::statekTrafiony(int id, AllSquares& squares) {
for (auto& statek : this->allShips) { //
if (statek.getID() == id) {
statek.ustawPolaPoZniszczeniu(squares); //
}
}
}
void AllShips::UstawPozycje(int id, int x, int y) { //ustawia pozycje
for (auto& statek : this->allShips) {
if (statek.getID() == id) {
statek.setPosXPosY(x, y); //ustawia pozycje statku
break;
}
}
}
void AllShips::ZmienRotacje(int id) {
for (auto& statek : this->allShips) {
if (statek.getID() == id) { //szuka statku o podanym id
statek.changeRotation(); //obraca statek na planszy
break;
}
}
}
bool AllShips::CzyStatekJestDoZniszczenia(int id) {
for (auto& statek : this->allShips) {
if (statek.getID() == id) { //szuka statku o podanym id
statek.Hit();
if (statek.getSize() - statek.getHit() > 0) //sprawdza czy statek ma wszystkie zniszczone pola.
return false;
else
return true;
}
}
}