FEAT: Added map image (though inaccurate), and added round attr to match

This commit is contained in:
2025-03-11 21:51:42 +01:00
parent 5e2c87b2ed
commit 8138e0d7cf
2 changed files with 38 additions and 15 deletions

View File

@@ -4,8 +4,12 @@ class Match:
def __init__(self, map_name, game_info, tick_rate=64):
self.players = []
self.map_name = map_name
self.round = 0
self.tick = 0
self.tick = 1
self.current_tick = game_info[game_info["tick"] == self.tick]
self.round = self.current_tick["team_rounds_total"].values[0]
self.max_tick = game_info.index[-1]
self.game_info = game_info # pd dataframe sorted by tick
self.tick_rate = tick_rate
@@ -15,20 +19,26 @@ class Match:
def next_tick(self) -> None:
self.tick += 1
self.current_tick = self.game_info[self.game_info["tick"] == self.tick]
self._update_player_positions()
self._update_round()
def _update_player_positions(self) -> None:
# inefficient, might need to change
current_tick = self.game_info[self.game_info["tick"] == self.tick]
# empty tick
if current_tick.empty:
if self.current_tick.empty:
return
for player in self.players:
player.x = current_tick[current_tick["player_steamid"] == player.steam_id]["X"].values[0]
player.y = current_tick[current_tick["player_steamid"] == player.steam_id]["Y"].values[0]
player.z = current_tick[current_tick["player_steamid"] == player.steam_id]["Z"].values[0]
player.pitch = current_tick[current_tick["player_steamid"] == player.steam_id]["pitch"].values[0]
player.yaw = current_tick[current_tick["player_steamid"] == player.steam_id]["yaw"].values[0]
player.dead = current_tick[current_tick["player_steamid"] == player.steam_id]["is_alive"].values[0] == 0
player.x = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["Y"].values[0]
player.y = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["X"].values[0]
player.z = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["Z"].values[0]
player.pitch = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["pitch"].values[0]
player.yaw = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["yaw"].values[0]
player.dead = self.current_tick[self.current_tick["player_steamid"] == player.steam_id]["is_alive"].values[0] == 0
def _update_round(self) -> None:
if self.current_tick.empty:
return
self.round = self.current_tick["team_rounds_total"].values[0]