From 4f9d00023a0843b26159ff992f5f1ccfedbd23ba Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Tue, 2 May 2023 23:47:26 +0200 Subject: [PATCH] #267 Added first client functionality~ --- pokete.py | 2 ++ pokete_classes/multiplayer/menu.py | 10 +++++----- server/responses/responses.go | 2 +- server/test.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/pokete.py b/pokete.py index f44e486c..41c11463 100755 --- a/pokete.py +++ b/pokete.py @@ -20,6 +20,7 @@ import scrap_engine as se import pokete_data as p_data from pokete_classes import animations +from pokete_classes.multiplayer.connector import connector from pokete_classes.multiplayer.menu import ModeChooser from pokete_classes.pokestats import PokeStats from pokete_classes.poke import Poke, upgrade_by_one_lvl @@ -928,6 +929,7 @@ def exiter(): reset_terminal() logging.info("[General] Exiting...") print("\033[?1049l\033[1A") + connector.ensure_closure() if audio.curr is not None: audio.kill() diff --git a/pokete_classes/multiplayer/menu.py b/pokete_classes/multiplayer/menu.py index be04f28d..66037b41 100644 --- a/pokete_classes/multiplayer/menu.py +++ b/pokete_classes/multiplayer/menu.py @@ -7,7 +7,7 @@ from pokete_classes.multiplayer.modeprovider import modeProvider, Mode from pokete_classes.tss import tss from pokete_classes.ui_elements import BetterChooseBox -from pokete_classes import movemap as mvp +from .connector import connector class PreGameMap(gm.GameSubmap): @@ -29,9 +29,9 @@ def __init__(self): ) super().__init__( 1, [ - se.Text("Singleplayer"), - se.Text("Multiplayer"), - se.Text("Leave..."), + se.Text("Singleplayer", state="float"), + se.Text("Multiplayer", state="float"), + se.Text("Leave...", state="float"), ], name="Mode", overview=self.map, _map=self.map @@ -53,7 +53,7 @@ def __call__(self): return elif num == 1: modeProvider.mode = Mode.MULTI - # Connection entrypoint here + connector(self.map, self) return else: sys.exit() diff --git a/server/responses/responses.go b/server/responses/responses.go index 3c122a6c..faf61f5c 100644 --- a/server/responses/responses.go +++ b/server/responses/responses.go @@ -25,7 +25,7 @@ func writeResponse(connection *net.Conn, response Response) error { return err } - _, err = (*connection).Write(resp) + _, err = (*connection).Write(append(resp, []byte("")...)) if err != nil { return err } diff --git a/server/test.py b/server/test.py index 5683a292..8848643b 100644 --- a/server/test.py +++ b/server/test.py @@ -1,7 +1,7 @@ import socket, time, json, sys HOST = "localhost" # The server's hostname or IP address -PORT = 9988 # The port used by the server +PORT = 9988 # The port used by the server with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT))