mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 17:23:21 +08:00
Parse scene info
This commit is contained in:
parent
a8289b782f
commit
e5efe00285
@ -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
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user