added server communication between client and server

This commit is contained in:
2024-01-07 19:26:41 +01:00
parent fab79061ea
commit 6adea1730e
31 changed files with 173 additions and 129 deletions

View File

@ -1,14 +0,0 @@
import json
import pygame
class Card(pygame.sprite.Sprite):
def __init__(self, pos:tuple, assetDir:str):
if assetDir == "":
return ValueError.add_note("Card: imagePath cannot be empty")

View File

@ -1,9 +1,8 @@
import json
from typing import Any
import pygame
from Classes.System.Components.InputHandler import InputHandler
from Classes.Game.Player import Player
class MonsterCard(pygame.sprite.Sprite):
__name:str
@ -15,16 +14,18 @@ class MonsterCard(pygame.sprite.Sprite):
__dragging:bool = False
__offset:pygame.Vector2 = pygame.Vector2(0,0)
__inputHandler: InputHandler
__owner:Player
image:pygame.image
rect:pygame.rect
def __init__(self, pos:pygame.Vector2, assetDir:str, inputHandler:InputHandler):
def __init__(self, pos:pygame.Vector2, assetDir:str, inputHandler:InputHandler, owner:Player):
if assetDir == "":
return ValueError.add_note("Card: imagePath cannot be empty")
pygame.sprite.Sprite.__init__(self)
data = json.load(open(assetDir + "/card.json"))
self.__owner = owner
self.__id = int(data["id"])
self.__pos = pos
self.__name = data["name"]
@ -42,7 +43,7 @@ class MonsterCard(pygame.sprite.Sprite):
self.__attacks.append(attack)
def update(self):
if self.getDragging():
if self.__dragging:
mouse_pos = self.__inputHandler.getMousePos()
self.__pos = mouse_pos
self.rect.center = self.__pos
@ -74,6 +75,9 @@ class MonsterCard(pygame.sprite.Sprite):
def getID(self) -> int:
return self.__id
def getOwner(self) -> Player:
return self.__owner
def setDragging(self, dragging:bool):
self.__dragging = dragging