-
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 |
---|---|---|
|
@@ -19,32 +19,31 @@ class Player(_Player): | |
|
||
# 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()} | ||
|
||
_teams_names = _team_data.get('names') | ||
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. This mapping is already available as players.teams.teams_by_name and should really just be imported from there rather than queried again from the INI file. |
||
_class_names = _team_data.get('classes') | ||
|
||
@property | ||
def team_name(self): | ||
return self.teams_by_number[self.team] | ||
teams_by_number = dict(zip(self._teams_names.values(), self._teams_names.keys())) | ||
return 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(): | ||
if team_id not in self._teams_names: | ||
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()} | ||
self.team = self._teams_names[team_name] | ||
|
||
@property | ||
def player_class_name(self): | ||
return self.class_by_number[self.player_class] | ||
class_by_number = dict(zip(self._class_names.values(), self._class_names.keys())) | ||
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. This is redundant to rebuild that mapping every calls, and it should really just be globalized into the |
||
return 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(): | ||
if team_id not in self._class_names: | ||
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] | ||
# Does this need to be desired_player_class or should there be a setter for desired class? | ||
self.player_class = self._class_names[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.