Combining with "patch" branch (#29)
* Update unobot.po * Update test_player.py * Update test_player.py * Update test_player.py * Update test_player.py * Update player.py * Update player.py * Update internationalization.py * Update internationalization.py * Update test_player.py * Update test_player.py * Update test_player.py * Update player.py * Update player.py * Update player.py * Update test_player.py * Update test_player.py * revert play 4 then 4 rule * Update test_player.py * Update player.py * Update player.py * Update player.py * Update game.py * Update game_manager.py * Update game_manager.py * Update game_manager.py * Update player.py * Update test_player.py * Update player.py * Update bot.py * Update credentials.py * Update credentials.py * Update bot.py * Update game.py * Update game_manager.py * Update game_manager.py * Update player.py
This commit is contained in:
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
import logging
|
||||
import random
|
||||
|
||||
from game import Game
|
||||
from player import Player
|
||||
@ -77,7 +78,8 @@ class GameManager(object):
|
||||
# Don not re-add a player and remove the player from previous games in
|
||||
# this chat, if he is in one of them
|
||||
for player in players:
|
||||
if player in game.players:
|
||||
# Try to pervent someone win or leave then join again.
|
||||
if player in game.players or user.id in game.joined_before:
|
||||
raise AlreadyJoinedError()
|
||||
else:
|
||||
try:
|
||||
@ -93,8 +95,14 @@ class GameManager(object):
|
||||
players = self.userid_players[user.id]
|
||||
|
||||
player = Player(game, user)
|
||||
|
||||
players.append(player)
|
||||
|
||||
# Randomize player position.
|
||||
game.joined_before.append(user.id)
|
||||
if len(players) > 2:
|
||||
players.insert(random.randrange(len(players)), player)
|
||||
else:
|
||||
players.append(player)
|
||||
|
||||
self.userid_current[user.id] = player
|
||||
|
||||
def leave_game(self, user, chat):
|
||||
|
Reference in New Issue
Block a user