Files
TheGame/packages/web/utils/formatHelpers.ts
Arsenije Savic ea42bea2c0 Dashboard fixes; closes #1209, #1210, #1223, & #1224
* Remove connect to progress if the network is not mainnet

* Move xpHelpers to the utils

* Add tests to the utils package

* Add xpHelpers test

* Add convertToRoman util function

* Display current season label dynamically

* Add onboarding text if player does not have xp

* Remove ConnectToProgress import

* Add connect to progress if the network is not mainnet

* Show edit button if network is not main

* Refactor xp helper season start

* displaying modal when chain change is needed 🛬

* using Unicode Roman numerals Ⅲ

* slight formatting fixes 🗯
2022-05-18 01:48:07 -04:00

64 lines
986 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export const convertToRoman = (_num: number): string => {
let num = _num;
type RomanOptions = {
[key: string]: number;
};
const romans: RomanOptions = {
: 100_000,
: 50_000,
: 10_000,
: 5_000,
: 1_000,
: 900,
: 500,
: 400,
: 100,
: 90,
: 50,
: 40,
: 10,
: 9,
: 5,
: 4,
: 1,
};
const smallRomans = [
'',
'Ⅱ',
'Ⅲ',
'Ⅳ',
'',
'Ⅵ',
'Ⅶ',
'Ⅷ',
'Ⅸ',
'',
'Ⅺ',
'Ⅻ',
'ⅩⅢ',
'ⅩⅣ',
'',
'ⅩⅥ',
'ⅩⅦ',
'ⅩⅡⅩ',
'',
];
if (num < smallRomans.length) {
return smallRomans[num - 1];
}
let str = '';
// eslint-disable-next-line no-restricted-syntax
for (const i of Object.keys(romans)) {
const q = Math.floor(num / romans[i]);
num -= q * romans[i];
str += i.repeat(q);
}
return str;
};