-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitemStats.ts
41 lines (37 loc) · 829 Bytes
/
itemStats.ts
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
interface ItemStats {
stamina: number;
agility: number;
luck: number;
strength: number;
}
function generateItemStats(quality: string): ItemStats {
let baseValue: number;
switch (quality) {
case 'Common':
baseValue = 1;
break;
case 'Uncommon':
baseValue = 5;
break;
case 'Rare':
baseValue = 10;
break;
case 'Epic':
baseValue = 15;
break;
case 'Legendary':
baseValue = 20;
break;
default:
baseValue = 1;
break;
}
const stats: ItemStats = {
stamina: baseValue + Math.ceil(Math.random() * 5),
agility: baseValue + Math.ceil(Math.random() * 5),
luck: baseValue + Math.ceil(Math.random() * 5),
strength: baseValue + Math.ceil(Math.random() * 5),
};
return stats;
}
export default generateItemStats;