mirror of
https://github.com/motajs/template.git
synced 2026-05-21 18:31:11 +08:00
Compare commits
3 Commits
92ff489811
...
79d06c31df
| Author | SHA1 | Date | |
|---|---|---|---|
| 79d06c31df | |||
| 4d9c6720aa | |||
| eaa725553b |
62
dev.md
Normal file
62
dev.md
Normal file
@ -0,0 +1,62 @@
|
||||
# 魔塔样板开发说明
|
||||
|
||||
## 项目结构
|
||||
|
||||
`public`: mota-js 样板所在目录。
|
||||
`packages`: 核心引擎代码 monorepo。
|
||||
`packages-user`: 用户代码 monorepo。
|
||||
`src`: 游戏入口代码。
|
||||
|
||||
`packages` `packages-user` 可以单独打包为库模式,`src` 单向引用 `packages-user`,`packages-user` 单向引用 `packages`,`src` 为游戏的入口代码。
|
||||
|
||||
## 开发环境
|
||||
|
||||
- `node.js ^20.0.0 || >=22.0.0`
|
||||
- `pnpm >= 10.0.0`
|
||||
- 任意支持 `ESNext` 特性的浏览器
|
||||
|
||||
**建议使用 `vscode`,搭配 `prettier` `eslint` 插件**
|
||||
|
||||
## 开发说明
|
||||
|
||||
1. 将项目拉取到本地。
|
||||
2. 运行 `pnpm i` 安装所有依赖,如有要求运行 `pnpm approve-builds`,请允许全部。
|
||||
3. 运行 `pnpm dev` 进入开发环境。
|
||||
|
||||
## 构建说明
|
||||
|
||||
- `pnpm build:packages`: 构建所有 `packages` 文件夹下的内容,使用库模式。
|
||||
- `pnpm build:game`: 构建为可以直接部署的构建包。
|
||||
- `pnpm build:lib`: 构建所有 `packages` `packages-user` 文件夹下的内容,使用库模式。
|
||||
|
||||
## 开发原则
|
||||
|
||||
- 模块无副作用原则:
|
||||
- 所有模块不包含副作用内容,全部由函数、类、常量的声明组成,不出现导出的变量声明、代码执行内容,允许但不建议编写类的静态块。
|
||||
- 如果需要模块初始化,编写一个 `createXxx` 函数,然后在 `index.ts` 中整合,再逐级向上传递,直至遇到包含 `create` 函数的 `index.ts`,所有初始化将会统一在顶层模块中执行。
|
||||
- 命名规则:
|
||||
- 变量、成员、一般常量、方法、函数使用小驼峰。
|
||||
- 类、接口、类型别名、命名空间、泛型、枚举、组件使用大驼峰。
|
||||
- 不变常量使用全大写命名法,单词之间使用下划线连接。
|
||||
- 专有名词缩写如 `HTTP`, `URI` 全部大写。
|
||||
- 会被 `implements` 的接口使用大写 `I` 开头。
|
||||
- `id`, `class` 等 `HTML/CSS` 内容使用连字符命名法。
|
||||
- 不使用下划线命名法。
|
||||
- 注释:
|
||||
- 常用属性成员、方法、接口、类型必须添加 `jsDoc` 注释。
|
||||
- 长文件可使用 `#region` 分段,可以写上 `#endretion` 允许折叠。
|
||||
- TODO 使用 `// TODO:` 或 `// todo:` 格式。
|
||||
- 单行注释的双斜杠与注释内容之间添加一个空格,多行注释只允许出现 `jsDoc` 注释,如果需要多行非 `jsDoc` 注释,使用多个单行注释。
|
||||
- 类型:
|
||||
- 不允许出现非必要的 `any` 类型。
|
||||
- 所有类的成员必须显式声明类型。
|
||||
- 如果有无法避免出现类型错误的地方,使用 `// @ts-expect-error` 标记,并填写原因。
|
||||
- 没用到的变量、方法使用下划线开头。
|
||||
- 合理运用 `readonly` `protected` `private` 关键字。
|
||||
- 函数不建议使用过多可选参数,如果可选参数过多,可以考虑换用对象。
|
||||
- 尽量少地使用 `as` 关键字进行类型断言,一般情况下不建议进行任何 `as` 类型断言。
|
||||
- 其他要求:
|
||||
- 严格遵循 `eslint` 配置,不允许出现 `eslint` 报错。
|
||||
- 尽量不使用 `?.` 运算符,一般建议仅在副作用函数调用(如 `this.obj?.func()`,`this.obj.func?.()`),或对象 `Required` 化(如 `{ value: obj?.value ?? 0 }`)中使用 `?.` 运算符。
|
||||
- 只进行必要的非空判断,不必要的非空判断直接使用非空断言 `!` 实现。
|
||||
- 除非参数要求传入函数等情况,不建议在函数内写任何局部函数。
|
||||
@ -16,7 +16,7 @@ export async function createMainExtension() {
|
||||
mainMapRenderer.useAsset(materials.trackedAsset);
|
||||
const layer = state.layer.getLayerByAlias('event');
|
||||
if (layer) {
|
||||
mainMapExtension.addHero(state.hero, layer);
|
||||
mainMapExtension.addHero(state.hero.mover, layer);
|
||||
mainMapExtension.addDoor(layer);
|
||||
}
|
||||
mainMapExtension.addText();
|
||||
|
||||
@ -8,17 +8,20 @@ import {
|
||||
IEnemyCommonQueryEffect,
|
||||
IEnemyContext,
|
||||
IEnemyFinalEffect,
|
||||
IEnemyHandler,
|
||||
IEnemySpecialModifier,
|
||||
IEnemySpecialQueryEffect,
|
||||
IEnemyView,
|
||||
IMapDamage,
|
||||
IReadonlyEnemy,
|
||||
IReadonlyEnemyHandler,
|
||||
ISpecial
|
||||
} from './types';
|
||||
import { EnemyView } from './enemy';
|
||||
import { MapLocIndexer } from './utils';
|
||||
import { IReadonlyHeroAttribute } from '../hero';
|
||||
|
||||
export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
export class EnemyContext<TAttr, THero> implements IEnemyContext<TAttr, THero> {
|
||||
private readonly enemyViewMap: Map<number, EnemyView<TAttr>> = new Map();
|
||||
private readonly enemyMap: Map<number, IEnemy<TAttr>> = new Map();
|
||||
private readonly locatorViewMap: Map<IEnemyView<TAttr>, number> = new Map();
|
||||
@ -28,23 +31,26 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
EnemyView<TAttr>
|
||||
> = new Map();
|
||||
|
||||
private readonly auraConverter: Set<IAuraConverter<TAttr>> = new Set();
|
||||
private readonly converterStatus: Map<IAuraConverter<TAttr>, boolean> =
|
||||
new Map();
|
||||
private readonly auraConverter: Set<IAuraConverter<TAttr, THero>> =
|
||||
new Set();
|
||||
private readonly converterStatus: Map<
|
||||
IAuraConverter<TAttr, THero>,
|
||||
boolean
|
||||
> = new Map();
|
||||
private readonly convertedAura: Map<ISpecial<any>, IAuraView<TAttr>> =
|
||||
new Map();
|
||||
|
||||
private readonly commonQueryMap: Map<
|
||||
number,
|
||||
IEnemyCommonQueryEffect<TAttr>[]
|
||||
IEnemyCommonQueryEffect<TAttr, THero>[]
|
||||
> = new Map();
|
||||
|
||||
private readonly specialQueryEffects: Map<
|
||||
number,
|
||||
IEnemySpecialQueryEffect<TAttr>[]
|
||||
IEnemySpecialQueryEffect<TAttr, THero>[]
|
||||
> = new Map();
|
||||
|
||||
private readonly finalEffects: IEnemyFinalEffect<TAttr>[] = [];
|
||||
private readonly finalEffects: IEnemyFinalEffect<TAttr, THero>[] = [];
|
||||
private readonly globalAuraList: Set<IAuraView<TAttr>> = new Set();
|
||||
private readonly sortedAura: Map<number, Set<IAuraView<TAttr>>> = new Map();
|
||||
|
||||
@ -52,10 +58,17 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
private readonly requestedCommonContext: Set<IEnemyView<TAttr>> = new Set();
|
||||
private readonly dirtyEnemy: Set<IEnemyView<TAttr>> = new Set();
|
||||
|
||||
private mapDamage: IMapDamage<TAttr> | null = null;
|
||||
private damageSystem: IDamageSystem<TAttr, unknown> | null = null;
|
||||
/** 当前绑定的勇士属性对象 */
|
||||
private bindedHero: IReadonlyHeroAttribute<THero> | null = null;
|
||||
/** 地图伤害对象 */
|
||||
private mapDamage: IMapDamage<TAttr, THero> | null = null;
|
||||
/** 伤害系统对象 */
|
||||
private damageSystem: IDamageSystem<TAttr, THero> | null = null;
|
||||
|
||||
/** 索引工具 */
|
||||
readonly indexer: MapLocIndexer = new MapLocIndexer();
|
||||
|
||||
/** 当前是否需要全量刷新 */
|
||||
private needUpdate: boolean = true;
|
||||
|
||||
built: boolean = false;
|
||||
@ -70,20 +83,20 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
this.needUpdate = true;
|
||||
}
|
||||
|
||||
registerAuraConverter(converter: IAuraConverter<TAttr>): void {
|
||||
registerAuraConverter(converter: IAuraConverter<TAttr, THero>): void {
|
||||
this.auraConverter.add(converter);
|
||||
this.converterStatus.set(converter, true);
|
||||
this.needUpdate = true;
|
||||
}
|
||||
|
||||
unregisterAuraConverter(converter: IAuraConverter<TAttr>): void {
|
||||
unregisterAuraConverter(converter: IAuraConverter<TAttr, THero>): void {
|
||||
this.auraConverter.delete(converter);
|
||||
this.converterStatus.delete(converter);
|
||||
this.needUpdate = true;
|
||||
}
|
||||
|
||||
setAuraConverterEnabled(
|
||||
converter: IAuraConverter<TAttr>,
|
||||
converter: IAuraConverter<TAttr, THero>,
|
||||
enabled: boolean
|
||||
): void {
|
||||
if (!this.auraConverter.has(converter)) return;
|
||||
@ -93,7 +106,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
|
||||
registerCommonQueryEffect(
|
||||
code: number,
|
||||
effect: IEnemyCommonQueryEffect<TAttr>
|
||||
effect: IEnemyCommonQueryEffect<TAttr, THero>
|
||||
): void {
|
||||
const array = this.commonQueryMap.getOrInsert(code, []);
|
||||
array.push(effect);
|
||||
@ -103,7 +116,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
|
||||
unregisterCommonQueryEffect(
|
||||
code: number,
|
||||
effect: IEnemyCommonQueryEffect<TAttr>
|
||||
effect: IEnemyCommonQueryEffect<TAttr, THero>
|
||||
): void {
|
||||
const array = this.commonQueryMap.get(code);
|
||||
if (!array) return;
|
||||
@ -113,14 +126,16 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
this.needUpdate = true;
|
||||
}
|
||||
|
||||
registerSpecialQueryEffect(effect: IEnemySpecialQueryEffect<TAttr>): void {
|
||||
registerSpecialQueryEffect(
|
||||
effect: IEnemySpecialQueryEffect<TAttr, THero>
|
||||
): void {
|
||||
const list = this.specialQueryEffects.getOrInsert(effect.priority, []);
|
||||
list.push(effect);
|
||||
this.needUpdate = true;
|
||||
}
|
||||
|
||||
unregisterSpecialQueryEffect(
|
||||
effect: IEnemySpecialQueryEffect<TAttr>
|
||||
effect: IEnemySpecialQueryEffect<TAttr, THero>
|
||||
): void {
|
||||
const list = this.specialQueryEffects.get(effect.priority);
|
||||
if (!list) return;
|
||||
@ -134,13 +149,13 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
this.needUpdate = true;
|
||||
}
|
||||
|
||||
registerFinalEffect(effect: IEnemyFinalEffect<TAttr>): void {
|
||||
registerFinalEffect(effect: IEnemyFinalEffect<TAttr, THero>): void {
|
||||
this.finalEffects.push(effect);
|
||||
this.finalEffects.sort((a, b) => b.priority - a.priority);
|
||||
this.needUpdate = true;
|
||||
}
|
||||
|
||||
unregisterFinalEffect(effect: IEnemyFinalEffect<TAttr>): void {
|
||||
unregisterFinalEffect(effect: IEnemyFinalEffect<TAttr, THero>): void {
|
||||
const index = this.finalEffects.indexOf(effect);
|
||||
if (index !== -1) {
|
||||
this.finalEffects.splice(index, 1);
|
||||
@ -148,6 +163,29 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
this.needUpdate = true;
|
||||
}
|
||||
|
||||
bindHero(hero: IReadonlyHeroAttribute<THero> | null): void {
|
||||
this.bindedHero = hero;
|
||||
this.needUpdate = true;
|
||||
this.damageSystem?.bindHeroStatus(hero);
|
||||
this.mapDamage?.refreshAll();
|
||||
}
|
||||
|
||||
getBindedHero(): IReadonlyHeroAttribute<THero> | null {
|
||||
return this.bindedHero;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建可修改信息对象
|
||||
* @param enemy 怪物对象
|
||||
* @param locator 怪物位置
|
||||
*/
|
||||
private createHandler(
|
||||
enemy: IEnemy<TAttr>,
|
||||
locator: ITileLocator
|
||||
): IEnemyHandler<TAttr, THero> {
|
||||
return { enemy, locator, hero: this.bindedHero! };
|
||||
}
|
||||
|
||||
getEnemyLocator(enemy: IEnemy<TAttr>): Readonly<ITileLocator> | null {
|
||||
const index = this.locatorEnemyMap.get(enemy);
|
||||
if (index === undefined) return null;
|
||||
@ -177,7 +215,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定索引位置的怪物以及与之关联的所有运行时状态。
|
||||
* 删除指定索引位置的怪物以及与之关联的所有运行时状态
|
||||
* @param index 地图索引
|
||||
*/
|
||||
private deleteEnemyAt(index: number) {
|
||||
@ -231,14 +269,14 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在指定范围内筛选出当前上下文中的怪物视图。
|
||||
* 在指定范围内筛选出当前上下文中的怪物视图
|
||||
* @param range 范围对象
|
||||
* @param param 范围参数
|
||||
*/
|
||||
private *internalScanRange<T>(
|
||||
range: IRange<T>,
|
||||
param: T
|
||||
): Iterable<EnemyView<TAttr>> {
|
||||
): Iterable<[ITileLocator, EnemyView<TAttr>]> {
|
||||
range.bindHost(this);
|
||||
const keys = new Set(this.enemyViewMap.keys());
|
||||
const matched = range.autoDetect(keys, param);
|
||||
@ -246,12 +284,16 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
for (const index of matched) {
|
||||
const view = viewMap.get(index);
|
||||
if (view) {
|
||||
yield view;
|
||||
const locator = this.indexer.indexToLocator(index);
|
||||
yield [locator, view];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scanRange<T>(range: IRange<T>, param: T): Iterable<IEnemyView<TAttr>> {
|
||||
scanRange<T>(
|
||||
range: IRange<T>,
|
||||
param: T
|
||||
): Iterable<[ITileLocator, IEnemyView<TAttr>]> {
|
||||
return this.internalScanRange(range, param);
|
||||
}
|
||||
|
||||
@ -272,44 +314,42 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
this.needUpdate = true;
|
||||
}
|
||||
|
||||
attachMapDamage(damage: IMapDamage<TAttr> | null): void {
|
||||
attachMapDamage(damage: IMapDamage<TAttr, THero> | null): void {
|
||||
this.mapDamage = damage;
|
||||
if (damage) {
|
||||
damage.refreshAll();
|
||||
}
|
||||
}
|
||||
|
||||
getMapDamage(): IMapDamage<TAttr> | null {
|
||||
getMapDamage(): IMapDamage<TAttr, THero> | null {
|
||||
return this.mapDamage;
|
||||
}
|
||||
|
||||
attachDamageSystem(system: IDamageSystem<TAttr, unknown> | null): void {
|
||||
this.damageSystem = system;
|
||||
if (system) {
|
||||
system.markAllDirty();
|
||||
system.bindHeroStatus(this.bindedHero);
|
||||
}
|
||||
}
|
||||
|
||||
getDamageSystem<THero>(): IDamageSystem<TAttr, THero> | null {
|
||||
return this.damageSystem as IDamageSystem<TAttr, THero> | null;
|
||||
getDamageSystem(): IDamageSystem<TAttr, THero> | null {
|
||||
return this.damageSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将怪物身上的特殊属性尝试转换为光环视图。
|
||||
* 将怪物身上的特殊属性尝试转换为光环视图
|
||||
* @param special 特殊属性
|
||||
* @param enemy 怪物对象
|
||||
* @param locator 怪物位置
|
||||
*/
|
||||
private convertSpecial(
|
||||
special: ISpecial<any>,
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
locator: ITileLocator
|
||||
handler: IReadonlyEnemyHandler<TAttr, THero>
|
||||
): IEnemyAuraView<TAttr, any, any> | null {
|
||||
let matched: IAuraConverter<TAttr> | null = null;
|
||||
|
||||
let matched: IAuraConverter<TAttr, THero> | null = null;
|
||||
for (const converter of this.auraConverter) {
|
||||
if (!this.converterStatus.get(converter)) continue;
|
||||
if (converter.shouldConvert(special, enemy, locator)) {
|
||||
if (converter.shouldConvert(special, handler)) {
|
||||
if (matched) {
|
||||
logger.warn(97, special.code.toString());
|
||||
return null;
|
||||
@ -319,11 +359,11 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
if (!matched) return null;
|
||||
return matched.convert(special, enemy, locator, this);
|
||||
return matched.convert(special, handler, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将光环按优先级插入到有序表中。
|
||||
* 将光环按优先级插入到有序表中
|
||||
* @param aura 光环视图
|
||||
*/
|
||||
private insertIntoSortedAura(aura: IAuraView<TAttr>): void {
|
||||
@ -335,7 +375,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从优先级表中移除一个光环。
|
||||
* 从优先级表中移除一个光环
|
||||
* @param aura 光环视图
|
||||
*/
|
||||
private removeFromSortedAura(aura: IAuraView<TAttr>): void {
|
||||
@ -349,7 +389,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行特殊属性修饰器,并返回因此受到影响的光环集合。
|
||||
* 执行特殊属性修饰器,并返回因此受到影响的光环集合
|
||||
* @param modifier 特殊属性修饰器
|
||||
* @param enemy 目标怪物
|
||||
* @param locator 怪物位置
|
||||
@ -357,14 +397,13 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
*/
|
||||
private processSpecialModifier(
|
||||
modifier: IEnemySpecialModifier<TAttr>,
|
||||
enemy: IEnemy<TAttr>,
|
||||
locator: ITileLocator,
|
||||
handler: IEnemyHandler<TAttr, THero>,
|
||||
currentPriority: number
|
||||
): Set<IAuraView<TAttr>> {
|
||||
const toAdd = modifier.add(enemy, locator);
|
||||
const toDelete = modifier.delete(enemy, locator);
|
||||
|
||||
const enemy = handler.enemy;
|
||||
const affectedAuras = new Set<IAuraView<TAttr>>();
|
||||
const toAdd = modifier.add(handler);
|
||||
const toDelete = modifier.delete(handler);
|
||||
|
||||
if (toAdd.length > 0 && toDelete.length > 0) {
|
||||
logger.warn(100);
|
||||
@ -372,9 +411,9 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
for (const adding of toAdd) {
|
||||
const aura = this.convertSpecial(adding, enemy, locator);
|
||||
const aura = this.convertSpecial(adding, handler);
|
||||
if (aura) {
|
||||
// 新生成的光环只能影响之后的阶段,不能反过来影响当前优先级链。
|
||||
// 新生成的光环只能影响之后的阶段,不能反过来影响当前优先级链
|
||||
if (import.meta.env.DEV && aura.priority > currentPriority) {
|
||||
logger.warn(
|
||||
99,
|
||||
@ -410,7 +449,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
for (const special of enemy.iterateSpecials()) {
|
||||
const success = modifier.modify(enemy, special, locator);
|
||||
const success = modifier.modify(handler, special);
|
||||
if (!success) continue;
|
||||
const aura = this.convertedAura.get(special);
|
||||
if (!aura) continue;
|
||||
@ -429,12 +468,12 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行单个特殊查询效果。
|
||||
* 执行单个特殊查询效果
|
||||
* @param effect 特殊查询效果
|
||||
* @param currentPriority 当前处理的优先级
|
||||
*/
|
||||
private processSpecialQuery(
|
||||
effect: IEnemySpecialQueryEffect<TAttr>,
|
||||
effect: IEnemySpecialQueryEffect<TAttr, THero>,
|
||||
currentPriority: number
|
||||
): void {
|
||||
const modifier = effect.for(this);
|
||||
@ -442,13 +481,13 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
for (const [index, view] of this.enemyViewMap) {
|
||||
const locator = this.indexer.indexToLocator(index);
|
||||
const enemy = view.getComputingEnemy();
|
||||
const handler = this.createHandler(enemy, locator);
|
||||
|
||||
if (!modifier.shouldQuery(enemy, locator)) continue;
|
||||
if (!modifier.shouldQuery(handler)) continue;
|
||||
|
||||
const affectedAuras = this.processSpecialModifier(
|
||||
modifier,
|
||||
enemy,
|
||||
locator,
|
||||
handler,
|
||||
currentPriority
|
||||
);
|
||||
|
||||
@ -461,7 +500,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行光环带来的特殊属性修饰效果。
|
||||
* 执行光环带来的特殊属性修饰效果
|
||||
* @param aura 光环视图
|
||||
* @param currentPriority 当前处理的优先级
|
||||
*/
|
||||
@ -470,30 +509,22 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
currentPriority: number
|
||||
): void {
|
||||
const param = aura.getRangeParam();
|
||||
const iter = this.internalScanRange(aura.range, param);
|
||||
|
||||
for (const enemyView of this.internalScanRange(aura.range, param)) {
|
||||
const locator = this.getEnemyLocatorByView(enemyView);
|
||||
if (!locator) continue;
|
||||
|
||||
for (const [locator, enemyView] of iter) {
|
||||
const enemy = enemyView.getComputingEnemy();
|
||||
const base = enemyView.getBaseEnemy();
|
||||
const modifier = aura.applySpecial(enemy, base, locator);
|
||||
|
||||
const handler = this.createHandler(enemy, locator);
|
||||
const modifier = aura.applySpecial(handler, base);
|
||||
if (!modifier) continue;
|
||||
|
||||
this.processSpecialModifier(
|
||||
modifier,
|
||||
enemy,
|
||||
locator,
|
||||
currentPriority
|
||||
);
|
||||
|
||||
this.processSpecialModifier(modifier, handler, currentPriority);
|
||||
this.needTotallyRefresh.add(enemyView);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建所有由特殊属性衍生出的光环与特殊查询结果。
|
||||
* 构建所有由特殊属性衍生出的光环与特殊查询结果
|
||||
*/
|
||||
private buildupSpecials(): void {
|
||||
for (const aura of this.globalAuraList) {
|
||||
@ -503,9 +534,10 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
for (const [index, view] of this.enemyViewMap) {
|
||||
const enemy = view.getComputingEnemy();
|
||||
const locator = this.indexer.indexToLocator(index);
|
||||
const handler = this.createHandler(enemy, locator);
|
||||
|
||||
for (const special of enemy.iterateSpecials()) {
|
||||
const aura = this.convertSpecial(special, enemy, locator);
|
||||
const aura = this.convertSpecial(special, handler);
|
||||
if (!aura) continue;
|
||||
this.convertedAura.set(special, aura);
|
||||
this.insertIntoSortedAura(aura);
|
||||
@ -554,7 +586,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 按优先级执行所有基础属性光环效果。
|
||||
* 按优先级执行所有基础属性光环效果
|
||||
*/
|
||||
private buildupBase(): void {
|
||||
const priorities = [...this.sortedAura.keys()].sort((a, b) => b - a);
|
||||
@ -563,23 +595,25 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
if (!auras) continue;
|
||||
for (const aura of auras) {
|
||||
const param = aura.getRangeParam();
|
||||
for (const view of this.internalScanRange(aura.range, param)) {
|
||||
const iter = this.internalScanRange(aura.range, param);
|
||||
for (const [locator, view] of iter) {
|
||||
const enemy = view.getComputingEnemy();
|
||||
const base = view.getBaseEnemy();
|
||||
const locator = this.getEnemyLocatorByView(view)!;
|
||||
aura.apply(enemy, base, locator);
|
||||
const handler = this.createHandler(enemy, locator);
|
||||
aura.apply(handler, base);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行常规查询效果,并记录哪些怪物查询了上下文。
|
||||
* 执行常规查询效果,并记录哪些怪物查询了上下文
|
||||
*/
|
||||
private buildupQuery(): void {
|
||||
for (const [index, view] of this.enemyViewMap) {
|
||||
const enemy = view.getComputingEnemy();
|
||||
const locator = this.indexer.indexToLocator(index);
|
||||
const handler = this.createHandler(enemy, locator);
|
||||
let queried = false;
|
||||
const query = () => {
|
||||
queried = true;
|
||||
@ -589,7 +623,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
const effects = this.commonQueryMap.get(special.code);
|
||||
if (!effects) continue;
|
||||
for (const effect of effects) {
|
||||
effect.apply(enemy, special, query, locator);
|
||||
effect.apply(handler, special, query);
|
||||
}
|
||||
}
|
||||
if (queried) {
|
||||
@ -599,20 +633,25 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行最终效果阶段。
|
||||
* 执行最终效果阶段
|
||||
*/
|
||||
private buildupFinal(): void {
|
||||
for (const [index, view] of this.enemyViewMap) {
|
||||
const enemy = view.getComputingEnemy();
|
||||
const locator = this.indexer.indexToLocator(index);
|
||||
const handler = this.createHandler(enemy, locator);
|
||||
for (const effect of this.finalEffects) {
|
||||
effect.apply(enemy, locator);
|
||||
effect.apply(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildup(): void {
|
||||
if (!this.needUpdate) return;
|
||||
if (!this.bindedHero) {
|
||||
logger.warn(110);
|
||||
return;
|
||||
}
|
||||
this.needUpdate = false;
|
||||
this.sortedAura.clear();
|
||||
this.convertedAura.clear();
|
||||
@ -650,18 +689,18 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在局部刷新期间执行特殊属性修饰器,但不重建光环拓扑。
|
||||
* 在局部刷新期间执行特殊属性修饰器,但不重建光环拓扑
|
||||
* @param modifier 特殊属性修饰器
|
||||
* @param enemy 目标怪物
|
||||
* @param locator 怪物位置
|
||||
*/
|
||||
private refreshSpecialModifier(
|
||||
modifier: IEnemySpecialModifier<TAttr>,
|
||||
enemy: IEnemy<TAttr>,
|
||||
locator: ITileLocator
|
||||
handler: IEnemyHandler<TAttr, THero>
|
||||
): void {
|
||||
const toAdd = modifier.add(enemy, locator);
|
||||
const toDelete = modifier.delete(enemy, locator);
|
||||
const enemy = handler.enemy;
|
||||
const toAdd = modifier.add(handler);
|
||||
const toDelete = modifier.delete(handler);
|
||||
|
||||
if (toAdd.length > 0 && toDelete.length > 0) {
|
||||
logger.warn(100);
|
||||
@ -671,7 +710,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
for (const adding of toAdd) {
|
||||
enemy.addSpecial(adding);
|
||||
if (import.meta.env.DEV) {
|
||||
const aura = this.convertSpecial(adding, enemy, locator);
|
||||
const aura = this.convertSpecial(adding, handler);
|
||||
if (aura) {
|
||||
logger.warn(101, adding.code.toString());
|
||||
}
|
||||
@ -681,7 +720,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
for (const deleting of toDelete) {
|
||||
enemy.deleteSpecial(deleting);
|
||||
if (import.meta.env.DEV) {
|
||||
const aura = this.convertSpecial(deleting, enemy, locator);
|
||||
const aura = this.convertSpecial(deleting, handler);
|
||||
if (aura) {
|
||||
logger.warn(101, deleting.code.toString());
|
||||
}
|
||||
@ -689,7 +728,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
for (const special of enemy.iterateSpecials()) {
|
||||
const success = modifier.modify(enemy, special, locator);
|
||||
const success = modifier.modify(handler, special);
|
||||
if (import.meta.env.DEV && success) {
|
||||
const aura = this.convertedAura.get(special);
|
||||
if (aura) {
|
||||
@ -700,7 +739,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新单个怪物视图的计算结果。
|
||||
* 刷新单个怪物视图的计算结果
|
||||
* @param view 怪物视图
|
||||
*/
|
||||
private refreshEnemy(view: EnemyView<TAttr>): void {
|
||||
@ -710,6 +749,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
view.reset();
|
||||
const enemy = view.getComputingEnemy();
|
||||
const base = view.getBaseEnemy();
|
||||
const handler = this.createHandler(enemy, locator);
|
||||
|
||||
const specialPriorities = new Set<number>();
|
||||
for (const priority of this.sortedAura.keys()) {
|
||||
@ -725,30 +765,28 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
|
||||
for (const priority of orderedSpecialPriorities) {
|
||||
const auras = this.sortedAura.get(priority);
|
||||
const effects = this.specialQueryEffects.get(priority);
|
||||
|
||||
if (auras) {
|
||||
for (const aura of auras) {
|
||||
if (!aura.couldApplySpecial) continue;
|
||||
const param = aura.getRangeParam();
|
||||
aura.range.bindHost(this);
|
||||
// 局部刷新只重新判断“这个怪物是否被该光环命中”。
|
||||
const inRange = aura.range.inRange(
|
||||
locator.x,
|
||||
locator.y,
|
||||
param
|
||||
);
|
||||
if (!inRange) continue;
|
||||
const modifier = aura.applySpecial(enemy, base, locator);
|
||||
// 局部刷新只重新判断“这个怪物是否被该光环命中”
|
||||
if (!aura.range.inRange(locator.x, locator.y, param)) {
|
||||
continue;
|
||||
}
|
||||
const modifier = aura.applySpecial(handler, base);
|
||||
if (!modifier) continue;
|
||||
this.refreshSpecialModifier(modifier, enemy, locator);
|
||||
this.refreshSpecialModifier(modifier, handler);
|
||||
}
|
||||
}
|
||||
|
||||
const effects = this.specialQueryEffects.get(priority);
|
||||
if (effects) {
|
||||
for (const effect of effects) {
|
||||
const modifier = effect.for(this);
|
||||
if (!modifier.shouldQuery(enemy, locator)) continue;
|
||||
this.refreshSpecialModifier(modifier, enemy, locator);
|
||||
if (!modifier.shouldQuery(handler)) continue;
|
||||
this.refreshSpecialModifier(modifier, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -762,10 +800,8 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
for (const aura of auras) {
|
||||
const param = aura.getRangeParam();
|
||||
aura.range.bindHost(this);
|
||||
if (!aura.range.inRange(locator.x, locator.y, param)) {
|
||||
continue;
|
||||
}
|
||||
aura.apply(enemy, base, locator);
|
||||
if (!aura.range.inRange(locator.x, locator.y, param)) continue;
|
||||
aura.apply(handler, base);
|
||||
}
|
||||
}
|
||||
|
||||
@ -779,7 +815,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
const effects = this.commonQueryMap.get(special.code);
|
||||
if (!effects) continue;
|
||||
for (const effect of effects) {
|
||||
effect.apply(enemy, special, query, locator);
|
||||
effect.apply(handler, special, query);
|
||||
}
|
||||
}
|
||||
if (queried) {
|
||||
@ -787,7 +823,7 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
}
|
||||
|
||||
for (const effect of this.finalEffects) {
|
||||
effect.apply(enemy, locator);
|
||||
effect.apply(handler);
|
||||
}
|
||||
|
||||
this.dirtyEnemy.delete(view);
|
||||
@ -846,5 +882,6 @@ export class EnemyContext<TAttr> implements IEnemyContext<TAttr> {
|
||||
this.commonQueryMap.clear();
|
||||
this.specialQueryEffects.clear();
|
||||
this.finalEffects.length = 0;
|
||||
this.bindedHero = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { logger } from '@motajs/common';
|
||||
import { ITileLocator, logger } from '@motajs/common';
|
||||
import {
|
||||
CriticalableHeroStatus,
|
||||
IDamageCalculator,
|
||||
@ -6,9 +6,12 @@ import {
|
||||
IEnemyContext,
|
||||
IEnemyCritical,
|
||||
IEnemyDamageInfo,
|
||||
IReadonlyEnemyHandler,
|
||||
IEnemyView,
|
||||
IReadonlyEnemy
|
||||
} from './types';
|
||||
import { IHeroAttribute, IReadonlyHeroAttribute } from '../hero';
|
||||
import { clamp } from 'lodash-es';
|
||||
|
||||
interface ICriticalSearchResult {
|
||||
/** 此临界点的属性值 */
|
||||
@ -21,12 +24,12 @@ export class DamageSystem<TAttr, THero> implements IDamageSystem<TAttr, THero> {
|
||||
/** 当前正在使用的计算器 */
|
||||
private calculator: IDamageCalculator<TAttr, THero> | null = null;
|
||||
/** 当前勇士属性 */
|
||||
private heroStatus: Readonly<THero> | null = null;
|
||||
private heroStatus: IReadonlyHeroAttribute<THero> | null = null;
|
||||
/** 怪物伤害缓存 */
|
||||
private readonly cache: Map<IEnemyView<TAttr>, IEnemyDamageInfo> =
|
||||
new Map();
|
||||
|
||||
constructor(readonly context: IEnemyContext<TAttr>) {}
|
||||
constructor(readonly context: IEnemyContext<TAttr, THero>) {}
|
||||
|
||||
useCalculator(calculator: IDamageCalculator<TAttr, THero>): void {
|
||||
this.calculator = calculator;
|
||||
@ -37,35 +40,23 @@ export class DamageSystem<TAttr, THero> implements IDamageSystem<TAttr, THero> {
|
||||
return this.calculator;
|
||||
}
|
||||
|
||||
bindHeroStatus(hero: Readonly<THero>): void {
|
||||
bindHeroStatus(hero: IReadonlyHeroAttribute<THero>): void {
|
||||
this.heroStatus = hero;
|
||||
this.markAllDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 深拷贝勇士属性
|
||||
* 创建只读信息对象
|
||||
* @param enemy 怪物对象
|
||||
* @param locator 怪物位置
|
||||
* @param hero 勇士属性对象
|
||||
*/
|
||||
private cloneHeroStatus(): THero | null {
|
||||
if (!this.heroStatus) return null;
|
||||
else return structuredClone(this.heroStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 在修改勇士属性的情况下计算怪物伤害
|
||||
* @param enemy 怪物属性
|
||||
* @param attribute 修改的属性键名
|
||||
* @param value 修改为的属性值
|
||||
* @returns
|
||||
*/
|
||||
private calculateDamageWithModified(
|
||||
private createReadonlyHandler(
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
attribute: CriticalableHeroStatus<THero>,
|
||||
value: number
|
||||
): IEnemyDamageInfo {
|
||||
const hero = this.cloneHeroStatus()!;
|
||||
// @ts-expect-error 之后会进行修复
|
||||
hero[attribute] = value;
|
||||
return this.calculator!.calculate(hero, enemy);
|
||||
locator: ITileLocator,
|
||||
hero: IReadonlyHeroAttribute<THero>
|
||||
): IReadonlyEnemyHandler<TAttr, THero> {
|
||||
return { enemy, locator, hero };
|
||||
}
|
||||
|
||||
getDamageInfo(enemy: IEnemyView<TAttr>): IEnemyDamageInfo | null {
|
||||
@ -77,15 +68,51 @@ export class DamageSystem<TAttr, THero> implements IDamageSystem<TAttr, THero> {
|
||||
logger.warn(106);
|
||||
return null;
|
||||
}
|
||||
const hero = this.cloneHeroStatus()!;
|
||||
const hero = this.heroStatus;
|
||||
const locator = this.context.getEnemyLocatorByView(enemy);
|
||||
if (!hero || !locator) return null;
|
||||
|
||||
const cached = this.cache.get(enemy);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const info = this.calculator.calculate(hero, enemy.getComputedEnemy());
|
||||
const computed = enemy.getComputedEnemy();
|
||||
const handler = this.createReadonlyHandler(computed, locator, hero);
|
||||
const info = this.calculator.calculate(handler);
|
||||
this.cache.set(enemy, info);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
getDamageInfoByComputed(
|
||||
enemy: IReadonlyEnemy<TAttr>
|
||||
): IEnemyDamageInfo | null {
|
||||
if (!this.heroStatus) {
|
||||
logger.warn(107);
|
||||
return null;
|
||||
}
|
||||
if (!this.calculator) {
|
||||
logger.warn(106);
|
||||
return null;
|
||||
}
|
||||
|
||||
const hero = this.heroStatus;
|
||||
if (!hero) return null;
|
||||
const view = this.context.getViewByComputed(enemy);
|
||||
if (!view) return null;
|
||||
const locator = this.context.getEnemyLocatorByView(view);
|
||||
if (!locator) return null;
|
||||
|
||||
const cached = this.cache.get(view);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const handler = this.createReadonlyHandler(enemy, locator, hero);
|
||||
const info = this.calculator.calculate(handler);
|
||||
this.cache.set(view, info);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
@ -104,7 +131,7 @@ export class DamageSystem<TAttr, THero> implements IDamageSystem<TAttr, THero> {
|
||||
*calculateCritical(
|
||||
view: IEnemyView<TAttr>,
|
||||
attribute: CriticalableHeroStatus<THero>,
|
||||
precision: number
|
||||
precision: number = 12
|
||||
): Generator<IEnemyCritical, void, void> {
|
||||
if (!this.heroStatus) {
|
||||
logger.warn(107);
|
||||
@ -115,26 +142,32 @@ export class DamageSystem<TAttr, THero> implements IDamageSystem<TAttr, THero> {
|
||||
return;
|
||||
}
|
||||
|
||||
const currentInfo = this.getDamageInfo(view);
|
||||
if (!currentInfo) return;
|
||||
const locator = this.context.getEnemyLocatorByView(view);
|
||||
if (!locator) return;
|
||||
|
||||
const enemy = view.getComputedEnemy();
|
||||
const hero = this.cloneHeroStatus()!;
|
||||
const currentValue = hero[attribute] as number;
|
||||
const hero = this.heroStatus.getModifiableClone();
|
||||
const handler = this.createReadonlyHandler(enemy, locator, hero);
|
||||
|
||||
const currentInfo = this.calculator.calculate(handler);
|
||||
if (!currentInfo) return;
|
||||
|
||||
const currentValue = hero.getBaseAttribute(attribute) as number;
|
||||
const upperLimit = Math.floor(
|
||||
this.calculator.getCriticalLimit(hero, enemy, attribute)
|
||||
this.calculator.getCriticalLimit(handler, attribute)
|
||||
);
|
||||
|
||||
if (currentValue >= upperLimit) return;
|
||||
|
||||
const maxIterations = Math.max(0, Math.floor(precision));
|
||||
// 超过 64 位的精度没有意义,所以最高设置为 64
|
||||
const maxIterations = clamp(Math.floor(precision), 4, 64);
|
||||
let baseValue = currentValue;
|
||||
let baseInfo = currentInfo;
|
||||
|
||||
while (baseValue < upperLimit) {
|
||||
const next = this.findNextCritical(
|
||||
enemy,
|
||||
handler,
|
||||
hero,
|
||||
attribute,
|
||||
baseValue,
|
||||
upperLimit,
|
||||
@ -159,7 +192,8 @@ export class DamageSystem<TAttr, THero> implements IDamageSystem<TAttr, THero> {
|
||||
|
||||
/**
|
||||
* 计算下一个临界点
|
||||
* @param enemy 怪物对象
|
||||
* @param handler 信息对象,其中的 `hero` 成员与 `hero` 参数同引用
|
||||
* @param hero 可修改勇士属性对象,与 `handler` 中的 `hero` 成员同引用
|
||||
* @param attribute 勇士属性名
|
||||
* @param currentValue 当前勇士属性值
|
||||
* @param upperLimit 二分上界
|
||||
@ -167,7 +201,8 @@ export class DamageSystem<TAttr, THero> implements IDamageSystem<TAttr, THero> {
|
||||
* @param maxIterations 最大迭代数量
|
||||
*/
|
||||
private findNextCritical(
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
handler: IReadonlyEnemyHandler<TAttr, THero>,
|
||||
hero: IHeroAttribute<THero>,
|
||||
attribute: CriticalableHeroStatus<THero>,
|
||||
currentValue: number,
|
||||
upperLimit: number,
|
||||
@ -176,36 +211,30 @@ export class DamageSystem<TAttr, THero> implements IDamageSystem<TAttr, THero> {
|
||||
): ICriticalSearchResult | null {
|
||||
let left = currentValue;
|
||||
let right = upperLimit;
|
||||
let rightInfo = this.calculateDamageWithModified(
|
||||
enemy,
|
||||
attribute,
|
||||
right
|
||||
);
|
||||
|
||||
if (rightInfo.damage >= referenceDamage) return null;
|
||||
hero.setBaseAttribute(attribute, right as THero[typeof attribute]);
|
||||
|
||||
let targetInfo = this.calculator!.calculate(handler);
|
||||
if (targetInfo.damage >= referenceDamage) return null;
|
||||
|
||||
let iter = 0;
|
||||
while (iter < maxIterations) {
|
||||
while (iter++ < maxIterations) {
|
||||
const middle = Math.floor((left + right) / 2);
|
||||
const middleInfo = this.calculateDamageWithModified(
|
||||
enemy,
|
||||
attribute,
|
||||
middle
|
||||
);
|
||||
hero.setBaseAttribute(attribute, middle as THero[typeof attribute]);
|
||||
const middleInfo = this.calculator!.calculate(handler);
|
||||
|
||||
if (middleInfo.damage < referenceDamage) {
|
||||
right = middle;
|
||||
rightInfo = middleInfo;
|
||||
} else {
|
||||
left = middle;
|
||||
targetInfo = middleInfo;
|
||||
}
|
||||
if (right - left <= 1) break;
|
||||
|
||||
iter++;
|
||||
}
|
||||
|
||||
return {
|
||||
value: right,
|
||||
info: rightInfo
|
||||
info: targetInfo
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ export class EnemyView<TAttr> implements IEnemyView<TAttr> {
|
||||
|
||||
constructor(
|
||||
readonly baseEnemy: IEnemy<TAttr>,
|
||||
readonly context: IEnemyContext<TAttr>
|
||||
readonly context: IEnemyContext<TAttr, unknown>
|
||||
) {
|
||||
this.computedEnemy = baseEnemy.clone();
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { logger, ITileLocator } from '@motajs/common';
|
||||
import {
|
||||
IEnemyContext,
|
||||
IReadonlyEnemyHandler,
|
||||
IEnemyView,
|
||||
IMapDamage,
|
||||
IMapDamageConverter,
|
||||
@ -33,9 +34,9 @@ interface IDamageStore<TAttr> {
|
||||
readonly index: number;
|
||||
}
|
||||
|
||||
export class MapDamage<TAttr> implements IMapDamage<TAttr> {
|
||||
export class MapDamage<TAttr, THero> implements IMapDamage<TAttr, THero> {
|
||||
/** 当前使用的地图伤害转换器 */
|
||||
private converter: IMapDamageConverter<TAttr> | null = null;
|
||||
private converter: IMapDamageConverter<TAttr, THero> | null = null;
|
||||
/** 当前使用的地图伤害合并器 */
|
||||
private reducer: IMapDamageReducer | null = null;
|
||||
|
||||
@ -62,15 +63,33 @@ export class MapDamage<TAttr> implements IMapDamage<TAttr> {
|
||||
/** 坐标索引对象 */
|
||||
private readonly indexer: IMapLocIndexer;
|
||||
|
||||
constructor(readonly context: IEnemyContext<TAttr>) {
|
||||
constructor(readonly context: IEnemyContext<TAttr, THero>) {
|
||||
this.indexer = context.indexer;
|
||||
}
|
||||
|
||||
useConverter(converter: IMapDamageConverter<TAttr>): void {
|
||||
useConverter(converter: IMapDamageConverter<TAttr, THero>): void {
|
||||
this.converter = converter;
|
||||
this.refreshAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建只读信息对象
|
||||
* @param view 怪物视图
|
||||
* @param locator 怪物位置
|
||||
*/
|
||||
private createReadonlyHandler(
|
||||
view: IEnemyView<TAttr>,
|
||||
locator: ITileLocator
|
||||
): IReadonlyEnemyHandler<TAttr, THero> | null {
|
||||
const hero = this.context.getBindedHero();
|
||||
if (!hero) return null;
|
||||
return {
|
||||
enemy: view.getComputedEnemy(),
|
||||
locator,
|
||||
hero
|
||||
};
|
||||
}
|
||||
|
||||
useReducer(reducer: IMapDamageReducer): void {
|
||||
this.reducer = reducer;
|
||||
this.reducedCache.clear();
|
||||
@ -174,6 +193,7 @@ export class MapDamage<TAttr> implements IMapDamage<TAttr> {
|
||||
const sourced = this.sourcedDamage.get(index);
|
||||
if (sourceless) {
|
||||
if (sourced) {
|
||||
// 大集合 union 小集合会更快,一般有来源伤害更多,所以 source union sourceless
|
||||
return sourced.damages.union(sourceless.damages);
|
||||
} else {
|
||||
return sourceless.damages;
|
||||
@ -237,9 +257,11 @@ export class MapDamage<TAttr> implements IMapDamage<TAttr> {
|
||||
locator: ITileLocator
|
||||
) {
|
||||
this.removeEnemyAffecting(view);
|
||||
const enemy = view.getComputedEnemy();
|
||||
const views = this.converter!.convert(enemy, locator, this.context);
|
||||
const set = new Set(views);
|
||||
if (!this.converter) return;
|
||||
const handler = this.createReadonlyHandler(view, locator);
|
||||
if (!handler) return;
|
||||
const views = this.converter.convert(handler, this.context);
|
||||
const set = new Set<IMapDamageView<any>>(views);
|
||||
if (set.size === 0) return;
|
||||
this.enemyStore.set(view, set);
|
||||
const collection = new Set<number>();
|
||||
@ -275,9 +297,11 @@ export class MapDamage<TAttr> implements IMapDamage<TAttr> {
|
||||
*/
|
||||
private refreshEnemy(view: IEnemyView<TAttr>, locator: ITileLocator) {
|
||||
this.removeEnemyAffecting(view);
|
||||
const enemy = view.getComputedEnemy();
|
||||
const views = this.converter!.convert(enemy, locator, this.context);
|
||||
const set = new Set(views);
|
||||
if (!this.converter) return;
|
||||
const handler = this.createReadonlyHandler(view, locator);
|
||||
if (!handler) return;
|
||||
const views = this.converter.convert(handler, this.context);
|
||||
const set = new Set<IMapDamageView<any>>(views);
|
||||
if (set.size === 0) return;
|
||||
this.enemyStore.set(view, set);
|
||||
set.forEach(viewItem => {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { IRange, ITileLocator } from '@motajs/common';
|
||||
import { IReadonlyHeroAttribute } from '../hero';
|
||||
|
||||
//#region 怪物基础
|
||||
|
||||
@ -246,13 +247,31 @@ export interface IMapLocIndexer extends IMapLocHelper {
|
||||
setWidth(width: number): void;
|
||||
}
|
||||
|
||||
export interface IEnemyHandler<TAttr, THero> {
|
||||
/** 怪物属性信息 */
|
||||
readonly enemy: IEnemy<TAttr>;
|
||||
/** 怪物定位符 */
|
||||
readonly locator: ITileLocator;
|
||||
/** 勇士属性信息 */
|
||||
readonly hero: IReadonlyHeroAttribute<THero>;
|
||||
}
|
||||
|
||||
export interface IReadonlyEnemyHandler<TAttr, THero> {
|
||||
/** 怪物属性信息 */
|
||||
readonly enemy: IReadonlyEnemy<TAttr>;
|
||||
/** 怪物定位符 */
|
||||
readonly locator: ITileLocator;
|
||||
/** 勇士属性信息 */
|
||||
readonly hero: IReadonlyHeroAttribute<THero>;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 怪物对象
|
||||
|
||||
export interface IEnemyView<TAttr> {
|
||||
/** 怪物视图所属的上下文 */
|
||||
readonly context: IEnemyContext<TAttr>;
|
||||
readonly context: IEnemyContext<TAttr, unknown>;
|
||||
|
||||
/**
|
||||
* 重置此怪物视图的状态,将计算后怪物对象恢复至初始状态
|
||||
@ -288,31 +307,24 @@ export interface IEnemyView<TAttr> {
|
||||
export interface IEnemySpecialModifier<TAttr> {
|
||||
/**
|
||||
* 获取要添加到指定怪物身上的特殊属性
|
||||
* @param enemy 怪物对象
|
||||
* @param locator 怪物定位符
|
||||
* @param handler 信息对象
|
||||
*/
|
||||
add(enemy: IReadonlyEnemy<TAttr>, locator: ITileLocator): ISpecial<any>[];
|
||||
add(handler: IReadonlyEnemyHandler<TAttr, unknown>): ISpecial<any>[];
|
||||
|
||||
/**
|
||||
* 获取制定怪物身上要删除的特殊属性
|
||||
* @param enemy 怪物对象
|
||||
* @param locator 怪物定位符
|
||||
* @param handler 信息对象
|
||||
*/
|
||||
delete(
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
locator: ITileLocator
|
||||
): ISpecial<any>[];
|
||||
delete(handler: IReadonlyEnemyHandler<TAttr, unknown>): ISpecial<any>[];
|
||||
|
||||
/**
|
||||
* 修改一个怪物的特殊属性,如果真正进行了修改则返回 true,否则返回 false
|
||||
* @param enemy 怪物对象
|
||||
* @param handler 信息对象
|
||||
* @param special 要修改的怪物特殊属性
|
||||
* @param locator 怪物定位符
|
||||
*/
|
||||
modify(
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
special: ISpecial<any>,
|
||||
locator: ITileLocator
|
||||
handler: IEnemyHandler<TAttr, unknown>,
|
||||
special: ISpecial<any>
|
||||
): boolean;
|
||||
}
|
||||
|
||||
@ -334,26 +346,22 @@ export interface IAuraView<TAttr, T = any> {
|
||||
|
||||
/**
|
||||
* 对指定怪物对象施加修饰器
|
||||
* @param enemy 怪物对象
|
||||
* @param handler 信息对象
|
||||
* @param baseEnemy 原始怪物对象,即未进行任何修改的怪物对象
|
||||
* @param locator 怪物定位符
|
||||
*/
|
||||
apply(
|
||||
enemy: IEnemy<TAttr>,
|
||||
baseEnemy: IReadonlyEnemy<TAttr>,
|
||||
locator: ITileLocator
|
||||
handler: IEnemyHandler<TAttr, unknown>,
|
||||
baseEnemy: IReadonlyEnemy<TAttr>
|
||||
): void;
|
||||
|
||||
/**
|
||||
* 对指定怪物对象添加特殊属性修饰器
|
||||
* @param enemy 怪物对象
|
||||
* @param handler 信息对象
|
||||
* @param baseEnemy 原始怪物对象,即未进行任何修改的怪物对象
|
||||
* @param locator 怪物定位符
|
||||
*/
|
||||
applySpecial(
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
baseEnemy: IReadonlyEnemy<TAttr>,
|
||||
locator: ITileLocator
|
||||
handler: IEnemyHandler<TAttr, unknown>,
|
||||
baseEnemy: IReadonlyEnemy<TAttr>
|
||||
): IEnemySpecialModifier<TAttr> | null;
|
||||
}
|
||||
|
||||
@ -366,14 +374,15 @@ export interface IEnemyAuraView<TAttr, R, S> extends IAuraView<TAttr, R> {
|
||||
readonly locator: ITileLocator;
|
||||
}
|
||||
|
||||
export interface IAuraConverter<TAttr> {
|
||||
export interface IAuraConverter<TAttr, THero> {
|
||||
/**
|
||||
* 判断一个特殊属性是否应该被当前光环转换器执行转换
|
||||
* @param special 要转换的特殊属性
|
||||
* @param handler 信息对象
|
||||
*/
|
||||
shouldConvert(
|
||||
special: ISpecial<any>,
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
locator: ITileLocator
|
||||
handler: IReadonlyEnemyHandler<TAttr, THero>
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
@ -381,32 +390,34 @@ export interface IAuraConverter<TAttr> {
|
||||
*/
|
||||
convert(
|
||||
special: ISpecial<any>,
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
locator: ITileLocator,
|
||||
context: IEnemyContext<TAttr>
|
||||
handler: IReadonlyEnemyHandler<TAttr, THero>,
|
||||
context: IEnemyContext<TAttr, THero>
|
||||
): IEnemyAuraView<TAttr, any, any>;
|
||||
}
|
||||
|
||||
export interface IEnemySpecialQueryModifier<
|
||||
TAttr
|
||||
TAttr,
|
||||
THero
|
||||
> extends IEnemySpecialModifier<TAttr> {
|
||||
/**
|
||||
* 判断一个怪物是否应该查询外部状态
|
||||
*/
|
||||
shouldQuery(enemy: IReadonlyEnemy<TAttr>, locator: ITileLocator): boolean;
|
||||
shouldQuery(handler: IReadonlyEnemyHandler<TAttr, THero>): boolean;
|
||||
}
|
||||
|
||||
export interface IEnemySpecialQueryEffect<TAttr> {
|
||||
export interface IEnemySpecialQueryEffect<TAttr, THero> {
|
||||
/** 效果优先级,与光环属性共用 */
|
||||
readonly priority: number;
|
||||
|
||||
/**
|
||||
* 根据传入的怪物上下文,获取对应的怪物特殊属性修饰器
|
||||
*/
|
||||
for(ctx: IEnemyContext<TAttr>): IEnemySpecialQueryModifier<TAttr>;
|
||||
for(
|
||||
ctx: IEnemyContext<TAttr, THero>
|
||||
): IEnemySpecialQueryModifier<TAttr, THero>;
|
||||
}
|
||||
|
||||
export interface IEnemyCommonQueryEffect<TAttr> {
|
||||
export interface IEnemyCommonQueryEffect<TAttr, THero> {
|
||||
/** 优先级,越高的越先执行 */
|
||||
readonly priority: number;
|
||||
|
||||
@ -414,21 +425,20 @@ export interface IEnemyCommonQueryEffect<TAttr> {
|
||||
* 对怪物的某个特殊属性施加常规查询效果
|
||||
*/
|
||||
apply(
|
||||
enemy: IEnemy<TAttr>,
|
||||
handler: IEnemyHandler<TAttr, THero>,
|
||||
special: ISpecial<any>,
|
||||
query: () => IEnemyContext<TAttr>,
|
||||
locator: ITileLocator
|
||||
query: () => IEnemyContext<TAttr, THero>
|
||||
): void;
|
||||
}
|
||||
|
||||
export interface IEnemyFinalEffect<TAttr> {
|
||||
export interface IEnemyFinalEffect<TAttr, THero> {
|
||||
/** 效果优先级,越高会越先被执行 */
|
||||
readonly priority: number;
|
||||
|
||||
/**
|
||||
* 向怪物施加最终修饰效果
|
||||
*/
|
||||
apply(enemy: IEnemy<TAttr>, locator: ITileLocator): void;
|
||||
apply(handler: IEnemyHandler<TAttr, THero>): void;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
@ -477,14 +487,13 @@ export interface IMapDamageView<T = any> {
|
||||
): Readonly<IMapDamageInfo> | null;
|
||||
}
|
||||
|
||||
export interface IMapDamageConverter<TAttr> {
|
||||
export interface IMapDamageConverter<TAttr, THero> {
|
||||
/**
|
||||
* 转换地图伤害视图
|
||||
*/
|
||||
convert(
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
locator: ITileLocator,
|
||||
context: IEnemyContext<TAttr>
|
||||
handler: IReadonlyEnemyHandler<TAttr, THero>,
|
||||
context: IEnemyContext<TAttr, THero>
|
||||
): IMapDamageView<any>[];
|
||||
}
|
||||
|
||||
@ -498,15 +507,15 @@ export interface IMapDamageReducer {
|
||||
): Readonly<IMapDamageInfo>;
|
||||
}
|
||||
|
||||
export interface IMapDamage<TAttr> {
|
||||
export interface IMapDamage<TAttr, THero> {
|
||||
/** 当前绑定的怪物上下文 */
|
||||
readonly context: IEnemyContext<TAttr>;
|
||||
readonly context: IEnemyContext<TAttr, THero>;
|
||||
|
||||
/**
|
||||
* 设置地图伤害转换器,并基于当前上下文重建所有地图伤害视图
|
||||
* @param converter 地图伤害转换器
|
||||
*/
|
||||
useConverter(converter: IMapDamageConverter<TAttr>): void;
|
||||
useConverter(converter: IMapDamageConverter<TAttr, THero>): void;
|
||||
|
||||
/**
|
||||
* 设置地图伤害合并器
|
||||
@ -593,36 +602,30 @@ export interface IEnemyCritical {
|
||||
}
|
||||
|
||||
export type CriticalableHeroStatus<THero> = keyof {
|
||||
[P in keyof THero as THero[P] extends number ? P : never]: unknown;
|
||||
[P in keyof THero as THero[P] extends number ? P : never]: number;
|
||||
};
|
||||
|
||||
export interface IDamageCalculator<TAttr, THero> {
|
||||
/**
|
||||
* 计算战斗伤害信息
|
||||
* @param hero 勇士信息
|
||||
* @param enemy 怪物信息
|
||||
* @param handler 信息对象
|
||||
*/
|
||||
calculate(
|
||||
hero: Readonly<THero>,
|
||||
enemy: IReadonlyEnemy<TAttr>
|
||||
): IEnemyDamageInfo;
|
||||
calculate(handler: IReadonlyEnemyHandler<TAttr, THero>): IEnemyDamageInfo;
|
||||
|
||||
/**
|
||||
* 获取临界计算的上界
|
||||
* @param hero 勇士信息
|
||||
* @param enemy 怪物信息
|
||||
* @param handler 信息对象
|
||||
* @param attribute 勇士的临界属性
|
||||
*/
|
||||
getCriticalLimit(
|
||||
hero: Readonly<THero>,
|
||||
enemy: IReadonlyEnemy<TAttr>,
|
||||
handler: IReadonlyEnemyHandler<TAttr, THero>,
|
||||
attribute: CriticalableHeroStatus<THero>
|
||||
): number;
|
||||
}
|
||||
|
||||
export interface IDamageSystem<TAttr, THero> {
|
||||
/** 伤害系统所属的上下文 */
|
||||
readonly context: IEnemyContext<TAttr>;
|
||||
readonly context: IEnemyContext<TAttr, THero>;
|
||||
|
||||
/**
|
||||
* 设置当前伤害计算系统使用的伤害计算器
|
||||
@ -639,7 +642,7 @@ export interface IDamageSystem<TAttr, THero> {
|
||||
* 绑定勇士信息
|
||||
* @param hero 勇士信息
|
||||
*/
|
||||
bindHeroStatus(hero: Readonly<THero>): void;
|
||||
bindHeroStatus(hero: IReadonlyHeroAttribute<THero> | null): void;
|
||||
|
||||
/**
|
||||
* 获取战斗伤害信息
|
||||
@ -647,6 +650,14 @@ export interface IDamageSystem<TAttr, THero> {
|
||||
*/
|
||||
getDamageInfo(enemy: IEnemyView<TAttr>): IEnemyDamageInfo | null;
|
||||
|
||||
/**
|
||||
* 根据怪物对象获取战斗伤害信息
|
||||
* @param enemy 怪物对象
|
||||
*/
|
||||
getDamageInfoByComputed(
|
||||
enemy: IReadonlyEnemy<TAttr>
|
||||
): IEnemyDamageInfo | null;
|
||||
|
||||
/**
|
||||
* 将指定的怪物标记为脏
|
||||
* @param enemy 怪物视图
|
||||
@ -668,12 +679,12 @@ export interface IDamageSystem<TAttr, THero> {
|
||||
* 计算怪物在指定勇士属性下的临界
|
||||
* @param enemy 怪物视图
|
||||
* @param attribute 计算临界的目标勇士属性,比如计算攻击临界、自定义属性的临界等等
|
||||
* @param precision 临界计算精度,表示会进行多少次二分计算,一般填写 `12-16` 之间的数即可
|
||||
* @param precision 临界计算精度,表示会进行多少次二分计算,一般填写 `12-16` 之间的数即可,默认是 12
|
||||
*/
|
||||
calculateCritical(
|
||||
enemy: IEnemyView<TAttr>,
|
||||
attribute: CriticalableHeroStatus<THero>,
|
||||
precision: number
|
||||
precision?: number
|
||||
): Generator<IEnemyCritical, void, void>;
|
||||
}
|
||||
|
||||
@ -681,7 +692,7 @@ export interface IDamageSystem<TAttr, THero> {
|
||||
|
||||
//#region 上下文
|
||||
|
||||
export interface IEnemyContext<TAttr> {
|
||||
export interface IEnemyContext<TAttr, THero> {
|
||||
/** 怪物上下文宽度 */
|
||||
readonly width: number;
|
||||
/** 怪物上下文高度 */
|
||||
@ -700,13 +711,13 @@ export interface IEnemyContext<TAttr> {
|
||||
* 注册一个光环转换器
|
||||
* @param converter 光环转换器
|
||||
*/
|
||||
registerAuraConverter(converter: IAuraConverter<TAttr>): void;
|
||||
registerAuraConverter(converter: IAuraConverter<TAttr, THero>): void;
|
||||
|
||||
/**
|
||||
* 注销一个光环转换器
|
||||
* @param converter 光环转换器
|
||||
*/
|
||||
unregisterAuraConverter(converter: IAuraConverter<TAttr>): void;
|
||||
unregisterAuraConverter(converter: IAuraConverter<TAttr, THero>): void;
|
||||
|
||||
/**
|
||||
* 设置光环转换器的启用状态
|
||||
@ -714,7 +725,7 @@ export interface IEnemyContext<TAttr> {
|
||||
* @param enabled 是否启用
|
||||
*/
|
||||
setAuraConverterEnabled(
|
||||
converter: IAuraConverter<TAttr>,
|
||||
converter: IAuraConverter<TAttr, THero>,
|
||||
enabled: boolean
|
||||
): void;
|
||||
|
||||
@ -722,13 +733,17 @@ export interface IEnemyContext<TAttr> {
|
||||
* 注册一个特殊属性查询效果
|
||||
* @param effect 特殊属性查询效果
|
||||
*/
|
||||
registerSpecialQueryEffect(effect: IEnemySpecialQueryEffect<TAttr>): void;
|
||||
registerSpecialQueryEffect(
|
||||
effect: IEnemySpecialQueryEffect<TAttr, THero>
|
||||
): void;
|
||||
|
||||
/**
|
||||
* 注销一个特殊属性查询效果
|
||||
* @param effect 特殊属性查询效果
|
||||
*/
|
||||
unregisterSpecialQueryEffect(effect: IEnemySpecialQueryEffect<TAttr>): void;
|
||||
unregisterSpecialQueryEffect(
|
||||
effect: IEnemySpecialQueryEffect<TAttr, THero>
|
||||
): void;
|
||||
|
||||
/**
|
||||
* 为指定特殊属性代码注册常规查询效果
|
||||
@ -737,7 +752,7 @@ export interface IEnemyContext<TAttr> {
|
||||
*/
|
||||
registerCommonQueryEffect(
|
||||
code: number,
|
||||
effect: IEnemyCommonQueryEffect<TAttr>
|
||||
effect: IEnemyCommonQueryEffect<TAttr, THero>
|
||||
): void;
|
||||
|
||||
/**
|
||||
@ -747,20 +762,31 @@ export interface IEnemyContext<TAttr> {
|
||||
*/
|
||||
unregisterCommonQueryEffect(
|
||||
code: number,
|
||||
effect: IEnemyCommonQueryEffect<TAttr>
|
||||
effect: IEnemyCommonQueryEffect<TAttr, THero>
|
||||
): void;
|
||||
|
||||
/**
|
||||
* 注册一个最终效果
|
||||
* @param effect 最终效果
|
||||
*/
|
||||
registerFinalEffect(effect: IEnemyFinalEffect<TAttr>): void;
|
||||
registerFinalEffect(effect: IEnemyFinalEffect<TAttr, THero>): void;
|
||||
|
||||
/**
|
||||
* 注销一个最终效果
|
||||
* @param effect 最终效果
|
||||
*/
|
||||
unregisterFinalEffect(effect: IEnemyFinalEffect<TAttr>): void;
|
||||
unregisterFinalEffect(effect: IEnemyFinalEffect<TAttr, THero>): void;
|
||||
|
||||
/**
|
||||
* 绑定勇士对象
|
||||
* @param hero 勇士属性对象
|
||||
*/
|
||||
bindHero(hero: IReadonlyHeroAttribute<THero> | null): void;
|
||||
|
||||
/**
|
||||
* 获取当前绑定的勇士属性对象
|
||||
*/
|
||||
getBindedHero(): IReadonlyHeroAttribute<THero> | null;
|
||||
|
||||
/**
|
||||
* 获取指定怪物对象当前所在位置
|
||||
@ -813,7 +839,10 @@ export interface IEnemyContext<TAttr> {
|
||||
* @param range 范围对象
|
||||
* @param param 范围参数
|
||||
*/
|
||||
scanRange<T>(range: IRange<T>, param: T): Iterable<IEnemyView<TAttr>>;
|
||||
scanRange<T>(
|
||||
range: IRange<T>,
|
||||
param: T
|
||||
): Iterable<[ITileLocator, IEnemyView<TAttr>]>;
|
||||
|
||||
/**
|
||||
* 迭代上下文中的全部怪物
|
||||
@ -836,12 +865,12 @@ export interface IEnemyContext<TAttr> {
|
||||
* 绑定地图伤害管理器
|
||||
* @param damage 地图伤害管理器
|
||||
*/
|
||||
attachMapDamage(damage: IMapDamage<TAttr> | null): void;
|
||||
attachMapDamage(damage: IMapDamage<TAttr, THero> | null): void;
|
||||
|
||||
/**
|
||||
* 获取当前绑定的地图伤害管理器
|
||||
*/
|
||||
getMapDamage(): IMapDamage<TAttr> | null;
|
||||
getMapDamage(): IMapDamage<TAttr, THero> | null;
|
||||
|
||||
/**
|
||||
* 绑定伤害计算系统
|
||||
@ -852,7 +881,7 @@ export interface IEnemyContext<TAttr> {
|
||||
/**
|
||||
* 获取当前绑定的伤害计算系统
|
||||
*/
|
||||
getDamageSystem<THero>(): IDamageSystem<TAttr, THero> | null;
|
||||
getDamageSystem(): IDamageSystem<TAttr, THero> | null;
|
||||
|
||||
/**
|
||||
* 重建当前上下文中的全部怪物计算结果
|
||||
|
||||
@ -149,4 +149,8 @@ export class HeroAttribute<THero> implements IHeroAttribute<THero> {
|
||||
}
|
||||
return cloned;
|
||||
}
|
||||
|
||||
getModifiableClone(): IHeroAttribute<THero> {
|
||||
return this.clone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,6 @@ export class HeroState<THero> implements IHeroState<THero> {
|
||||
}
|
||||
|
||||
getIsolatedAttribute(): IHeroAttribute<THero> {
|
||||
return this.attribute.clone();
|
||||
return this.attribute.getModifiableClone();
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,7 +71,12 @@ export interface IReadonlyHeroAttribute<THero> {
|
||||
* 深拷贝此勇士属性对象
|
||||
* @param cloneModifier 是否同时复制修饰器,默认复制
|
||||
*/
|
||||
clone(cloneModifier?: boolean): IHeroAttribute<THero>;
|
||||
clone(cloneModifier?: boolean): IReadonlyHeroAttribute<THero>;
|
||||
|
||||
/**
|
||||
* 获取此勇士属性对象的可修改副本
|
||||
*/
|
||||
getModifiableClone(): IHeroAttribute<THero>;
|
||||
}
|
||||
|
||||
export interface IHeroAttribute<THero> extends IReadonlyHeroAttribute<THero> {
|
||||
@ -101,6 +106,12 @@ export interface IHeroAttribute<THero> extends IReadonlyHeroAttribute<THero> {
|
||||
name: K,
|
||||
modifier: IHeroModifier<THero[K], unknown>
|
||||
): void;
|
||||
|
||||
/**
|
||||
* 深拷贝此勇士属性对象
|
||||
* @param cloneModifier 是否同时复制修饰器,默认复制
|
||||
*/
|
||||
clone(cloneModifier?: boolean): IHeroAttribute<THero>;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@ -13,18 +13,19 @@ import {
|
||||
HeroState,
|
||||
IHeroState
|
||||
} from '@user/data-base';
|
||||
import { IEnemyAttributes } from './enemy/types';
|
||||
import { IEnemyAttr } from './enemy/types';
|
||||
import {
|
||||
CommonAuraConverter,
|
||||
EnemyLegacyBridge,
|
||||
GuardAuraConverter,
|
||||
MainDamageCalculator,
|
||||
MainEnemyFinalEffect,
|
||||
MainMapDamageConverter,
|
||||
MainMapDamageReducer,
|
||||
registerSpecials
|
||||
} from './enemy';
|
||||
import { HERO_DEFAULT_ATTRIBUTE, TILE_HEIGHT, TILE_WIDTH } from './shared';
|
||||
import { IHeroAttributeObject } from './hero';
|
||||
import { IHeroAttr } from './hero';
|
||||
|
||||
export class CoreState implements ICoreState {
|
||||
readonly layer: ILayerState;
|
||||
@ -32,10 +33,10 @@ export class CoreState implements ICoreState {
|
||||
readonly idNumberMap: Map<string, number>;
|
||||
readonly numberIdMap: Map<number, string>;
|
||||
|
||||
readonly hero: IHeroState<IHeroAttributeObject>;
|
||||
readonly hero: IHeroState<IHeroAttr>;
|
||||
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
|
||||
readonly enemyContext: IEnemyContext<IEnemyAttributes>;
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttr>;
|
||||
readonly enemyContext: IEnemyContext<IEnemyAttr, IHeroAttr>;
|
||||
|
||||
constructor() {
|
||||
this.layer = new LayerState();
|
||||
@ -43,6 +44,15 @@ export class CoreState implements ICoreState {
|
||||
this.idNumberMap = new Map();
|
||||
this.numberIdMap = new Map();
|
||||
|
||||
//#region 勇士初始化
|
||||
|
||||
const heroMover = new HeroMover();
|
||||
const heroAttribute = new HeroAttribute(HERO_DEFAULT_ATTRIBUTE);
|
||||
const heroState = new HeroState(heroMover, heroAttribute);
|
||||
this.hero = heroState;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 怪物初始化
|
||||
|
||||
// 怪物管理器初始化
|
||||
@ -56,8 +66,9 @@ export class CoreState implements ICoreState {
|
||||
registerSpecials(enemyManager);
|
||||
this.enemyManager = enemyManager;
|
||||
// 怪物上下文初始化
|
||||
const enemyContext = new EnemyContext<IEnemyAttributes>();
|
||||
const enemyContext = new EnemyContext<IEnemyAttr, IHeroAttr>();
|
||||
const damageSystem = new DamageSystem(enemyContext);
|
||||
damageSystem.useCalculator(new MainDamageCalculator());
|
||||
const mapDamage = new MapDamage(enemyContext);
|
||||
mapDamage.useConverter(new MainMapDamageConverter());
|
||||
mapDamage.useReducer(new MainMapDamageReducer());
|
||||
@ -67,18 +78,10 @@ export class CoreState implements ICoreState {
|
||||
enemyContext.registerAuraConverter(new GuardAuraConverter());
|
||||
enemyContext.registerFinalEffect(new MainEnemyFinalEffect());
|
||||
enemyContext.resize(TILE_WIDTH, TILE_HEIGHT);
|
||||
enemyContext.bindHero(heroAttribute);
|
||||
this.enemyContext = enemyContext;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 勇士初始化
|
||||
|
||||
const heroMover = new HeroMover();
|
||||
const heroAttribute = new HeroAttribute(HERO_DEFAULT_ATTRIBUTE);
|
||||
const heroState = new HeroState(heroMover, heroAttribute);
|
||||
this.hero = heroState;
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
||||
saveState(): IStateSaveData {
|
||||
|
||||
@ -9,16 +9,18 @@ import {
|
||||
} from '@motajs/common';
|
||||
import {
|
||||
IAuraConverter,
|
||||
IEnemyHandler,
|
||||
IEnemyAuraView,
|
||||
IEnemyContext,
|
||||
IEnemySpecialModifier,
|
||||
IEnemyView,
|
||||
IReadonlyEnemyHandler,
|
||||
IReadonlyEnemy,
|
||||
ISpecial,
|
||||
IEnemy
|
||||
ISpecial
|
||||
} from '@user/data-base';
|
||||
import { IHaloValue } from './special';
|
||||
import { IEnemyAttributes } from './types';
|
||||
import { IEnemyAttr } from './types';
|
||||
import { IHeroAttr } from '../hero';
|
||||
|
||||
const FULL_RANGE = new FullRange();
|
||||
const RECT_RANGE = new RectRange();
|
||||
@ -26,22 +28,24 @@ const MANHATTAN_RANGE = new ManhattanRange();
|
||||
|
||||
//#region 25-光环
|
||||
|
||||
export class CommonAuraConverter implements IAuraConverter<IEnemyAttributes> {
|
||||
export class CommonAuraConverter implements IAuraConverter<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
shouldConvert(special: ISpecial<any>): boolean {
|
||||
return special.code === 25;
|
||||
}
|
||||
|
||||
convert(
|
||||
special: ISpecial<IHaloValue>,
|
||||
enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator
|
||||
handler: IReadonlyEnemyHandler<IEnemyAttr, IHeroAttr>
|
||||
): CommonAura {
|
||||
return new CommonAura(enemy, special, locator);
|
||||
return new CommonAura(handler.enemy, special, handler.locator);
|
||||
}
|
||||
}
|
||||
|
||||
export class CommonAura implements IEnemyAuraView<
|
||||
IEnemyAttributes,
|
||||
IEnemyAttr,
|
||||
IRectRangeParam | IManhattanRangeParam | void,
|
||||
IHaloValue
|
||||
> {
|
||||
@ -51,7 +55,7 @@ export class CommonAura implements IEnemyAuraView<
|
||||
readonly range: IRange<IRectRangeParam | IManhattanRangeParam | void>;
|
||||
|
||||
constructor(
|
||||
readonly enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
readonly enemy: IReadonlyEnemy<IEnemyAttr>,
|
||||
readonly special: ISpecial<IHaloValue>,
|
||||
readonly locator: ITileLocator
|
||||
) {
|
||||
@ -89,9 +93,10 @@ export class CommonAura implements IEnemyAuraView<
|
||||
}
|
||||
|
||||
apply(
|
||||
enemy: IEnemy<IEnemyAttributes>,
|
||||
baseEnemy: IReadonlyEnemy<IEnemyAttributes>
|
||||
handler: IEnemyHandler<IEnemyAttr, unknown>,
|
||||
baseEnemy: IReadonlyEnemy<IEnemyAttr>
|
||||
): void {
|
||||
const { enemy } = handler;
|
||||
const { hpBuff, atkBuff, defBuff } = this.special.value;
|
||||
|
||||
if (hpBuff !== 0) {
|
||||
@ -110,7 +115,7 @@ export class CommonAura implements IEnemyAuraView<
|
||||
}
|
||||
}
|
||||
|
||||
applySpecial(): IEnemySpecialModifier<IEnemyAttributes> | null {
|
||||
applySpecial(): IEnemySpecialModifier<IEnemyAttr> | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -119,23 +124,25 @@ export class CommonAura implements IEnemyAuraView<
|
||||
|
||||
//#region 26-支援
|
||||
|
||||
export class GuardAuraConverter implements IAuraConverter<IEnemyAttributes> {
|
||||
export class GuardAuraConverter implements IAuraConverter<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
shouldConvert(special: ISpecial<any>): boolean {
|
||||
return special.code === 26;
|
||||
}
|
||||
|
||||
convert(
|
||||
special: ISpecial<void>,
|
||||
enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator,
|
||||
context: IEnemyContext<IEnemyAttributes>
|
||||
handler: IReadonlyEnemyHandler<IEnemyAttr, IHeroAttr>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>
|
||||
): GuardAura {
|
||||
return new GuardAura(context, enemy, special, locator);
|
||||
return new GuardAura(context, handler.enemy, special, handler.locator);
|
||||
}
|
||||
}
|
||||
|
||||
export class GuardAura implements IEnemyAuraView<
|
||||
IEnemyAttributes,
|
||||
IEnemyAttr,
|
||||
IRectRangeParam,
|
||||
void
|
||||
> {
|
||||
@ -144,11 +151,11 @@ export class GuardAura implements IEnemyAuraView<
|
||||
readonly couldApplySpecial: boolean = false;
|
||||
readonly range: IRange<IRectRangeParam> = RECT_RANGE;
|
||||
|
||||
private readonly sourceView: IEnemyView<IEnemyAttributes> | null;
|
||||
private readonly sourceView: IEnemyView<IEnemyAttr> | null;
|
||||
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
readonly enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
readonly enemy: IReadonlyEnemy<IEnemyAttr>,
|
||||
readonly special: ISpecial<void>,
|
||||
readonly locator: ITileLocator
|
||||
) {
|
||||
@ -164,19 +171,16 @@ export class GuardAura implements IEnemyAuraView<
|
||||
};
|
||||
}
|
||||
|
||||
apply(
|
||||
enemy: IEnemy<IEnemyAttributes>,
|
||||
_baseEnemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator
|
||||
): void {
|
||||
apply(handler: IEnemyHandler<IEnemyAttr, IHeroAttr>): void {
|
||||
if (!this.sourceView) return;
|
||||
const { enemy, locator } = handler;
|
||||
if (locator.x === this.locator.x && locator.y === this.locator.y) {
|
||||
return;
|
||||
}
|
||||
enemy.getAttribute('guard').add(this.sourceView);
|
||||
}
|
||||
|
||||
applySpecial(): IEnemySpecialModifier<IEnemyAttributes> | null {
|
||||
applySpecial(): IEnemySpecialModifier<IEnemyAttr> | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
177
packages-user/data-state/src/enemy/calculator.ts
Normal file
177
packages-user/data-state/src/enemy/calculator.ts
Normal file
@ -0,0 +1,177 @@
|
||||
import {
|
||||
CriticalableHeroStatus,
|
||||
IDamageCalculator,
|
||||
IEnemyDamageInfo,
|
||||
IReadonlyEnemyHandler
|
||||
} from '@user/data-base';
|
||||
import { IEnemyAttr } from './types';
|
||||
import { IVampireValue } from './special';
|
||||
import { IHeroAttr } from '../hero';
|
||||
|
||||
export class MainDamageCalculator implements IDamageCalculator<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
/** 当前是否正在计算支援怪的伤害 */
|
||||
private inGuard: boolean = false;
|
||||
|
||||
/**
|
||||
* 计算战斗伤害信息
|
||||
* @param handler 信息对象
|
||||
*/
|
||||
calculate(
|
||||
handler: IReadonlyEnemyHandler<IEnemyAttr, IHeroAttr>
|
||||
): IEnemyDamageInfo {
|
||||
const { enemy, locator, hero } = handler;
|
||||
const hp = hero.getBaseAttribute('hp');
|
||||
const atk = hero.getFinalAttribute('atk');
|
||||
const def = hero.getFinalAttribute('def');
|
||||
const mdef = this.inGuard ? 0 : hero.getFinalAttribute('mdef');
|
||||
// 支援中魔防只会被计算一次,因此除了当前怪物,计算其他怪物伤害时魔防为 0
|
||||
const monAtk = enemy.getAttribute('atk');
|
||||
const monDef = enemy.getAttribute('def');
|
||||
let monHp = enemy.getAttribute('hp');
|
||||
|
||||
// 无敌
|
||||
if (enemy.hasSpecial(20) && core.itemCount('cross') < 1) {
|
||||
return { damage: Infinity, turn: 0 };
|
||||
}
|
||||
|
||||
/** 怪物会对勇士造成的总伤害 */
|
||||
let damage = 0;
|
||||
|
||||
/** 勇士每轮造成的伤害 */
|
||||
let heroPerDamage = 0;
|
||||
/** 怪物每轮造成的伤害 */
|
||||
let enemyPerDamage = 0;
|
||||
|
||||
// 勇士每轮伤害为勇士攻击减去怪物防御
|
||||
heroPerDamage += atk - monDef;
|
||||
if (heroPerDamage <= 0) {
|
||||
return { damage: Infinity, turn: 0 };
|
||||
}
|
||||
|
||||
// 吸血
|
||||
const vampire = enemy.getSpecial<IVampireValue>(11);
|
||||
if (vampire) {
|
||||
const value = (vampire.value.vampire / 100) * hp;
|
||||
damage += value;
|
||||
// 如果吸血加到自身
|
||||
if (vampire.value.add) {
|
||||
monHp += value;
|
||||
}
|
||||
}
|
||||
|
||||
// 魔攻
|
||||
if (enemy.hasSpecial(2)) {
|
||||
enemyPerDamage = monAtk;
|
||||
} else {
|
||||
enemyPerDamage = monAtk - def;
|
||||
}
|
||||
|
||||
// 连击
|
||||
if (enemy.hasSpecial(4)) enemyPerDamage *= 2;
|
||||
if (enemy.hasSpecial(5)) enemyPerDamage *= 3;
|
||||
|
||||
const multiHit = enemy.getSpecial<number>(6);
|
||||
if (multiHit) {
|
||||
enemyPerDamage *= multiHit.value;
|
||||
}
|
||||
|
||||
if (enemyPerDamage < 0) enemyPerDamage = 0;
|
||||
|
||||
let turn = Math.ceil(monHp / heroPerDamage);
|
||||
|
||||
// 支援,当怪物被支援且不包含支援标记时执行,因为支援怪不能再被支援了
|
||||
const guards = enemy.getAttribute('guard');
|
||||
if (guards.size > 0 && !this.inGuard) {
|
||||
this.inGuard = true;
|
||||
// 计算支援怪的伤害,同时把打支援怪花费的回合数加到当前怪物上,因为打支援怪的时候当前怪物也会打你
|
||||
// 因此回合数需要加上打支援怪的回合数
|
||||
for (const guard of guards) {
|
||||
// 直接把 enemy 传过去,因此支援的 enemy 会吃到其原本所在位置的光环加成
|
||||
const extraInfo = this.calculate({
|
||||
enemy: guard.getComputedEnemy(),
|
||||
locator,
|
||||
hero
|
||||
});
|
||||
turn += extraInfo.turn;
|
||||
damage += extraInfo.damage;
|
||||
}
|
||||
this.inGuard = false;
|
||||
}
|
||||
|
||||
// 先攻
|
||||
if (enemy.hasSpecial(1)) {
|
||||
damage += enemyPerDamage;
|
||||
}
|
||||
|
||||
// 破甲
|
||||
const breakArmor = enemy.getSpecial<number>(7);
|
||||
if (breakArmor) {
|
||||
damage += (breakArmor.value / 100) * def;
|
||||
}
|
||||
|
||||
// 反击
|
||||
const counterAttack = enemy.getSpecial<number>(8);
|
||||
if (counterAttack) {
|
||||
// 反击是每回合生效,因此加到 enemyPerDamage 上
|
||||
enemyPerDamage += (counterAttack.value / 100) * atk;
|
||||
}
|
||||
|
||||
// 净化
|
||||
const purify = enemy.getSpecial<number>(9);
|
||||
if (purify) {
|
||||
damage += purify.value * mdef;
|
||||
}
|
||||
|
||||
damage += (turn - 1) * enemyPerDamage;
|
||||
|
||||
// 魔防
|
||||
damage -= mdef;
|
||||
|
||||
// 未开启负伤时,如果伤害为负,则设为 0
|
||||
if (!core.flags.enableNegativeDamage && damage < 0) {
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
// 固伤,无法被魔防减伤
|
||||
const fixedDamage = enemy.getSpecial<number>(22);
|
||||
if (fixedDamage) {
|
||||
damage += fixedDamage.value;
|
||||
}
|
||||
|
||||
// 仇恨,无法被魔防减伤
|
||||
if (enemy.hasSpecial(17)) {
|
||||
damage += core.getFlag('hatred', 0);
|
||||
}
|
||||
|
||||
return {
|
||||
damage: Math.floor(damage),
|
||||
turn
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取临界计算的上界
|
||||
* @param handler 信息对象
|
||||
* @param attribute 目标属性名
|
||||
*/
|
||||
getCriticalLimit(
|
||||
handler: IReadonlyEnemyHandler<IEnemyAttr, IHeroAttr>,
|
||||
attribute: CriticalableHeroStatus<IHeroAttr>
|
||||
): number {
|
||||
switch (attribute) {
|
||||
case 'atk': {
|
||||
if (handler.enemy.hasSpecial(3)) {
|
||||
return Infinity;
|
||||
}
|
||||
return (
|
||||
handler.enemy.getAttribute('def') +
|
||||
handler.enemy.getAttribute('hp')
|
||||
);
|
||||
}
|
||||
}
|
||||
return handler.hero.getFinalAttribute(attribute);
|
||||
}
|
||||
}
|
||||
@ -1,29 +1,28 @@
|
||||
import { IEnemy, IEnemyFinalEffect } from '@user/data-base';
|
||||
import { IEnemyAttributes } from './types';
|
||||
import { ITileLocator } from '@motajs/common';
|
||||
import { IEnemyFinalEffect, IEnemyHandler } from '@user/data-base';
|
||||
import { IEnemyAttr } from './types';
|
||||
import { IHeroAttr } from '../hero';
|
||||
|
||||
const HERO_STATUS_PLACEHOLDER = {
|
||||
atk: 0,
|
||||
def: 0
|
||||
} as const;
|
||||
|
||||
export class MainEnemyFinalEffect implements IEnemyFinalEffect<IEnemyAttributes> {
|
||||
export class MainEnemyFinalEffect implements IEnemyFinalEffect<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
readonly priority: number = 0;
|
||||
|
||||
apply(enemy: IEnemy<IEnemyAttributes>, _locator: ITileLocator): void {
|
||||
apply(handler: IEnemyHandler<IEnemyAttr, IHeroAttr>): void {
|
||||
const enemy = handler.enemy;
|
||||
const heroAtk = handler.hero.getFinalAttribute('atk');
|
||||
const heroDef = handler.hero.getFinalAttribute('def');
|
||||
|
||||
// 3-坚固
|
||||
if (enemy.hasSpecial(3)) {
|
||||
const target = Math.max(
|
||||
enemy.getAttribute('def'),
|
||||
HERO_STATUS_PLACEHOLDER.atk - 1
|
||||
);
|
||||
const target = Math.max(enemy.getAttribute('def'), heroAtk - 1);
|
||||
enemy.setAttribute('def', target);
|
||||
}
|
||||
|
||||
// 10-模仿
|
||||
if (enemy.hasSpecial(10)) {
|
||||
enemy.setAttribute('atk', HERO_STATUS_PLACEHOLDER.atk);
|
||||
enemy.setAttribute('def', HERO_STATUS_PLACEHOLDER.def);
|
||||
enemy.setAttribute('atk', heroAtk);
|
||||
enemy.setAttribute('def', heroDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
export * from './aura';
|
||||
export * from './calculator';
|
||||
export * from './damage';
|
||||
export * from './final';
|
||||
export * from './legacy';
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { IEnemyLegacyBridge } from '@user/data-base';
|
||||
import { IEnemyAttributes } from './types';
|
||||
import { IEnemyAttr } from './types';
|
||||
|
||||
export class EnemyLegacyBridge implements IEnemyLegacyBridge<IEnemyAttributes> {
|
||||
export class EnemyLegacyBridge implements IEnemyLegacyBridge<IEnemyAttr> {
|
||||
fromLegacyEnemy(
|
||||
enemy: Enemy,
|
||||
defaultAttr: Partial<IEnemyAttributes>
|
||||
): IEnemyAttributes {
|
||||
defaultAttr: Partial<IEnemyAttr>
|
||||
): IEnemyAttr {
|
||||
return {
|
||||
hp: enemy.hp ?? defaultAttr.hp ?? 0,
|
||||
atk: enemy.atk ?? defaultAttr.atk ?? 0,
|
||||
|
||||
@ -11,17 +11,21 @@ import {
|
||||
RectRange,
|
||||
ITileLocator
|
||||
} from '@motajs/common';
|
||||
import { IReadonlyEnemy, ISpecial } from '@user/data-base';
|
||||
import {
|
||||
IEnemyContext,
|
||||
IMapDamageConverter,
|
||||
IMapDamageInfo,
|
||||
IMapDamageInfoExtra,
|
||||
IMapDamageReducer,
|
||||
IMapDamageView
|
||||
IReadonlyEnemyHandler,
|
||||
ISpecial,
|
||||
IMapDamageView,
|
||||
IReadonlyHeroAttribute,
|
||||
IReadonlyEnemy
|
||||
} from '@user/data-base';
|
||||
import { IZoneValue } from './special';
|
||||
import { IEnemyAttributes, MapDamageType } from './types';
|
||||
import { IEnemyAttr, MapDamageType } from './types';
|
||||
import { IHeroAttr } from '../hero';
|
||||
|
||||
const RECT_RANGE = new RectRange();
|
||||
const MANHATTAN_RANGE = new ManhattanRange();
|
||||
@ -33,7 +37,9 @@ const DIR4 = [...DIRECTION_MAPPER.map(InternalDirectionGroup.Dir4)];
|
||||
//#region 地图伤害
|
||||
|
||||
abstract class BaseMapDamageView<T> implements IMapDamageView<T> {
|
||||
constructor(protected readonly context: IEnemyContext<IEnemyAttributes>) {}
|
||||
constructor(
|
||||
protected readonly context: IEnemyContext<IEnemyAttr, IHeroAttr>
|
||||
) {}
|
||||
|
||||
abstract getRange(): IRange<T>;
|
||||
|
||||
@ -80,7 +86,7 @@ export class ZoneDamageView extends BaseMapDamageView<
|
||||
IRectRangeParam | IManhattanRangeParam
|
||||
> {
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>,
|
||||
private readonly special: Readonly<ISpecial<IZoneValue>>
|
||||
) {
|
||||
@ -108,16 +114,14 @@ export class ZoneDamageView extends BaseMapDamageView<
|
||||
};
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(
|
||||
_locator: ITileLocator
|
||||
): Readonly<IMapDamageInfo> | null {
|
||||
getDamageWithoutCheck(): Readonly<IMapDamageInfo> | null {
|
||||
return this.createInfo(this.special.value.zone, MapDamageType.Zone);
|
||||
}
|
||||
}
|
||||
|
||||
export class RepulseDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>,
|
||||
private readonly special: Readonly<ISpecial<number>>
|
||||
) {
|
||||
@ -151,7 +155,7 @@ export class RepulseDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
|
||||
export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>,
|
||||
private readonly special: Readonly<ISpecial<number>>,
|
||||
private readonly dir: IDirectionDescriptor[] = DIR4
|
||||
@ -171,23 +175,17 @@ export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
|
||||
};
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(
|
||||
locator: ITileLocator
|
||||
): Readonly<IMapDamageInfo> | null {
|
||||
if (locator.x === this.locator.x && locator.y === this.locator.y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(): Readonly<IMapDamageInfo> | null {
|
||||
return this.createInfo(this.special.value, MapDamageType.Layer);
|
||||
}
|
||||
}
|
||||
|
||||
export class BetweenDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
private static readonly DAMAGE = 1;
|
||||
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
private readonly locator: Readonly<ITileLocator>
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly enemy: IReadonlyEnemy<IEnemyAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>,
|
||||
private readonly hero: IReadonlyHeroAttribute<IHeroAttr>
|
||||
) {
|
||||
super(context);
|
||||
}
|
||||
@ -228,17 +226,34 @@ export class BetweenDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
if (!other) {
|
||||
return null;
|
||||
}
|
||||
if (!other.getComputedEnemy().hasSpecial(16)) {
|
||||
const otherEnemy = other.getComputedEnemy();
|
||||
if (!otherEnemy.hasSpecial(16)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.createInfo(BetweenDamageView.DAMAGE, MapDamageType.Between);
|
||||
const half = this.hero.getFinalAttribute('hp') / 2;
|
||||
if (core.flags.betweenAttackMax) {
|
||||
// 夹击不超伤害值,需要获取两个怪物的伤害
|
||||
const sys = this.context.getDamageSystem();
|
||||
if (!sys) {
|
||||
return this.createInfo(half, MapDamageType.Between);
|
||||
} else {
|
||||
const currInfo = sys.getDamageInfoByComputed(this.enemy);
|
||||
const otherInfo = sys.getDamageInfoByComputed(otherEnemy);
|
||||
const currDamage = currInfo?.damage ?? Infinity;
|
||||
const otherDamage = otherInfo?.damage ?? Infinity;
|
||||
const min = Math.min(half, currDamage, otherDamage);
|
||||
return this.createInfo(min, MapDamageType.Between);
|
||||
}
|
||||
} else {
|
||||
return this.createInfo(half, MapDamageType.Between);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class AmbushDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>
|
||||
) {
|
||||
super(context);
|
||||
@ -256,13 +271,7 @@ export class AmbushDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
};
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(
|
||||
locator: ITileLocator
|
||||
): Readonly<IMapDamageInfo> | null {
|
||||
if (locator.x === this.locator.x && locator.y === this.locator.y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(): Readonly<IMapDamageInfo> | null {
|
||||
return this.createInfo(0, MapDamageType.Unknown, {
|
||||
catch: new Set([this.locator])
|
||||
});
|
||||
@ -273,13 +282,16 @@ export class AmbushDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
|
||||
//#region 转换器
|
||||
|
||||
export class MainMapDamageConverter implements IMapDamageConverter<IEnemyAttributes> {
|
||||
export class MainMapDamageConverter implements IMapDamageConverter<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
convert(
|
||||
enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator,
|
||||
context: IEnemyContext<IEnemyAttributes>
|
||||
handler: IReadonlyEnemyHandler<IEnemyAttr, IHeroAttr>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>
|
||||
): IMapDamageView<any>[] {
|
||||
const views: IMapDamageView<any>[] = [];
|
||||
const { enemy, locator, hero } = handler;
|
||||
|
||||
const zone = enemy.getSpecial<IZoneValue>(15);
|
||||
if (zone) {
|
||||
@ -287,7 +299,7 @@ export class MainMapDamageConverter implements IMapDamageConverter<IEnemyAttribu
|
||||
}
|
||||
|
||||
if (enemy.hasSpecial(16)) {
|
||||
views.push(new BetweenDamageView(context, locator));
|
||||
views.push(new BetweenDamageView(context, enemy, locator, hero));
|
||||
}
|
||||
|
||||
const repulse = enemy.getSpecial<number>(18);
|
||||
@ -313,10 +325,7 @@ export class MainMapDamageConverter implements IMapDamageConverter<IEnemyAttribu
|
||||
//#region 合并器
|
||||
|
||||
export class MainMapDamageReducer implements IMapDamageReducer {
|
||||
reduce(
|
||||
info: Iterable<Readonly<IMapDamageInfo>>,
|
||||
_locator: ITileLocator
|
||||
): Readonly<IMapDamageInfo> {
|
||||
reduce(info: Iterable<Readonly<IMapDamageInfo>>): Readonly<IMapDamageInfo> {
|
||||
let damage = 0;
|
||||
let type = MapDamageType.Unknown;
|
||||
let maxDamage = -Infinity;
|
||||
|
||||
@ -4,7 +4,7 @@ import {
|
||||
IEnemyManager
|
||||
} from '@user/data-base';
|
||||
import { getHeroStatusOn } from '../legacy/hero';
|
||||
import { IEnemyAttributes } from './types';
|
||||
import { IEnemyAttr } from './types';
|
||||
|
||||
//#region 复合属性值类型
|
||||
|
||||
@ -48,9 +48,7 @@ export interface IHaloValue {
|
||||
* 8. 重生属性:还在脚本编辑的 changingFloor
|
||||
* 9. 阻击 | 捕捉 的每步效果:packages-user/legacy-plugin-data/src/enemy/checkblock.ts
|
||||
*/
|
||||
export function registerSpecials(
|
||||
manager: IEnemyManager<IEnemyAttributes>
|
||||
): void {
|
||||
export function registerSpecials(manager: IEnemyManager<IEnemyAttr>): void {
|
||||
manager.setAttributeDefaults('guard', new Set());
|
||||
|
||||
// 0 - 空
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { IEnemyView } from '@user/data-base';
|
||||
|
||||
export interface IEnemyAttributes {
|
||||
export interface IEnemyAttr {
|
||||
/** 怪物生命值 */
|
||||
hp: number;
|
||||
/** 怪物攻击力 */
|
||||
@ -14,7 +14,7 @@ export interface IEnemyAttributes {
|
||||
/** 怪物加点量 */
|
||||
point: number;
|
||||
/** 支援来源怪物视图列表 */
|
||||
guard: Set<IEnemyView<IEnemyAttributes>>;
|
||||
guard: Set<IEnemyView<IEnemyAttr>>;
|
||||
}
|
||||
|
||||
export const enum MapDamageType {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//#region 勇士属性
|
||||
|
||||
export interface IHeroAttributeObject {
|
||||
export interface IHeroAttr {
|
||||
/** 勇士名称 */
|
||||
name: string;
|
||||
/** 勇士生命值 */
|
||||
|
||||
@ -288,7 +288,7 @@ export class HeroMover extends ObjectMoverBase {
|
||||
protected async onMoveStart(controller: IMoveController): Promise<void> {
|
||||
this.beforeMoveSpeed = this.moveSpeed;
|
||||
if (!core.isReplaying() || core.status.replay.speed <= 12) {
|
||||
state.hero.startMove();
|
||||
state.hero.mover.startMove();
|
||||
}
|
||||
// 这里要检查前面那一格能不能走,不能走则不触发平滑视角,以避免撞墙上视角卡住
|
||||
if (!this.ignoreTerrain) {
|
||||
@ -310,7 +310,7 @@ export class HeroMover extends ObjectMoverBase {
|
||||
protected async onMoveEnd(controller: IMoveController): Promise<void> {
|
||||
this.moveSpeed = this.beforeMoveSpeed;
|
||||
this.onSetMoveSpeed(this.moveSpeed, controller);
|
||||
await state.hero.endMove();
|
||||
await state.hero.mover.endMove();
|
||||
// viewport.sync('endMove');
|
||||
core.clearContinueAutomaticRoute();
|
||||
core.stopAutomaticRoute();
|
||||
@ -442,19 +442,22 @@ export class HeroMover extends ObjectMoverBase {
|
||||
const replaying = core.isReplaying();
|
||||
if (replaying) {
|
||||
if (core.status.replay.speed > 12) {
|
||||
await state.hero.endMove();
|
||||
await state.hero.mover.endMove();
|
||||
await sleep(speed);
|
||||
state.hero.setPosition(x, y);
|
||||
state.hero.mover.setPosition(x, y);
|
||||
} else {
|
||||
state.hero.startMove();
|
||||
await state.hero.move(
|
||||
state.hero.mover.startMove();
|
||||
await state.hero.mover.move(
|
||||
fromDirectionString(moveDir),
|
||||
this.moveSpeed / core.status.replay.speed
|
||||
);
|
||||
}
|
||||
} else {
|
||||
state.hero.startMove();
|
||||
await state.hero.move(fromDirectionString(moveDir), this.moveSpeed);
|
||||
state.hero.mover.startMove();
|
||||
await state.hero.mover.move(
|
||||
fromDirectionString(moveDir),
|
||||
this.moveSpeed
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IHeroAttributeObject } from './hero';
|
||||
import { IHeroAttr } from './hero';
|
||||
|
||||
/** 每个地图的默认宽度 */
|
||||
export const TILE_WIDTH = 13;
|
||||
@ -11,7 +11,7 @@ export const TILE_HEIGHT = 13;
|
||||
export const DEFAULT_HERO_IMAGE: ImageIds = 'hero.png';
|
||||
|
||||
/** 勇士的初始属性,数值填多少目前都无所谓,因为最终会从旧样板读取,但是必须得填 */
|
||||
export const HERO_DEFAULT_ATTRIBUTE: IHeroAttributeObject = {
|
||||
export const HERO_DEFAULT_ATTRIBUTE: IHeroAttr = {
|
||||
name: '',
|
||||
hp: 1,
|
||||
hpmax: 0,
|
||||
|
||||
@ -6,12 +6,12 @@ import {
|
||||
IHeroFollower,
|
||||
IHeroState
|
||||
} from '@user/data-base';
|
||||
import { IEnemyAttributes } from './enemy/types';
|
||||
import { IHeroAttributeObject } from './hero';
|
||||
import { IEnemyAttr } from './enemy/types';
|
||||
import { IHeroAttr } from './hero';
|
||||
|
||||
export interface IGameDataState {
|
||||
/** 怪物管理器 */
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttr>;
|
||||
}
|
||||
|
||||
export interface IStateSaveData {
|
||||
@ -23,7 +23,7 @@ export interface ICoreState {
|
||||
/** 地图状态 */
|
||||
readonly layer: ILayerState;
|
||||
/** 勇士状态 */
|
||||
readonly hero: IHeroState<IHeroAttributeObject>;
|
||||
readonly hero: IHeroState<IHeroAttr>;
|
||||
/** 朝向绑定 */
|
||||
readonly roleFace: IRoleFaceBinder;
|
||||
/** id 到图块数字的映射 */
|
||||
@ -32,9 +32,9 @@ export interface ICoreState {
|
||||
readonly numberIdMap: Map<number, string>;
|
||||
|
||||
/** 怪物管理器 */
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttr>;
|
||||
/** 怪物上下文 */
|
||||
readonly enemyContext: IEnemyContext<IEnemyAttributes>;
|
||||
readonly enemyContext: IEnemyContext<IEnemyAttr, IHeroAttr>;
|
||||
|
||||
/**
|
||||
* 保存状态
|
||||
|
||||
@ -153,13 +153,13 @@ export function initFallback() {
|
||||
core.status.hero.loc[name] = value;
|
||||
if (name === 'direction') {
|
||||
const dir = fromDirectionString(value as Dir);
|
||||
state.hero.turn(dir);
|
||||
state.hero.mover.turn(dir);
|
||||
setHeroDirection(value as Dir);
|
||||
} else if (name === 'x') {
|
||||
// 为了防止逆天样板出问题
|
||||
core.bigmap.posX = value as number;
|
||||
if (!noGather) {
|
||||
state.hero.setPosition(
|
||||
state.hero.mover.setPosition(
|
||||
value as number,
|
||||
core.status.hero.loc.y
|
||||
);
|
||||
@ -168,7 +168,7 @@ export function initFallback() {
|
||||
// 为了防止逆天样板出问题
|
||||
core.bigmap.posY = value as number;
|
||||
if (!noGather) {
|
||||
state.hero.setPosition(
|
||||
state.hero.mover.setPosition(
|
||||
core.status.hero.loc.x,
|
||||
value as number
|
||||
);
|
||||
@ -218,7 +218,7 @@ export function initFallback() {
|
||||
|
||||
patch2.add('setHeroIcon', function (name: ImageIds) {
|
||||
core.status.hero.image = name;
|
||||
state.hero.setImage(name);
|
||||
state.hero.mover.setImage(name);
|
||||
});
|
||||
|
||||
patch.add('isMoving', function () {
|
||||
@ -564,7 +564,7 @@ export function initFallback() {
|
||||
time /= core.status.replay.speed;
|
||||
if (core.status.replay.speed === 24) time = 1;
|
||||
|
||||
await state.hero.jumpHero(ex, ey, time);
|
||||
await state.hero.mover.jumpHero(ex, ey, time);
|
||||
|
||||
if (!locked) core.unlockControl();
|
||||
core.setHeroLoc('x', ex);
|
||||
|
||||
@ -165,6 +165,7 @@
|
||||
"107": "Hero status is not bound, damage calculation is unavailable.",
|
||||
"108": "Hero modifier '$1' has already been added once. Ignore repeated add for attribute '$2'.",
|
||||
"109": "Expected a different object reference returned, but got a same reference at modifier '$1' for property '$2'.",
|
||||
"110": "Expected a hero attribute binding before executing any enemy context calculation.",
|
||||
"1001": "Item-detail extension needs 'floor-binder' and 'floor-damage' extension as dependency."
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,19 +104,20 @@ export class ManhattanRange extends BaseRange<IManhattanRangeParam> {
|
||||
protected estimatePointCount(
|
||||
param: Readonly<IManhattanRangeParam>
|
||||
): number {
|
||||
const radius = Math.max(0, param.radius);
|
||||
const radius = Math.abs(param.radius);
|
||||
return 1 + 2 * radius * (radius + 1);
|
||||
}
|
||||
|
||||
*iterateLoc(param: Readonly<IManhattanRangeParam>): Iterable<number> {
|
||||
const { width, height } = this.host;
|
||||
for (let dy = -param.radius; dy <= param.radius; dy++) {
|
||||
const radius = Math.abs(param.radius);
|
||||
for (let dy = -radius; dy <= radius; dy++) {
|
||||
const y = param.cy + dy;
|
||||
if (y < 0 || y >= height) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const span = param.radius - Math.abs(dy);
|
||||
const span = radius - Math.abs(dy);
|
||||
const startX = Math.max(0, param.cx - span);
|
||||
const endX = Math.min(width - 1, param.cx + span);
|
||||
for (let x = startX; x <= endX; x++) {
|
||||
@ -130,10 +131,10 @@ export class ManhattanRange extends BaseRange<IManhattanRangeParam> {
|
||||
y: number,
|
||||
param: Readonly<IManhattanRangeParam>
|
||||
): boolean {
|
||||
return (
|
||||
this.inBound(x, y) &&
|
||||
Math.abs(x - param.cx) + Math.abs(y - param.cy) <= param.radius
|
||||
);
|
||||
const radius = Math.abs(param.radius);
|
||||
const dx = Math.abs(x - param.cx);
|
||||
const dy = Math.abs(y - param.cy);
|
||||
return this.inBound(x, y) && dx + dy <= radius;
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,6 +142,7 @@ export class RayRange extends BaseRange<IRayRangeParam> {
|
||||
protected estimatePointCount(param: Readonly<IRayRangeParam>): number {
|
||||
const { width, height } = this.host;
|
||||
// 考虑到这种范围的 `inRange` 判断要更加耗时,因此将返回值略微降低,更倾向于使用 `scan` 方式
|
||||
// 正常情况下应该 / 2
|
||||
return ((width + height) * param.dir.length) / 3;
|
||||
}
|
||||
|
||||
|
||||
98
tasks.md
98
tasks.md
@ -1,98 +0,0 @@
|
||||
## 第二章 智慧
|
||||
|
||||
### 怪物
|
||||
|
||||
[x] 同化
|
||||
[x] 同化+阻击
|
||||
[x] 电摇嘲讽:到同行或同列直接怼过去,门和墙撞碎,不消耗钥匙,攻击怪物,捡道具,改变 bgm,可吃补给用
|
||||
[x] 乾坤挪移:平移光环位置
|
||||
[x] 加光环的光环
|
||||
|
||||
### Boss
|
||||
|
||||
音游,音乐为一个被遗忘的夜晚,可选简单与困难,困难可获得成就冰与火之舞
|
||||
|
||||
玩法:一个会转动的圆盘,带有一个伸出去的把手,boss 从四面八方射子弹,当子弹恰好落到把手前端时,点击按键或屏幕,可以抵挡子弹,简单难度 3 条命,困难 1 条。简单难度音符密度低。困难难度为冰与火之舞的节奏。简单难度判定时间为前后各 100ms,困难为 50ms
|
||||
|
||||
### 技能
|
||||
|
||||
[x] 铸剑为盾:主动技能,减少攻击,增加防御
|
||||
|
||||
### 机制
|
||||
|
||||
[x] 苍蓝之殿 1: 红蓝黄门转换
|
||||
[x] 苍蓝之殿 2: 乾坤挪移、杀戮光环等
|
||||
[x] 苍蓝之殿 3: 传送门
|
||||
[x] 苍蓝之殿 4: 同化
|
||||
[x] 苍蓝之殿中: 让我们把这些东西结合起来...
|
||||
|
||||
### 成就
|
||||
|
||||
[x] 虚惊一场:打完山洞门口的怪只剩 1 滴血
|
||||
[x] 真能刷:勇气之路的刷血怪刷到 15w 以上的血
|
||||
[] 冰与火之舞:通过第二章特殊战的困难难度
|
||||
[x] 你是怎么做到的?!:山路地图与勇气之路地图中与若干个神秘的木牌对话
|
||||
|
||||
## 第三章 战争
|
||||
|
||||
移入飞书文档。
|
||||
|
||||
## 第四章 和平
|
||||
|
||||
移入飞书文档。
|
||||
|
||||
## 零散 TODO
|
||||
|
||||
[x] 成就系统
|
||||
[] 自动宝物规划,选中两个或更多宝物后自动在本地图中规划出最优拾取路线,原则是尽量减少其余宝物的捡拾,自动切换主动技能,怪物造成的伤害最低的路线
|
||||
[x] 临界显示方式,宝石数还是数值
|
||||
[x] 怪物目标设定
|
||||
[x] 木牌查看系统(百科全书)
|
||||
[] 每个怪物加一个怪物说明
|
||||
[] 歌词展示系统
|
||||
[x] 小地图显示框,可以选择是否显示剩余怪物数量等
|
||||
[x] 怪物死亡特效
|
||||
[] 区域名称显示特效,3D 粒子特效
|
||||
[x] 单独的工具栏,可以自定义按键
|
||||
[x] 完全 ts 化
|
||||
[] 平行光(待定)
|
||||
[] 视角控制系统
|
||||
[x] 重构设置界面
|
||||
[] 优化开头动画
|
||||
[x] 玩家可以设置字体大小
|
||||
[] 完全删除 functions.js
|
||||
[x] 优化插件加载系统
|
||||
[] 重写技能控制系统
|
||||
[x] 自定义快捷键
|
||||
[x] 优化 ui 控制系统
|
||||
[x] 优化游戏进程与渲染进程间的通讯
|
||||
[x] 优化资源分离,音乐放到 bgm 目录下
|
||||
[] 一次性道具拾取与清怪
|
||||
[] 重构数据统计
|
||||
[] 优化路径显示,瞬移可以闪一下再熄灭
|
||||
[] 勇士身上显示攻防血
|
||||
[] 优化地图拖动
|
||||
[x] 加入随机小贴士
|
||||
[x] ui 中如果元素发生改变,那么做出背景亮一下再熄灭的效果
|
||||
[] 双击怪物手册拐点可以直接在拖动条上定位
|
||||
[x] 重构技能树结构
|
||||
[] 技能树允许自动升级
|
||||
[] 重构装备系统
|
||||
[x] 弹幕系统
|
||||
[x] 优化各种 ui
|
||||
[] 怪物脚下加入阴影
|
||||
[x] 着色器特效
|
||||
[x] 完全删除 core.plugin,采用 Plugin.register 的形式进行插件编写
|
||||
[x] 完善加载系统
|
||||
[] 不同怪物可以在怪物手册中添加一些不同的边框
|
||||
[] 按住一个按键时显示怪物的攻防血
|
||||
[] 新的事件系统,并丰富自定义事件
|
||||
[] 事件、eval 内容预编译
|
||||
[x] 渐变切 bgm
|
||||
[] 新的 Flag 系统,使用 for 申请变量,dispose 释放变量,可设为渲染进程与游戏进程共通变量
|
||||
[] 机关门显示绑定怪物
|
||||
[x] 复写 api,rewrite()
|
||||
[x] Box 组件右下角添加 resize 按钮
|
||||
[] 被光环加成的怪显示受到了哪些加成
|
||||
[x] 鼠标放到光环怪上时高亮它产生的光环
|
||||
[] 删除 unplugin-vue-components 插件,换用 import 引入
|
||||
@ -1,15 +0,0 @@
|
||||
## 更新记录
|
||||
|
||||
此处会列出每次更新的更新记录。
|
||||
|
||||
## 1.0.0-alpha
|
||||
|
||||
1. 新增第二章的前半部分,包含两个区域 - 智慧小径和冰封高原
|
||||
2. 重构大部分 ui,包括 怪物手册、楼层传送器、装备栏、道具栏、状态栏、开始界面、商店 等
|
||||
3. 新增成就系统
|
||||
4. 新增怪物标记功能
|
||||
5. 新增定点查看功能与快捷查看怪物属性功能
|
||||
6. 新增百科全书
|
||||
7. 新增自动切换技能
|
||||
8. 新增全屏游戏
|
||||
9. 修复录像
|
||||
Loading…
Reference in New Issue
Block a user