server module

Server for online game.

class server.ComputerGameStat(**kwargs)

Bases: sqlalchemy.orm.decl_api.Model

Computer game statistics class for use in SQLAlchemy.

class server.OnlineGameStat(**kwargs)

Bases: sqlalchemy.orm.decl_api.Model

Online game statistics class for use in SQLAlchemy.

class server.User(**kwargs)

Bases: sqlalchemy.orm.decl_api.Model

User class for use in SQLAlchemy.

server.authenticate_user(username: str, password: str) Optional[str]

Verify the existence of a user.

Parameters
  • username (class: str) – User username

  • password (class str) – User password

Returns

Id of user or None

Return type

class: str or None

server.check_opponent(data: Dict[str, str]) None

Check if the opponent is in the game.

Tell the user that it is possible to start the game, or tells the user that the opponent reset the game.

Parameters

data (class: dict[str, str]) – Dictionary with game parameters

server.create_user(username: str, password: str) str

Create a user profile.

Parameters
  • username (class: str) – User username

  • password (class str) – User password

Returns

Id of user

Return type

class: str

server.game_over(data: Dict[str, Union[str, bool, int]]) None

Tell the opponent that the game is over.

Parameters

data (class: dict[str, str | bool | int]) – Dictionary with game parameters

server.hash_password(password: str) str

Hash password.

Parameters

password (class str) – User password

Returns

Hashed password

Return type

class: str

server.index() flask.wrappers.Response

Send the necessary data to the user when launching the client with the game.

Returns

Server response

Return type

class: flask.Response

server.is_game_searched() flask.wrappers.Response

Tell if a game has been found for the user.

Returns

Server response

Return type

class: flask.Response

server.join_queue() flask.wrappers.Response

Add a user to the list of users who are looking for a game.

Returns

Server response

Return type

class: flask.Response

server.leave(data: Dict[str, str]) None

Exit the game at the end of it.

Parameters

data (class: dict[str, str]) – Dictionary with game parameters

server.login() flask.wrappers.Response

Authorize the user in the game.

Returns

Server response

Return type

class: flask.Response

server.logout() flask.wrappers.Response

Log the user out of the game.

Returns

Server response

Return type

class: flask.Response

server.on_connect(*args) None

Connect the user to the game.

server.on_play(data: Dict[str, Union[str, int]]) None

Inform the opponent about the user’s progress.

Parameters

data (class: dict[str, str | int]) – Dictionary with game parameters

server.register() flask.wrappers.Response

Register a user.

Returns

Server response

Return type

class: flask.Response

server.reset_game(data: Dict[str, str]) None

Cancel the game for the user.

Parameters

data (class: dict[str, str]) – Dictionary with game parameters

Reset the game search.

Returns

Server response

Return type

class: flask.Response

server.start_game() None

Select two players in a separate thread to start the game.

server.update_computer_statistic() flask.wrappers.Response

Update statistics of computer games of user.

Returns

Server response

Return type

class: flask.Response

server.update_friend_statistic() flask.wrappers.Response

Update statistics of online games of user.

Returns

Server response

Return type

class: flask.Response