featurz
This commit is contained in:
20
main.py
20
main.py
@ -344,7 +344,27 @@ def main_loop(screen):
|
|||||||
# Format with timestamp before displaying
|
# Format with timestamp before displaying
|
||||||
formatted_msg, attributes = format_message(parsed)
|
formatted_msg, attributes = format_message(parsed)
|
||||||
ui.print_message(formatted_msg)
|
ui.print_message(formatted_msg)
|
||||||
|
ui.update_server_info(game_state)
|
||||||
|
|
||||||
|
# Check if we need to revive players
|
||||||
|
if game_state.server_info.gametype == 'Clan Arena':
|
||||||
|
# CA: revive all players 3s after round end
|
||||||
|
if game_state.server_info.round_end_time:
|
||||||
|
if time.time() - game_state.server_info.round_end_time >= 3.0:
|
||||||
|
game_state.server_info.dead_players.clear()
|
||||||
|
game_state.server_info.round_end_time = None
|
||||||
ui.update_server_info(game_state)
|
ui.update_server_info(game_state)
|
||||||
|
else:
|
||||||
|
# Other modes: revive individual players 3s after death
|
||||||
|
current_time = time.time()
|
||||||
|
players_to_revive = [
|
||||||
|
name for name, death_time in game_state.server_info.dead_players.items()
|
||||||
|
if current_time - death_time >= 3.0
|
||||||
|
]
|
||||||
|
if players_to_revive:
|
||||||
|
for name in players_to_revive:
|
||||||
|
del game_state.server_info.dead_players[name]
|
||||||
|
ui.update_server_info(game_state)
|
||||||
|
|
||||||
# Process RCON messages
|
# Process RCON messages
|
||||||
if event > 0:
|
if event > 0:
|
||||||
|
|||||||
10
parser.py
10
parser.py
@ -146,6 +146,11 @@ class EventParser:
|
|||||||
self.game_state.player_tracker.update_team(victim_name, victim['TEAM'])
|
self.game_state.player_tracker.update_team(victim_name, victim['TEAM'])
|
||||||
self.game_state.player_tracker.add_player(victim_name)
|
self.game_state.player_tracker.add_player(victim_name)
|
||||||
|
|
||||||
|
# Mark as dead
|
||||||
|
if not data.get('WARMUP', False):
|
||||||
|
import time
|
||||||
|
self.game_state.server_info.dead_players[victim_name] = time.time()
|
||||||
|
|
||||||
victim_prefix = get_team_prefix(victim_name, self.game_state.player_tracker)
|
victim_prefix = get_team_prefix(victim_name, self.game_state.player_tracker)
|
||||||
warmup = " ^8^3(Warmup)^0" if data.get('WARMUP', False) else ""
|
warmup = " ^8^3(Warmup)^0" if data.get('WARMUP', False) else ""
|
||||||
score_prefix = ""
|
score_prefix = ""
|
||||||
@ -222,6 +227,9 @@ class EventParser:
|
|||||||
self.game_state.server_info.blue_rounds += 1
|
self.game_state.server_info.blue_rounds += 1
|
||||||
logger.info(f"Round {round_num}: BLUE wins (RED: {self.game_state.server_info.red_rounds}, BLUE: {self.game_state.server_info.blue_rounds})")
|
logger.info(f"Round {round_num}: BLUE wins (RED: {self.game_state.server_info.red_rounds}, BLUE: {self.game_state.server_info.blue_rounds})")
|
||||||
|
|
||||||
|
import time
|
||||||
|
self.game_state.server_info.round_end_time = time.time()
|
||||||
|
|
||||||
return None # Don't display in chat
|
return None # Don't display in chat
|
||||||
|
|
||||||
def _handle_medal(self, data):
|
def _handle_medal(self, data):
|
||||||
@ -304,4 +312,4 @@ class EventParser:
|
|||||||
|
|
||||||
weapon_name = WEAPON_NAMES.get(best_weapon, best_weapon)
|
weapon_name = WEAPON_NAMES.get(best_weapon, best_weapon)
|
||||||
|
|
||||||
return f"{team_prefix}^8^7{name}^0^7 K/D: {kills}/{deaths} | Best Weapon: {weapon_name} - Acc: {best_accuracy:.2f}% - Kills: {best_weapon_kills}\n"
|
return f"^8^5[PLAYER STATS]^7^0 {team_prefix}^8^7{name}^0^7 K/D: {kills}/{deaths} | Best Weapon: {weapon_name} - Acc: {best_accuracy:.2f}% - Kills: {best_weapon_kills}\n"
|
||||||
|
|||||||
3
state.py
3
state.py
@ -31,6 +31,8 @@ class ServerInfo:
|
|||||||
self.players = []
|
self.players = []
|
||||||
self.last_update = 0
|
self.last_update = 0
|
||||||
self.warmup = False
|
self.warmup = False
|
||||||
|
self.dead_players = {}
|
||||||
|
self.round_end_time = None
|
||||||
|
|
||||||
def is_team_mode(self):
|
def is_team_mode(self):
|
||||||
"""Check if current gametype is a team mode"""
|
"""Check if current gametype is a team mode"""
|
||||||
@ -40,6 +42,7 @@ class ServerInfo:
|
|||||||
"""Reset round scores (for new matches)"""
|
"""Reset round scores (for new matches)"""
|
||||||
self.red_rounds = 0
|
self.red_rounds = 0
|
||||||
self.blue_rounds = 0
|
self.blue_rounds = 0
|
||||||
|
self.dead_players.clear()
|
||||||
|
|
||||||
def update_from_cvar(self, cvar_name, value):
|
def update_from_cvar(self, cvar_name, value):
|
||||||
"""Update server info from a cvar response"""
|
"""Update server info from a cvar response"""
|
||||||
|
|||||||
24
ui.py
24
ui.py
@ -347,7 +347,7 @@ class UIManager:
|
|||||||
teams = game_state.player_tracker.get_players_by_team()
|
teams = game_state.player_tracker.get_players_by_team()
|
||||||
|
|
||||||
if server_info.gametype in TEAM_MODES:
|
if server_info.gametype in TEAM_MODES:
|
||||||
if server_info.gametype == 'CA':
|
if server_info.gametype == 'Clan Arena':
|
||||||
red_score = f"{server_info.red_rounds:>3} "
|
red_score = f"{server_info.red_rounds:>3} "
|
||||||
blue_score = f"{server_info.blue_rounds:>3} "
|
blue_score = f"{server_info.blue_rounds:>3} "
|
||||||
|
|
||||||
@ -416,9 +416,13 @@ class UIManager:
|
|||||||
blue_score = player.get('score', '0')
|
blue_score = player.get('score', '0')
|
||||||
break
|
break
|
||||||
|
|
||||||
# Format: " 9 PlayerName" with right-aligned score
|
# Check if players are dead
|
||||||
red = f"{red_score:>3} {red_name}" if red_name else ''
|
red_dead = red_name in server_info.dead_players
|
||||||
blue = f"{blue_score:>3} {blue_name}" if blue_name else ''
|
blue_dead = blue_name in server_info.dead_players
|
||||||
|
|
||||||
|
# Format with strikethrough for dead players (using dim text)
|
||||||
|
red = f"{red_score:>3} {'^8^1X^7^0 ' if red_dead else ''}{red_name}" if red_name else ''
|
||||||
|
blue = f"{blue_score:>3} {'^8^1X^7^0 ' if blue_dead else ''}{blue_name}" if blue_name else ''
|
||||||
|
|
||||||
from formatter import strip_color_codes
|
from formatter import strip_color_codes
|
||||||
red_clean = strip_color_codes(red)
|
red_clean = strip_color_codes(red)
|
||||||
@ -467,9 +471,13 @@ class UIManager:
|
|||||||
col2_score = player.get('score', '0')
|
col2_score = player.get('score', '0')
|
||||||
break
|
break
|
||||||
|
|
||||||
# Format: " 9 PlayerName" with right-aligned score
|
# Check if players are dead
|
||||||
col1 = f"{col1_score:>3} {col1_name}" if col1_name else ''
|
col1_dead = col1_name in server_info.dead_players
|
||||||
col2 = f"{col2_score:>3} {col2_name}" if col2_name else ''
|
col2_dead = col2_name in server_info.dead_players
|
||||||
|
|
||||||
|
# Format: " 9 PlayerName" with right-aligned score and dead marker
|
||||||
|
col1 = f"{col1_score:>3} {'^8^1X^7^0 ' if col1_dead else ''}{col1_name}" if col1_name else ''
|
||||||
|
col2 = f"{col2_score:>3} {'^8^1X^7^0 ' if col2_dead else ''}{col2_name}" if col2_name else ''
|
||||||
|
|
||||||
from formatter import strip_color_codes
|
from formatter import strip_color_codes
|
||||||
col1_clean = strip_color_codes(col1)
|
col1_clean = strip_color_codes(col1)
|
||||||
@ -485,7 +493,7 @@ class UIManager:
|
|||||||
|
|
||||||
# List spectators on one line
|
# List spectators on one line
|
||||||
spec_list = " ".join(spec_players)
|
spec_list = " ".join(spec_players)
|
||||||
line = f" ^8^3SPEC^0:^7^8 {spec_list}\n"
|
line = f"^8^3Spectators:^7 {spec_list}\n"
|
||||||
print_colored(self.info_window, line, 0)
|
print_colored(self.info_window, line, 0)
|
||||||
|
|
||||||
# Blank lines to fill
|
# Blank lines to fill
|
||||||
|
|||||||
Reference in New Issue
Block a user