Skip to content

Commit 45d5825

Browse files
committed
scoreboard: добавил вывод урона в виде шкалы
1 parent 05abc20 commit 45d5825

21 files changed

+2908
-951
lines changed

qllr/blueprints/scoreboard/methods.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,15 @@ async def get_scoreboard(con: Connection, match_id: str):
183183
LEFT JOIN (
184184
SELECT
185185
t.steam_id, t.team,
186-
json_object_agg(t.weapon_short, ARRAY[t.frags, t.hits, t.shots, t.accuracy]) AS weapon_stats
186+
json_object_agg(t.weapon_short, ARRAY[t.frags, t.hits, t.shots, t.accuracy, t.damage_dealt, t.damage_dealt_percent]) AS weapon_stats
187187
FROM
188188
(
189189
SELECT
190190
s.steam_id, s.team, w.weapon_short, sw.frags, sw.hits, sw.shots,
191+
sw.damage_dealt,
192+
CASE WHEN s.damage_dealt = 0 THEN 0
193+
ELSE 100. * sw.damage_dealt / s.damage_dealt
194+
END AS damage_dealt_percent,
191195
CASE WHEN sw.shots = 0 THEN 0
192196
ELSE CAST(100. * sw.hits / sw.shots AS INT)
193197
END AS accuracy

static/counterstrikesource.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,46 @@ li.dropdown:hover > .dropdown-menu {
229229
#navbar-toggle-cbox:checked ~ .collapse {
230230
display: block;
231231
}
232+
233+
.w-bar-gt {
234+
background-color: #00d9ff;
235+
}
236+
.w-bar-mg {
237+
background-color: #ff0;;
238+
}
239+
.w-bar-sg {
240+
background-color: #ff7e00;
241+
}
242+
.w-bar-gl {
243+
background-color: #00910a;
244+
}
245+
.w-bar-rl {
246+
background-color: #f00;
247+
}
248+
.w-bar-lg {
249+
background-color: #ffffb2;
250+
}
251+
.w-bar-rg {
252+
background-color: #00b11d;
253+
}
254+
.w-bar-pg {
255+
background-color: #c600ff;
256+
}
257+
.w-bar-bfg {
258+
background-color: #005aff;
259+
}
260+
.w-bar-pm {
261+
background-color: #fc1c8a;
262+
}
263+
.w-bar-cg {
264+
background-color: #b9b9b9;
265+
}
266+
.w-bar-ng {
267+
background-color: #00ffb5;
268+
}
269+
.w-bar-hmg {
270+
background-color: #cfa700;
271+
}
272+
.w-bar-gh {
273+
background-color: #5bb0de;
274+
}

templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<link rel="icon" type="image/png" href="{{ url_for('static', path='images/favicon.png') }}">
55
<link rel="stylesheet" href="{{ url_for('static', path='bootstrap.css?20210602') }}">
6-
<link rel="stylesheet" href="{{ url_for('static', path='counterstrikesource.css?20211004') }}"> <!-- :D -->
6+
<link rel="stylesheet" href="{{ url_for('static', path='counterstrikesource.css?20230121') }}"> <!-- :D -->
77
<meta charset="UTF-8" />
88
<meta name="robots" content="noindex, nofollow"/>
99
<meta name="viewport" content="width=device-width, initial-scale=1">

templates/scoreboard.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
{% endif %}
2828
{%- endmacro %}
2929

30+
{% macro wpn_damage_percent(player, key) -%}
31+
{% if player['weapon_stats'][key] and player['weapon_stats'][key][5] %}
32+
<div title="{{ player['weapon_stats'][key][4] }} ({{ player['weapon_stats'][key][5] | int }}%)" class="w-bar-{{ key }}" style="display: inline-block; height: 20px; width: {{ player['weapon_stats'][key][5] }}%"></div>
33+
{% endif %}
34+
{%- endmacro %}
3035

3136
{% macro rating_diff(data) -%}
3237
{% if not data['old'] or not data['new'] %}
@@ -65,6 +70,7 @@
6570
{% for m in ma %}
6671
<th class="s sm" style="display: none"><div class="m-{{ m }}"></div></th>
6772
{% endfor %}
73+
<th class="s sdp" style="display: none"></th>
6874
</tr></thead>
6975
<tbody>{% for player in players|selectattr("team", "equalto", team) %}<tr class="{{ 'red' if team == '1' else 'blue' }}">
7076
<td class="player-nick"><a href="/player/{{ player['steam_id'] }}">{{ player['name'] | ql_nickname | safe }}</a></td>
@@ -90,6 +96,11 @@
9096
{% for m in ma %}
9197
<td class="s sm" style="display: none">{{ medal( player, m ) }}</td>
9298
{% endfor %}
99+
<td class="s sdp" style="font-size: 0; display: none">
100+
{% for w in wa %}
101+
{{ wpn_damage_percent(player, w) }}
102+
{% endfor %}
103+
</td>
93104
</tr>{% endfor %}</tbody>
94105
</table></div>
95106

@@ -117,6 +128,7 @@ <h3>Match Detail</h3>
117128
<a class="sw" onClick="toggle_table('sw', this)">Frags</a>
118129
<a class="sw" onClick="toggle_table('sa', this)">Accuracy</a>
119130
<a class="sm" onClick="toggle_table('sm', this)">Medals</a>
131+
<a class="sm" onClick="toggle_table('sdp', this)">Damage %</a>
120132
</div>
121133

122134
<div class="row">

0 commit comments

Comments
 (0)