Comment out debugging
This commit is contained in:
parent
5918dc5212
commit
1a22c65c1d
31
client.py
31
client.py
@ -29,11 +29,12 @@ def recv_str(sock,print_str=True):
|
||||
break
|
||||
str+=ch
|
||||
if print_str:
|
||||
print("Got string: "+str)
|
||||
pass
|
||||
# print("Got string: "+str)
|
||||
return str
|
||||
|
||||
def send_str(sock,str):
|
||||
print("Sending string: "+str)
|
||||
# print("Sending string: "+str)
|
||||
sock.send((str+"\n").encode("utf-8"))
|
||||
|
||||
def recv_hash(sock):
|
||||
@ -43,7 +44,7 @@ def recv_hash(sock):
|
||||
key=recv_str(sock,False)
|
||||
val=recv_str(sock,False)
|
||||
hash[key]=val
|
||||
print("Got hash: "+pp.pformat(hash))
|
||||
# print("Got hash: "+pp.pformat(hash))
|
||||
return hash
|
||||
|
||||
def recvall(sock):
|
||||
@ -54,7 +55,7 @@ def recvall(sock):
|
||||
data+=part
|
||||
if len(part)<BUFF_SIZE:
|
||||
break
|
||||
print("Got data: "+pp.pformat(pickle.loads(data)))
|
||||
# print("Got data: "+pp.pformat(pickle.loads(data)))
|
||||
return data
|
||||
|
||||
|
||||
@ -65,33 +66,33 @@ recipes.init()
|
||||
pygame.display.set_caption(UNAME)
|
||||
screen=pygame.display.set_mode((constants.WINDWIDTH,constants.WINDHEIGHT))
|
||||
sock=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
show_step("Connecting to game server")
|
||||
# show_step("Connecting to game server")
|
||||
sock.connect(("localhost",2000))
|
||||
show_step("Adding user to server (Sending ADD_USR {})".format(UNAME))
|
||||
# show_step("Adding user to server (Sending ADD_USR {})".format(UNAME))
|
||||
send_str(sock,"ADD_USR")
|
||||
send_str(sock,UNAME)
|
||||
show_step("Recieving UID")
|
||||
# show_step("Recieving UID")
|
||||
my_uid=int(recv_str(sock))
|
||||
show_step("Got UID {}".format(my_uid))
|
||||
show_step("Initializing UID map")
|
||||
# show_step("Got UID {}".format(my_uid))
|
||||
# show_step("Initializing UID map")
|
||||
uid_map={}
|
||||
show_step("Initializing level map")
|
||||
# show_step("Initializing level map")
|
||||
map=Map(screen,sock,my_uid)
|
||||
map.tiles={}
|
||||
|
||||
show_step("Retreiving player position and facing (Sending GET_POS_FOR_UID {})".format(my_uid))
|
||||
# show_step("Retreiving player position and facing (Sending GET_POS_FOR_UID {})".format(my_uid))
|
||||
send_str(sock,"GET_POS_FOR_UID")
|
||||
send_str(sock,str(my_uid))
|
||||
x=int(recv_str(sock))
|
||||
y=int(recv_str(sock))
|
||||
fac=recv_str(sock)
|
||||
show_step("Got position ({},{}), facing {}".format(x,y,fac))
|
||||
show_step("Initializing player")
|
||||
# show_step("Got position ({},{}), facing {}".format(x,y,fac))
|
||||
# show_step("Initializing player")
|
||||
player=Player(x,y,map,screen,UNAME,"player_local")
|
||||
player.dir=fac
|
||||
show_step("Adding workbench to inventory")
|
||||
# show_step("Adding workbench to inventory")
|
||||
player.inv.addTile("workbench",1)
|
||||
show_step("Initializing misc game variables")
|
||||
# show_step("Initializing misc game variables")
|
||||
others={}
|
||||
running=True
|
||||
move=False
|
||||
|
@ -24,7 +24,7 @@ class Block(Sprite):
|
||||
self.mp_upd=False
|
||||
|
||||
def draw(self,x,y):
|
||||
print("DRAW BLOCK")
|
||||
# print("DRAW BLOCK")
|
||||
if self.tname==None:
|
||||
raise Exception("No texture name for block. Did you forget to call setTextureName()?".format())
|
||||
self.screen.blit(Block.background,(x*constants.TILESIZE,y*constants.TILESIZE))
|
||||
@ -32,8 +32,7 @@ class Block(Sprite):
|
||||
if texture==False:
|
||||
texture=Block.textures[self.tname]
|
||||
self.screen.blit(texture,(x*constants.TILESIZE,y*constants.TILESIZE))
|
||||
pygame.display.flip()
|
||||
sleep(0.05)
|
||||
# sleep(0.05)
|
||||
def setTextureName(self,name):
|
||||
if not name in Block.textures.keys():
|
||||
raise Exception("{} is not a valid texture. Did you forget to call registerTexture(\"{}\")?".format(name,name))
|
||||
|
@ -27,7 +27,7 @@ class Map:
|
||||
data+=part
|
||||
if len(part)<BUFF_SIZE:
|
||||
break
|
||||
print(pickle.loads(data))
|
||||
#print(pickle.loads(data))
|
||||
return data
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ class Player(Character):
|
||||
to_place=self.inv.selected
|
||||
if to_place=="":
|
||||
return
|
||||
self.map.tiles[coords[1]][coords[0]]=None
|
||||
self.map.tiles[(coords[0],coords[1])]=None
|
||||
self.map.addTile(to_place,coords[0],coords[1])
|
||||
self.inv.remove(to_place)
|
||||
else:
|
||||
@ -52,7 +52,7 @@ class Player(Character):
|
||||
name=tile.unlocalisedName
|
||||
if name=="grass":
|
||||
return
|
||||
self.map.tiles[coords[1]][coords[0]]=None
|
||||
self.map.tiles[(coords[0],coords[1])]=None
|
||||
self.map.addTile("grass",coords[0],coords[1])
|
||||
if tile.drops==False:
|
||||
self.inv.addTile(name,1)
|
||||
|
9
serv.py
9
serv.py
@ -39,16 +39,17 @@ def recv_str(sock):
|
||||
if ch=="\n":
|
||||
break
|
||||
str+=ch
|
||||
print("Got string: "+str)
|
||||
# print("Got string: "+str)
|
||||
return str
|
||||
|
||||
def send_str(sock,str,print_str=True):
|
||||
if print_str:
|
||||
print("Sending string: "+str)
|
||||
pass
|
||||
# print("Sending string: "+str)
|
||||
sock.send((str+"\n").encode("utf-8"))
|
||||
|
||||
def send_hash(sock,hash):
|
||||
print("Sending hash: "+pp.pformat(hash))
|
||||
# print("Sending hash: "+pp.pformat(hash))
|
||||
send_str(sock,str(len(hash)),False)
|
||||
for key,val in hash.items():
|
||||
send_str(sock,str(key),False)
|
||||
@ -62,7 +63,7 @@ def recvall(sock):
|
||||
data+=part
|
||||
if len(part)<BUFF_SIZE:
|
||||
break
|
||||
print("Got data: "+pp.pformat(pickle.loads(data)))
|
||||
# print("Got data: "+pp.pformat(pickle.loads(data)))
|
||||
return data
|
||||
|
||||
def on_new_client(sock):
|
||||
|
Loading…
x
Reference in New Issue
Block a user