feat(profiles): track EOD minesweeper progress
This commit is contained in:
parent
512cdd62ad
commit
3e82ef4ed9
3 changed files with 93 additions and 6 deletions
|
|
@ -107,11 +107,17 @@ export const Profiles: CollectionConfig = {
|
|||
let xpAcc = 0;
|
||||
|
||||
const progressionData = siblingData as {
|
||||
awards?: Array<{
|
||||
award?: number | Award;
|
||||
} | number>;
|
||||
awards?: Array<
|
||||
| {
|
||||
award?: number | Award;
|
||||
}
|
||||
| number
|
||||
>;
|
||||
scoreboard?: Record<string, number | null>;
|
||||
minigames?: { flappyBird?: { xpEarned?: number | null } };
|
||||
minigames?: {
|
||||
flappyBird?: { xpEarned?: number | null };
|
||||
eodMinesweeper?: { xpEarned?: number | null };
|
||||
};
|
||||
};
|
||||
const awardsList = progressionData?.awards || [];
|
||||
const awardIds = awardsList.flatMap((entry) => {
|
||||
|
|
@ -122,6 +128,7 @@ export const Profiles: CollectionConfig = {
|
|||
});
|
||||
const scoreboard = progressionData?.scoreboard || {};
|
||||
const flappyXp = progressionData?.minigames?.flappyBird?.xpEarned ?? 0;
|
||||
const eodXp = progressionData?.minigames?.eodMinesweeper?.xpEarned ?? 0;
|
||||
|
||||
if (awardIds.length > 0) {
|
||||
await req.payload
|
||||
|
|
@ -159,6 +166,8 @@ export const Profiles: CollectionConfig = {
|
|||
|
||||
// Flappy Bird training sim: 1 XP per 15 pipes passed in a single run
|
||||
xpAcc += flappyXp;
|
||||
// EOD Minesweeper: XP from cleared minefields
|
||||
xpAcc += eodXp;
|
||||
|
||||
return xpAcc;
|
||||
},
|
||||
|
|
@ -175,7 +184,7 @@ export const Profiles: CollectionConfig = {
|
|||
relationTo: "awards",
|
||||
required: true,
|
||||
admin: {
|
||||
appearance: "drawer"
|
||||
appearance: "drawer",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -186,7 +195,8 @@ export const Profiles: CollectionConfig = {
|
|||
// issuer's progression/awards when a profile is read.
|
||||
maxDepth: 0,
|
||||
admin: {
|
||||
description: 'Who issued the award. If no one, the award will be attributed as "on behalf of the unit."',
|
||||
description:
|
||||
'Who issued the award. If no one, the award will be attributed as "on behalf of the unit."',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -285,6 +295,60 @@ export const Profiles: CollectionConfig = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "eodMinesweeper",
|
||||
label: "EOD Minesweeper",
|
||||
type: "group",
|
||||
fields: [
|
||||
{
|
||||
name: "gamesPlayed",
|
||||
type: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
name: "wins",
|
||||
label: "Wins",
|
||||
type: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
name: "losses",
|
||||
label: "Losses",
|
||||
type: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
name: "bestScore",
|
||||
label: "Best Score",
|
||||
type: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
name: "xpEarned",
|
||||
label: "XP Earned",
|
||||
type: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
name: "bestTrainingTime",
|
||||
label: "Best Training Pad Time (s)",
|
||||
type: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
name: "bestPerimeterTime",
|
||||
label: "Best FOB Perimeter Time (s)",
|
||||
type: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
name: "bestSupplyRoadTime",
|
||||
label: "Best Main Supply Road Time (s)",
|
||||
type: "number",
|
||||
defaultValue: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1677,6 +1677,16 @@ export interface Profile {
|
|||
bestScore?: number | null;
|
||||
xpEarned?: number | null;
|
||||
};
|
||||
eodMinesweeper?: {
|
||||
gamesPlayed?: number | null;
|
||||
wins?: number | null;
|
||||
losses?: number | null;
|
||||
bestScore?: number | null;
|
||||
xpEarned?: number | null;
|
||||
bestTrainingTime?: number | null;
|
||||
bestPerimeterTime?: number | null;
|
||||
bestSupplyRoadTime?: number | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
updatedAt: string;
|
||||
|
|
@ -3456,6 +3466,18 @@ export interface ProfilesSelect<T extends boolean = true> {
|
|||
bestScore?: T;
|
||||
xpEarned?: T;
|
||||
};
|
||||
eodMinesweeper?:
|
||||
| T
|
||||
| {
|
||||
gamesPlayed?: T;
|
||||
wins?: T;
|
||||
losses?: T;
|
||||
bestScore?: T;
|
||||
xpEarned?: T;
|
||||
bestTrainingTime?: T;
|
||||
bestPerimeterTime?: T;
|
||||
bestSupplyRoadTime?: T;
|
||||
};
|
||||
};
|
||||
};
|
||||
updatedAt?: T;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ export const EventTypes = {
|
|||
|
||||
// Minigames
|
||||
MinigameFlappy: "minigame:flappy",
|
||||
MinigameEod: "minigame:eod",
|
||||
|
||||
// Market
|
||||
MarketListingCreate: "market:listing-create",
|
||||
|
|
|
|||
Loading…
Reference in a new issue