-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_client.py
50 lines (37 loc) · 1.96 KB
/
test_client.py
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
from networking.client import Client
host_address = 'localhost'
host_port = 65432
grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, "C", 0, 0, 0, "D", 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, "B", 0, 0, 0, "C", 0, 0, 0, "D", 0, 0, 0, "S", 0, 0, 0, 0],
[0, 0, 0, "B", 0, 0, 0, "C", 0, 0, 0, "D", 0, 0, 0, "S", 0, 0, 0, 0],
[0, 0, 0, "B", 0, 0, 0, "C", 0, 0, 0, "D", 0, 0, 0, "S", 0, 0, 0, 0],
[0, 0, 0, "B", 0, 0, 0, "C", 0, 0, 0, "D", 0, 0, 0, "S", 0, 0, 0, 0],
[0, 0, 0, "B", 0, 0, 0, "C", 0, 0, 0, 0, 0, 0, 0, "S", 0, 0, 0, 0],
[0, 0, 0, "B", 0, 0, 0, "C", 0, 0, 0, 0, 0, 0, 0, "S", 0, 0, 0, 0],
["R", 0, 0, "B", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "S", 0, 0, 0, 0],
["R", 0, 0, "B", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
["R", 0, 0, "B", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
["R", 0, 0, "B", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
["R", 0, 0, "B", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
linkrs = Client('LinkRs', host_address, host_port)
zeldars = Client('ZeldaRs', host_address, host_port)
linkrs.connect_to_server()
zeldars.connect_to_server()
linkrs.lock_ships(grid)
zeldars.lock_ships(grid)
print('Before attack')
print(linkrs.get_game_data())
print(zeldars.get_game_data())
linkrs.attack_enemy_tile((13, 0))
zeldars.attack_enemy_tile((14, 0))
print('After attack')
print(linkrs.get_game_data())
print(zeldars.get_game_data())