30 lines
1.2 KiB
Python

import pygame
from Classes.Game.World import World
from Classes.System.Components.InputHandler import InputHandler
from Classes.Game.Cards.Card import Card
# the event the client sends to the server when it places a card
def PlaceCard(tcpClient, card:Card, player):
# 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(),
"type": card.getType(),
"user": player.getID(),
"x": card.getX(),
"y": card.getY(),
}
tcpClient.send(payload)
# the event send from the server to display a card on the field
def CardPlaced(world:World, card:int, type:str, owner:str, pos:pygame.Vector2, inputHandler:InputHandler):
# todo: make this work with all cardtypes
world.spawnCard(f"Assets/Cards/{card}/", pos, inputHandler, owner)
def MovedCard(world:World, card:int, type:str, owner:str, oldPos:pygame.Vector2, newPos:pygame.Vector2, inputHandler:InputHandler):
pass