Skip to content

Commit e14a30c

Browse files
committed
Feat: Round all attributes
1 parent 72998d4 commit e14a30c

File tree

1 file changed

+51
-15
lines changed

1 file changed

+51
-15
lines changed

react-discretize-components/src/character/Attributes/Attributes.tsx

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,52 @@ const roundTwo = (num: number) => Math.round(num * 100) / 100;
77

88
const attributes: {
99
name: AttributeType;
10-
text?: (value?: number) => string;
10+
text: (value?: number) => string;
1111
}[] = [
12-
{ name: 'Power' },
13-
{ name: 'Toughness' },
14-
{ name: 'Vitality' },
15-
{ name: 'Precision' },
16-
{ name: 'Ferocity' },
17-
{ name: 'Condition Damage' },
18-
{ name: 'Expertise' },
19-
{ name: 'Concentration' },
20-
{ name: 'Agony Resistance' },
21-
{ name: 'Armor' },
22-
{ name: 'Health' },
12+
{
13+
name: 'Power',
14+
text: (value?: number) => `${roundTwo(value || 0)}`,
15+
},
16+
{
17+
name: 'Toughness',
18+
text: (value?: number) => `${roundTwo(value || 0)}`,
19+
},
20+
{
21+
name: 'Vitality',
22+
text: (value?: number) => `${roundTwo(value || 0)}`,
23+
},
24+
{
25+
name: 'Precision',
26+
text: (value?: number) => `${roundTwo(value || 0)}`,
27+
},
28+
{
29+
name: 'Ferocity',
30+
text: (value?: number) => `${roundTwo(value || 0)}`,
31+
},
32+
{
33+
name: 'Condition Damage',
34+
text: (value?: number) => `${roundTwo(value || 0)}`,
35+
},
36+
{
37+
name: 'Expertise',
38+
text: (value?: number) => `${roundTwo(value || 0)}`,
39+
},
40+
{
41+
name: 'Concentration',
42+
text: (value?: number) => `${roundTwo(value || 0)}`,
43+
},
44+
{
45+
name: 'Agony Resistance',
46+
text: (value?: number) => `${roundTwo(value || 0)}`,
47+
},
48+
{
49+
name: 'Armor',
50+
text: (value?: number) => `${roundTwo(value || 0)}`,
51+
},
52+
{
53+
name: 'Health',
54+
text: (value?: number) => `${roundTwo(value || 0)}`,
55+
},
2356
{
2457
name: 'Critical Chance',
2558
text: (value?: number) => `${roundTwo((value || 0) * 100)}%`,
@@ -28,7 +61,10 @@ const attributes: {
2861
name: 'Critical Damage',
2962
text: (value?: number) => `${roundOne((value || 0) * 100)}%`,
3063
},
31-
{ name: 'Healing Power' },
64+
{
65+
name: 'Healing Power',
66+
text: (value?: number) => `${roundTwo(value || 0)}`,
67+
},
3268
{
3369
name: 'Condition Duration',
3470
text: (value?: number) => `${roundTwo((value || 0) * 100)}%`,
@@ -53,11 +89,11 @@ const Attributes = ({ profession, data }: AttributesProps) => {
5389
<div className={classes.wrapper}>
5490
<div className={classes.half}>
5591
<ul className={classes.list}>
56-
{attributes.slice(0, 9).map(({ name }) => (
92+
{attributes.slice(0, 9).map(({ name, text }) => (
5793
<li key={name} className={classes.gridItem}>
5894
<Attribute
5995
name={name}
60-
text={`${data[name]}`}
96+
text={text ? text(data[name]) : `${data[name]}`}
6197
className={classes.gw2Item}
6298
/>
6399
</li>

0 commit comments

Comments
 (0)