initial commit for rework
This commit is contained in:
16
Game Client/Classes/Game/NetworkEvents/GameStart.py
Normal file
16
Game Client/Classes/Game/NetworkEvents/GameStart.py
Normal file
@ -0,0 +1,16 @@
|
||||
import pygame
|
||||
from Classes.Game.World import World
|
||||
from Classes.Game.Cards.Card import Card
|
||||
from Classes.Game.Player import Player
|
||||
from Classes.Engine.InputHandler import InputHandler
|
||||
|
||||
|
||||
# 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, handCards:list, inputHandler:InputHandler, owner:Player, opponent:Player):
|
||||
index:int = 0
|
||||
world.setEnemy(opponent)
|
||||
|
||||
for card in handCards:
|
||||
world.AddToPlayerHand(Card(pygame.Vector2(500 + (index + 100), 1050), f"Assets/Cards/{card}/", inputHandler, owner))
|
||||
|
22
Game Client/Classes/Game/NetworkEvents/Login.py
Normal file
22
Game Client/Classes/Game/NetworkEvents/Login.py
Normal file
@ -0,0 +1,22 @@
|
||||
import json
|
||||
import pygame
|
||||
from Classes.Engine.TCPClient import TCPClient
|
||||
from Classes.Game.World import World
|
||||
from Classes.Game.Player import Player
|
||||
|
||||
|
||||
# event the client sends to let the server know it logged in
|
||||
def Login(tcpClient:TCPClient):
|
||||
payload = {
|
||||
"event":"login",
|
||||
"username": "player",
|
||||
"deck": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
|
||||
}
|
||||
|
||||
tcpClient.send(payload)
|
||||
|
||||
# server response for login event
|
||||
def LoginResponse(message:json):
|
||||
# checks if the response on the login request is successfull
|
||||
if message["status"] != "success":
|
||||
print("login failed")
|
36
Game Client/Classes/Game/NetworkEvents/PlaceCard.py
Normal file
36
Game Client/Classes/Game/NetworkEvents/PlaceCard.py
Normal file
@ -0,0 +1,36 @@
|
||||
import pygame
|
||||
from Classes.Game.World import World
|
||||
from Classes.Engine.InputHandler import InputHandler
|
||||
|
||||
# the event the client sends to the server when it places a card
|
||||
def PlaceCard(tcpClient, card):
|
||||
# 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(),
|
||||
"x": card.getPos().x,
|
||||
"y": card.getPos().y,
|
||||
}
|
||||
|
||||
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):
|
||||
if type == "MonsterCard":
|
||||
world.spawnMonsterCard(f"Assets/Cards/{card}/", pos, inputHandler, owner)
|
||||
pass
|
||||
elif type == "SpellCard":
|
||||
world.spawnSpellCard(f"Assets/Cards/{card}/", pos, inputHandler, owner)
|
||||
pass
|
||||
elif type == "TrapCard":
|
||||
world.spawnTrapCard(f"Assets/Cards/{card}/", pos, inputHandler, owner)
|
||||
pass
|
||||
pass
|
||||
|
||||
def MovedCard(world:World, card:int, type:str, owner:str, oldPos:pygame.Vector2, newPos:pygame.Vector2, inputHandler:InputHandler):
|
||||
pass
|
Reference in New Issue
Block a user