mirror of
https://github.com/Coldsmiles/infstarweb.git
synced 2026-04-23 02:30:41 +08:00
Add kills tracking to player stats and update leaderboard display
This commit is contained in:
15
stats.html
15
stats.html
@@ -337,6 +337,17 @@
|
||||
<div class="lb-top-player">加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 6. Kills -->
|
||||
<div class="lb-card" style="border-top: 4px solid #e74c3c;">
|
||||
<div class="lb-header">
|
||||
<div class="lb-icon"><i class="fas fa-crosshairs"></i></div>
|
||||
<div class="lb-title">屠夫</div>
|
||||
</div>
|
||||
<div class="lb-content" id="lb-kills">
|
||||
<div class="lb-top-player">加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Search & Grid -->
|
||||
@@ -385,6 +396,10 @@
|
||||
<span class="stat-label"><i class="fas fa-skull"></i> 死亡次数</span>
|
||||
<span class="stat-value" id="modal-deaths">0</span>
|
||||
</div>
|
||||
<div class="stat-row">
|
||||
<span class="stat-label"><i class="fas fa-crosshairs"></i> 击杀数量</span>
|
||||
<span class="stat-value" id="modal-kills">0</span>
|
||||
</div>
|
||||
<div class="stat-row">
|
||||
<span class="stat-label"><i class="fas fa-crown"></i> 游玩时间</span>
|
||||
<span class="stat-value" id="modal-playtime">0 秒</span>
|
||||
|
||||
@@ -144,6 +144,10 @@ function renderLeaderboards() {
|
||||
// 5. Play Time (stats.play_time_raw)
|
||||
const topPlayTime = getTop('play_time_fmt'); // uses play_time_raw internally
|
||||
renderCard('lb-playtime', topPlayTime, p => p.stats.play_time_fmt);
|
||||
|
||||
// 6. Kills (stats.kills)
|
||||
const topKills = getTop('kills');
|
||||
renderCard('lb-kills', topKills, p => p.stats.kills);
|
||||
}
|
||||
|
||||
function renderPlayerGrid(reset = false) {
|
||||
@@ -228,6 +232,7 @@ function openModal(player) {
|
||||
document.getElementById('modal-placed').innerText = player.stats.placed.toLocaleString();
|
||||
document.getElementById('modal-mined').innerText = player.stats.mined.toLocaleString();
|
||||
document.getElementById('modal-deaths').innerText = player.stats.deaths;
|
||||
document.getElementById('modal-kills').innerText = player.stats.kills;
|
||||
document.getElementById('modal-playtime').innerText = player.stats.play_time_fmt;
|
||||
|
||||
modal.style.display = "flex";
|
||||
|
||||
@@ -142,6 +142,10 @@ def process_player(filename):
|
||||
killed_by = stats.get('minecraft:killed_by', {})
|
||||
total_deaths = sum(killed_by.values())
|
||||
|
||||
# Kills (Killed)
|
||||
killed = stats.get('minecraft:killed', {})
|
||||
total_kills = sum(killed.values())
|
||||
|
||||
# Inject into JSON
|
||||
data['extra'] = {
|
||||
'player_name': player_name,
|
||||
@@ -150,6 +154,7 @@ def process_player(filename):
|
||||
'total_mined': total_mined,
|
||||
'total_placed': total_placed,
|
||||
'total_deaths': total_deaths,
|
||||
'total_kills': total_kills,
|
||||
'play_time_fmt': play_time_fmt,
|
||||
'play_time_ticks': play_time_ticks
|
||||
}
|
||||
@@ -168,19 +173,19 @@ def process_player(filename):
|
||||
'mined': total_mined,
|
||||
'placed': total_placed,
|
||||
'deaths': total_deaths,
|
||||
'kills': total_kills,
|
||||
'play_time_fmt': play_time_fmt,
|
||||
'play_time_raw': play_time_ticks
|
||||
}
|
||||
}
|
||||
|
||||
# Process in parallel with progress bar
|
||||
# Process sequentially with progress bar
|
||||
results = []
|
||||
if files:
|
||||
with ThreadPoolExecutor(max_workers=4) as executor:
|
||||
# Use tqdm to show progress
|
||||
results = list(tqdm(executor.map(process_player, files), total=len(files), desc="Processing players"))
|
||||
|
||||
results = [r for r in results if r is not None]
|
||||
for filename in tqdm(files, desc="Processing players"):
|
||||
result = process_player(filename)
|
||||
if result is not None:
|
||||
results.append(result)
|
||||
|
||||
# Sort by name perhaps? Or just raw list.
|
||||
results.sort(key=lambda x: x['name'])
|
||||
|
||||
Reference in New Issue
Block a user