def _confirmTheGame(game): """ Performs the overhead necessary to confirm a Game Keyword arguments: game -- the Game to be confirmed Contributors: Richard Douglas Output: LifeStats of the PongUsers who played the Game are updated to reflect the Events of the Game. The Game is then marked as being confirmed/denied and kept in the database. """ #get Events events = game.getEvents() cupEvents = events[0:len(events) - 1] #process Events that involve cups being sunk for cupEvent in cupEvents: responsibleUser = cupEvent.getUser() stats = responsibleUser.getLifeStats() _updateCupShotStats(stats,cupEvent) _updateCupNumberStats(stats,cupEvent) winningTeam, losingTeam = obtainWinningTeam(game), obtainLosingTeam(game) _updateWinsAndLosses(winningTeam,losingTeam) _updateRankings(winningTeam,losingTeam) game.setIsConfirmed(True) game.save() return
def _obtainOutcomeOfEndedGame(self, game): """Determines whether the form's outcome attribute should be "Team 1 Won" or "Team 2 Won" when a Game's information is being written to it. Keyword arguments: game -- the Game whose information is being written to the form (game must have ended) Contributors: Richard Douglas Output: outcome, a String that is "Team 1 Won" if Team 1 won the Game and "Team 2 Won" otherwise. """ winningTeam = obtainWinningTeam(game) if winningTeam == game.getTeam1(): outcome = "Team 1 Won" else: outcome = "Team 2 Won" return outcome