Skip to content

Commit d48a055

Browse files
committed
Format display items and add last seen
1 parent 3f74d73 commit d48a055

3 files changed

Lines changed: 45 additions & 15 deletions

File tree

site/src/account-viewer/listBuilder.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ import { profileStatMappings, playerMappings, galacticPowerMappings, speedModMap
44
import { getSpeedModCount, getPipCount, countOffensePercentRolls } from "./mods.ts";
55
import { ULLocation, relicChart, gearChart, starChart, activeChart } from "./locations.ts"
66

7+
function handleLastSeen(player: PlayerResp): void {
8+
let lastSeen = new Date(Number(player.lastActivityTime)).toLocaleString();
9+
ULLocation("mainList", `Last Seen: ${lastSeen}`);
10+
}
11+
712
function handleProfileStat(player: PlayerResp): void {
813
profileStatMappings.forEach(stat => {
914
const playerStat = player.profileStat.find(ps => ps.index === stat.index);
1015
if (playerStat) {
11-
ULLocation("profileStatList", `${stat.displayName}: ${playerStat.value}`);
16+
ULLocation("profileStatList", `${stat.displayName}: ${Number(playerStat.value).toLocaleString()}`);
1217
}
1318
});
1419
}
@@ -17,7 +22,7 @@ function handleGP(player: PlayerResp): void {
1722
galacticPowerMappings.forEach(stat => {
1823
const playerStat = player.profileStat.find(ps => ps.index === stat.index)
1924
if (playerStat) {
20-
ULLocation("GPList", `${stat.displayName}: ${playerStat.value}`);
25+
ULLocation("GPList", `${stat.displayName}: ${Number(playerStat.value).toLocaleString()}`);
2126
}
2227
});
2328
}
@@ -101,9 +106,9 @@ function handleOffenseMods(player: PlayerResp): void {
101106
function handlePips(player: PlayerResp): void {
102107
const { sixDot, fiveDot, other } = getPipCount(player);
103108

104-
ULLocation("pipList", `${pipMappings.sixDot}: ${sixDot}`);
105-
ULLocation("pipList", `${pipMappings.fiveDot}: ${fiveDot}`);
106-
ULLocation("pipList", `${pipMappings.other}: ${other}`);
109+
ULLocation("pipList", `${pipMappings.sixDot}: ${sixDot.toLocaleString()}`);
110+
ULLocation("pipList", `${pipMappings.fiveDot}: ${fiveDot.toLocaleString()}`);
111+
ULLocation("pipList", `${pipMappings.other}: ${other.toLocaleString()}`);
107112
}
108113

109114
function handleStars(player: PlayerResp): void {
@@ -149,6 +154,10 @@ export async function FillList(allyCode: string) {
149154

150155
switch (playerMappings[key].displayType) {
151156
case 0:
157+
if (playerMappings[key].displayName == "Player Allycode") {
158+
ULLocation("mainList", `${playerMappings[key].displayName}: ${Number(player[key]).toLocaleString("en-US").replace(/,/g, "-")}`);
159+
break;
160+
}
152161
ULLocation("mainList", `${playerMappings[key].displayName}: ${player[key]}`);
153162
break;
154163
case 1:
@@ -176,7 +185,10 @@ export async function FillList(allyCode: string) {
176185
handleActivated(player, units);
177186
break;
178187
case 9:
179-
handleOffenseMods(player)
188+
handleOffenseMods(player);
189+
break;
190+
case 10:
191+
handleLastSeen(player);
180192
break;
181193
default:
182194
console.error(`Found unknown playerMappings key: ${key}`)

site/src/account-viewer/listBuilderMappings.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const profileStatMappings: { index: number, displayName: string }[] = [
5454
{
5555
"index": 19,
5656
"displayName": "GAC Territories Defeated"
57-
}
57+
},
5858
];
5959

6060
export const galacticPowerMappings: { index: number; displayName: string }[] = [
@@ -226,5 +226,9 @@ export const playerMappings: Record<string, { displayType: number; displayName:
226226
"profileStat": {
227227
"displayType": 1,
228228
"displayName": "",
229+
},
230+
"lastActive": {
231+
"displayType": 10,
232+
"displayName": "",
229233
}
230234
};

site/src/account-viewer/requestMaker.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ async function makeHMACSigCryptoJS(secret: string, message: string): Promise<str
3030

3131
async function makeHMACSig(secret: string, message: string): Promise<string> {
3232
if (crypto.subtle) {
33-
return makeHMACSigCrypto(secret, message);
34-
} else {
35-
return makeHMACSigCryptoJS(secret, message);
36-
}
33+
return makeHMACSigCrypto(secret, message);
34+
} else {
35+
return makeHMACSigCryptoJS(secret, message);
36+
}
3737
}
3838

3939
async function makeAuthHeader(secret: string, user: string, method: string, path: string): Promise<string> {
@@ -46,24 +46,24 @@ async function makeAuthHeader(secret: string, user: string, method: string, path
4646
return `HMAC user=${user},ts=${ts},sig=${sig}`;
4747
}
4848

49-
type ProfileStat = {
49+
export type ProfileStat = {
5050
value: string;
5151
index: number;
5252
};
5353

54-
type SecondaryStat = {
54+
export type SecondaryStat = {
5555
stat: {
5656
unitStatId: number;
5757
unscaledDecimalValue: number;
5858
};
5959
};
6060

61-
type EquippedStatMod = {
61+
export type EquippedStatMod = {
6262
secondaryStat: SecondaryStat[];
6363
definitionId: string;
6464
};
6565

66-
type RosterUnit = {
66+
export type RosterUnit = {
6767
equippedStatMod: EquippedStatMod[];
6868
purchasedAbilityId: string[];
6969
definitionId: string;
@@ -74,10 +74,24 @@ type RosterUnit = {
7474
};
7575
};
7676

77+
export type PlayerRating = {
78+
playerSkillRating: {
79+
skillRating: number;
80+
};
81+
playerRankStatus: {
82+
leagueId: string;
83+
divisionId: number;
84+
};
85+
};
86+
7787
export type PlayerResp = {
7888
name: string;
7989
guildName: string;
8090
allyCode: string;
91+
playerId: string;
92+
guildId: string;
93+
lastActivityTime: string;
94+
playerRating: PlayerRating
8195
profileStat: ProfileStat[];
8296
rosterUnit: RosterUnit[];
8397
};

0 commit comments

Comments
 (0)