-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuman.cpp
More file actions
37 lines (33 loc) · 807 Bytes
/
Human.cpp
File metadata and controls
37 lines (33 loc) · 807 Bytes
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
//
// Created by Marcin on 2018-11-11.
//
#include "Human.h"
Human::Human(int x, int y):Player(x, y) {}
bool Human::placeShip(int size) {
int x, y, dir;
std::cout << "Placing ship of size " << size << " (x, y, dir): ";
std::cin >> x;
std::cin >> y;
std::cin >> dir;
if(x == 0 && y == 0 && dir == 0) {
return false;
}
bool result = board.placeShip(x, y, size, (Board::directions)dir);
if(!result) {
result = placeShip(size);
} else {
printBoard();
}
return result;
}
bool Human::target(Player &enemy) {
int x = 0 , y = 0;
do {
std::cin >> x;
std::cin >> y;
if(!x && !y) {
printCheatEnemyBoard(enemy);
}
} while(enemyBoard.getAt(x, y) != '.');
return shoot(x, y, enemy);
}