mirror of
https://github.com/motajs/template.git
synced 2026-11-16 00:44:43 +08:00
feat: 完成数据端数据类型的构建
This commit is contained in:
1 parent
c0a58706d9
commit
d12790280a
30 files changed
+885
-52
No files matched your search
@@ -122,7 +122,7 @@ export class CoreState implements ICoreState {
|
||||
// 图块
|
||||
this.tileStore = new TileStore();
|
||||
// 道具
|
||||
this.itemStore = new ItemStore<IHeroAttr>();
|
||||
this.itemStore = new ItemStore<IHeroAttr>(this.tileStore);
|
||||
// 地图
|
||||
this.mapStore = new MapStore();
|
||||
// 游戏事件
|
||||
|
||||
@@ -126,7 +126,7 @@ export function registerSpecials(manager: IEnemyManager<IEnemyAttr>): void {
|
||||
defineCommonSerializableSpecial(7, 0, {
|
||||
getSpecialName: () => '破甲',
|
||||
getDescription: special =>
|
||||
`战斗前,附加角色防御的${special.value || core.values.breakArmor}%作为伤害。`,
|
||||
`战斗前,附加角色防御的${special.value}%作为伤害。`,
|
||||
fromLegacyEnemy: enemy => enemy.breakArmor ?? 0
|
||||
})
|
||||
);
|
||||
@@ -137,7 +137,7 @@ export function registerSpecials(manager: IEnemyManager<IEnemyAttr>): void {
|
||||
defineCommonSerializableSpecial(8, 0, {
|
||||
getSpecialName: () => '反击',
|
||||
getDescription: special =>
|
||||
`战斗时,怪物每回合附加角色攻击的${special.value || core.values.counterAttack}%作为伤害,无视角色防御。`,
|
||||
`战斗时,怪物每回合附加角色攻击的${special.value}%作为伤害,无视角色防御。`,
|
||||
fromLegacyEnemy: enemy => enemy.counterAttack ?? 0
|
||||
})
|
||||
);
|
||||
@@ -148,7 +148,7 @@ export function registerSpecials(manager: IEnemyManager<IEnemyAttr>): void {
|
||||
defineCommonSerializableSpecial(9, 0, {
|
||||
getSpecialName: () => '净化',
|
||||
getDescription: special =>
|
||||
`战斗前,怪物附加角色护盾的${special.value || core.values.purify}倍作为伤害。`,
|
||||
`战斗前,怪物附加角色护盾的${special.value}倍作为伤害。`,
|
||||
fromLegacyEnemy: enemy => enemy.purify ?? 0
|
||||
})
|
||||
);
|
||||
|
||||
@@ -9,5 +9,6 @@ import { CoreState } from './core';
|
||||
* 否则可能导致录像验证失败。
|
||||
*/
|
||||
export const state = new CoreState({
|
||||
loadStarter: new WebLoadStarter()
|
||||
loadStarter: new WebLoadStarter(),
|
||||
coreURL: 'placeholder'
|
||||
});
|
||||
@@ -30,6 +30,7 @@ export const DEFAULT_HERO_IMAGE: ImageIds = 'hero.png';
|
||||
/** 勇士的初始属性,数值填多少目前都无所谓,因为最终会从旧样板读取,但是必须得填 */
|
||||
export const HERO_DEFAULT_ATTRIBUTE: IHeroAttr = {
|
||||
name: '',
|
||||
level: 0,
|
||||
hp: 1,
|
||||
hpmax: 0,
|
||||
atk: 0,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { IMotaDataLoader, IStateBase } from '@user/data-base';
|
||||
import { ILoadManager, ILoadTaskStarter } from '@motajs/loader';
|
||||
import { IStateSystem } from '@user/data-system';
|
||||
import { ISaveableContent } from '@user/data-common';
|
||||
import { IHeroAttr, ISaveableContent } from '@user/data-common';
|
||||
|
||||
//#region 数据端主对象
|
||||
|
||||
export interface ICoreStateConfig {
|
||||
/**
|
||||
@@ -9,6 +11,8 @@ export interface ICoreStateConfig {
|
||||
* 例如网页端会使用 Web 加载器,而 node 端会使用专门的 node 加载器
|
||||
*/
|
||||
readonly loadStarter: ILoadTaskStarter;
|
||||
/** 核心配置文件的 URL 路径,也就是 `core.jsonc` 的文件路径 */
|
||||
readonly coreURL: string;
|
||||
}
|
||||
|
||||
export interface ISaveableExecutor<T> {
|
||||
@@ -38,3 +42,82 @@ export interface ICoreState
|
||||
executor: ISaveableExecutor<T>
|
||||
): void;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 数据端主配置
|
||||
|
||||
export interface ICoreStateContentConfig {
|
||||
/** 地图文件夹路径 */
|
||||
readonly mapsDir: string;
|
||||
/** 需要加载的地图列表文件的文件路径 */
|
||||
readonly mapListDir: string;
|
||||
/** 怪物数据文件路径 */
|
||||
readonly enemyDir: string;
|
||||
/** 道具数据文件路径 */
|
||||
readonly itemDir: string;
|
||||
/** 图库数据文件路径 */
|
||||
readonly tileDir: string;
|
||||
}
|
||||
|
||||
export interface ICoreStateHeroInitConfig<T> {
|
||||
/** 勇士的初始横坐标 */
|
||||
readonly x: number;
|
||||
/** 勇士的初始纵坐标 */
|
||||
readonly y: number;
|
||||
/** 勇士初始所在楼层 */
|
||||
readonly floorId: string;
|
||||
/** 勇士的初始装备栏 */
|
||||
readonly equipSlots: string[];
|
||||
/** 勇士的初始属性 */
|
||||
readonly attribute: Readonly<T>;
|
||||
}
|
||||
|
||||
export interface ICoreStateInitConfig {
|
||||
/** 初始事件 id,游戏开始时将在执行完毕此事件后正式开始 */
|
||||
readonly startEvent: string;
|
||||
/** 勇士初始状态,包含起始位置、初始属性等 */
|
||||
readonly hero: ICoreStateHeroInitConfig<IHeroAttr>;
|
||||
}
|
||||
|
||||
export interface ICoreStateFlagConfig {
|
||||
/** 楼层传送是否要求在楼梯边才能使用 */
|
||||
readonly flyNearStair: boolean;
|
||||
/** 楼层传送是否为平面塔模式,即传送时会传送至上一次离开此位置的位置而非楼梯口 */
|
||||
readonly flyRecordLocation: boolean;
|
||||
/** 道具在首次拾取时是否显示其文字说明 */
|
||||
readonly itemHint: boolean;
|
||||
/** 是否启用负伤机制,开启后怪物总伤害可以变为负值 */
|
||||
readonly enableNegativeDamage: boolean;
|
||||
/** 是否限制夹击最高伤害为两夹击怪物中伤害最高者 */
|
||||
readonly betweenDamageMax: boolean;
|
||||
/** 是否启用轻按机制,即可以按下空格来拾取玩家四周的物品 */
|
||||
readonly enablePick: boolean;
|
||||
/** 若在寻路时需要穿过楼梯,是否允许穿越 */
|
||||
readonly ignoreChangeFLoor: boolean;
|
||||
/** 若继续前进会导致勇士受到地图伤害而死亡,是否允许前进 */
|
||||
readonly allowDeadZone: boolean;
|
||||
/** 是否允许点击瞬移 */
|
||||
readonly enableTeleport: boolean;
|
||||
/** 是否开启录像折叠,这可以使走路的录像大幅减少,但可能导致某些机制出错,可查看文档详细了解 */
|
||||
readonly enableRouteFolding: boolean;
|
||||
/** 是否开启瞬移合并机制,开启后,连续瞬移会在录像中合并为单次瞬移,但可能导致某些机制出错 */
|
||||
readonly enableTeleportMerge: boolean;
|
||||
}
|
||||
|
||||
export interface ICoreStateCoreConfig {
|
||||
/** 游戏的唯一标识符 */
|
||||
readonly name: string;
|
||||
/** 呈现给玩家的游戏名称 */
|
||||
readonly title: string;
|
||||
/** 游戏版本号,仅呈现作用,对游戏本身没有任何影响 */
|
||||
readonly version: string;
|
||||
/** 游戏数据配置 */
|
||||
readonly content: ICoreStateContentConfig;
|
||||
/** 游戏的初始状态数据 */
|
||||
readonly init: ICoreStateInitConfig;
|
||||
/** 游戏的全局设置 */
|
||||
readonly flag: ICoreStateFlagConfig;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Reference in new issue
Block a user