added clientside placecard event

This commit is contained in:
2024-01-14 18:42:56 +01:00
parent 677552a617
commit ae49b1cec7
3162 changed files with 77 additions and 446348 deletions

View File

@@ -47,12 +47,12 @@ class App:
# create sprite groups
# todo: remove these and let server handle card creation instead
# blocker: server - client communication [WIP]
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(500, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(600, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(700, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(800, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(900, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1/", pygame.Vector2(1000, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(500, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(600, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(700, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(800, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(900, 1050), self.__inputHandler, Player(1000, 0, "test"))
self.__world.spawnCard("Assets/Cards/1", pygame.Vector2(1000, 1050), self.__inputHandler, Player(1000, 0, "test"))
while self.__running:
self.__clock.tick(self.__FPS)
@@ -116,11 +116,11 @@ class App:
mouse_pos = pygame.Vector2(mouse_x, mouse_y)
if event.button == 1: # Wenn linke Maustaste losgelassen wird
for card in self.__world.getCards():
card.setDragging(False)
card.setState("placed")
# TODO: send place card event to server
# resets the currently selected card in order to prevent it getting moved
try:
card.setDragging(False)
card.setState("placed")
# TODO: send place card event to server
# resets the currently selected card in order to prevent it getting moved
PlaceCard(self.__tcpClient, card) # tells the server that the player placed this card
except Exception as e:
print(f"failed to place card on server due to error: {e}")