feat: Add CS:GO rank icons for legacy matches
Implemented rank icon display system for pre-CS2 matches: New Components: - RankIcon.svelte: Displays CS:GO skill group icons (0-18) - Supports sm/md/lg sizes - Shows appropriate rank icon based on skill group - Includes hover tooltips with rank names - Handles all 19 rank tiers (Silver I → Global Elite) Updated Components: - PremierRatingBadge: Now intelligently switches between: - CS:GO rank icons (when rank_old exists, rank_new doesn't) - Premier rating badge (when rank_new exists) - "Unranked" text (when neither exists) Assets: - Rank icons already present in static/images/rank_icons/ - Weapon icons already present in static/images/weapons/ - All icons in SVG format for crisp display at any size Display Logic: - Legacy matches (pre-Sept 2023): Show CS:GO rank icons - Modern matches (CS2): Show Premier rating with trophy icon - Automatically detects based on rank_old/rank_new fields The scoreboard now displays the appropriate ranking visualization based on match era, matching the original CSGO.WTF design. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
69
src/lib/components/ui/RankIcon.svelte
Normal file
69
src/lib/components/ui/RankIcon.svelte
Normal file
@@ -0,0 +1,69 @@
|
||||
<script lang="ts">
|
||||
/**
|
||||
* CS:GO Skill Group Rank Icon Component
|
||||
* Displays the appropriate rank icon based on skill group (0-18)
|
||||
*/
|
||||
interface Props {
|
||||
/** CS:GO skill group (0-18) */
|
||||
skillGroup: number | undefined | null;
|
||||
size?: 'sm' | 'md' | 'lg';
|
||||
showLabel?: boolean;
|
||||
class?: string;
|
||||
}
|
||||
|
||||
let { skillGroup, size = 'md', showLabel = false, class: className = '' }: Props = $props();
|
||||
|
||||
// Map skill groups to rank names
|
||||
const rankNames: Record<number, string> = {
|
||||
0: 'Unranked',
|
||||
1: 'Silver I',
|
||||
2: 'Silver II',
|
||||
3: 'Silver III',
|
||||
4: 'Silver IV',
|
||||
5: 'Silver Elite',
|
||||
6: 'Silver Elite Master',
|
||||
7: 'Gold Nova I',
|
||||
8: 'Gold Nova II',
|
||||
9: 'Gold Nova III',
|
||||
10: 'Gold Nova Master',
|
||||
11: 'Master Guardian I',
|
||||
12: 'Master Guardian II',
|
||||
13: 'Master Guardian Elite',
|
||||
14: 'Distinguished Master Guardian',
|
||||
15: 'Legendary Eagle',
|
||||
16: 'Legendary Eagle Master',
|
||||
17: 'Supreme Master First Class',
|
||||
18: 'The Global Elite'
|
||||
};
|
||||
|
||||
const sizeClasses = {
|
||||
sm: 'h-6 w-6',
|
||||
md: 'h-8 w-8',
|
||||
lg: 'h-12 w-12'
|
||||
};
|
||||
|
||||
const labelSizeClasses = {
|
||||
sm: 'text-xs',
|
||||
md: 'text-sm',
|
||||
lg: 'text-base'
|
||||
};
|
||||
|
||||
const iconPath = $derived(
|
||||
skillGroup !== undefined && skillGroup !== null && skillGroup >= 0 && skillGroup <= 18
|
||||
? `/images/rank_icons/skillgroup${skillGroup}.svg`
|
||||
: '/images/rank_icons/skillgroup_none.svg'
|
||||
);
|
||||
|
||||
const rankName = $derived(
|
||||
skillGroup !== undefined && skillGroup !== null ? rankNames[skillGroup] || 'Unknown' : 'Unknown'
|
||||
);
|
||||
</script>
|
||||
|
||||
{#if showLabel}
|
||||
<div class="inline-flex items-center gap-2 {className}">
|
||||
<img src={iconPath} alt={rankName} class={sizeClasses[size]} />
|
||||
<span class="font-medium {labelSizeClasses[size]}">{rankName}</span>
|
||||
</div>
|
||||
{:else}
|
||||
<img src={iconPath} alt={rankName} title={rankName} class={`${sizeClasses[size]} ${className}`} />
|
||||
{/if}
|
||||
Reference in New Issue
Block a user