mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
fix: crew skill off by 1 roman numerals
This commit is contained in:
1 parent
282b8f8a37
commit
ab0d3f7170
3 files changed
+48
-5
No files matched your search
@@ -43,4 +43,5 @@ export * from './uniqueGuns';
|
||||
export * from './unwrapBlitzkitResponse';
|
||||
export * from './votes';
|
||||
// export * from './withCORSProxy';
|
||||
export * from './romanize';
|
||||
export * from './youtubers';
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Thank you, Rene Pot!
|
||||
*
|
||||
* https://stackoverflow.com/a/9083076/12294756
|
||||
*/
|
||||
export function romanize(num: number) {
|
||||
if (isNaN(num)) return NaN;
|
||||
var digits = String(+num).split(''),
|
||||
key = [
|
||||
'',
|
||||
'C',
|
||||
'CC',
|
||||
'CCC',
|
||||
'CD',
|
||||
'D',
|
||||
'DC',
|
||||
'DCC',
|
||||
'DCCC',
|
||||
'CM',
|
||||
'',
|
||||
'X',
|
||||
'XX',
|
||||
'XXX',
|
||||
'XL',
|
||||
'L',
|
||||
'LX',
|
||||
'LXX',
|
||||
'LXXX',
|
||||
'XC',
|
||||
'',
|
||||
'I',
|
||||
'II',
|
||||
'III',
|
||||
'IV',
|
||||
'V',
|
||||
'VI',
|
||||
'VII',
|
||||
'VIII',
|
||||
'IX',
|
||||
],
|
||||
roman = '',
|
||||
i = 3;
|
||||
while (i--) roman = (key[+digits.pop()! + i * 10] || '') + roman;
|
||||
return Array(+digits.join('') + 1).join('M') + roman;
|
||||
}
|
||||
@@ -2,8 +2,7 @@ import {
|
||||
asset,
|
||||
fetchSkillDefinitions,
|
||||
permanentSkills,
|
||||
TIER_ROMAN_NUMERALS,
|
||||
type Tier,
|
||||
romanize,
|
||||
} from '@blitzkit/core';
|
||||
import { Flex } from '@radix-ui/themes';
|
||||
import { GenericTankComponentButton } from './ModuleButtons/GenericTankComponentButton';
|
||||
@@ -31,9 +30,7 @@ export function CrewSkillManager({
|
||||
key={skill}
|
||||
special={!permanentSkills.includes(skill)}
|
||||
selected={level > 0}
|
||||
discriminator={
|
||||
level === 0 ? undefined : TIER_ROMAN_NUMERALS[level as Tier]
|
||||
}
|
||||
discriminator={level === 0 ? undefined : romanize(level)}
|
||||
icon={asset(`icons/skills/${skill}.webp`)}
|
||||
onClick={(event) => {
|
||||
if (!onChange) return;
|
||||
|
||||
Reference in new issue
Block a user