コード例 #1
0
 def __hitWall(self, cookie):
     service = PlayerService()
     player = service.get(cookie.playerId)
     previousSpace = self.playerGrid.getMapSpace(cookie.position)
     previousSpace.cookies.remove(cookie)
     player.getHitByCookie(cookie)
     service.save(player)
     return (cookie, player)
コード例 #2
0
 def __hitWall(self, cookie):
     service = PlayerService()
     player = service.get(cookie.playerId)
     previousSpace = self.playerGrid.getMapSpace(cookie.position)
     previousSpace.cookies.remove(cookie)
     player.getHitByCookie(cookie)
     service.save(player)
     return (cookie, player)
コード例 #3
0
 def __hitPlayer(self, cookie, nextMapSpace):
     service = PlayerService()
     previousPlayer = service.get(cookie.playerId)
     previousSpace = self.playerGrid.getMapSpace(cookie.position)
     previousSpace.cookies.remove(cookie)
     hitPlayer = nextMapSpace.players[0]
     hitPlayer.getHitByCookie(cookie)
     service.save(hitPlayer)
     if len(previousPlayer.cookies) == 0:
         raise WinnerFound(previousPlayer.playerId)
     return (cookie, hitPlayer)
コード例 #4
0
 def __hitPlayer(self, cookie, nextMapSpace):
     service = PlayerService()
     previousPlayer = service.get(cookie.playerId)
     previousSpace = self.playerGrid.getMapSpace(cookie.position)
     previousSpace.cookies.remove(cookie)
     hitPlayer = nextMapSpace.players[0]
     hitPlayer.getHitByCookie(cookie)
     service.save(hitPlayer)
     if len(previousPlayer.cookies) == 0:
         raise WinnerFound(previousPlayer.playerId)
     return (cookie, hitPlayer)
コード例 #5
0
from flask import Flask, jsonify, request, abort
from domain import User
from services import UserService, PlayerService, TournamentService
from repositories import UserRepository, PlayerRepository, TournamentRepository
from dbOperations import dbConnection
import os

dbConnectionPool = dbConnection.connectionPool()

userRepository = UserRepository.UserRepository(dbConnectionPool)
userService = UserService.UserService(userRepository)

playerRepository = PlayerRepository.PlayerRepository(dbConnectionPool)
playerService = PlayerService.PlayerService(playerRepository)

tournamentRepository = TournamentRepository.TournamentRepository(
    dbConnectionPool)
tournamentService = TournamentService.TournamentService(tournamentRepository)


def isLoggedIn(function):
    def check(*args, **kwargs):
        uuid = request.headers.get('uuid')
        if uuid:

            loggedUser = userService.isLoggedIn(
                {"uuid": request.headers.get('uuid')})

            if isinstance(loggedUser, User.User):
                return function(loggedUser, *args, **kwargs)
            else: