mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 19:42:53 +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.
|
Use Grasscutter's dumpers to generate the data to put here.
|
||||||
|
|
||||||
## Files Required
|
## Files Required
|
||||||
- `avatars.json`
|
|
||||||
- `commands.json`
|
- `commands.json`
|
||||||
|
- `avatars.csv`
|
||||||
|
- `scenes.csv`
|
||||||
- `items.csv`
|
- `items.csv`
|
||||||
|
|
||||||
# Item Icon Notes
|
# Item Icon Notes
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import commands from "@data/commands.json";
|
import commands from "@data/commands.json";
|
||||||
import avatars from "@data/avatars.csv";
|
import avatars from "@data/avatars.csv";
|
||||||
|
import scenes from "@data/scenes.csv";
|
||||||
import items from "@data/items.csv";
|
import items from "@data/items.csv";
|
||||||
|
|
||||||
import { Quality, ItemType, ItemCategory } from "@backend/types";
|
import { Quality, ItemType, ItemCategory, SceneType } from "@backend/types";
|
||||||
import type { Command, Avatar, Item } from "@backend/types";
|
import type { Command, Avatar, Item, Scene } from "@backend/types";
|
||||||
|
|
||||||
import { inRange } from "@app/utils";
|
import { inRange } from "@app/utils";
|
||||||
|
|
||||||
type AvatarDump = { [key: number]: Avatar };
|
type AvatarDump = { [key: number]: Avatar };
|
||||||
type CommandDump = { [key: string]: Command };
|
type CommandDump = { [key: string]: Command };
|
||||||
type TaggedItems = { [key: number]: Item[] };
|
type TaggedItems = { [key: number]: Item[] };
|
||||||
type ItemIcons = { [key: number]: string };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see {@file src/handbook/data/README.md}
|
* @see {@file src/handbook/data/README.md}
|
||||||
@ -97,6 +97,21 @@ export function listAvatars(): Avatar[] {
|
|||||||
return Object.values(getAvatars());
|
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.
|
* Fetches and casts all items in the file.
|
||||||
*/
|
*/
|
||||||
|
@ -16,6 +16,12 @@ export type Avatar = {
|
|||||||
id: number;
|
id: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type Scene = {
|
||||||
|
identifier: string;
|
||||||
|
type: string;
|
||||||
|
id: number;
|
||||||
|
};
|
||||||
|
|
||||||
export type Item = {
|
export type Item = {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
@ -70,6 +76,16 @@ export enum ItemType {
|
|||||||
Furniture = "ITEM_FURNITURE"
|
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 {
|
export enum ItemCategory {
|
||||||
Constellation,
|
Constellation,
|
||||||
Avatar,
|
Avatar,
|
||||||
|
Loading…
Reference in New Issue
Block a user