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

@ -0,0 +1,7 @@
from Classes.Game.World import World
# send from the server to tell the player the game starts
# gives the client its and the opponents stats (not cards!!)
def GameStart(world: World):
pass

View File

@ -1,42 +1,9 @@
import pygame
from Classes.Game.World import World
from Classes.System.Network.NetworkManager import NetworkManager
from Classes.Game.Cards.MonsterCard import MonsterCard
from Game_Client.Classes.Game.Cards.SpellCard import SpellCard
from Game_Client.Classes.Game.Cards.TrapCard import TrapCard
# the event the client sends to the server when it places a card
def PlaceMonsterCard(networkManager: NetworkManager, card:MonsterCard):
# todo: send card information to the server
# todo: required info is:
# - position
# - field type (used for validating what field the card is played in will be compared on server side)
# - card id (server will do the rest to fetch card info)
payload = {
"event":"placecard",
"card": card.getID(),
"pos": card.getPos(),
}
networkManager.udp.send(payload)
# the event the client sends to the server when it places a card
def PlaceSpellCard(networkManager: NetworkManager, card:SpellCard):
# todo: send card information to the server.
# todo: required info is:
# - position
# - field type (used for validating what field the card is played in will be compared on server side)
# - card id (server will do the rest to fetch card info)
payload = {
"event":"placecard",
"card": card.getID(),
"pos": card.getPos(),
}
networkManager.udp.send(payload)
# the event the client sends to the server when it places a card
def PlaceTrapCard(networkManager: NetworkManager, card:TrapCard):
def PlaceCard(networkManager: NetworkManager, card):
# todo: send card information to the server
# todo: required info is:
# - position
@ -51,5 +18,6 @@ def PlaceTrapCard(networkManager: NetworkManager, card:TrapCard):
networkManager.udp.send(payload)
# the event send from the server to display a card on the field
def CardPlaced(world:World):
def CardPlaced(world:World, card:int, pos:pygame.Vector2):
pass