feat: extended map popup
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dawid Wysokiński 2023-02-04 12:23:08 +01:00
parent 363a43181b
commit c3445112ef
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
1 changed files with 17 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import {
} from './lib/twhelp';
import { Cache, InMemoryStorage } from './lib/cache';
import { calcDistance, calcLoyalty } from './lib/tw';
import { createTranslationFunc } from './utils';
declare global {
interface Window {
@ -29,6 +30,17 @@ declare global {
}
}
const t = createTranslationFunc({
pl_PL: {
'Ennobled at': 'Ostatnio przejęta',
Loyalty: 'Poparcie',
'Can send a nobleman': 'Można wysłać szlachica',
Yes: 'Tak',
No: 'Nie',
Never: 'Nigdy',
},
});
class TWHelpConnector {
private static readonly SERVER_CONFIG_CACHE_KEY =
'extended_map_popup_server_config';
@ -181,8 +193,8 @@ class Popup {
const tr = document.createElement('tr');
tr.innerHTML = `
<td>Can send a nobleman:</td>
<td>${dist <= this.config.snob.maxDist ? 'Yes' : 'No'}</td>
<td>${t('Can send a nobleman')}:</td>
<td>${dist <= this.config.snob.maxDist ? t('Yes') : t('No')}</td>
`;
tbody.appendChild(tr);
@ -202,14 +214,14 @@ class Popup {
[
{
id: Popup.ID_ENNOBLED_AT,
title: 'Ennobled at',
title: t('Ennobled at'),
value: ennoblement
? new Date(ennoblement.createdAt).toLocaleString()
: 'Never',
: t('Never'),
},
{
id: Popup.ID_LOYALTY,
title: 'Loyalty',
title: t('Loyalty'),
value: calcLoyalty(
ennoblement?.createdAt ?? new Date(0),
this.config.speed