mirror of
https://github.com/motajs/template.git
synced 2026-11-19 02:34:30 +08:00
refactor: 删除 data-fallback
This commit is contained in:
1 parent
10755475a4
commit
e2e27d9ff2
11 files changed
+14
-174
No files matched your search
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"name": "@user/data-fallback",
|
||||
"dependencies": {
|
||||
"@motajs/legacy-common": "workspace:*",
|
||||
"@user/data-state": "workspace:*",
|
||||
"@user/data-base": "workspace:*"
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
import { logger } from '@motajs/common';
|
||||
import { Patch, PatchClass } from '@motajs/legacy-common';
|
||||
import { ICoreState } from '@user/data-state';
|
||||
|
||||
/**
|
||||
* Flag 系统 patch
|
||||
*/
|
||||
export function patchFlags(state: ICoreState) {
|
||||
const patch = new Patch(PatchClass.Control);
|
||||
const flags = state.flags;
|
||||
patch.add('setFlag', (name, value) => {
|
||||
logger.warn(56, 'core.setFlag', 'state.flags.setFieldValue');
|
||||
if (value === null || value === undefined) {
|
||||
flags.deleteField(name);
|
||||
} else {
|
||||
flags.setFieldValue(name, value);
|
||||
}
|
||||
});
|
||||
patch.add('getFlag', <T>(name: string, defaultValue?: T) => {
|
||||
logger.warn(56, 'core.getFlag', 'state.flags.getFieldValueDefaults');
|
||||
if (defaultValue === undefined) {
|
||||
return flags.getFieldValue<T>(name);
|
||||
} else {
|
||||
return flags.getFieldValueDefaults(name, defaultValue);
|
||||
}
|
||||
});
|
||||
patch.add('addFlag', (name, value) => {
|
||||
logger.warn(56, 'core.addFlag', 'state.flags.addFieldValue');
|
||||
if (typeof value !== 'number') return;
|
||||
flags.addFieldValue(name, value);
|
||||
});
|
||||
patch.add('hasFlag', name => {
|
||||
logger.warn(56, 'core.hasFlag', 'state.flags.occupied');
|
||||
return flags.occupied(name);
|
||||
});
|
||||
patch.add('removeFlag', name => {
|
||||
logger.warn(56, 'core.removeFlag', 'state.flags.deleteField');
|
||||
flags.deleteField(name);
|
||||
});
|
||||
|
||||
const switchName = (
|
||||
x?: number,
|
||||
y?: number,
|
||||
floorId?: string,
|
||||
name?: string
|
||||
) => {
|
||||
return (
|
||||
(floorId ?? core.status.floorId ?? ':f') +
|
||||
'@' +
|
||||
(x ?? 'x') +
|
||||
'@' +
|
||||
(y ?? 'y') +
|
||||
'@' +
|
||||
name
|
||||
);
|
||||
};
|
||||
|
||||
patch.add('getSwitch', (x, y, floorId, name, defaultValue) => {
|
||||
logger.warn(56, 'core.getSwitch', 'state.flags.getFieldValue');
|
||||
return flags.getFieldValueDefaults(
|
||||
switchName(x, y, floorId, name),
|
||||
defaultValue
|
||||
);
|
||||
});
|
||||
patch.add('setSwitch', (x, y, floorId, name, value) => {
|
||||
logger.warn(56, 'core.setSwitch', 'state.flags.setFieldValue');
|
||||
flags.setFieldValue(switchName(x, y, floorId, name), value);
|
||||
});
|
||||
patch.add('addSwitch', (x, y, floorId, name, value) => {
|
||||
logger.warn(56, 'core.addSwitch', 'state.flags.addFieldValue');
|
||||
flags.addFieldValue(switchName(x, y, floorId, name), value ?? 0);
|
||||
});
|
||||
patch.add('hasSwitch', (x, y, floorId, name) => {
|
||||
logger.warn(56, 'core.hasSwitch', 'state.flags.occupied');
|
||||
return flags.occupied(switchName(x, y, floorId, name));
|
||||
});
|
||||
patch.add('removeSwitch', (x, y, floorId, name) => {
|
||||
logger.warn(56, 'core.removeSwitch', 'state.flags.deleteField');
|
||||
flags.deleteField(switchName(x, y, floorId, name));
|
||||
});
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import { logger } from '@motajs/common';
|
||||
import { hook } from '@user/data-base';
|
||||
import { ICoreState } from '@user/data-state';
|
||||
|
||||
export function patchHero(state: ICoreState) {
|
||||
hook.on('resetHero', hero => {
|
||||
// patch 旧样板的 core.status.hero,主要是为编辑器服务的
|
||||
const attr = state.hero.getModifiableAttribute();
|
||||
const proxy = new Proxy(hero, {
|
||||
set(target, p, newValue) {
|
||||
logger.warn(56, 'core.status.hero', 'state.hero');
|
||||
target[p] = newValue;
|
||||
// @ts-expect-error 旧样板无法处理此类型
|
||||
attr.set(p, newValue);
|
||||
return true;
|
||||
},
|
||||
get(_, p) {
|
||||
logger.warn(56, 'core.status.hero', 'state.hero');
|
||||
// @ts-expect-error 旧样板无法处理此类型
|
||||
return attr.getBaseAttribute(p);
|
||||
}
|
||||
});
|
||||
core.status.hero = proxy;
|
||||
|
||||
// 不允许再使用旧样板的 flags 接口
|
||||
const flagsProxy = new Proxy(core.status.hero.flags, {
|
||||
set() {
|
||||
logger.error(54, 'flags', 'state.flags');
|
||||
return false;
|
||||
},
|
||||
get() {
|
||||
logger.error(54, 'flags', 'state.flags');
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
core.status.hero.flags = flagsProxy;
|
||||
window.flags = flagsProxy;
|
||||
});
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { ICoreState } from '@user/data-state';
|
||||
import { patchFlags } from './flag';
|
||||
import { patchHero } from './hero';
|
||||
|
||||
export function patchAll(state: ICoreState) {
|
||||
patchFlags(state);
|
||||
patchHero(state);
|
||||
}
|
||||
@@ -43,11 +43,10 @@ export interface IHaloValue {
|
||||
* 1. 调参类属性 | 仅影响战斗过程的属性:./damage.ts calDamageWithTurn 函数
|
||||
* 2. 地图伤害:./damage.ts DamageEnemy.calMapDamage 方法
|
||||
* 3. 光环属性:./damage.ts DamageEnemy.provideHalo 方法
|
||||
* 4. 仇恨 | 退化 等战后效果:packages-user/data-fallback/src/battle.ts 中的 afterBattle
|
||||
* 5. 中毒的每步效果:../state/move.ts HeroMover.onStepEnd 方法
|
||||
* 6. 中毒的瞬移效果:还在脚本编辑的 moveDirectly
|
||||
* 7. 衰弱效果:../state/hero.ts getHeroStatusOf 方法
|
||||
* 8. 重生属性:还在脚本编辑的 changingFloor
|
||||
* 4. 中毒的每步效果:../state/move.ts HeroMover.onStepEnd 方法
|
||||
* 5. 中毒的瞬移效果:还在脚本编辑的 moveDirectly
|
||||
* 6. 衰弱效果:../state/hero.ts getHeroStatusOf 方法
|
||||
* 7. 重生属性:还在脚本编辑的 changingFloor
|
||||
*/
|
||||
export function registerSpecials(manager: IEnemyManager<IEnemyAttr>): void {
|
||||
manager.setAttributeDefaults('guard', new Set());
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
"@user/data-common": "workspace:*",
|
||||
"@user/data-base": "workspace:*",
|
||||
"@user/data-system": "workspace:*",
|
||||
"@user/data-fallback": "workspace:*",
|
||||
"@user/data-state": "workspace:*"
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import * as LegacyCommon from '@motajs/legacy-common';
|
||||
import * as DataCommon from '@user/data-common';
|
||||
import * as DataBase from '@user/data-base';
|
||||
import * as DataSystem from '@user/data-system';
|
||||
import * as DataFallback from '@user/data-fallback';
|
||||
import * as DataState from '@user/data-state';
|
||||
|
||||
export function create() {
|
||||
@@ -13,7 +12,6 @@ export function create() {
|
||||
Mota.register('@user/data-common', DataCommon);
|
||||
Mota.register('@user/data-base', DataBase);
|
||||
Mota.register('@user/data-system', DataSystem);
|
||||
Mota.register('@user/data-fallback', DataFallback);
|
||||
Mota.register('@user/data-state', DataState);
|
||||
|
||||
DataBase.loading.emit('dataRegistered');
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { createMota } from './mota';
|
||||
import { create } from './create';
|
||||
import { patchAll } from '@user/data-fallback';
|
||||
import { loading } from '@user/data-base';
|
||||
import { Patch } from '@motajs/legacy-common';
|
||||
import { logger } from '@motajs/common';
|
||||
import { state } from '@user/data-state';
|
||||
|
||||
export function createData() {
|
||||
createMota();
|
||||
patchAll(state);
|
||||
create();
|
||||
|
||||
if (main.replayChecking) {
|
||||
|
||||
@@ -14,7 +14,6 @@ import type * as DataCommon from '@user/data-common';
|
||||
import type * as DataBase from '@user/data-base';
|
||||
import type * as DataSystem from '@user/data-system';
|
||||
import type * as DataState from '@user/data-state';
|
||||
import type * as DataFallback from '@user/data-fallback';
|
||||
import type * as LegacyPluginClient from '@user/legacy-plugin-client';
|
||||
// ---------- 必要的第三方库
|
||||
import type * as MutateAnimate from 'mutate-animate';
|
||||
@@ -37,7 +36,6 @@ interface ModuleInterface {
|
||||
'@user/data-common': typeof DataCommon;
|
||||
'@user/data-base': typeof DataBase;
|
||||
'@user/data-system': typeof DataSystem;
|
||||
'@user/data-fallback': typeof DataFallback;
|
||||
'@user/data-state': typeof DataState;
|
||||
'@user/legacy-plugin-client': typeof LegacyPluginClient;
|
||||
// ---------- 必要的第三方库
|
||||
|
||||
Reference in new issue
Block a user