added first event functions documented server behaviour for some events
This commit is contained in:
parent
0cd9857795
commit
518804051d
37
Game Server/server logic notes.md
Normal file
37
Game Server/server logic notes.md
Normal file
@ -0,0 +1,37 @@
|
||||
# validation for placing cards:
|
||||
- is the game still running
|
||||
- is it the players turn
|
||||
- does the card exist
|
||||
- does the player have that card in his deck
|
||||
- does the player have this card in his hand
|
||||
- is the type of card allowed in that type of field
|
||||
- is the field already blocked by another card
|
||||
|
||||
# validation for attacking another player
|
||||
- is the game still running
|
||||
- is it the players turn
|
||||
- does the card exist
|
||||
- does the player have that card in his deck
|
||||
- is that card played
|
||||
- does the enemy have remaining monster cards on his side
|
||||
- if yes a direct attack would only be possible if a effect allows it
|
||||
- can this card attack
|
||||
- is the card of correct type
|
||||
- is it blocked by effects (will be implemented after card effects are implemented)
|
||||
|
||||
# player death management (win condition)
|
||||
- does a players hp go to 0?
|
||||
- make the other player the winner
|
||||
- if an effect affects the playing player card priority comes first
|
||||
|
||||
# handle a player leaving
|
||||
- check if game still runs
|
||||
- make remaining player win if yes
|
||||
|
||||
# turn management
|
||||
- server keeps track of each turn
|
||||
- whos turn is it
|
||||
- what turn state is currently active
|
||||
- draw state
|
||||
- place state
|
||||
- is the player trying to do actions not allowed in the given state
|
20
Game_Client/Classes/Game/Events/Login.py
Normal file
20
Game_Client/Classes/Game/Events/Login.py
Normal file
@ -0,0 +1,20 @@
|
||||
import pygame
|
||||
from Classes.System.Network.NetworkManager import NetworkManager
|
||||
from Classes.Game.World import World
|
||||
|
||||
|
||||
# event the client sends to let the server know it logged in
|
||||
def Login(networkManager:NetworkManager):
|
||||
payload = {
|
||||
"event":"login",
|
||||
"username": "player"
|
||||
}
|
||||
|
||||
networkManager.tcp.send(payload)
|
||||
|
||||
# server response for login event
|
||||
def LoginResponse(networkManager:NetworkManager, gameWorld: World):
|
||||
# todo: get labels from world
|
||||
# todo: get name for enemy
|
||||
# todo: adjust enemy name label
|
||||
pass
|
17
Game_Client/Classes/Game/Events/PlaceCard.py
Normal file
17
Game_Client/Classes/Game/Events/PlaceCard.py
Normal file
@ -0,0 +1,17 @@
|
||||
from Classes.Game.Cards.Card import Card
|
||||
from Classes.Game.World import World
|
||||
from Classes.System.Network.NetworkManager import NetworkManager
|
||||
|
||||
|
||||
# the event the client sends to the server when it places a card
|
||||
def PlaceCard(networkManager: NetworkManager, card: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)
|
||||
pass
|
||||
|
||||
# the event send from the server to display a card on the field
|
||||
def CardPlaced(world:World):
|
||||
pass
|
@ -1,7 +1,7 @@
|
||||
import pygame
|
||||
from Classes.Objects.BoardField import BoardField
|
||||
from Classes.Game.BoardField import BoardField
|
||||
from Classes.System.Components.Label import Label
|
||||
from Classes.Objects.Cards.MonsterCard import MonsterCard
|
||||
from Classes.Game.Cards.MonsterCard import MonsterCard
|
||||
from Classes.System.Components.InputHandler import InputHandler
|
||||
|
||||
class World():
|
@ -1,11 +1,12 @@
|
||||
import pygame
|
||||
from pygame.locals import *
|
||||
|
||||
from Classes.Objects.Cards.MonsterCard import MonsterCard
|
||||
from Classes.Game.Cards.MonsterCard import MonsterCard
|
||||
from Classes.System.Components.Window import Window
|
||||
from Classes.System.Components.InputHandler import InputHandler
|
||||
from Classes.Objects.World import World
|
||||
from Classes.Game.World import World
|
||||
from Classes.System.Network.NetworkManager import NetworkManager
|
||||
from Classes.Game.Events.Login import Login
|
||||
|
||||
class App:
|
||||
|
||||
@ -24,6 +25,7 @@ class App:
|
||||
self.__window = Window(width=width, height=height, title=title)
|
||||
self.__inputHandler = InputHandler()
|
||||
self.__networkManager("127.0.0.1", "54322", "54323")
|
||||
Login(self.__networkManager) # will login to the server
|
||||
|
||||
# game word
|
||||
self.__world = World(self.__window.getScreen())
|
||||
@ -100,7 +102,8 @@ class App:
|
||||
if event.button == 1: # Wenn linke Maustaste losgelassen wird
|
||||
for card in self.__world.getCards():
|
||||
card.setDragging(False)
|
||||
# TODO: send server command
|
||||
# TODO: send place card event to server
|
||||
# resets the currently selected card in order to prevent it getting moved
|
||||
if not card == None:
|
||||
card = None
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import selectors
|
||||
import socket
|
||||
import json
|
||||
import types
|
||||
|
||||
sel = selectors.DefaultSelector()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user