type: 注明弃用api

This commit is contained in:
unanmed 2024-08-29 02:18:41 +08:00
parent 470be5edba
commit ef50b985cb
9 changed files with 100 additions and 426 deletions

View File

@ -218,6 +218,7 @@ interface Control {
readonly controlData: ControlData;
/**
* @deprecated
* animationFrame
* @param name 使
* @param needPlaying
@ -230,6 +231,7 @@ interface Control {
): void;
/**
* @deprecated
* animationFrame
* @param name
*/
@ -313,7 +315,7 @@ interface Control {
/**
* @deprecated 使使使 `eventMoveHero`
* 使 `moveHero`
* 使
*
* @example core.moveAction(core.doAction); // 尝试前进一步,然后继续事件处理
* @param callback
@ -397,6 +399,7 @@ interface Control {
): void;
/**
* @deprecated
*
* @param canvasId ts的说法应该只能填数字
*
@ -410,6 +413,7 @@ interface Control {
): void;
/**
* @deprecated
*
* @param x
* @param y
@ -471,11 +475,13 @@ interface Control {
nearHero(x: number, y: number, n?: number): boolean;
/**
* @deprecated
*
*/
gatherFollowers(): void;
/**
* @deprecated
*
*/
updateFollowers(): void;
@ -942,6 +948,7 @@ interface Control {
unregisterWeather(name: string): void;
/**
* @deprecated
* 使core.events._action_setCurtain()
* @example core.setCurtain(); // 恢复画面色调,用时四分之三秒
* @param color [0, 0, 0, 0]
@ -957,6 +964,7 @@ interface Control {
): void;
/**
* @deprecated
*
* @example core.screenFlash([255, 0, 0, 1], 3); // 红屏一闪而过
* @param color
@ -974,6 +982,7 @@ interface Control {
): void;
/**
* @deprecated
* flags.__bgm__
* @example core.playBgm('bgm.mp3', 30); // 播放bgm.mp3并跳过前半分钟
* @param bgm
@ -982,26 +991,31 @@ interface Control {
playBgm(bgm: BgmIds | NameMapIn<BgmIds>, startTime?: number): void;
/**
* @deprecated
*
*/
pauseBgm(): void;
/**
* @deprecated
*
*/
resumeBgm(resumeTime?: number): void;
/**
* @deprecated
*
*/
setMusicBtn(): void;
/**
* @deprecated
*
*/
triggerBgm(): void;
/**
* @deprecated
*
* @param sound
* @param pitch 100
@ -1015,18 +1029,21 @@ interface Control {
): number;
/**
* @deprecated
*
* @param id
*/
stopSound(id?: number): void;
/**
* @deprecated
* id列表
* @param name
*/
getPlayingSounds(name?: SoundIds | NameMapIn<SoundIds>): number[];
/**
* @deprecated
* bgm状态
*/
checkBgm(): void;
@ -1067,6 +1084,7 @@ interface Control {
setToolbarButton(useButton?: boolean): void;
/**
* @deprecated
* resize函数
* @param name 使
* @param func
@ -1074,11 +1092,13 @@ interface Control {
registerResize(name: string, func: ResizeFunc): void;
/**
* @deprecated
* resize函数
*/
unregisterResize(name: string): void;
/**
* @deprecated
*
*/
resize(): void;

81
src/types/enemy.d.ts vendored
View File

@ -128,87 +128,6 @@ interface EnemySpecialBase {
special: number[];
}
interface EnemyInfoBase extends EnemySpecialBase {
/**
*
*/
hp: number;
/**
*
*/
atk: number;
/**
*
*/
def: number;
/**
*
*/
money: number;
/**
*
*/
exp: number;
/**
*
*/
point: number;
}
interface EnemyInfo extends EnemyInfoBase {
/**
*
*/
guards: [x: number, y: number, id: EnemyIds];
}
interface DamageInfo {
/**
*
*/
mon_hp: number;
/**
*
*/
mon_atk: number;
/**
*
*/
mon_def: number;
/**
*
*/
init_damage: number;
/**
*
*/
per_damage: number;
/**
*
*/
hero_per_damage: number;
/**
*
*/
turn: number;
/**
*
*/
damage: number;
}
interface BookEnemyInfo extends Enemy, EnemyInfo {
/**
*

View File

@ -714,6 +714,7 @@ interface Events extends EventData {
eventMoveHero(steps: Step[], time?: number, callback?: () => void): void;
/**
* @deprecated
* ex和ey为目标点的坐标null表示原地跳跃time为总跳跃时间
* @example core.jumpHero(); // 主角原地跳跃半秒
* @param ex

View File

@ -1,5 +1,6 @@
interface ActionData {
/**
* @deprecated
*
* @param keyCode keyCode
* @param altKey alt键
@ -40,6 +41,7 @@ interface ControlData {
moveDirectly(x: number, y: number, ignoreSteps?: number): boolean;
/**
* @deprecated
*
* @param time
*/

View File

@ -3,6 +3,7 @@
*/
interface Loader {
/**
* @deprecated
*
* @param dir
* @param names
@ -17,6 +18,7 @@ interface Loader {
): void;
/**
* @deprecated
*
* @param dir
* @param imgName
@ -29,6 +31,7 @@ interface Loader {
): void;
/**
* @deprecated
* zip中加载一系列图片
* @param url
* @param names
@ -42,24 +45,28 @@ interface Loader {
): void;
/**
* @deprecated
*
* @param name
*/
loadOneMusic(name: BgmIds): void;
/**
* @deprecated
*
* @param name
*/
loadOneSound(name: SoundIds): void;
/**
* @deprecated
* bgm
* @param name bgm的id或名称
*/
loadBgm(name: BgmIds | NameMapIn<BgmIds>): void;
/**
* @deprecated
* bgm的缓存
* @param name bgm的id或名称
*/

21
src/types/map.d.ts vendored
View File

@ -570,6 +570,7 @@ interface Maps {
compressMap(mapArr?: number[][], floorId?: FloorIds): number[][];
/**
* @deprecated
*
* @param opacity
* @param x
@ -584,6 +585,7 @@ interface Maps {
): void;
/**
* @deprecated
*
* @param filter
* @param x
@ -793,6 +795,7 @@ interface Maps {
automaticRoute(destX: number, destY: number): DiredLoc[];
/**
* @deprecated
*
* @param block
* @param animate
@ -801,12 +804,14 @@ interface Maps {
drawBlock(block?: Block, animate?: number, ctx?: CtxRefer): void;
/**
* @deprecated
* groundPattern
* @param floorId id
*/
generateGroundPattern(floorId?: FloorIds): void;
/**
* @deprecated
*
* @example core.drawMap(); // 绘制当前地图
* @param floorId id
@ -814,11 +819,13 @@ interface Maps {
drawMap(floorId?: FloorIds): void;
/**
* @deprecated
*
*/
redrawMap(): void;
/**
* @deprecated
*
* @example core.drawBg(); // 绘制当前地图的背景层
* @param floorId id
@ -827,6 +834,7 @@ interface Maps {
drawBg(floorId?: FloorIds, config?: Partial<DrawMapConfig>): void;
/**
* @deprecated
*
* @example core.drawEvents(); // 绘制当前地图的事件层
* @param floorId id
@ -840,6 +848,7 @@ interface Maps {
): void;
/**
* @deprecated
*
* @example core.drawFg(); // 绘制当前地图的前景层
* @param floorId id
@ -848,6 +857,7 @@ interface Maps {
drawFg(floorId?: FloorIds, config?: Partial<DrawMapConfig>): void;
/**
* @deprecated
*
* @example core.drawThumbnail(); // 绘制当前地图的缩略图
* @param floorId id
@ -1266,6 +1276,7 @@ interface Maps {
resetMap(floorId?: FloorIds | FloorIds[]): void;
/**
* @deprecated
*
* @example core.moveBlock(0, 0, ['down']); // 令地图左上角的图块下移一格,用时半秒,再花半秒淡出
* @param x
@ -1285,6 +1296,7 @@ interface Maps {
): void;
/**
* @deprecated
* V2.7
* @example core.jumpBlock(0, 0, 0, 0); // 令地图左上角的图块原地跳跃半秒,再花半秒淡出
* @param sx
@ -1342,6 +1354,7 @@ interface Maps {
drawBoxAnimate(): void;
/**
* @deprecated
* 使使core.drawHeroAnimate(name, callback)
* @example core.drawAnimate('attack', core.nextX(), core.nextY(), false, core.vibrate); // 在主角面前一格播放普攻动画动画停止后视野左右抖动1秒
* @param name
@ -1357,9 +1370,10 @@ interface Maps {
y: number,
alignWindow?: boolean,
callback?: () => void
): number;
): void;
/**
* @deprecated
*
* @param name
* @param callback
@ -1368,7 +1382,7 @@ interface Maps {
drawHeroAnimate(
name: AnimationIds | NameMapIn<AnimationIds>,
callback?: () => void
): number;
): void;
/**
* id列表
@ -1377,7 +1391,8 @@ interface Maps {
getPlayingAnimates(name?: AnimationIds): number[];
/**
*
* @deprecated
*
* @param id drawAnimate或drawHeroAnimate返回值
* @param doCallback
*/

344
src/types/plugin.d.ts vendored
View File

@ -1,11 +1,5 @@
// 这里包含所有插件导出的函数及变量声明声明的函数会在类型标注中标注到core上
type Ref<T> = {
value: T;
};
type DragFn = (x: number, y: number, e: MouseEvent | TouchEvent) => void;
type CanParseCss = keyof {
[P in keyof CSSStyleDeclaration as CSSStyleDeclaration[P] extends string
? P extends string
@ -14,341 +8,9 @@ type CanParseCss = keyof {
: never]: CSSStyleDeclaration[P];
};
interface PluginDeclaration
extends PluginUtils,
PluginUis,
PluginUse,
MiniMap,
PluginAchievement {
/**
*
*/
utils: GamePluginUtils;
loopMap: GamePluginLoopMap;
skillTree: GamePluginSkillTree;
study: GamePluginStudy;
hero: GamePluginHeroRealStatus;
replay: PluginReplay;
chase: PluginChase;
skills: Record<Chapter, Skill[]>;
skillEffects: SkillEffects;
/**
* 使core.addPop或core.plugin.addPop调用
* @param px
* @param py
* @param value
*/
addPop(px: number, py: number, value: string): void;
/** 添加变量 例所有的正在弹出的文字像这个就可以使用core.plugin.pop获取 */
pop: any[];
/** 状态栏信息,取反后刷新状态栏 */
readonly statusBarStatus: Ref<boolean>;
/**
*
* @param fn
*/
addAnimate(fn: (time: number) => void);
/**
*
* @param fn
*/
removeAnimate(fn: (time: number) => void);
/**
* undefined或null
* @param value
*/
has<T>(value: T): value is NonNullable<T>;
applyFragWith(
canvas: HTMLCanvasElement,
length?: number,
time?: number
): {
canvas: HTMLCanvasElement;
onEnd: Promise<void>;
animation: import('mutate-animate').Animation;
};
}
interface GamePluginUtils {
/**
* undefined或null
* @param value
*/
has<T>(value: T): value is NonNullable<T>;
/**
*
* @param arr
* @param delta
*/
slide<T>(arr: T[], delta: number): T[];
/**
*
* @param dir
*/
backDir(dir: Dir): Dir;
/**
*
* @param n
*/
maxGameScale(n?: number): void;
}
interface GamePluginLoopMap {
checkLoopMap(): void;
}
interface PluginUtils {
/**
* undefined或null
* @param value
*/
has<T>(value: T): value is NonNullable<T>;
/**
*
* @param damage
*/
getDamageColor(damage: number): string;
/**
* css字符串为CSSStyleDeclaration对象
* @param css css字符串
*/
parseCss(css: string): Partial<Record<CanParseCss, string>>;
/**
*
* @param text
*/
tip(
type: 'warn' | 'info' | 'success' | 'error' | 'warning' | 'loading',
text: string
): void;
/**
*
* @param index
*/
startChase(index: number): Promise<void>;
}
interface PluginUis {
/** 是否正在进行章节显示 */
readonly chapterShowed: Ref<boolean>;
/** 章节显示的内容 */
readonly chapterContent: Ref<boolean>;
/** 是否展示标记的怪物 */
readonly showMarkedEnemy: Ref<boolean>;
/**
*
*/
openSkill(): void;
}
interface PluginUse {
/** 是否是移动设备 */
readonly isMobile: boolean;
/**
*
* @param ele
* @param fn x y和鼠标事件或点击事件
* @param ondown
* @param global
*/
useDrag(
ele: HTMLElement,
fn: DragFn,
ondown?: DragFn,
onUp?: (e: MouseEvent | TouchEvent) => void,
global?: boolean
): void;
/**
*
* @param fn
*/
cancelGlobalDrag(fn: DragFn): void;
/**
*
* @param ele
* @param fn
*/
useWheel(
ele: HTMLElement,
fn: (x: number, y: number, z: number, e: WheelEvent) => void
): void;
/**
*
* @param ele
* @param fn
*/
useUp(ele: HTMLElement, fn: DragFn): void;
}
interface GamePluginSkillTree {
/**
*
* @param skill
*/
getSkillLevel(skill: number): number;
/**
*
* @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;
}
interface MiniMap {
/**
*
*/
splitArea(): void;
}
interface GamePluginStudy {
/**
*
* @param enemy
* @param num
*/
studySkill(enemy: Enemy, num: number): void;
}
interface GamePluginHeroRealStatus {
/**
*
* @param name
* @param x
* @param y
* @param floorId
*/
getHeroStatusOn(name: 'all', floorId?: FloorIds): HeroStatus;
getHeroStatusOn(
name: (keyof HeroStatus)[],
floorId?: FloorIds
): Partial<HeroStatus>;
getHeroStatusOn<K extends keyof HeroStatus>(
name: K,
floorId?: FloorIds
): HeroStatus[K];
/**
*
* @param status
* @param name
* @param x
* @param y
* @param floorId
*/
getHeroStatusOf(
status: Partial<HeroStatus>,
name: 'all',
floorId?: FloorIds
): HeroStatus;
getHeroStatusOf(
status: Partial<HeroStatus>,
name: (keyof HeroStatus)[],
floorId?: FloorIds
): Partial<HeroStatus>;
getHeroStatusOf<K extends keyof HeroStatus>(
status: Partial<HeroStatus>,
name: K,
floorId?: FloorIds
): HeroStatus[K];
}
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;
}
interface PluginReplay {
ready(): void;
readyClip(): number;
clip(...replace: string[]): void;
}
interface PluginChase {
chaseInit1(): void;
}
interface SkillEffects {
jumpIgnoreFloor: FloorIds[];
}
type Chapter = 'chapter1' | 'chapter2';
interface Skill {
index: number;
title: string;
desc: string[];
consume: string;
front: LocArr[];
loc: LocArr;
max: number;
effect: string[];
interface PluginDeclaration {
init(): void;
_afterLoadResouce(): void;
}
type Forward<T> = {

41
src/types/ui.d.ts vendored
View File

@ -213,12 +213,14 @@ interface Ui {
uidata: UiData;
/**
* @deprecated
* contextnull
* context自身
*/
getContextByName(canvas: CtxRefer): CanvasRenderingContext2D | null;
/**
* @deprecated
*
* name为画布名context本身
* name也可以是'all'all则为清空所有系统画布
@ -232,6 +234,7 @@ interface Ui {
): void;
/**
* @deprecated
*
* @param text
* @param style
@ -249,6 +252,7 @@ interface Ui {
): void;
/**
* @deprecated
*
* @param name
* @param text
@ -263,6 +267,7 @@ interface Ui {
): void;
/**
* @deprecated
*
* @param text
* @param style
@ -283,6 +288,7 @@ interface Ui {
): void;
/**
* @deprecated
*
* @param style
* @param angle
@ -298,6 +304,7 @@ interface Ui {
): void;
/**
* @deprecated
*
* @param style
* @param angle
@ -314,6 +321,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个圆角矩形
*/
fillRoundRect(
@ -328,6 +336,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个圆角矩形的边框
*/
strokeRoundRect(
@ -343,6 +352,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个多边形
*/
fillPolygon(
@ -352,6 +362,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个多边形的边框
*/
strokePolygon(
@ -362,6 +373,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个椭圆
* @param a
* @param b
@ -378,6 +390,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个圆
*/
fillCircle(
@ -389,6 +402,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个椭圆的边框
* @param a
* @param b
@ -406,6 +420,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个圆的边框
*/
strokeCircle(
@ -418,6 +433,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个扇形
*/
fillArc(
@ -431,6 +447,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一段弧
*/
strokeArc(
@ -445,6 +462,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一条线
*/
drawLine(
@ -458,6 +476,7 @@ interface Ui {
): void;
/**
* @deprecated
* canvas上绘制一个箭头
*/
drawArrow(
@ -471,67 +490,80 @@ interface Ui {
): void;
/**
* @deprecated
* canvas的文字字体
*/
setFont(name: CtxRefer, font: string): void;
/**
* @deprecated
* canvas的线宽度
*/
setLineWidth(name: CtxRefer, lineWidth: number): void;
/**
* @deprecated
* canvas状态
*/
saveCanvas(name: CtxRefer): void;
/**
* @deprecated
* 退canvas状态
*/
loadCanvas(name: CtxRefer): void;
/**
* @deprecated
* canvas的绘制不透明度
* @returns
*/
setAlpha(name: CtxRefer, alpha: number): number;
/**
* @deprecated
*
*/
setOpacity(name: CtxRefer, opacity: number): void;
/**
* @deprecated
* canvas的滤镜
*/
setFilter(name: CtxRefer, filter?: string): void;
/**
* @deprecated
* canvas的填充样式
*/
setFillStyle(name: CtxRefer, style: CanvasStyle): void;
/**
* @deprecated
* canvas描边样式
*/
setStrokeStyle(name: CtxRefer, style: CanvasStyle): void;
/**
* @deprecated
* canvas的文字左右对齐方式
*/
setTextAlign(name: CtxRefer, align: CanvasTextAlign): void;
/**
* @deprecated
* canvas的文字上下对齐方式
*/
setTextBaseline(name: CtxRefer, baseline: CanvasTextBaseline): void;
/**
* @deprecated
*
*/
calWidth(name: CtxRefer, text: string, font?: string): number;
/**
* @deprecated
*
*/
splitLines(
@ -542,12 +574,14 @@ interface Ui {
): string[];
/**
* @deprecated
*
* @param dx
* @param dy
*/
drawImage(name: CtxRefer, image: ImageSource, dx: number, dy: number): void;
/**
* @deprecated
*
* @param dx
* @param dy
@ -563,6 +597,7 @@ interface Ui {
dh: number
): void;
/**
* @deprecated
*
* @param sx
* @param sy
@ -756,6 +791,7 @@ interface Ui {
getToolboxItems<T extends Exclude<ItemCls, 'items'>>(cls: T): ItemIdOf<T>[];
/**
* @deprecated
*
* @param name
* @param x
@ -776,6 +812,7 @@ interface Ui {
): CanvasRenderingContext2D;
/**
* @deprecated
*
*/
relocateCanvas(
@ -786,6 +823,7 @@ interface Ui {
): void;
/**
* @deprecated
*
*/
rotateCanvas(
@ -796,6 +834,7 @@ interface Ui {
): void;
/**
* @deprecated
*
* @param styleOnly styletrue
* @param isTempCanvas true
@ -809,11 +848,13 @@ interface Ui {
): void;
/**
* @deprecated
*
*/
deleteCanvas(name: string | ((name: string) => boolean)): void;
/**
* @deprecated
*
*/
deleteAllCanvas(): void;

7
src/types/util.d.ts vendored
View File

@ -68,6 +68,7 @@ interface Utils {
decompress(value: string): any;
/**
* @deprecated
*
* @param key
* @param value
@ -75,6 +76,7 @@ interface Utils {
setLocalStorage(key: string, value?: any): void;
/**
* @deprecated
*
* @param key
* @param defaultValue
@ -82,6 +84,7 @@ interface Utils {
getLocalStorage<T>(key: string, defaultValue?: T): T;
/**
* @deprecated
*
* @param key
*/
@ -168,6 +171,7 @@ interface Utils {
getGlobal<T>(key: string, defaultValue?: T): T;
/**
* @deprecated
* ()
* @example core.clone(core.status.hero, (name, value) => (name == 'items' || typeof value == 'number'), false); // 深拷贝主角的属性和道具
* @param data
@ -182,6 +186,7 @@ interface Utils {
): T;
/**
* @deprecated
* 1D或2D的数组
* @param data
*/
@ -294,6 +299,7 @@ interface Utils {
decodeRoute(route: string): string[];
/**
* @deprecated
* nullundefined和NaN
* @example core.isset(0/0); // false因为0/0等于NaN
* @param v
@ -334,6 +340,7 @@ interface Utils {
getCookie(name: string): string;
/**
* @deprecated
*
* @example
* // 更新状态栏中的主角生命,使用加载画面的宣传色