Parse scene info

This commit is contained in:
KingRainbow44 2023-04-09 20:38:19 -04:00
parent a8289b782f
commit e5efe00285
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
3 changed files with 36 additions and 4 deletions

View File

@ -2,8 +2,9 @@
Use Grasscutter's dumpers to generate the data to put here.
## Files Required
- `avatars.json`
- `commands.json`
- `avatars.csv`
- `scenes.csv`
- `items.csv`
# Item Icon Notes

View File

@ -1,16 +1,16 @@
import commands from "@data/commands.json";
import avatars from "@data/avatars.csv";
import scenes from "@data/scenes.csv";
import items from "@data/items.csv";
import { Quality, ItemType, ItemCategory } from "@backend/types";
import type { Command, Avatar, Item } from "@backend/types";
import { Quality, ItemType, ItemCategory, SceneType } from "@backend/types";
import type { Command, Avatar, Item, Scene } from "@backend/types";
import { inRange } from "@app/utils";
type AvatarDump = { [key: number]: Avatar };
type CommandDump = { [key: string]: Command };
type TaggedItems = { [key: number]: Item[] };
type ItemIcons = { [key: number]: string };
/**
* @see {@file src/handbook/data/README.md}
@ -97,6 +97,21 @@ export function listAvatars(): Avatar[] {
return Object.values(getAvatars());
}
/**
* Fetches and casts all scenes in the file.
*/
export function getScenes(): Scene[] {
return scenes.map((entry) => {
const values = Object.values(entry) as string[];
const id = parseInt(values[0]);
return {
id,
identifier: values[1],
type: values[2] as SceneType
};
});
}
/**
* Fetches and casts all items in the file.
*/

View File

@ -16,6 +16,12 @@ export type Avatar = {
id: number;
};
export type Scene = {
identifier: string;
type: string;
id: number;
};
export type Item = {
id: number;
name: string;
@ -70,6 +76,16 @@ export enum ItemType {
Furniture = "ITEM_FURNITURE"
}
export enum SceneType {
None = "SCENE_NONE",
World = "SCENE_WORLD",
Dungeon = "SCENE_DUNGEON",
Room = "SCENE_ROOM",
HomeWorld = "SCENE_HOME_WORLD",
HomeRoom = "SCENE_HOME_ROOM",
Activity = "SCENE_ACTIVITY"
}
export enum ItemCategory {
Constellation,
Avatar,