diff --git a/Auth Server/database.py b/Auth Server/database.py index a43d5a8..4d1ab01 100644 --- a/Auth Server/database.py +++ b/Auth Server/database.py @@ -15,6 +15,6 @@ class Database: self.__cursor.execute(query) return self.__cursor.fetchall() - def fetchall(self, query:str): + def fetchone(self, query:str): self.__cursor.execute(query) return self.__cursor.fetchone() \ No newline at end of file diff --git a/Auth Server/index.py b/Auth Server/index.py index 5966ec6..4fc26aa 100644 --- a/Auth Server/index.py +++ b/Auth Server/index.py @@ -2,6 +2,7 @@ import socket import threading import os import json +import database from dotenv import load_dotenv load_dotenv() @@ -9,6 +10,9 @@ load_dotenv() # retrieves host data from environment HOST = os.getenv("HOST") PORT = os.getenv("PORT") +db = database.Database(os.getenv("DBNAME"), os.getenv("DBHOST"), os.getenv("DBUSER"), os.getenv("DBPASSWORD"), os.getenv("DBPORT")) + +sessions = {} # TODO: setup tcp service for authorization def handle_connection(socket:socket, address): @@ -28,9 +32,13 @@ def handle_connection(socket:socket, address): # decide which event should be performed if message_json["event"] == "login": + + username = message_json["username"] + password = message_json["password"] + # encode message and respond to client - # TODO: connect to databasse # TODO: request user data + db.fetchone(f"SELECT * FROM users WHERE username={username} AND password={password}") # TODO: validate user data # TODO: create session # TODO: return session to client diff --git a/Game Client/Classes/System/App.py b/Game Client/Classes/System/App.py deleted file mode 100644 index e6881be..0000000 --- a/Game Client/Classes/System/App.py +++ /dev/null @@ -1,46 +0,0 @@ -import pygame -from pygame.locals import * - -from Classes.System.Window import Window -from Classes.System.InputHandler import InputHandler - - -class App: - - __window:Window - __running:bool = True - __player = pygame.Rect((300,250, 50,50)) - __FPS = 60 - __speed = 5 - __clock = pygame.time.Clock() - - def __init__(self, width:int=800, height:int=600, title:str="default title"): - self.__window = Window(width=width, height=height, title=title) - self.startGameLoop() - self.onCleanup() - - def startGameLoop(self): - while self.__running: - - self.__clock.tick(self.__FPS) - - #temporary refresh - self.__window.clea().fill((0,0,0)) - pygame.draw.rect(self.__window.getScreen(), (255,0,0), self.__player) - - self.__player.move_ip((InputHandler.getInputAxis()[0]*self.__speed),(InputHandler.getInputAxis()[1]*self.__speed)) - - # event handler - for event in pygame.event.get(): - if event.type == pygame.QUIT: - self.onCleanup() - - # emits update to the game - pygame.display.update() - - def setRunning(self, running:bool): - self.__running = running - - def onCleanup(self): - self.__running = False - pygame.quit() \ No newline at end of file diff --git a/Game_Client/Classes/Objects/Cards/__pycache__/MonsterCard.cpython-311.pyc b/Game_Client/Classes/Objects/Cards/__pycache__/MonsterCard.cpython-311.pyc index f1a4275..5c820ac 100644 Binary files a/Game_Client/Classes/Objects/Cards/__pycache__/MonsterCard.cpython-311.pyc and b/Game_Client/Classes/Objects/Cards/__pycache__/MonsterCard.cpython-311.pyc differ diff --git a/Game_Client/Classes/System/App.py b/Game_Client/Classes/System/App.py index afd97dc..1b49e03 100644 --- a/Game_Client/Classes/System/App.py +++ b/Game_Client/Classes/System/App.py @@ -14,7 +14,7 @@ class App: __FPS = 60 __clock = pygame.time.Clock() - def __init__(self, width:int=1280, height:int=720, title:str="default title"): + def __init__(self, width:int=1920, height:int=1080, title:str="default title"): self.__window = Window(width=width, height=height, title=title) self.startGameLoop() self.onCleanup() @@ -25,7 +25,31 @@ class App: cards = pygame.sprite.Group() # game word - world = World(pygame.image.load("Assets/Arenas/default.png").convert_alpha()) + # the field + playerMonsterGroup = [] + playerSpellGroup = [] + enemyMonsterGroup = [] + ememySpellGroup = [] + enemyOtherGroup = [] + playerOtherGroup = [] + + cardWith = 200 + cardHeight = 250 + cardOffset = 400 + + # player card fields + for i in range(5): + playerMonsterGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * i), (2 * cardHeight) + 60, cardWith, cardHeight)) + playerSpellGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * i), (2 * cardHeight) + cardHeight + 70, cardWith, cardHeight)) + + enemyMonsterGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * (i+1)), 15, cardWith, cardHeight)) + ememySpellGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * (i+1)), cardHeight + 25, cardWith, cardHeight)) + + enemyOtherGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * 0), 15, cardWith, cardHeight)) + enemyOtherGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * 0), cardHeight + 25, cardWith, cardHeight)) + + playerOtherGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * 5), (2*cardHeight) + 60, cardWith, cardHeight)) + playerOtherGroup.append(pygame.Rect(cardOffset + ((cardWith + 10) * 5), (2*cardHeight) + cardHeight + 70, cardWith, cardHeight)) testMonsterCard = MonsterCard((500,500), "Assets/Cards/MonsterCards/testmonstercard/") cards.add(testMonsterCard) @@ -34,8 +58,26 @@ class App: self.__clock.tick(self.__FPS) - self.__window.getScreen().fill("grey100") - world.draw(self.__window.getScreen()) + self.__window.getScreen().fill((0,0,0)) + # world.draw(self.__window.getScreen()) + + for card in playerOtherGroup: + pygame.draw.rect(self.__window.getScreen(), (0,255,0), card) + + for card in playerMonsterGroup: + pygame.draw.rect(self.__window.getScreen(), (255,255,255), card) + + for card in playerSpellGroup: + pygame.draw.rect(self.__window.getScreen(), (255,255,255), card) + + for card in enemyOtherGroup: + pygame.draw.rect(self.__window.getScreen(), (255,0,0), card) + + for card in enemyMonsterGroup: + pygame.draw.rect(self.__window.getScreen(), (255,0,255), card) + + for card in ememySpellGroup: + pygame.draw.rect(self.__window.getScreen(), (255,0,255), card) # update sprite groups cards.update() diff --git a/Game_Client/Classes/System/Window.py b/Game_Client/Classes/System/Window.py index 4296a39..8a3bd44 100644 --- a/Game_Client/Classes/System/Window.py +++ b/Game_Client/Classes/System/Window.py @@ -13,7 +13,7 @@ class Window: self.__height = height self.__title = title - self.__screen = pygame.display.set_mode((self.__width, self.__height)) + self.__screen = pygame.display.set_mode((self.__width, self.__height), pygame.FULLSCREEN) pygame.display.init() pygame.display.set_caption = self.__title diff --git a/Game_Client/Classes/System/__pycache__/App.cpython-311.pyc b/Game_Client/Classes/System/__pycache__/App.cpython-311.pyc index 7aba81d..f8f707c 100644 Binary files a/Game_Client/Classes/System/__pycache__/App.cpython-311.pyc and b/Game_Client/Classes/System/__pycache__/App.cpython-311.pyc differ diff --git a/Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc b/Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc index 84b66c5..682f95e 100644 Binary files a/Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc and b/Game_Client/Classes/System/__pycache__/Window.cpython-311.pyc differ diff --git a/card files/Unbenannt-1.psd b/card files/Unbenannt-1.psd new file mode 100644 index 0000000..37388c8 Binary files /dev/null and b/card files/Unbenannt-1.psd differ diff --git a/card files/arena.psd b/card files/arena.psd new file mode 100644 index 0000000..a36c2e4 Binary files /dev/null and b/card files/arena.psd differ