feat: extended player profile
This commit is contained in:
parent
7102eece1f
commit
4b0dbabf02
|
@ -67,7 +67,7 @@ export class DialogTable<T> {
|
||||||
page >= maxPage ? ' disabled' : ''
|
page >= maxPage ? ' disabled' : ''
|
||||||
}>></button>
|
}>></button>
|
||||||
</div>
|
</div>
|
||||||
<table class="vis">
|
<table style="width: 100%" class="vis">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
${this.columns.map((col) => `<th>${col.header}</th>`).join('')}
|
${this.columns.map((col) => `<th>${col.header}</th>`).join('')}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
TWHelpClient,
|
TWHelpClient,
|
||||||
} from './lib/client';
|
} from './lib/client';
|
||||||
import { DialogTable } from './common/DialogTable';
|
import { DialogTable } from './common/DialogTable';
|
||||||
|
import { buildURL } from './lib/twstats';
|
||||||
|
|
||||||
const SCREEN = 'info_player';
|
const SCREEN = 'info_player';
|
||||||
const MODE = null;
|
const MODE = null;
|
||||||
|
@ -19,6 +20,7 @@ const translations: Record<string, Record<string, string>> = {
|
||||||
'Best rank': 'Najlepszy ranking',
|
'Best rank': 'Najlepszy ranking',
|
||||||
'Most points': 'Najwięcej punktów',
|
'Most points': 'Najwięcej punktów',
|
||||||
'Most villages': 'Najwięcej wiosek',
|
'Most villages': 'Najwięcej wiosek',
|
||||||
|
'Show other servers': 'Pokaż inne światy',
|
||||||
'Show tribe changes': 'Pokaż zmiany plemion',
|
'Show tribe changes': 'Pokaż zmiany plemion',
|
||||||
'Show history': 'Pokaż historię',
|
'Show history': 'Pokaż historię',
|
||||||
'Show ennoblements': 'Pokaż przejęcia',
|
'Show ennoblements': 'Pokaż przejęcia',
|
||||||
|
@ -31,6 +33,10 @@ const translations: Record<string, Record<string, string>> = {
|
||||||
Points: 'Punkty',
|
Points: 'Punkty',
|
||||||
Barbarian: 'Barbarzyńska',
|
Barbarian: 'Barbarzyńska',
|
||||||
Unknown: 'Nieznany',
|
Unknown: 'Nieznany',
|
||||||
|
Server: 'Serwer',
|
||||||
|
Deleted: 'Usunięty',
|
||||||
|
Yes: 'Tak',
|
||||||
|
No: 'Nie',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,6 +74,7 @@ class TWHelpConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DialogId {
|
enum DialogId {
|
||||||
|
OTHER_SERVERS = 'kichiyaki_other_servers',
|
||||||
TRIBE_CHANGES = 'kichiyaki_tribe_changes',
|
TRIBE_CHANGES = 'kichiyaki_tribe_changes',
|
||||||
ENNOBLEMENTS = 'kichiyaki_ennoblements',
|
ENNOBLEMENTS = 'kichiyaki_ennoblements',
|
||||||
}
|
}
|
||||||
|
@ -142,6 +149,10 @@ class UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
[
|
[
|
||||||
|
{
|
||||||
|
name: t('Show other servers'),
|
||||||
|
handler: this.showOtherServers.bind(this),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: t('Show tribe changes'),
|
name: t('Show tribe changes'),
|
||||||
handler: this.showTribeChanges.bind(this),
|
handler: this.showTribeChanges.bind(this),
|
||||||
|
@ -166,6 +177,39 @@ class UI {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async showOtherServers(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
await new DialogTable(
|
||||||
|
DialogId.OTHER_SERVERS,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
header: t('Server'),
|
||||||
|
accessor: (s) =>
|
||||||
|
`<a href="${buildURL({
|
||||||
|
entity: 'player',
|
||||||
|
server: s.key,
|
||||||
|
id: this.player.id,
|
||||||
|
})}">${s.key}</a>`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: t('Deleted'),
|
||||||
|
accessor: (s) =>
|
||||||
|
s.deletedAt
|
||||||
|
? `${t('Yes')} (${new Date(s.deletedAt).toLocaleString()})`
|
||||||
|
: t('No'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
this.player.otherServers.length,
|
||||||
|
() => {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: this.player.otherServers,
|
||||||
|
total: this.player.otherServers.length,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
).render();
|
||||||
|
}
|
||||||
|
|
||||||
private async showTribeChanges(e: Event) {
|
private async showTribeChanges(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,11 @@ export type Version = {
|
||||||
timezone: string;
|
timezone: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type PlayerServer = {
|
||||||
|
key: string;
|
||||||
|
deletedAt: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
export type Player = {
|
export type Player = {
|
||||||
id: number;
|
id: number;
|
||||||
bestRank: number;
|
bestRank: number;
|
||||||
|
@ -20,6 +25,7 @@ export type Player = {
|
||||||
mostVillagesAt: string;
|
mostVillagesAt: string;
|
||||||
lastActivityAt: string;
|
lastActivityAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
otherServers: PlayerServer[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TribeMeta = {
|
export type TribeMeta = {
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
export type BuildURLParams = {
|
||||||
|
entity: 'player';
|
||||||
|
id: number;
|
||||||
|
server: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const buildURL = (params: BuildURLParams) => {
|
||||||
|
switch (params.entity) {
|
||||||
|
case 'player':
|
||||||
|
return `https://www.twstats.com/in/${params.server}/player/${params.id}`;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown entity: ${params.entity}`);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue