Skip to content

Commit

Permalink
deploy: d0152da
Browse files Browse the repository at this point in the history
  • Loading branch information
Askaholic committed Dec 27, 2023
1 parent 28796d1 commit 8c8ae65
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 87 deletions.
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6294,8 +6294,11 @@ <h3>Inherited members</h3>

def remove_player(self, player: Player):
if player.id in self._players:
# This signals that the player is now disconnected
del player.lobby_connection
del self._players[player.id]
metrics.players_online.set(len(self._players))
self.mark_dirty(player)

async def has_permission_role(self, player: Player, role_name: str) -&gt; bool:
async with self._db.acquire() as conn:
Expand Down Expand Up @@ -6589,8 +6592,11 @@ <h3>Methods</h3>
</summary>
<pre><code class="python">def remove_player(self, player: Player):
if player.id in self._players:
# This signals that the player is now disconnected
del player.lobby_connection
del self._players[player.id]
metrics.players_online.set(len(self._players))</code></pre>
metrics.players_online.set(len(self._players))
self.mark_dirty(player)</code></pre>
</details>
</dd>
<dt id="server.PlayerService.signal_player_rating_change"><code class="name flex">
Expand Down
11 changes: 10 additions & 1 deletion player_service.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ <h1 class="title">Module <code>server.player_service</code></h1>

def remove_player(self, player: Player):
if player.id in self._players:
# This signals that the player is now disconnected
del player.lobby_connection
del self._players[player.id]
metrics.players_online.set(len(self._players))
self.mark_dirty(player)

async def has_permission_role(self, player: Player, role_name: str) -&gt; bool:
async with self._db.acquire() as conn:
Expand Down Expand Up @@ -407,8 +410,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>

def remove_player(self, player: Player):
if player.id in self._players:
# This signals that the player is now disconnected
del player.lobby_connection
del self._players[player.id]
metrics.players_online.set(len(self._players))
self.mark_dirty(player)

async def has_permission_role(self, player: Player, role_name: str) -&gt; bool:
async with self._db.acquire() as conn:
Expand Down Expand Up @@ -702,8 +708,11 @@ <h3>Methods</h3>
</summary>
<pre><code class="python">def remove_player(self, player: Player):
if player.id in self._players:
# This signals that the player is now disconnected
del player.lobby_connection
del self._players[player.id]
metrics.players_online.set(len(self._players))</code></pre>
metrics.players_online.set(len(self._players))
self.mark_dirty(player)</code></pre>
</details>
</dd>
<dt id="server.player_service.PlayerService.signal_player_rating_change"><code class="name flex">
Expand Down
170 changes: 85 additions & 85 deletions players.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,37 +159,37 @@ <h1 class="title">Module <code>server.players</code></h1>
with suppress(DisconnectedError):
self.lobby_connection.write(message)

def to_dict(self):
def to_dict(self) -&gt; dict:
&#34;&#34;&#34;
Return a dictionary representing this player object
&#34;&#34;&#34;

def filter_none(t):
_, v = t
return v is not None

return dict(
filter(
filter_none, (
(&#34;id&#34;, self.id),
(&#34;login&#34;, self.login),
(&#34;avatar&#34;, self.avatar),
(&#34;country&#34;, self.country),
(&#34;clan&#34;, self.clan),
(&#34;ratings&#34;, {
rating_type: {
&#34;rating&#34;: self.ratings[rating_type],
&#34;number_of_games&#34;: self.game_count[rating_type]
}
for rating_type in self.ratings
}),
# Deprecated
(&#34;global_rating&#34;, self.ratings[RatingType.GLOBAL]),
(&#34;ladder_rating&#34;, self.ratings[RatingType.LADDER_1V1]),
(&#34;number_of_games&#34;, self.game_count[RatingType.GLOBAL]),
)
)
)
assert self.state is not None and self.state.value is not None

cmd = {
&#34;id&#34;: self.id,
&#34;login&#34;: self.login,
&#34;avatar&#34;: self.avatar,
&#34;country&#34;: self.country,
&#34;clan&#34;: self.clan,
# NOTE: We are only sending an &#39;offline&#39; state for now to signal to
# the client when a player disconnects. However, this could be
# expanded in the future to expose more of the internal state
# tracking to the client to make the UI for showing players in game
# more correct.
&#34;state&#34;: None if self.lobby_connection else &#34;offline&#34;,
&#34;ratings&#34;: {
rating_type: {
&#34;rating&#34;: self.ratings[rating_type],
&#34;number_of_games&#34;: self.game_count[rating_type]
}
for rating_type in self.ratings
},
# DEPRECATED: Use ratings instead
&#34;global_rating&#34;: self.ratings[RatingType.GLOBAL],
&#34;ladder_rating&#34;: self.ratings[RatingType.LADDER_1V1],
&#34;number_of_games&#34;: self.game_count[RatingType.GLOBAL],
}
return {k: v for k, v in cmd.items() if v is not None}

def __str__(self) -&gt; str:
return (f&#34;Player({self.login}, {self.id}, &#34;
Expand Down Expand Up @@ -330,37 +330,37 @@ <h2 class="section-title" id="header-classes">Classes</h2>
with suppress(DisconnectedError):
self.lobby_connection.write(message)

def to_dict(self):
def to_dict(self) -&gt; dict:
&#34;&#34;&#34;
Return a dictionary representing this player object
&#34;&#34;&#34;

def filter_none(t):
_, v = t
return v is not None

return dict(
filter(
filter_none, (
(&#34;id&#34;, self.id),
(&#34;login&#34;, self.login),
(&#34;avatar&#34;, self.avatar),
(&#34;country&#34;, self.country),
(&#34;clan&#34;, self.clan),
(&#34;ratings&#34;, {
rating_type: {
&#34;rating&#34;: self.ratings[rating_type],
&#34;number_of_games&#34;: self.game_count[rating_type]
}
for rating_type in self.ratings
}),
# Deprecated
(&#34;global_rating&#34;, self.ratings[RatingType.GLOBAL]),
(&#34;ladder_rating&#34;, self.ratings[RatingType.LADDER_1V1]),
(&#34;number_of_games&#34;, self.game_count[RatingType.GLOBAL]),
)
)
)
assert self.state is not None and self.state.value is not None

cmd = {
&#34;id&#34;: self.id,
&#34;login&#34;: self.login,
&#34;avatar&#34;: self.avatar,
&#34;country&#34;: self.country,
&#34;clan&#34;: self.clan,
# NOTE: We are only sending an &#39;offline&#39; state for now to signal to
# the client when a player disconnects. However, this could be
# expanded in the future to expose more of the internal state
# tracking to the client to make the UI for showing players in game
# more correct.
&#34;state&#34;: None if self.lobby_connection else &#34;offline&#34;,
&#34;ratings&#34;: {
rating_type: {
&#34;rating&#34;: self.ratings[rating_type],
&#34;number_of_games&#34;: self.game_count[rating_type]
}
for rating_type in self.ratings
},
# DEPRECATED: Use ratings instead
&#34;global_rating&#34;: self.ratings[RatingType.GLOBAL],
&#34;ladder_rating&#34;: self.ratings[RatingType.LADDER_1V1],
&#34;number_of_games&#34;: self.game_count[RatingType.GLOBAL],
}
return {k: v for k, v in cmd.items() if v is not None}

def __str__(self) -&gt; str:
return (f&#34;Player({self.login}, {self.id}, &#34;
Expand Down Expand Up @@ -509,45 +509,45 @@ <h1 id="errors">Errors</h1>
</details>
</dd>
<dt id="server.players.Player.to_dict"><code class="name flex">
<span>def <span class="ident">to_dict</span></span>(<span>self)</span>
<span>def <span class="ident">to_dict</span></span>(<span>self)> dict</span>
</code></dt>
<dd>
<div class="desc"><p>Return a dictionary representing this player object</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def to_dict(self):
<pre><code class="python">def to_dict(self) -&gt; dict:
&#34;&#34;&#34;
Return a dictionary representing this player object
&#34;&#34;&#34;

def filter_none(t):
_, v = t
return v is not None

return dict(
filter(
filter_none, (
(&#34;id&#34;, self.id),
(&#34;login&#34;, self.login),
(&#34;avatar&#34;, self.avatar),
(&#34;country&#34;, self.country),
(&#34;clan&#34;, self.clan),
(&#34;ratings&#34;, {
rating_type: {
&#34;rating&#34;: self.ratings[rating_type],
&#34;number_of_games&#34;: self.game_count[rating_type]
}
for rating_type in self.ratings
}),
# Deprecated
(&#34;global_rating&#34;, self.ratings[RatingType.GLOBAL]),
(&#34;ladder_rating&#34;, self.ratings[RatingType.LADDER_1V1]),
(&#34;number_of_games&#34;, self.game_count[RatingType.GLOBAL]),
)
)
)</code></pre>
assert self.state is not None and self.state.value is not None

cmd = {
&#34;id&#34;: self.id,
&#34;login&#34;: self.login,
&#34;avatar&#34;: self.avatar,
&#34;country&#34;: self.country,
&#34;clan&#34;: self.clan,
# NOTE: We are only sending an &#39;offline&#39; state for now to signal to
# the client when a player disconnects. However, this could be
# expanded in the future to expose more of the internal state
# tracking to the client to make the UI for showing players in game
# more correct.
&#34;state&#34;: None if self.lobby_connection else &#34;offline&#34;,
&#34;ratings&#34;: {
rating_type: {
&#34;rating&#34;: self.ratings[rating_type],
&#34;number_of_games&#34;: self.game_count[rating_type]
}
for rating_type in self.ratings
},
# DEPRECATED: Use ratings instead
&#34;global_rating&#34;: self.ratings[RatingType.GLOBAL],
&#34;ladder_rating&#34;: self.ratings[RatingType.LADDER_1V1],
&#34;number_of_games&#34;: self.game_count[RatingType.GLOBAL],
}
return {k: v for k, v in cmd.items() if v is not None}</code></pre>
</details>
</dd>
<dt id="server.players.Player.write_message"><code class="name flex">
Expand Down

0 comments on commit 8c8ae65

Please sign in to comment.