-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRaritySystem.php
More file actions
71 lines (65 loc) · 1.86 KB
/
RaritySystem.php
File metadata and controls
71 lines (65 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
class RaritySystem {
private static array $rarityTiers = [
[
'threshold' => 80,
'label' => 'Very Common',
'color' => '#8BC34A',
'class' => 'very-common'
],
[
'threshold' => 50,
'label' => 'Common',
'color' => '#8BC34A',
'class' => 'common'
],
[
'threshold' => 20,
'label' => 'Uncommon',
'color' => '#FF9800',
'class' => 'uncommon'
],
[
'threshold' => 10,
'label' => 'Rare',
'color' => '#9C27B0',
'class' => 'rare'
],
[
'threshold' => 5,
'label' => 'Very Rare',
'color' => '#E91E63',
'class' => 'very-rare'
],
[
'threshold' => 1,
'label' => 'Ultra Rare',
'color' => '#F44336',
'class' => 'ultra-rare'
],
[
'threshold' => 0,
'label' => 'Legendary',
'color' => '#FFD700',
'class' => 'legendary'
]
];
public static function getRarity(float $percentage): array {
foreach (self::$rarityTiers as $tier) {
if ($percentage >= $tier['threshold']) {
return $tier;
}
}
// Fallback to legendary (should never reach due to 0 threshold)
return end(self::$rarityTiers);
}
public static function getLabel(float $percentage): string {
return self::getRarity($percentage)['label'];
}
public static function getColor(float $percentage): string {
return self::getRarity($percentage)['color'];
}
public static function getClass(float $percentage): string {
return self::getRarity($percentage)['class'];
}
}