Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
spookybear0 committed Sep 27, 2024
2 parents ede3179 + ede8ef8 commit d531bc0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
10 changes: 10 additions & 0 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -659,4 +659,14 @@ a {
padding: 0.01rem;
text-align: center;
font-size: 0.5rem;
}

.yellow-card {
background-color: yellow;
display: inline-block;
width: 0.75em;
height: 1.5em;
border-radius: 6px;
vertical-align: center;
margin-right: 0px;
}
19 changes: 16 additions & 3 deletions assets/html/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@

{% macro player_reference(player) -%}
{% if not player.player_info %}
<p>{{ player.name }}</p>
{{ player.name }}
{% else %}
{% if player.player_info.is_member %}
<a href="/player/{{player.player_info.entity_start.name}}"><p>{{ player.player_info.display_name }}</p></a>
<a href="/player/{{player.player_info.entity_start.name}}">{{ player.player_info.display_name }}</a>
{% else %}
<p>{{ player.player_info.display_name }}</p>
{{ player.player_info.display_name }}
{% endif %}
{% endif %}
{%- endmacro %}
Expand All @@ -85,6 +85,19 @@
{{ tooltip_info.insert_tooltip(tooltip_id) }}
{%- endmacro %}

{% macro player_penalties(player) -%}
{% if player.penalties > 0 %}
<div class="yellow-card" {{ tooltip("sm5_penalty") }}></div>
{% if player.penalties > 1 %}
x{{ player.penalties }}
{% endif %}
{% endif %}
{%- endmacro %}

{% macro player_with_penalties(player) -%}
<span style="white-space: nowrap;">{{ player_reference(player) }}&nbsp;{{ player_penalties(player) }}</span>
{%- endmacro %}

{% macro uptime_chart(entity_id, state_distribution) -%}

new Chart("uptime_{{entity_id}}", {
Expand Down
2 changes: 1 addition & 1 deletion assets/html/game/scorecard_sm5.html
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ <h2 class="{{ team.team.css_class }} team-header">{{ team.name }}: {{ team.score
{% for player in team.players_with_sum %}
<tr class="{{ player.css_class }}">
<td class="role fixed-column">{{ sm5_role_icon(player) }}</td>
<td class="second-fixed-column">{{ player_reference(player) }}</td>
<td class="second-fixed-column">{{ player_with_penalties(player) }}</td>
<td>{{ player.score }}</td>
<td>{{ player.get_gross_positive_score() }}</td>
<td>{{ player.points_per_minute }}</td>
Expand Down
2 changes: 1 addition & 1 deletion assets/html/game/sm5.html
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ <h2 style="font-size: 20px;" class="team_score {{ team.css_class }}">{{ team.ele

<tr class="{{ player.css_class }}">
<td class="role fixed-column" style="width: 30px"><p>{{ sm5_role_icon(player) }}</p></td>
<td class="second-fixed-column">{{ player_reference(player) }}</td>
<td class="second-fixed-column">{{ player_with_penalties(player) }}</td>
{% if game.ranked %}
{% if player.entity_end %}
<td title="mu: {{ player.entity_end.current_rating_mu|round(2) }}, sigma: {{ player.entity_end.current_rating_sigma|round(2)}}">{{ (player.entity_end.current_rating_mu - 3 * player.entity_end.current_rating_sigma)|round(2) }}</td>
Expand Down
13 changes: 13 additions & 0 deletions helpers/sm5helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def nuke_cancels(self) -> int:
def medic_hits(self) -> int:
return self.stats.medic_hits

@property
def penalties(self) -> int:
return self.stats.penalties

@property
def role(self) -> Optional[IntRole]:
return self.entity_start.role if self.entity_start else None
Expand Down Expand Up @@ -134,6 +138,8 @@ class Sm5PlayerGameStatsSum(PlayerSm5GameStats):

average_time_alive_millis: int

total_penalties: int

@property
def name(self) -> str:
return "Total"
Expand Down Expand Up @@ -185,6 +191,10 @@ def medic_hits(self) -> int:
def time_in_game_millis(self) -> int:
return self.average_time_alive_millis

@property
def penalties(self) -> int:
return self.total_penalties


@dataclass
class TeamSm5GameStats(TeamCoreGameStats):
Expand Down Expand Up @@ -298,6 +308,7 @@ async def get_sm5_player_stats(game: SM5Game, main_player: Optional[EntityStarts
sum_missiled_main_player = 0
sum_missiled_by_main_player = 0
sum_score = 0
sum_penalties = 0
sum_points_per_minute = 0
sum_gross_positive_score = 0
sum_shot_team = 0
Expand Down Expand Up @@ -371,6 +382,7 @@ async def get_sm5_player_stats(game: SM5Game, main_player: Optional[EntityStarts

# Run a tally so we can compute the sum/average for the team.
sum_score += player.score
sum_penalties += player.penalties
sum_gross_positive_score += player.get_gross_positive_score()
sum_points_per_minute += player.points_per_minute
sum_mvp_points += player.mvp_points
Expand Down Expand Up @@ -416,6 +428,7 @@ async def get_sm5_player_stats(game: SM5Game, main_player: Optional[EntityStarts
css_class="team_totals",
total_score=sum_score,
total_gross_positive_score=sum_gross_positive_score,
total_penalties=sum_penalties,
average_points_per_minute=int(sum_points_per_minute / average_divider),
state_distribution=avg_state_distribution,
score_components=avg_score_components,
Expand Down
1 change: 1 addition & 0 deletions helpers/tooltiphelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"sm5_hit_ratio": "The ratio between you zapping the player and they zapping you",
"sm5_you_missiled": "How many times you missiled this particular player",
"sm5_missiled_you": "How many times this particular player missiled you",
"sm5_penalty": "Penalty",
}

# Tooltips that are complex that they're implemented as separate DIV tags. The value is the ID of the tag.
Expand Down

0 comments on commit d531bc0

Please sign in to comment.