- Add pre-compiled regex pattern for color codes - Add SPECIAL_CHAR constant (chr(25)) for clarity - Move time import to module level in parser - Centralize color code stripping via strip_color_codes() - Make qlpycon.bash fully configurable (workdir, serverip) - Add validation checks for workdir and venv - Fix port numbers in help text (28960-28969)
116 lines
2.6 KiB
Python
116 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Configuration and constants for QLPyCon
|
|
"""
|
|
|
|
import re
|
|
|
|
VERSION = "0.8.1"
|
|
|
|
# Pattern matching
|
|
COLOR_CODE_PATTERN = re.compile(r'\^\d') # Quake color codes (^0-^9)
|
|
SPECIAL_CHAR = chr(25) # ASCII EM (End of Medium) - used in Quake messages
|
|
|
|
# Network defaults
|
|
DEFAULT_HOST = 'tcp://127.0.0.1:27961'
|
|
POLL_TIMEOUT = 100
|
|
|
|
# Timing constants
|
|
QUIT_CONFIRM_TIMEOUT = 3.0 # Seconds to confirm quit (Ctrl-C twice)
|
|
RESPAWN_DELAY = 3.0 # Seconds before players respawn after death
|
|
STATS_CONNECTION_DELAY = 0.5 # Initial stats connection delay
|
|
|
|
# UI dimensions
|
|
INFO_WINDOW_HEIGHT = 12
|
|
INFO_WINDOW_Y = 2
|
|
OUTPUT_WINDOW_Y = 14
|
|
INPUT_WINDOW_HEIGHT = 2
|
|
|
|
# Event deduplication
|
|
MAX_RECENT_EVENTS = 10
|
|
|
|
# UI settings
|
|
MAX_COMMAND_HISTORY = 10 # Number of commands to remember
|
|
|
|
# Team game modes
|
|
TEAM_MODES = [
|
|
"Team Deathmatch",
|
|
"Clan Arena",
|
|
"Capture The Flag",
|
|
"One Flag CTF",
|
|
"Overload",
|
|
"Harvester",
|
|
"Freeze Tag"
|
|
]
|
|
|
|
# Team mappings
|
|
TEAM_MAP = {
|
|
0: 'FREE',
|
|
1: 'RED',
|
|
2: 'BLUE',
|
|
3: 'SPECTATOR'
|
|
}
|
|
|
|
TEAM_COLORS = {
|
|
'RED': '^1(RED)^7',
|
|
'BLUE': '^4(BLUE)^7',
|
|
'FREE': '',
|
|
'SPECTATOR': '^3(SPEC)^7'
|
|
}
|
|
|
|
# Weapon names
|
|
WEAPON_NAMES = {
|
|
'ROCKET': '^8^1Rocket Launcher^7^0',
|
|
'LIGHTNING': '^8^3Lightning Gun^7^0',
|
|
'RAILGUN': '^8^2Railgun^7^0',
|
|
'SHOTGUN': '^8^3Shotgun^7^0',
|
|
'GAUNTLET': '^8^1Gauntlet^7^0',
|
|
'GRENADE': '^8^2Grenade Launcher^7^0',
|
|
'PLASMA': '^8^6Plasma Gun^7^0',
|
|
'MACHINEGUN': '^8^3Machine Gun^7^0'
|
|
}
|
|
|
|
# Weapon names for kill messages
|
|
WEAPON_KILL_NAMES = {
|
|
'ROCKET': 'the ^8^1Rocket Launcher',
|
|
'LIGHTNING': 'the ^8^3Lightning Gun',
|
|
'RAILGUN': 'the ^8^2Railgun',
|
|
'SHOTGUN': 'the ^8^3Shotgun',
|
|
'GAUNTLET': 'the ^8^1Gauntlet',
|
|
'GRENADE': 'the ^8^2Grenade Launcher',
|
|
'PLASMA': 'the ^8^6Plasma Gun',
|
|
'MACHINEGUN': 'the ^8^3Machine Gun'
|
|
}
|
|
|
|
# Death messages
|
|
DEATH_MESSAGES = {
|
|
'FALLING': "%s^8%s^0 ^7cratered.",
|
|
'HURT': "%s^8%s^0 ^7was in the wrong place.",
|
|
'LAVA': "%s^8%s^0 ^7does a backflip into the lava.",
|
|
'WATER': "%s^8%s^0 ^7sank like a rock.",
|
|
'SLIME': "%s^8%s^0 ^7melted.",
|
|
'CRUSH': "%s^8%s^0 ^7was crushed."
|
|
}
|
|
|
|
# Powerup names and colors
|
|
POWERUP_COLORS = {
|
|
'Quad Damage': '^8^5Quad Damage^7^0',
|
|
'Battle Suit': '^8^3Battle Suit^7^0',
|
|
'Regeneration': '^8^1Regeneration^7^0',
|
|
'Haste': '^8^3Haste^7^0',
|
|
'Invisibility': '^8^5Invisibility^7^0',
|
|
'Flight': '^8^5Flight^7^0',
|
|
'Medkit': '^8^1Medkit^7^0',
|
|
'MegaHealth': '^8^4MegaHealth^7^0'
|
|
}
|
|
|
|
# Curses color pairs
|
|
COLOR_PAIRS = {
|
|
1: 1, # Red
|
|
2: 2, # Green
|
|
3: 3, # Yellow
|
|
4: 4, # Blue
|
|
5: 6, # Cyan (swapped)
|
|
6: 5 # Magenta (swapped)
|
|
}
|