コード例 #1
0
 def vote_Puzzle_Action(self,vote,user_id,puzzleid,action):
     hasvoted = UserDAO().has_user_voted(puzzleid,user_id)
     if hasvoted and action=='remove':
         UserDAO().delete_vote_user(user_id,puzzleid)
         return {'votes': GameDAO().get_likes_game(puzzleid)}
     elif not hasvoted and action=='create':
         UserDAO().insert_vote_user(vote,user_id,puzzleid)
         return {'votes': GameDAO().get_likes_game(puzzleid)}
     else:
         return {'votes': 'wrong request parameters for Voting in UserService.vote_Puzzle_Action'}
コード例 #2
0
 def get_highscores(self, uri, metadata=True):
     row = GameDAO().get_game_uri(uri)
     game = Game(row[0], row[1], row[2], row[3], row[4], row[5], row[6],
                 row[7])
     highscores = GameDAO().get_highscores(game.id)
     if metadata:
         newhighscores = list()
         for highscore in highscores:
             metadata = UserDAO().get_user_metadata(highscore['userid'])
             newhighscores.append({**highscore, **metadata})
         return newhighscores
     else:
         return highscores
コード例 #3
0
 def get_game_uri(self, uri):
     row = GameDAO().get_game_uri(uri)
     if row is None:
         generated = GenDAO().get_game_uri(uri)
         if generated is None:
             return {'uri': ''}
         return Gen(generated[0], generated[1], generated[2], generated[3],
                    generated[4], generated[5], generated[6]).serialize()
     else:
         return Game(row[0], row[1], row[2], row[3], row[4], row[5], row[6],
                     row[7], row[8], '', row[10]).serialize()
コード例 #4
0
 def insert_highscore(self, name, userid, authorname, solutiondata,
                      highscore, uri):
     row = GameDAO().get_game_uri(uri)
     game = Game(row[0], row[1], row[2], row[3], row[4], row[5], row[6],
                 row[7], row[8])
     if checkSolution(solutiondata, game.puzzledata, highscore):
         scoreList = GameDAO().get_highscores(game.id)
         UpdateUserScore = False
         rtnMessage = ""
         userSubmitted = False
         idtoupdate = None
         for Solution in scoreList:
             if (Solution['numMoves'] == highscore
                     and Solution['comment'] == name and userid == 1):
                 return "Duplicate highscore cannot be submitted."
             if (Solution['numMoves'] >= highscore
                     and Solution['userid'] == userid and userid != 1):
                 UpdateUserScore = True
                 idtoupdate = Solution['id']
             if (Solution['userid'] == userid):
                 userSubmitted = True
         gameid = game.id
         if (UpdateUserScore):
             GameDAO().increment_plays(gameid)
             return GameDAO().update_highscore(idtoupdate, gameid, name,
                                               userid, authorname,
                                               solutiondata, highscore)
         else:
             if (not userSubmitted or userid == 1):
                 GameDAO().increment_plays(gameid)
                 GameDAO().insert_highscore(gameid, name, userid,
                                            authorname, solutiondata,
                                            highscore)
                 rtnMessage = "Submitted"
                 return rtnMessage
             else:
                 return 'not a higher score'
     else:
         return 'not a valid submission'
コード例 #5
0
 def get_games_by_search_highest_score(self, numPuzzles, Offset, searchterm,
                                       userID):
     return GameDAO().get_games_by_search_highest_score(
         numPuzzles, Offset, searchterm, userID)
コード例 #6
0
 def get_games_by_search_most_liked(self, numPuzzles, Offset, searchterm,
                                    userID):
     return GameDAO().get_games_by_search_most_liked(
         numPuzzles, Offset, searchterm, userID)
コード例 #7
0
 def check_same_game(self, puzzledata):
     return GameDAO().check_same_game(puzzledata)
コード例 #8
0
 def get_game(self, gameid):
     return GameDAO().get_game(gameid)
コード例 #9
0
 def insert_game(self, name, type, description, authorid, authorname,
                 difficulty, puzzledata):
     return GameDAO().insert_game(name, type, description, authorid,
                                  authorname, difficulty, puzzledata)
コード例 #10
0
 def get_solutions_profile_view(self, user_id):
     return GameDAO().get_solutions_profile_view(user_id)
コード例 #11
0
 def get_games_profile_view(self, user_id):
     return GameDAO().get_games_profile_view(user_id)
コード例 #12
0
 def get_all_games(self, numGames, offset):
     return GameDAO().get_all_games(numGames, offset)