-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameplay.cpp
More file actions
48 lines (48 loc) · 1.63 KB
/
Gameplay.cpp
File metadata and controls
48 lines (48 loc) · 1.63 KB
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
#include <iostream>
#include <string.h>
using namespace std;
#include "Patch.h"
#include "Ship.h"
#include "Board.h"
#include "Person.h"
int main(){
//setting random number be different every time it is used during program
srand(time(0));
//creating different players, their boards, and placing ships
Human human_player;
AI ai_player;
human_player.create_boards();
human_player.enter_ships();
ai_player.create_boards();
ai_player.enter_ships();
bool gamecontinue=true;
//gameplay. game goes on until a player wins and each time a player attack then the other.
while (gamecontinue==true)
{
cout<<endl<<"---------Your turn:---------"<<endl;
cout<<endl<<"---------Your sunked ships: "<<human_player.sunked_ships_getter()<<" ---------"<<endl;
human_player.Activate_bombs();
//check if human won
if (human_player.won_status_getter())
{
cout<<endl<<"You won!"<<endl;
gamecontinue=false;
break;
}
cout<<endl<<"---------Smith's turn:---------"<<endl;
cout<<endl<<"---------Smith's sunked ships: "<<ai_player.sunked_ships_getter()<<" ---------"<<endl;
ai_player.Activate_bombs();
//check if AI won
if (ai_player.won_status_getter())
{
cout<<endl<<"A. Smith won!"<<endl;
gamecontinue=false;
break;
}
}
cout<<endl<<"end of the game!"<<endl;
//last time displaying the boards of two players
human_player.Draw_Full_Player_Board();
ai_player.Draw_Full_Player_Board();
return 0;
}