-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gameclient.py
48 lines (37 loc) · 1.07 KB
/
Gameclient.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
from Mastermind import *
#Connection Mastermind
server_ip = 'localhost'
client_ip = 'localhost'#192.168.178.37'
port = 42042
client_timeout_connect = 5.0
client_timeout_receive = 10.0
client = None
def create_Client(mainport,mainclient_ip):
global client,server_ip,client_ip, port
port = mainport
client_ip = mainclient_ip
client = MastermindClientTCP(client_timeout_connect,client_timeout_receive)
client.connect(client_ip,port)
def send_data(data):
client.send(data)
recieved_data = client.receive(True)
if data == "gg" or recieved_data == "gg":
return "gg"
elif recieved_data[0] == "level finished":
return recieved_data
elif data[0] == 1: # Spieler 1 oder 2
return recieved_data[1]
else:
return recieved_data[0]
def get_player_number(ghostmode):
global p2_ghostmode
player = 0
client.send([0,ghostmode])
x = client.receive(True)
if x == [None,None]:
player = 1
else:
player = 2
if x == "duell":
return (player,False)
return (player,True)