reset
This commit is contained in:
parent
9dd0c78850
commit
49fffc20a3
19 changed files with 2551 additions and 12482 deletions
|
@ -21,6 +21,10 @@ export type Zone = {
|
|||
id: string;
|
||||
name: string;
|
||||
population: Population;
|
||||
vehicles?: Record<(typeof allVehicles)[number], Population> & {
|
||||
total: number;
|
||||
};
|
||||
classes?: Record<(typeof allClasses)[number], Population>;
|
||||
};
|
||||
|
||||
export type World = {
|
||||
|
@ -88,3 +92,79 @@ export const indexQuery = async (): Promise<IndexResponse> => {
|
|||
|
||||
return indexData;
|
||||
};
|
||||
|
||||
export type WorldResponse = {
|
||||
world: World;
|
||||
};
|
||||
|
||||
export const allVehicles = [
|
||||
"flash",
|
||||
"sunderer",
|
||||
"lightning",
|
||||
"scythe",
|
||||
"vanguard",
|
||||
"prowler",
|
||||
"reaver",
|
||||
"mosquito",
|
||||
"galaxy",
|
||||
"valkyrie",
|
||||
"liberator",
|
||||
"ant",
|
||||
"harasser",
|
||||
"dervish",
|
||||
"chimera",
|
||||
"javelin",
|
||||
"corsair",
|
||||
"magrider",
|
||||
];
|
||||
|
||||
export const allClasses = [
|
||||
"infiltrator",
|
||||
"lightAssault",
|
||||
"combatMedic",
|
||||
"engineer",
|
||||
"heavyAssault",
|
||||
"max",
|
||||
];
|
||||
|
||||
export const worldQuery = async (worldID: string): Promise<WorldResponse> => {
|
||||
const query = `query {
|
||||
world(by: {id: ${Number(worldID)}}) {
|
||||
id
|
||||
name
|
||||
population {
|
||||
total
|
||||
nc
|
||||
tr
|
||||
vs
|
||||
}
|
||||
zones {
|
||||
all {
|
||||
id
|
||||
name
|
||||
classes {
|
||||
${allClasses.map((cls) => `${cls} { total nc tr vs }`).join(" ")}
|
||||
}
|
||||
vehicles {
|
||||
total
|
||||
${allVehicles
|
||||
.map((vehicle) => `${vehicle} { total nc tr vs }`)
|
||||
.join(" ")}
|
||||
}
|
||||
population {
|
||||
total
|
||||
nc
|
||||
tr
|
||||
vs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`;
|
||||
|
||||
console.log(query);
|
||||
|
||||
const worldData: WorldResponse = await saerroFetch(query);
|
||||
|
||||
return worldData;
|
||||
};
|
||||
|
|
9
app/utils/strings.ts
Normal file
9
app/utils/strings.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
export const toTitleCase = (str: string) => {
|
||||
return str.replace(/\w\S*/g, (txt) => {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
});
|
||||
};
|
||||
|
||||
export const pascalCaseToTitleCase = (str: string) => {
|
||||
return toTitleCase(str.replace(/([A-Z])/g, " $1"));
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue