Player (model.game.player)¶
model.game.player
¶
Player representation tracking game side, user association, and Elo ratings.
Player
¶
Represents a chess participant associated with a side and an optional user profile.
Source code in src/model/game/player.py
__init__(color, user=None)
¶
Initialize a Player.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
int
|
Side color (1 for White, -1 for Black). |
required |
user
|
Optional[Any]
|
Optional User profile instance. |
None
|
getColor()
¶
Get the player's color identifier.
Returns:
| Type | Description |
|---|---|
int
|
Color identifier (1 for White, -1 for Black). |
getEloRating()
¶
Get the Elo rating of the player from their user profile.
Returns:
| Type | Description |
|---|---|
int
|
Integer Elo rating, defaulting to 1200 if unrated. |
Source code in src/model/game/player.py
getUser()
¶
Get the associated user profile.
Returns:
| Type | Description |
|---|---|
Optional[Any]
|
User profile object or None if not linked. |
setUser(user)
¶
Associate a user profile with this player.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user
|
Any
|
User profile instance. |
required |