From cb4b24106d3a39ba2564c3935e74bb79821dd401 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 2 Mar 2024 19:27:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/project/plugins.js | 4 ++++ src/game/enemy/damage.ts | 4 ++-- src/types/util.d.ts | 16 ++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/public/project/plugins.js b/public/project/plugins.js index e648d8d..8cafc4c 100644 --- a/public/project/plugins.js +++ b/public/project/plugins.js @@ -578,6 +578,10 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { battle: function () { // 这个插件负责战斗相关内容 + // 注意,对于电脑作者,极度推荐使用 vscode 进行代码编写,可以享受到新版的类型标注 + // 同时由于类型标注过于复杂,样板编辑器无法部署,因此样板编辑器也无法享受到新API的代码补全等 + // 因此极度推荐使用 vscode 进行编写 + // --------------- 战后脚本 // enemy: DamageEnemy实例,也就是怪物本身 // x, y: 怪物坐标 diff --git a/src/game/enemy/damage.ts b/src/game/enemy/damage.ts index 388f9c2..6837eaf 100644 --- a/src/game/enemy/damage.ts +++ b/src/game/enemy/damage.ts @@ -644,8 +644,8 @@ export namespace Damage { * @param hero 勇士信息 */ export function calDamageWith( - info: EnemyInfo, - hero: Partial + info: DeepReadonly, + hero: DeepReadonly> ): number | null { return null; } diff --git a/src/types/util.d.ts b/src/types/util.d.ts index 3793852..9f6a046 100644 --- a/src/types/util.d.ts +++ b/src/types/util.d.ts @@ -820,31 +820,27 @@ type Save = DeepReadonly<{ time: number; }>; +type ValueType = number | string | boolean | undefined | null | bigint | symbol; + /** * 深度只读一个对象,使其所有属性都只读 */ type DeepReadonly = { - readonly [P in keyof T]: T[P] extends number | string | boolean - ? T[P] - : DeepReadonly; + readonly [P in keyof T]: T[P] extends ValueType ? T[P] : DeepReadonly; }; /** * 深度可选一个对象,使其所有属性都可选 */ type DeepPartial = { - [P in keyof T]?: T[P] extends number | string | boolean - ? T[P] - : DeepPartial; + [P in keyof T]?: T[P] extends ValueType ? T[P] : DeepPartial; }; /** * 深度必选一个对象,使其所有属性都必选 */ type DeepRequired = { - [P in keyof T]-?: T[P] extends number | string | boolean - ? T[P] - : DeepRequired; + [P in keyof T]-?: T[P] extends ValueType ? T[P] : DeepRequired; }; /** @@ -858,7 +854,7 @@ type Writable = { * 深度可写一个对象,使其所有属性都可写 */ type DeepWritable = { - -readonly [P in keyof T]: T[P] extends number | string | boolean + -readonly [P in keyof T]: T[P] extends ValueType ? T[P] : DeepWritable; };