-
Notifications
You must be signed in to change notification settings - Fork 37
Add TF2 specific player subclass. Add class names and id's to team data #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# ../players/engines/orangebox/cstrike.py | ||
|
||
"""Provides Team Fortress 2 specific Player based functionality.""" | ||
|
||
# ============================================================================= | ||
# >> IMPORTS | ||
# ============================================================================= | ||
# Source.Python Imports | ||
from . import Player as _Player | ||
from configobj import ConfigObj | ||
from core import GAME_NAME | ||
from paths import SP_DATA_PATH | ||
|
||
# ============================================================================= | ||
# >> CLASSES | ||
# ============================================================================= | ||
class Player(_Player): | ||
caching = True | ||
|
||
# Team | ||
_team_data = ConfigObj(SP_DATA_PATH / 'teams' / GAME_NAME + '.ini', unrepr=True) | ||
teams_by_name = _team_data.get('names') | ||
teams_by_number = {number: alias for alias, number in teams_by_name.items()} | ||
|
||
@property | ||
def team_name(self): | ||
return self.teams_by_number[self.team] | ||
|
||
@team_name.setter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than having multiples |
||
def team_name(self, team_name): | ||
if team_id not in self.team_by_name.keys(): | ||
raise ValueError(f"Invalid team_name: {team_name}") | ||
|
||
self.team = self.teams_by_name[team_name] | ||
|
||
# Mercanary class | ||
class_by_name = _team_data.get('classes') | ||
class_by_number = {number: alias for alias, number in class_by_name.items()} | ||
|
||
@property | ||
def player_class_name(self): | ||
return self.class_by_number[self.player_class] | ||
|
||
@player_class_name.setter | ||
def player_class_name(self, class_name): | ||
if team_id not in self.class_by_name.keys(): | ||
raise ValueError(f"Invalid class_name: {class_name}") | ||
|
||
# Does this need to be desired_player_class? | ||
self.player_class = self.class_by_name[team_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to parse that file again here, as it is already parsed into ../players/teams.py.