mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +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;
|
||||
}
|
||||
Reference in new issue
Block a user