Inventory item info
This commit is contained in:
parent
2bfce22530
commit
22dc1a5d9c
3 changed files with 64 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import type { IItem } from "./structures/items.js";
|
||||
import type { IItem, IStat } from "./structures/items.js";
|
||||
import {
|
||||
rarities,
|
||||
Rarity,
|
||||
|
|
@ -20,4 +20,18 @@ const getRarity = (id: Rarity): IRarity => {
|
|||
return rarity ? rarity : rarityCommon;
|
||||
};
|
||||
|
||||
export { getFullItemName, getRarityName, getRarity };
|
||||
const getTotalStats = (item: IItem): IStat => {
|
||||
const totalStats: IStat = {
|
||||
damage: 0,
|
||||
defense: 0,
|
||||
};
|
||||
|
||||
item.stats.forEach((stat) => {
|
||||
totalStats.damage += stat.damage;
|
||||
totalStats.defense += stat.defense;
|
||||
});
|
||||
|
||||
return totalStats;
|
||||
};
|
||||
|
||||
export { getFullItemName, getRarityName, getRarity, getTotalStats };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue