HumanBreak/src/types/plugin.d.ts

468 lines
11 KiB
TypeScript
Raw Normal View History

2022-11-13 18:02:05 +08:00
// 这里包含所有插件导出的函数及变量声明声明的函数会在类型标注中标注到core上
2022-11-14 17:11:23 +08:00
type Ref<T> = {
value: T;
};
2022-11-19 11:30:14 +08:00
type DragFn = (x: number, y: number, e: MouseEvent | TouchEvent) => void;
2022-11-21 20:00:34 +08:00
type CanParseCss = keyof {
[P in keyof CSSStyleDeclaration as CSSStyleDeclaration[P] extends string
? P extends string
? P
: never
: never]: CSSStyleDeclaration[P];
};
2022-12-30 23:28:27 +08:00
interface PluginDeclaration
extends PluginUtils,
PluginUis,
PluginUse,
MiniMap,
2023-02-23 23:10:57 +08:00
PluginAchievement {
2023-02-28 17:49:34 +08:00
/**
*
*/
utils: GamePluginUtils;
loopMap: GamePluginLoopMap;
skillTree: GamePluginSkillTree;
study: GamePluginStudy;
hero: GamePluginHeroRealStatus;
2023-04-24 20:27:21 +08:00
replay: PluginReplay;
2023-04-29 11:25:18 +08:00
chase: PluginChase;
2023-02-28 17:49:34 +08:00
skills: Record<Chapter, Skill[]>;
2023-04-22 17:01:35 +08:00
skillEffects: SkillEffects;
2023-02-28 17:49:34 +08:00
2022-11-13 18:02:05 +08:00
/**
* 使core.addPop或core.plugin.addPop调用
* @param px
* @param py
* @param value
*/
addPop(px: number, py: number, value: string): void;
/** 添加变量 例所有的正在弹出的文字像这个就可以使用core.plugin.pop获取 */
pop: any[];
2022-11-14 17:11:23 +08:00
2022-12-29 19:57:31 +08:00
/** 状态栏信息,取反后刷新状态栏 */
readonly statusBarStatus: Ref<boolean>;
/** 检查标记的怪物,取反后更新显示信息 */
readonly checkMarkedStatus: Ref<boolean>;
/**
*
* @param fn
*/
addAnimate(fn: (time: number) => void);
/**
*
* @param fn
*/
removeAnimate(fn: (time: number) => void);
/**
2022-12-29 23:56:35 +08:00
*
2022-12-29 19:57:31 +08:00
*/
checkMarkedEnemy(): void;
2022-12-30 11:06:46 +08:00
/**
*
* @param id id
*/
markEnemy(id: EnemyIds): void;
/**
*
*/
hasMarkedEnemy(id: EnemyIds): void;
/**
*
*/
unmarkEnemy(id: EnemyIds): void;
2022-12-29 19:57:31 +08:00
/**
*
*/
resetSettings(): void;
2022-12-30 14:14:28 +08:00
/**
*
*/
resetFlagSettings(): void;
2022-12-29 19:57:31 +08:00
}
2023-02-28 17:49:34 +08:00
interface GamePluginUtils {
2022-12-29 19:57:31 +08:00
/**
* undefined或null
* @param value
*/
has<T>(value: T): value is NonNullable<T>;
/**
2023-02-28 17:49:34 +08:00
*
* @param arr
* @param delta
2022-12-29 19:57:31 +08:00
*/
2023-02-28 17:49:34 +08:00
slide<T>(arr: T[], delta: number): T[];
2022-12-29 19:57:31 +08:00
/**
2023-02-28 17:49:34 +08:00
*
* @param dir
2022-12-29 19:57:31 +08:00
*/
2023-02-28 17:49:34 +08:00
backDir(dir: Dir): Dir;
2022-12-30 11:06:46 +08:00
/**
2023-02-28 17:49:34 +08:00
*
* @param n
2022-12-30 11:06:46 +08:00
*/
2023-02-28 17:49:34 +08:00
maxGameScale(n?: number): void;
}
2023-01-03 22:24:05 +08:00
2023-02-28 17:49:34 +08:00
interface GamePluginLoopMap {
checkLoopMap(): void;
}
2023-01-03 22:36:50 +08:00
2023-02-28 17:49:34 +08:00
interface PluginUtils {
2023-01-04 16:23:26 +08:00
/**
2023-02-28 17:49:34 +08:00
* undefined或null
* @param value
2023-01-04 16:23:26 +08:00
*/
2023-02-28 17:49:34 +08:00
has<T>(value: T): value is NonNullable<T>;
/**
2023-02-28 17:49:34 +08:00
*
* @param damage
*/
2023-02-28 17:49:34 +08:00
getDamageColor(damage: number): string;
2023-01-11 11:06:04 +08:00
/**
2023-02-28 17:49:34 +08:00
* css字符串为CSSStyleDeclaration对象
* @param css css字符串
2023-01-11 11:06:04 +08:00
*/
2023-02-28 17:49:34 +08:00
parseCss(css: string): Partial<Record<CanParseCss, string>>;
2023-02-22 21:39:44 +08:00
/**
2023-02-28 17:49:34 +08:00
*
* @param text
2023-02-22 21:39:44 +08:00
*/
2023-02-28 17:49:34 +08:00
tip(
type: 'warn' | 'info' | 'success' | 'error' | 'warning' | 'loading',
text: string
): void;
/**
*
* @param index
*/
startChase(index: number): Promise<void>;
2022-12-29 19:57:31 +08:00
}
interface PluginUis {
2022-11-19 11:30:14 +08:00
/** 怪物手册的怪物详细信息的初始位置 */
bookDetailPos: number;
/** 怪物手册详细信息展示的怪物 */
2022-12-29 00:26:12 +08:00
bookDetailEnemy: DetailedEnemy;
2022-11-19 11:30:14 +08:00
2023-01-08 22:59:39 +08:00
/** 定点查看的界面,特殊属性还是临界 */
fixedDetailPanel: 'special' | 'critical';
2023-01-16 22:32:04 +08:00
/** 打开的商店id */
openedShopId: string;
2022-11-21 20:00:34 +08:00
/** ui是否使用渐变 */
readonly transition: Ref<boolean>;
2022-11-14 17:11:23 +08:00
/** 手册是否打开 */
readonly bookOpened: Ref<boolean>;
2022-11-21 20:00:34 +08:00
/** 道具栏是否打开 */
readonly toolOpened: Ref<boolean>;
2022-11-30 16:42:44 +08:00
/** 装备栏是否打开 */
readonly equipOpened: Ref<boolean>;
2022-12-28 20:34:23 +08:00
/** 是否显示状态栏 */
readonly showStatusBar: Ref<boolean>;
2022-12-29 00:26:12 +08:00
/** 设置界面是否打开 */
readonly settingsOpened: Ref<boolean>;
2022-12-29 19:57:31 +08:00
/** 是否正在进行章节显示 */
readonly chapterShowed: Ref<boolean>;
/** 章节显示的内容 */
readonly chapterContent: Ref<boolean>;
2022-12-30 00:55:03 +08:00
/** 百科全书是否打开了 */
readonly descOpened: Ref<boolean>;
2022-12-30 15:25:58 +08:00
/** 技能查看界面是否打开 */
readonly skillOpened: Ref<boolean>;
2022-12-30 23:28:27 +08:00
/** 技能树界面是否打开 */
readonly skillTreeOpened: Ref<boolean>;
2023-01-01 22:02:58 +08:00
/** 楼传界面是否打开 */
readonly flyOpened: Ref<boolean>;
2023-01-04 16:23:26 +08:00
/** 是否展示标记的怪物 */
readonly showMarkedEnemy: Ref<boolean>;
2023-01-06 16:21:17 +08:00
/** 是否展示已学习的技能 */
readonly showStudiedSkill: Ref<boolean>;
2023-01-06 22:18:33 +08:00
/** 定点查看是否打开 */
readonly fixedDetailOpened: Ref<boolean>;
/** 是否展示移动鼠标显示怪物信息的盒子 */
readonly showFixed: Ref<boolean>;
2023-01-16 22:32:04 +08:00
/** 商店是否打开 */
readonly shopOpened: Ref<boolean>;
2023-02-20 20:34:42 +08:00
/** 开始界面是否打开 */
readonly startOpened: Ref<boolean>;
2023-02-22 20:23:37 +08:00
/** 成就界面是否打开 */
readonly achievementOpened: Ref<boolean>;
2023-03-01 22:50:43 +08:00
/** bgm界面是否打开 */
readonly bgmOpened: Ref<boolean>;
2022-11-14 17:11:23 +08:00
/** ui栈 */
readonly uiStack: Ref<any[]>;
2022-11-14 17:11:23 +08:00
2022-12-29 19:57:31 +08:00
/**
*
* @param chapter
*/
showChapter(chapter: string): void;
2022-12-30 15:25:58 +08:00
/**
*
*/
openSkill(): void;
2022-12-29 19:57:31 +08:00
}
interface PluginUse {
2022-11-16 23:01:23 +08:00
/** 是否是移动设备 */
readonly isMobile: boolean;
2022-11-14 17:11:23 +08:00
/**
*
* @param ele
* @param fn x y和鼠标事件或点击事件
* @param ondown
* @param global
*/
useDrag(
ele: HTMLElement,
2022-11-19 11:30:14 +08:00
fn: DragFn,
ondown?: DragFn,
onUp?: (e: MouseEvent | TouchEvent) => void,
global?: boolean
2022-11-14 17:11:23 +08:00
): void;
2022-11-19 11:30:14 +08:00
/**
*
* @param fn
*/
cancelGlobalDrag(fn: DragFn): void;
2022-11-14 17:11:23 +08:00
/**
*
* @param ele
* @param fn
*/
useWheel(
ele: HTMLElement,
fn: (x: number, y: number, z: number, e: WheelEvent) => void
): void;
2022-11-16 23:01:23 +08:00
2022-11-19 11:30:14 +08:00
/**
*
* @param ele
* @param fn
*/
useUp(ele: HTMLElement, fn: DragFn): void;
2022-11-13 18:02:05 +08:00
}
2023-02-28 17:49:34 +08:00
interface GamePluginSkillTree {
2022-12-30 15:25:58 +08:00
/**
*
* @param skill
*/
getSkillLevel(skill: number): number;
2022-12-30 23:28:27 +08:00
/**
*
* @param index
*/
getSkillFromIndex(index: number): Skill;
/**
*
* @param skill
*/
getSkillConsume(skill: number): number;
/**
*
* @param skill
*/
upgradeSkill(skill: number): boolean;
/**
*
*/
saveSkillTree(): number[];
/**
*
* @param data
*/
loadSkillTree(data: number[]): void;
}
2023-01-01 22:02:58 +08:00
interface MiniMap {
/**
*
*/
splitArea(): void;
}
2023-02-28 17:49:34 +08:00
interface GamePluginStudy {
2023-01-05 22:21:40 +08:00
/**
*
* @param enemy
* @param num
*/
studySkill(enemy: Enemy, num: number): void;
}
2023-02-28 17:49:34 +08:00
interface GamePluginHeroRealStatus {
/**
*
* @param name
* @param x
* @param y
* @param floorId
*/
getHeroStatusOn(
name: 'all',
x?: number,
y?: number,
floorId?: FloorIds
): HeroStatus;
getHeroStatusOn(
name: (keyof HeroStatus)[],
x?: number,
y?: number,
floorId?: FloorIds
): Partial<HeroStatus>;
getHeroStatusOn<K extends keyof HeroStatus>(
name: K,
x?: number,
y?: number,
floorId?: FloorIds
): HeroStatus[K];
/**
*
* @param status
* @param name
* @param x
* @param y
* @param floorId
*/
getHeroStatusOf(
status: Partial<HeroStatus>,
name: 'all',
x?: number,
y?: number,
floorId?: FloorIds
): HeroStatus;
getHeroStatusOf(
status: Partial<HeroStatus>,
name: (keyof HeroStatus)[],
x?: number,
y?: number,
floorId?: FloorIds
): Partial<HeroStatus>;
getHeroStatusOf<K extends keyof HeroStatus>(
status: Partial<HeroStatus>,
name: K,
x?: number,
y?: number,
floorId?: FloorIds
): HeroStatus[K];
}
2023-02-23 23:10:57 +08:00
interface PluginAchievement {
/**
*
* @param type
* @param index
*/
completeAchievement(type: AchievementType, index: number): void;
/**
*
* @param type
* @param index
*/
hasCompletedAchievement(type: AchievementType, index: number): boolean;
/**
*
*/
getNowPoint(): number;
/**
*
*/
checkVisitedFloor(): void;
}
2023-04-24 20:27:21 +08:00
interface PluginReplay {
ready(): void;
readyClip(): number;
clip(...replace: string[]): void;
}
2023-04-29 11:25:18 +08:00
interface PluginChase {
chaseInit1(): void;
}
2023-04-22 17:01:35 +08:00
interface SkillEffects {
jumpIgnoreFloor: FloorIds[];
}
type Chapter = 'chapter1' | 'chapter2';
2022-12-30 23:28:27 +08:00
interface Skill {
index: number;
title: string;
desc: string[];
consume: string;
front: LocArr[];
loc: LocArr;
max: number;
effect: string[];
2022-12-30 15:25:58 +08:00
}
2022-11-13 18:02:05 +08:00
type Forward<T> = {
[K in keyof T as T[K] extends Function
? K extends `_${string}`
? never
: K
: never]: T[K];
};
type ForwardKeys<T> = keyof Forward<T>;