replace items record with full end-of-game stats record
All checks were successful
record-daemon / Build, check and test (push) Successful in 2m5s
All checks were successful
record-daemon / Build, check and test (push) Successful in 2m5s
- record-daemon: remove items parsing module - tauri-app: add items parsing from recorded end-of-game stats
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from "vue";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import type { GameHistoryItem, GameResult, TimestampedEvent, ItemInfo } from "../types/timeline";
|
||||
import type { GameHistoryItem, TimestampedEvent, ItemInfo, RawEndGameStats, EndGamePlayer } from "../types/timeline";
|
||||
import {
|
||||
getGameResult,
|
||||
formatDuration,
|
||||
@@ -49,21 +49,57 @@ function closeDetail() {
|
||||
selectedGame.value = null;
|
||||
}
|
||||
|
||||
// Helper to get items array for display (6 slots + trinket)
|
||||
function getItemsArray(game: GameHistoryItem): (ItemInfo | null)[] {
|
||||
const result: (ItemInfo | null)[] = [null, null, null, null, null, null, null];
|
||||
if (game.final_items) {
|
||||
// Fill main items (slots 0-5)
|
||||
for (const item of game.final_items.items) {
|
||||
if (item.slot >= 0 && item.slot <= 5) {
|
||||
result[item.slot] = item;
|
||||
// Helper to find local player from raw end game stats
|
||||
function getLocalPlayer(stats: RawEndGameStats | null): EndGamePlayer | null {
|
||||
if (!stats) return null;
|
||||
|
||||
// Try local_player field first
|
||||
if (stats.local_player) {
|
||||
return stats.local_player;
|
||||
}
|
||||
|
||||
// Try teams
|
||||
if (stats.teams) {
|
||||
for (const team of stats.teams) {
|
||||
if (team.players) {
|
||||
for (const player of team.players) {
|
||||
if (player.is_local_player) {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fill trinket (slot 6)
|
||||
if (game.final_items.trinket) {
|
||||
result[6] = game.final_items.trinket;
|
||||
}
|
||||
|
||||
// Try legacy players array
|
||||
if (stats.players && stats.players.length > 0) {
|
||||
return stats.players[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Helper to get items array for display (6 slots + trinket)
|
||||
// Items are now stored as raw item IDs in raw_end_game_stats
|
||||
function getItemsArray(game: GameHistoryItem): (ItemInfo | null)[] {
|
||||
const result: (ItemInfo | null)[] = [null, null, null, null, null, null, null];
|
||||
|
||||
const localPlayer = getLocalPlayer(game.raw_end_game_stats);
|
||||
if (localPlayer && localPlayer.items) {
|
||||
// Items are stored as an array of item IDs (up to 7 items: 6 main + 1 trinket)
|
||||
for (let i = 0; i < Math.min(localPlayer.items.length, 7); i++) {
|
||||
const itemId = localPlayer.items[i];
|
||||
if (itemId && itemId > 0) {
|
||||
// Slot 6 is trinket, slots 0-5 are main items
|
||||
result[i] = {
|
||||
itemId: itemId,
|
||||
name: null,
|
||||
slot: i
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -217,9 +253,9 @@ onMounted(() => {
|
||||
</div>
|
||||
<div class="item-slot trinket">
|
||||
<img
|
||||
v-if="getItemsArray(game)[6] && getItemsArray(game)[6].itemId"
|
||||
:src="getItemImageUrl(getItemsArray(game)[6].itemId)"
|
||||
:alt="getItemsArray(game)[6].name || 'Trinket'"
|
||||
v-if="getItemsArray(game)[6]?.itemId"
|
||||
:src="getItemImageUrl(getItemsArray(game)[6]!.itemId)"
|
||||
:alt="getItemsArray(game)[6]?.name || 'Trinket'"
|
||||
class="item-image"
|
||||
/>
|
||||
<div v-else class="item-empty"></div>
|
||||
|
||||
Reference in New Issue
Block a user