track player is dead
All checks were successful
Build and Push Docker Image / build (push) Successful in 12s
All checks were successful
Build and Push Docker Image / build (push) Successful in 12s
This commit is contained in:
parent
2c30e719ce
commit
38dbc1a419
@ -83,7 +83,7 @@ class PlayersCog(commands.Cog):
|
|||||||
|
|
||||||
embed = await player.get_embed()
|
embed = await player.get_embed()
|
||||||
embed.title = "Player Has Died"
|
embed.title = "Player Has Died"
|
||||||
embed.colour = Colour.brand_green()
|
embed.colour = Colour.dark_orange()
|
||||||
|
|
||||||
await channel.send(embed=embed)
|
await channel.send(embed=embed)
|
||||||
|
|
||||||
@ -109,6 +109,12 @@ class PlayersCog(commands.Cog):
|
|||||||
await player.update_steam_summary(re_match.group("steam_id"), self.bot.steam_api_key)
|
await player.update_steam_summary(re_match.group("steam_id"), self.bot.steam_api_key)
|
||||||
await player.save()
|
await player.save()
|
||||||
|
|
||||||
|
# This connection method is called when the player respawns
|
||||||
|
if player.is_dead:
|
||||||
|
await player.is_dead = False # player must be alive if fully connected
|
||||||
|
await player.save()
|
||||||
|
return
|
||||||
|
|
||||||
channel = self.bot.get_channel(self.bot.in_game_channel_id)
|
channel = self.bot.get_channel(self.bot.in_game_channel_id)
|
||||||
channel = channel or await self.bot.fetch_channel(self.bot.in_game_channel_id)
|
channel = channel or await self.bot.fetch_channel(self.bot.in_game_channel_id)
|
||||||
|
|
||||||
@ -137,6 +143,9 @@ class PlayersCog(commands.Cog):
|
|||||||
await player.update_steam_summary(re_match.group("steam_id"), self.bot.steam_api_key)
|
await player.update_steam_summary(re_match.group("steam_id"), self.bot.steam_api_key)
|
||||||
await player.save()
|
await player.save()
|
||||||
|
|
||||||
|
if player.is_dead:
|
||||||
|
return
|
||||||
|
|
||||||
channel = self.bot.get_channel(self.bot.in_game_channel_id)
|
channel = self.bot.get_channel(self.bot.in_game_channel_id)
|
||||||
channel = channel or await self.bot.fetch_channel(self.bot.in_game_channel_id)
|
channel = channel or await self.bot.fetch_channel(self.bot.in_game_channel_id)
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ class Player(Model):
|
|||||||
last_connection = fields.DatetimeField(null=True)
|
last_connection = fields.DatetimeField(null=True)
|
||||||
last_disconnection = fields.DatetimeField(null=True)
|
last_disconnection = fields.DatetimeField(null=True)
|
||||||
play_time_seconds = fields.IntField(default=0)
|
play_time_seconds = fields.IntField(default=0)
|
||||||
|
is_dead = fields.BooleanField(default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
table = "players"
|
table = "players"
|
||||||
@ -79,6 +80,8 @@ class Player(Model):
|
|||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
log.debug("Assigning death to player: %s", self.username)
|
log.debug("Assigning death to player: %s", self.username)
|
||||||
|
self.is_dead = True
|
||||||
|
await self.save()
|
||||||
return await PlayerDeath.create(
|
return await PlayerDeath.create(
|
||||||
player=self,
|
player=self,
|
||||||
coordinate_x=coord_x,
|
coordinate_x=coord_x,
|
||||||
|
Reference in New Issue
Block a user