-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBattle.cpp
48 lines (47 loc) · 1.2 KB
/
Battle.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
#include "Battle.hpp"
#include "Board55.hpp"
namespace Shogi55{
void client(IProtocol &protocol, IGame &game){
Board55 board;
board.init_board();
protocol.start(board, 0, 0);
game.initialize(protocol.get_initial_board(), protocol.is_your_turn_first(), protocol.get_start_turn());
board = protocol.get_initial_board();
if(protocol.get_start_turn() != protocol.is_your_turn_first()){
PlayLog move;
bool resign;
protocol.get_move(board, move, resign);
if(resign){
cout << "You Win!!" << endl;
return;
}
IGame::Move m;
m.move = move;
m.resign = false;
game.opposite_move(m);
board.move_piece(move);
}
while(true){
IGame::Move m = game.get_move();
if(m.resign){
protocol.resign();
cout << "You Lose!!" << endl;
break;
}else{
protocol.move(m.move);
}
board.move_piece(m.move);
PlayLog move;
bool resign;
protocol.get_move(board, move, resign);
if(resign){
cout << "You Win!!" << endl;
break;
}
m.move = move;
m.resign = false;
game.opposite_move(m);
board.move_piece(move);
}
}
}