def on_post(self, req, resp, game_id, player_id): """ :type req: falcon.Request :type resp: falcon.Response :type game_id: str :type user_id: str :precondition: len(game_id) > 0 :precondition: len(user_id) > 0 """ assert isinstance(req, falcon.Request) assert isinstance(resp, falcon.Response) assert isinstance(game_id, str) assert isinstance(player_id, str) assert len(game_id) > 0 assert len(player_id) > 0 json_payload = self.get_json_payload(req) card_id = str(json_payload['card_id']) sphere_id = str(json_payload['sphere_id']) GameAService.make_move(game_id, player_id, card_id, sphere_id) resp.status = falcon.HTTP_NO_CONTENT
def on_post(self, req, resp): """ :type req: falcon.Request :type resp: falcon.Response """ assert isinstance(req, falcon.Request) assert isinstance(resp, falcon.Response) json_payload = self.get_json_payload(req) player_id = json_payload['player_id'] game_details = GameAService.find_a_game(player_id) resp.status = falcon.HTTP_200 resp.body = json.dumps({ 'game_id': game_details.game_id })
def on_get(self, req, resp, game_id, player_id): """ :type req: falcon.Request :type resp: falcon.Response :type game_id: str :type user_id: str """ assert isinstance(req, falcon.Request) assert isinstance(resp, falcon.Response) assert isinstance(game_id, str) assert isinstance(player_id, str) assert len(game_id) > 0 assert len(player_id) > 0 game = GameAService.get_game(game_id, player_id) resp.status = falcon.HTTP_200 resp.body = json.dumps(game)
from synapse.commands.test_command import TestCommand from synapse.services.application_services.game_a_service import GameAService from synapse.services.board import Board from synapse.services.card import Card from synapse.services.deck import Deck from synapse.services.game import Game from synapse.services.player import Player from synapse.utils.queue_util import QueueUtil system.initialize(os.path.abspath(os.path.join(os.path.dirname(__file__), ".env"))) #player_one_id = "player_one" player_one = str(uuid.uuid4().hex) game = GameAService.find_a_game(player_one) #game = GameAService.get_game("5cc5b2f6fff54dfdbe2742ab89d86019", '694aea7730f3410f817d44583e014c31') print "Game Id: " + game.game_id print "Game Player IDs: " + ", ".join([x.player_id for x in game.players]) #card_id = '86c232083bc448e0be5f457461d7d37d' #sphere_id = '48aa32237c9d4ed3af3463fbd74d6eef' #GameAService.make_move(game.game_id, '694aea7730f3410f817d44583e014c31', card_id, sphere_id) sys.exit() player = Player('temp_player_one_uuid') player2 = Player('temp_player_one_uuid')