aboutsummaryrefslogtreecommitdiff
path: root/diplomacy
diff options
context:
space:
mode:
Diffstat (limited to 'diplomacy')
-rw-r--r--diplomacy/engine/game.py4
-rw-r--r--diplomacy/server/server.py6
2 files changed, 5 insertions, 5 deletions
diff --git a/diplomacy/engine/game.py b/diplomacy/engine/game.py
index 3f218e4..03a25af 100644
--- a/diplomacy/engine/game.py
+++ b/diplomacy/engine/game.py
@@ -19,10 +19,10 @@
- Contains the game engine
"""
# pylint: disable=too-many-lines
+import base64
import os
import sys
import time
-import uuid
import random
from copy import deepcopy
@@ -266,7 +266,7 @@ class Game(Jsonable):
# Check game ID.
if self.game_id is None:
- self.game_id = '%s/%s' % (self.timestamp_created, uuid.uuid4())
+ self.game_id = base64.b64encode(os.urandom(12), b'-_').decode('utf-8')
# Validating status
self._validate_status(reinit_powers=(self.timestamp_created is None))
diff --git a/diplomacy/server/server.py b/diplomacy/server/server.py
index 5763991..fed4eb6 100644
--- a/diplomacy/server/server.py
+++ b/diplomacy/server/server.py
@@ -47,10 +47,10 @@
"""
import atexit
+import base64
import logging
import os
import signal
-import uuid
import tornado
import tornado.web
@@ -739,9 +739,9 @@ class Server():
def create_game_id(self):
""" Create and return a game ID not already used by a game in server database. """
- game_id = str(uuid.uuid4())
+ game_id = base64.b64encode(os.urandom(12), b'-_').decode('utf-8')
while self.has_game_id(game_id):
- game_id = str(uuid.uuid4())
+ game_id = base64.b64encode(os.urandom(12), b'-_').decode('utf-8')
return game_id
def remove_token(self, token):