class Game(object):
- def __init__(self, start_dt=None, game_type_cd=None,
+ def __init__(self, game_id=None, start_dt=None, game_type_cd=None,
server_id=None, map_id=None, winner=None):
+ self.game_id = game_id
self.start_dt = start_dt
self.game_type_cd = game_type_cd
self.server_id = server_id
class PlayerGameStat(object):
- def __init__(self, create_dt=None):
+ def __init__(self, player_game_stat_id=None, create_dt=None):
+ self.player_game_stat_id = player_game_stat_id
self.create_dt = create_dt
def __repr__(self):
import time\r
from pyramid.config import get_current_registry\r
from pyramid.response import Response\r
+from sqlalchemy import Sequence\r
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound\r
from xonstat.d0_blind_id import d0_blind_id_verify\r
from xonstat.models import *\r
map_id - map on which the game was played\r
winner - the team id of the team that won\r
"""\r
-\r
- game = Game(start_dt=start_dt, game_type_cd=game_type_cd,\r
+ seq = Sequence('games_game_id_seq')\r
+ game_id = session.execute(seq)\r
+ game = Game(game_id=game_id, start_dt=start_dt, game_type_cd=game_type_cd,\r
server_id=server_id, map_id=map_id, winner=winner)\r
session.add(game)\r
- session.flush()\r
log.debug("Created game id {0} on server {1}, map {2} at \\r
{3}".format(game.game_id, \r
server_id, map_id, start_dt))\r
# in here setup default values (e.g. if game type is CTF then\r
# set kills=0, score=0, captures=0, pickups=0, fckills=0, etc\r
# TODO: use game's create date here instead of now()\r
- pgstat = PlayerGameStat(create_dt=datetime.datetime.now())\r
+ seq = Sequence('player_game_stats_player_game_stat_id_seq')\r
+ pgstat_id = session.execute(seq)\r
+ pgstat = PlayerGameStat(player_game_stat_id=pgstat_id, \r
+ create_dt=datetime.datetime.now())\r
\r
# set player id from player record\r
pgstat.player_id = player.player_id\r
session.add(game)\r
\r
session.add(pgstat)\r
- session.flush()\r
\r
return pgstat\r
\r