mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-01-13 00:28:15 -05:00
* 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 🗯
64 lines
986 B
TypeScript
64 lines
986 B
TypeScript
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;
|
||
};
|