Ejemplo n.º 1
0
  def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    g = Game(opponent='test', date=datetime.date.today(), venue='test', team=Team.TEST)

    players = []
    for i in range(0, 10):
      p = Player(name='Player ' + str(i))
      p.put()
      players.append(p)

    g.players = [p.key for p in players]
    g.put()

    # Rankings:
    # Player 3 - 7 votes (two threes)
    # Player 4 - 7 votes (one three, two twos)
    # Player 7 - 7 votes (one three, one two)
    v = Vote(game=g.key, three=players[3].key, two=players[4].key, one=players[7].key)
    v.put()
    v = Vote(game=g.key, three=players[7].key, two=players[4].key, one=players[5].key)
    v.put()
    v = Vote(game=g.key, three=players[3].key, two=players[9].key, one=players[7].key)
    v.put()
    v = Vote(game=g.key, three=players[4].key, two=players[7].key, one=players[3].key)
    v.put()
Ejemplo n.º 2
0
  def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    self.g1 = \
      Game(opponent='test', date=datetime.date(2015, 10, 01), venue='test', team=Team.TEST, weight=0.4)
    self.g2 = \
      Game(opponent='test', date=datetime.date(2015, 11, 01), venue='test', team=Team.TEST, weight=0.6)

    players = []
    for i in range(0, 10):
      p = Player(name='Player ' + str(i))
      p.put()
      players.append(p)

    self.g1.players = [p.key for p in players]
    self.g1.put()

    self.g2.players = [p.key for p in players]
    self.g2.put()

    v = Vote(game=self.g1.key, three=players[7].key, two=players[9].key, one=players[3].key)
    v.put()
    v = Vote(game=self.g2.key, three=players[9].key, two=players[7].key, one=players[3].key)
    v.put()
Ejemplo n.º 3
0
def start_game():

    board_model: Board = Board()
    player_1: Player = Player(Order.FIRST)
    player_2: Player = Player(Order.SECOND)

    game = Hex(board_model, PlayersController(player_1, player_2))
    game.on_execute()
Ejemplo n.º 4
0
def test_determine_player__should_return_p2():
    turn_count = 2
    P1 = Player()
    P2 = Player()
    starting_player = P1
    players = [P1, P2]

    actual = utilities.determine_player(turn_count, starting_player, players)

    assert actual is P2
Ejemplo n.º 5
0
 async def _add_item_to_inventory(self,
                                  ctx,
                                  item_id: int = 0,
                                  count: int = 0):
     """Add any item to inventory"""
     player = Player(ctx.message.author.id)
     player.add_to_inventory(item_id, count)
     item_object = Item(item_id)
     await ctx.send(
         str(count) + ' of ' + item_object.name + ' added to inventory')
Ejemplo n.º 6
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = Player(username=form.username.data, password=form.password.data)
        user.save_to_db()
        flash('Congratulations, you are now a registered user!')
        return redirect(url_for('login'))
    return render_template('register.html', title='Register', form=form)
Ejemplo n.º 7
0
def test_has_card_in_hand__should_return_false():
    player = Player()
    player.hand = [
        all_cards.COCKATRICE, all_cards.COCKATRICE, all_cards.COCKATRICE,
        all_cards.COCKATRICE, all_cards.BLOBRA
    ]
    card = 'Zell'

    actual = utilities.has_card_in_hand(player, card)

    assert actual is False
Ejemplo n.º 8
0
def test_has_card_in_hand__should_return_true():
    player = Player()
    player.hand = [
        all_cards.COCKATRICE, all_cards.COCKATRICE, all_cards.COCKATRICE,
        all_cards.COCKATRICE, all_cards.BLOBRA
    ]
    card = 'Blobra'

    actual = utilities.has_card_in_hand(player, card)

    assert actual is True
Ejemplo n.º 9
0
  def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_datastore_v3_stub()
    self.testbed.init_memcache_stub()

    g = Game(opponent='test', date=datetime.date.today(), venue='test', team=Team.TEST)

    players = []
    for i in range(0, 10):
      p = Player(name='Player ' + str(i))
      p.put()
      players.append(p)

    g.players = [p.key for p in players]
    g.put()
Ejemplo n.º 10
0
 async def _store(self, ctx):
     """View store information and inventory."""
     player = Player(ctx.message.author.id)
     location = Location(player.current_location)
     store_ids = self.stores.list_id()
     for store_id in store_ids:
         store = Store(store_id)
         prices = store.settings['prices']
         if store.location.location_id == player.current_location:
             embed = discord.Embed(
                 title=location.name,
                 color=discord.Color.green(),
                 description='Welcome to **' + store.name + '**, ' + ctx.message.author.display_name + '!')
             items = self.items.list()
             embed.add_field(name='Items for Sale', value='The following are available for sale.\n', inline=False)
             for item in items:
                 if item['id'] in store.available_items:
                     embed.add_field(
                         name=item['emoji'] + ' ' + str(item['id']) + '. ' + item['name'],
                         value='Price: ' + str(prices[str(item['id'])])
                     )
             embed.set_footer(text='Requested by '+ctx.message.author.display_name + '. Prices updated: '
                                   + str(prices['date']),
                              icon_url=ctx.message.author.avatar_url)
             if hasattr(store, 'thumbnail'):
                 embed.set_thumbnail(url=store.thumbnail)
             await ctx.send(embed=embed)
def get_rostered_players(owners: List[Owner], current_week: int,
                         soup_kitchen: SoupKitchen) -> List[Player]:
    print('\nLoading rosters...')
    players: List[Player] = []
    weeks = range(current_week + 1, num_weeks + 1)
    for owner, week in tqdm(list(product(owners, weeks))):
        soup = soup_kitchen.get('/f1/%s/%s?week=%s&stat1=P&stat2=PW' %
                                (league_id, owner.id, week))
        for table_id in ['statTable0', 'statTable1', 'statTable2']:
            table = soup.find('table', id=table_id)
            for tr in table.find('tbody').findAll('tr'):
                info = tr.find('div', {'class': 'ysf-player-name'})
                _id = [
                    t for t in info.find('a')['href'].split('/') if t != ''
                ][-1]
                player = next((p for p in players if p.id == _id), None)
                if not player:
                    name = info.find('a').text
                    team, position = [
                        token.strip()
                        for token in info.find('span').text.split('-')
                    ]
                    players.append(Player(_id, name, team, position, owner.id))
                bolded_trs = tr.findAll('span', {'class': 'Fw-b'})
                projection = int(float(
                    bolded_trs[-1].text.strip())) if bolded_trs else 0
                next(p for p in players
                     if p.id == _id).set_weekly_projection(week, projection)
    return players
Ejemplo n.º 12
0
 def __init__(self):
     self.pool = Pool(load_champ_data())
     self.rankings = []
     self.round = 0
     self.players = [
         Player(i, f"Player #{i}", self.pool) for i in range(NUM_PLAYERS)
     ]
Ejemplo n.º 13
0
    def swap_first_tile(self, current_player: Player):

        if self._board.move_count() == 1 and not self._board.is_swapped():
            first_tile: Tile = self._board.last_move()
            tile_controler = TileController(first_tile)
            tile_controler.set_color(current_player.color())
            self._board.swapped()
Ejemplo n.º 14
0
 def remove_player(name):
     name = name.upper()
     find_player = Player.find_by_name(name)
     if find_player is not None:
         find_player.remove_from_mongo()
         pAll = Player_All.find_by_name(name)
         pAll.remove_from_mongo()
     else:
         return None
Ejemplo n.º 15
0
 def remove_player(name):
     name = name.upper()
     find_player = Player.find_by_name(name)
     if find_player is not None:
         find_player.remove_from_mongo()
         pAll = Player_All.find_by_name(name)
         pAll.remove_from_mongo()
     else:
         return None
Ejemplo n.º 16
0
def test_place_card__should_place_card_in_mid_center():
    game = Board()
    player = Player()
    card = all_cards.BLOBRA
    position = 'mid_center'

    actual = utilities.place_card(game, player, card, position)

    assert actual['mid_center']['card'] == all_cards.BLOBRA
Ejemplo n.º 17
0
 async def _subway(self, ctx, location_id: int = 0):
     """Use map to view station map, or an id to move to another station."""
     await ctx.trigger_typing()
     if not location_id:
         return await ctx.send('Try either map or a valid location id.')
     player = Player(ctx.message.author.id)
     if player.current_location == location_id:
         return await ctx.send('You are already there.')
     distance = abs(location_id - player.current_location)
     current_location = Location(player.current_location)
     await ctx.send(':train: ' + ctx.message.author.display_name +
                    ' is now leaving: **' + current_location.name +
                    '** :train:')
     player.move_to(location_id)
     location = Location(location_id)
     time.sleep(distance)
     return await ctx.send(':train: ' + ctx.message.author.display_name +
                           ' is now arriving at: **' + location.name +
                           '** :train:')
Ejemplo n.º 18
0
def get_or_create_player(headers: dict, color: str = "White"):
    name = headers.get(color)  # surname, given_name
    if not name:
        LOGGER.error("Name was empty %s" % headers)
    fide_id_str = f"{color}FideId"
    fide_id = headers.get(fide_id_str)
    given_name = name[name.find(",") + 2:]
    surname = name[:name.find(",")]
    LOGGER.debug(f"given_name: {given_name}, surname: {surname}, fide_id: {fide_id}")
    try:
        player = Player.query.filter(
            or_(Player.fide_id.is_(None), Player.fide_id == fide_id),
            Player.given_name == given_name,
            Player.surname == surname
        ).one_or_none()
    except MultipleResultsFound as e:
        LOGGER.error("Multiple results found for combination: %s, %s fide_id: %s" % (surname, given_name, fide_id))
        player = None
    if not player:
        player = Player(given_name=given_name, surname=surname, fide_id=fide_id)
        player.store()
    return player
Ejemplo n.º 19
0
    def undo(self, current_player: Player):
        number_moves: int = self._board.move_count()
        if number_moves > 0 and self._board.is_current():
            last_tile: Tile = self._board.last_move()
            tile_controler = TileController(last_tile)

            if self._board.is_swapped() and self._board.move_count() == 1:
                tile_controler.set_color(current_player.color())
                self._board.unswapped()
            else:
                self._board.decrement_move_count()
                tile_controler.reset()
                self._board.not_current()
Ejemplo n.º 20
0
 async def _get_profile(self, ctx):
     """See your player profile, balances, current location and inventory."""
     player = Player(ctx.message.author.id)
     inventory_list = player.get_inventory()
     balances = player.get_balance()
     location = Location(player.current_location)
     stores = self.stores.at_location(player.current_location)
     stores_str = ''
     for store in stores:
         if store.location.location_id == player.current_location:
             if store != stores[-1]:
                 stores_str = stores_str + store.name + ', '
             else:
                 stores_str = stores_str + store.name
     embed = discord.Embed(title='Profile',
                           description='Current Location: ' + location.name,
                           colour=discord.Colour.gold())
     if stores_str != '':
         embed.add_field(name='Stores:', value=stores_str, inline=False)
     inventory_str = ''
     if len(inventory_list) > 0:
         for inventory in inventory_list:
             item_object = Item(inventory['id'])
             inventory_str = inventory_str + item_object.emoji + '(' + str(
                 inventory['count']) + ') ' + ' ' + item_object.name + '\n'
     else:
         inventory_str = 'Empty Inventory'
     embed.add_field(name='Bank Balance:',
                     value=':moneybag:' +
                     '{:20,.0f}'.format(balances['bank']))
     embed.add_field(name='Cash Balance:',
                     value=':moneybag:' +
                     '{:20,.0f}'.format(balances['wallet']))
     embed.add_field(name='Inventory', value=inventory_str, inline=False)
     embed.set_author(name=ctx.message.author.display_name,
                      icon_url=ctx.message.author.avatar_url)
     embed.set_thumbnail(url=ctx.message.author.avatar_url)
     return await ctx.send(embed=embed)
Ejemplo n.º 21
0
def remove_player():
    if request.method == 'GET':
        return redirect('/dashboard')
    else:
        name = request.form['player_name']
        password = request.form['password']
        _id = session['_id']
        room = Room.find_by_id(_id)
        if room.password == password and name is not None:
            player = Player.find_by_name(name)
            player.remove_from_mongo()
            return redirect('/dashboard')
        else:
            return redirect('/dashboard-error')
Ejemplo n.º 22
0
 async def _buy_item(self, ctx, item_id: int = 0, count: int = 0):
     """Buy an item from the store."""
     item_object = Item(item_id)
     cost = item_object.get_price() * count
     player = Player(ctx.message.author.id)
     balance = player.get_balance()
     wallet = balance['wallet']
     if cost > wallet:
         return await ctx.send("Not enough cash. Need: " + str(cost))
     else:
         player.add_balance('wallet', -cost)
         player.add_to_inventory(item_id, count)
         return await ctx.send("Successfully purchased.")
Ejemplo n.º 23
0
    def _draw_game_labels(self, current_player: Player):
        label: Font = Font(MAIN_FONT, MEDIUM_TEXT)
        label_surface: Surface = label.render(
            'Turn: ',
            True,
            BLACK
        )
        label_rect: Rect = label_surface.get_rect()
        label_rect.center = ((label_rect.width / 2) + 50, self._height - 50)
        self._screen.blit(label_surface, label_rect)

        player_label: Font = Font(TITLE_FONT, MEDIUM_TEXT)
        player_label_surface: Surface = player_label.render(
            current_player.name(),
            True,
            RED_TILE if current_player.color() == Color.RED else BLUE_TILE
        )
        plauer_label_rect: Rect = player_label_surface.get_rect()
        plauer_label_rect.center = (
            (plauer_label_rect.width / 2) + 50 + label_rect.width,
            self._height - 50
        )

        self._screen.blit(player_label_surface, plauer_label_rect)
Ejemplo n.º 24
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = LoginForm()
    if form.validate_on_submit():
        user = Player.load_by_username(form.username.data)
        if user is None or not user.check_password(form.password.data):
            flash('Invalid username or password')
            return redirect(url_for('login'))
        login_user(user, remember=form.remember_me.data)
        next_page = request.args.get('next')
        if not next_page or url_parse(next_page).netloc != '':
            next_page = url_for('index')
        return redirect(next_page)
    return render_template('login.html', title='Sign In', form=form)
Ejemplo n.º 25
0
def stat():
    if request.method == 'GET':
        return redirect('/dashboard')
    else:
        name = request.form['player_name']
        _id = session['_id']
        room = Room.find_by_id(_id)
        player = Player.find_by_name(name)
        playerAll = Player_All.find_by_name(name)
        current_rate = ((player.wins / player.games_played) * 100)
        ovr_rate = ((playerAll.wins / playerAll.games_played) * 100)
        matches = room.get_matches()
        player_match = []
        for match in matches:
            if match.p1 == player.name or match.p2 == player.name and name is not None:
                player_match.append(match)
        return render_template('stat.html', player=player, matches=player_match, playerAll=playerAll, current_rate=current_rate, ovr_rate=ovr_rate)
Ejemplo n.º 26
0
def join_game_room(json):
    game = ChessGame.load_by_id(json['game_id'])
    player = Player.load_by_id(json['user_id'])
    if game and player:
        join_room(game.id)
        session['game_room'] = game.id
        session['current_game'] = game.id
        if json['color'] == Color.WHITE.value:
            game.white_player = player
            game.save_to_db()
        else:
            game.black_player = player
            game.save_to_db()

        game_dict = game.to_dict()
        game_dict['board_string'] = str(game)

        emit('update_game', game_dict)
Ejemplo n.º 27
0
 def end_season(self):
     players = self.get_players()
     current_winner = None
     current_winner_points = 0
     for player in players:
         if current_winner == None:
             current_winner = player._id
             current_winner_points = player.points
         elif player.points > current_winner_points:
             current_winner = player._id
             current_winner_points = player.points
         player.wins = 0
         player.draw = 0
         player.games_played = 0
         player.loss = 0
         player.points = 0
         player.update_mongo()
     winner = Player.find_by_id(current_winner)
     winner.tourneys_won += 1
     winner.update_mongo()
Ejemplo n.º 28
0
 def end_season(self):
     players = self.get_players()
     current_winner = None
     current_winner_points = 0
     for player in players:
         if current_winner == None:
             current_winner = player._id
             current_winner_points = player.points
         elif player.points > current_winner_points:
             current_winner = player._id
             current_winner_points = player.points
         player.wins = 0
         player.draw = 0
         player.games_played = 0
         player.loss = 0
         player.points = 0
         player.update_mongo()
     winner = Player.find_by_id(current_winner)
     winner.tourneys_won += 1
     winner.update_mongo()
Ejemplo n.º 29
0
    def _draw_winning_labels(self, current_player: Player):
        label: Font = Font(TITLE_FONT, MEDIUM_TEXT)
        label_surface: Surface = label.render(
            'Game Over!!',
            True,
            BLACK
        )
        label_rect: Rect = label_surface.get_rect()
        label_rect.center = (87 + 50, self._height - 50)
        self._screen.blit(label_surface, label_rect)

        player_label: Font = Font(TITLE_FONT, LARGE_TEXT)
        player_label_surface: Surface = player_label.render(
            f'{current_player.name()} Wins!!',
            True,
            RED_TILE if current_player.color() == Color.RED else BLUE_TILE
        )
        player_label_rect: Rect = player_label_surface.get_rect()
        player_label_rect.center = (self._width / 2, self._height - 150)
        self._screen.blit(player_label_surface, player_label_rect)
Ejemplo n.º 30
0
 async def _subway_maps(self, ctx):
     """View a map of this system's stations."""
     await ctx.trigger_typing()
     player = Player(ctx.message.author.id)
     current_location = Location(player.current_location)
     locations = self.locations.list()
     stops_str = ''
     for location in locations:
         if location['id'] == player.current_location:
             stops_str = stops_str + ':small_orange_diamond: '
         else:
             stops_str = stops_str + ':small_blue_diamond: '
         stops_str = stops_str + str(
             location['id']) + '. ' + location['name']
         stores = self.stores.at_location(location['id'])
         if len(stores) > 0:
             stores_str = ' ('
             for store in stores:
                 stores_str = stores_str + store.name
                 if store != stores[-1]:
                     stores_str = stores_str + ', '
             stops_str = stops_str + stores_str
             stops_str = stops_str + ')'
         stops_str = stops_str + '\n'
     guild = ctx.message.guild.name
     embed = discord.Embed(title='Subway Stops',
                           color=discord.Color.blurple(),
                           description='Map of ' + guild +
                           '\nYou are currently in ' +
                           current_location.name)
     embed.set_footer(text='Queried by ' + ctx.message.author.display_name,
                      icon_url=ctx.message.author.avatar_url)
     embed.add_field(name='Stops', value=stops_str)
     embed.set_thumbnail(
         url=
         'https://upload.wikimedia.org/wikipedia/commons/thumb/6/64/MBTA.svg/1200px-MBTA.svg.png'
     )
     return await ctx.send(embed=embed)
Ejemplo n.º 31
0
    def update_table(p1, p2, p1score, p2score):
        p1 = p1.upper()
        p2 = p2.upper()
        room_id = session['_id']
        points = Points.get_points(room_id)
        player1_data = Database.find_one("players", {"name": p1})
        player2_data = Database.find_one("players", {"name": p2})

        if player1_data and player2_data is not None:
            if p1score > p2score:
                winner = Player.find_by_name(p1)
                winner.wins = winner.wins + 1
                winner.games_played = winner.games_played + 1
                winner.points = winner.points + int(points.ppw)
                loser = Player.find_by_name(p2)
                loser.loss = loser.loss + 1
                loser.games_played = loser.games_played + 1

                winnertot = Player_All.find_by_name(p1)
                winnertot.wins = winnertot.wins + 1
                winnertot.games_played = winnertot.games_played + 1
                winnertot.points = winnertot.points + int(points.ppw)
                losertot = Player_All.find_by_name(p2)
                losertot.loss = losertot.loss + 1
                losertot.games_played = losertot.games_played + 1

                winner.update_mongo()
                loser.update_mongo()
                winnertot.update_mongo()
                losertot.update_mongo()

            elif p2score > p1score:
                winner = Player.find_by_name(p2)
                winner.wins = winner.wins + 1
                winner.games_played = winner.games_played + 1
                winner.points = winner.points + int(points.ppw)
                loser = Player.find_by_name(p1)
                loser.loss = loser.loss + 1
                loser.games_played = loser.games_played + 1

                winnertot = Player_All.find_by_name(p2)
                winnertot.wins = winnertot.wins + 1
                winnertot.games_played = winnertot.games_played + 1
                winnertot.points = winnertot.points + int(points.ppw)
                losertot = Player_All.find_by_name(p1)
                losertot.loss = losertot.loss + 1
                losertot.games_played = losertot.games_played + 1

                winner.update_mongo()
                loser.update_mongo()
                winnertot.update_mongo()
                losertot.update_mongo()

            else:
                p1 = Player.find_by_name(p1)
                p2 = Player.find_by_name(p2)
                p1.draw = p1.draw + int(points.ppd)
                p2.draw = p2.draw + int(points.ppd)
                p1.points = p1.points + 1
                p2.points = p2.points + 1

                p1tot = Player_All.find_by_name(p1)
                p2tot = Player_All.find_by_name(p2)
                p1tot.draw = p1tot.draw + int(points.ppd)
                p2tot.draw = p2tot.draw + int(points.ppd)
                p1tot.points = p1tot.points + 1
                p2tot.points = p2tot.points + 1

                p1.update_mongo()
                p2.update_mongo()
                p1tot.update_mongo()
                p2tot.update_mongo()
        else:
            return None
Ejemplo n.º 32
0
 def new_player(name, room_id):
     name = name.upper()
     player = Player(name, 0, 0, 0, 0, 0, 0, room_id)
     player_all = Player_All(name, 0, 0, 0, 0, 0, 0, room_id, player._id)
     player.save_to_mongo()
     player_all.save_to_mongo()
Ejemplo n.º 33
0
 def get_players(self):
     return Player.find_by_room_id(self._id)
Ejemplo n.º 34
0
import random
from src.models.board import Board
from src.models.player import Player
from src.models.challenges import challenges
from src.services import utilities

game = Board()
turn_count = 1
P1 = Player()
P2 = Player()
P1.name = input('What is Player 1\'s name? ')
P2.name = input('What is Player 2\'s name? ')
players = [P1, P2]
starting_player = random.choice(players)

while turn_count < 10:
    print(f'The current turn is {turn_count}')
    current_player = utilities.determine_player(turn_count, starting_player,
                                                players)
    print(f'The current player is {current_player.name}.')

    print(f'{P1.name} has {P1.cards}')
    print(f'{P2.name} has {P2.cards}')

    selected_card = input('Choose a card from your hand ... ')
    while not utilities.has_card_in_hand(current_player, selected_card):
        selected_card = input('That card is not in your hand. Try again ... ')

    played_card = [
        item for item in current_player.hand if item['name'] == selected_card
    ][0]
Ejemplo n.º 35
0
 def validate_email(self, email):
     user = Player.load_by_email(email.data)
     if user:
         raise ValidationError('Please use a different email address.')
Ejemplo n.º 36
0
 def get_players(self):
     return Player.find_by_room_id(self._id)
Ejemplo n.º 37
0
 def new_player(name, room_id):
     name = name.upper()
     player = Player(name,0,0,0,0,0,0,room_id)
     player_all = Player_All(name,0,0,0,0,0,0,room_id,player._id)
     player.save_to_mongo()
     player_all.save_to_mongo()
Ejemplo n.º 38
0
    def update_table(p1, p2, p1score, p2score):
        p1 = p1.upper()
        p2 = p2.upper()
        room_id = session['_id']
        points = Points.get_points(room_id)
        player1_data = Database.find_one("players", {"name": p1})
        player2_data = Database.find_one("players", {"name": p2})

        if player1_data and player2_data is not None:
            if p1score > p2score:
                winner = Player.find_by_name(p1)
                winner.wins = winner.wins + 1
                winner.games_played = winner.games_played + 1
                winner.points = winner.points + int(points.ppw)
                loser = Player.find_by_name(p2)
                loser.loss = loser.loss + 1
                loser.games_played = loser.games_played + 1

                winnertot = Player_All.find_by_name(p1)
                winnertot.wins = winnertot.wins + 1
                winnertot.games_played = winnertot.games_played + 1
                winnertot.points = winnertot.points + int(points.ppw)
                losertot = Player_All.find_by_name(p2)
                losertot.loss = losertot.loss + 1
                losertot.games_played = losertot.games_played + 1

                winner.update_mongo()
                loser.update_mongo()
                winnertot.update_mongo()
                losertot.update_mongo()

            elif p2score > p1score:
                winner = Player.find_by_name(p2)
                winner.wins = winner.wins + 1
                winner.games_played = winner.games_played + 1
                winner.points = winner.points + int(points.ppw)
                loser = Player.find_by_name(p1)
                loser.loss = loser.loss + 1
                loser.games_played = loser.games_played + 1

                winnertot = Player_All.find_by_name(p2)
                winnertot.wins = winnertot.wins + 1
                winnertot.games_played = winnertot.games_played + 1
                winnertot.points = winnertot.points + int(points.ppw)
                losertot = Player_All.find_by_name(p1)
                losertot.loss = losertot.loss + 1
                losertot.games_played = losertot.games_played + 1

                winner.update_mongo()
                loser.update_mongo()
                winnertot.update_mongo()
                losertot.update_mongo()

            else:
                p1 = Player.find_by_name(p1)
                p2 = Player.find_by_name(p2)
                p1.draw = p1.draw + int(points.ppd)
                p2.draw = p2.draw + int(points.ppd)
                p1.points = p1.points + 1
                p2.points = p2.points + 1

                p1tot = Player_All.find_by_name(p1)
                p2tot = Player_All.find_by_name(p2)
                p1tot.draw = p1tot.draw + int(points.ppd)
                p2tot.draw = p2tot.draw + int(points.ppd)
                p1tot.points = p1tot.points + 1
                p2tot.points = p2tot.points + 1

                p1.update_mongo()
                p2.update_mongo()
                p1tot.update_mongo()
                p2tot.update_mongo()
        else:
            return None