added more events
This commit is contained in:
parent
6acde9e295
commit
7315c68eb3
@ -6,14 +6,15 @@ import pygame
|
||||
from Classes.System.Components.InputHandler import InputHandler
|
||||
|
||||
class MonsterCard(pygame.sprite.Sprite):
|
||||
__attacks = []
|
||||
__name:str
|
||||
__id:int
|
||||
__description:str
|
||||
__attacks = []
|
||||
__type:str = "MonsterCard"
|
||||
__pos:pygame.Vector2
|
||||
__dragging:bool = False
|
||||
__offset:pygame.Vector2 = pygame.Vector2(0,0)
|
||||
__inputHandler: InputHandler
|
||||
__type:str = "MonsterCard"
|
||||
image:pygame.image
|
||||
rect:pygame.rect
|
||||
|
||||
@ -24,6 +25,7 @@ class MonsterCard(pygame.sprite.Sprite):
|
||||
pygame.sprite.Sprite.__init__(self)
|
||||
|
||||
data = json.load(open(assetDir + "/card.json"))
|
||||
self.__id = int(data["id"])
|
||||
self.__pos = pos
|
||||
self.__name = data["name"]
|
||||
self.image = pygame.image.load(assetDir + "/card.png").convert_alpha()
|
||||
@ -69,6 +71,9 @@ class MonsterCard(pygame.sprite.Sprite):
|
||||
def getType(self):
|
||||
return self.__type
|
||||
|
||||
def getID(self) -> int:
|
||||
return self.__id
|
||||
|
||||
def setDragging(self, dragging:bool):
|
||||
self.__dragging = dragging
|
||||
|
||||
|
@ -1,16 +1,54 @@
|
||||
from Classes.Game.Cards.Card import Card
|
||||
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 PlaceCard(networkManager: NetworkManager, card: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)
|
||||
pass
|
||||
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):
|
||||
# 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 send from the server to display a card on the field
|
||||
def CardPlaced(world:World):
|
||||
|
Loading…
x
Reference in New Issue
Block a user