diff --git a/src/app/assets/data/method-suit.json b/src/app/assets/data/method-suit.json new file mode 100644 index 0000000..bd8fc49 --- /dev/null +++ b/src/app/assets/data/method-suit.json @@ -0,0 +1,20 @@ +{ + "xianxia": ["逍遥诀", "乾坤大挪移", "九阳神功", "太乙真经", "玉女心经", "玄天剑法", "金刚不坏体", "九阴白骨爪", "紫霞神功", "北冥神功"], + "magic": ["幻影咒", "光明圣典", "黑暗秘法", "元素融合术", "灵魂束缚咒", "星辰召唤", "元素风暴", "禁咒之书", "魔力涌动", "时光逆流"], + "fantasy": ["精灵之歌", "龙语魔法", "亡灵召唤术", "元素之舞", "光之祈祷", "暗影潜行", "自然之怒", "梦境编织", "神谕降临", "时空裂缝"], + "technology": [ + "量子跃迁", + "神经链接", + "反重力引擎", + "时间加速仪", + "能量护盾", + "纳米修复", + "智能矩阵", + "量子纠缠器", + "空间折叠技术", + "光速引擎" + ], + "modern": ["格斗奥义", "枪械精通", "战术指挥", "黑客帝国", "狙击艺术", "特战突击", "信息战术", "潜行大师", "爆破专家", "心理战术"], + "imperial": ["帝王心术", "治国方略", "兵法六韬", "龙战于野", "一统江山", "九鼎之重", "天子剑意", "御龙在天", "天下布武", "皇极经世"], + "adventure": ["荒野求生", "宝藏探寻", "迷宫解谜", "勇者斗恶龙", "神秘遗迹", "航海日志", "大陆探险", "遗迹守护", "秘境追踪", "异界旅行"] +} diff --git a/src/app/components/init-modal/init-modal.component.html b/src/app/components/init-modal/init-modal.component.html index 4d79049..b1f2f76 100644 --- a/src/app/components/init-modal/init-modal.component.html +++ b/src/app/components/init-modal/init-modal.component.html @@ -21,11 +21,11 @@ {{ item.name }} } - {{ item.skillInfo.hp }} - {{ item.skillInfo.mp }} - {{ item.skillInfo.attack }} - {{ item.skillInfo.defence }} - {{ item.skillInfo.speed }} + {{ item.innateInfo.hp }} + {{ item.innateInfo.mp }} + {{ item.innateInfo.attack }} + {{ item.innateInfo.defence }} + {{ item.innateInfo.speed }} } diff --git a/src/app/layouts/character/character.component.html b/src/app/layouts/character/character.component.html index 37c4c1c..bc1789d 100644 --- a/src/app/layouts/character/character.component.html +++ b/src/app/layouts/character/character.component.html @@ -37,10 +37,10 @@
战斗属性
天资属性
- {{ character.skillInfo.hp }} - {{ character.skillInfo.mp }} - {{ character.skillInfo.attack }} - {{ character.skillInfo.defence }} - {{ character.skillInfo.speed }} + {{ character.innateInfo.hp }} + {{ character.innateInfo.mp }} + {{ character.innateInfo.attack }} + {{ character.innateInfo.defence }} + {{ character.innateInfo.speed }} diff --git a/src/app/models/battle.model.ts b/src/app/models/battle.model.ts index d3c2d7a..0d975d6 100644 --- a/src/app/models/battle.model.ts +++ b/src/app/models/battle.model.ts @@ -6,4 +6,4 @@ export interface BattleInfo { round: number; } -export type BattleCharacter = Omit & { isEnemy?: boolean }; +export type BattleCharacter = Omit & { isEnemy?: boolean }; diff --git a/src/app/models/character.model.ts b/src/app/models/character.model.ts index 045e4cc..bf5db24 100644 --- a/src/app/models/character.model.ts +++ b/src/app/models/character.model.ts @@ -4,7 +4,7 @@ export interface Character { id: string; baseInfo: BaseInfo; // 基本信息 statusInfo: StatusInfo; // 状态信息 - skillInfo: SkillInfo; // 技能点信息 + innateInfo: InnateInfo; // 技能点信息 levelInfo: LevelInfo; // 等级信息 attrInfo: AttrInfo; // 属性信息 } @@ -29,7 +29,7 @@ export interface StatusInfo { buffs: Buff[]; // 当前获得的状态 } -export interface SkillInfo { +export interface InnateInfo { hp: number; // 基础生命 mp: number; // 基础灵力 attack: number; // 攻击力 diff --git a/src/app/models/env.model.ts b/src/app/models/env.model.ts index 1824c28..cb5758a 100644 --- a/src/app/models/env.model.ts +++ b/src/app/models/env.model.ts @@ -1,3 +1,5 @@ +import { MethodSuit } from './method.model'; + export interface Env { id: string; name: string; // 环境名称 @@ -6,6 +8,7 @@ export interface Env { maxExp: number; // 最大经验值 weight: number; // 权重 galaxiesId: string; // 所属星系id + methodSuits: MethodSuit[]; } export enum EnvType { diff --git a/src/app/models/index.ts b/src/app/models/index.ts index 4f876e3..64e300d 100644 --- a/src/app/models/index.ts +++ b/src/app/models/index.ts @@ -6,6 +6,7 @@ export * from './env.model'; // 环境 export * from './event.model'; // 事件 export * from './item.model'; // 物品 export * from './log.model'; // 日志 +export * from './method.model'; // 功法 export * from './reward.model'; // 奖励池 export * from './runtime.model'; // 运行时 export * from './statistics.model'; // 统计 diff --git a/src/app/models/method.model.ts b/src/app/models/method.model.ts new file mode 100644 index 0000000..8cff4dc --- /dev/null +++ b/src/app/models/method.model.ts @@ -0,0 +1,18 @@ +export interface MethodConfig { + methods: Map; +} + +export interface MethodBook { + id: string; + suit: MethodSuit; // 功法体系 + level: number; // 当前残本对应体系等级 + skill: MethodSkill; // 功法技能 +} + +export interface MethodSuit { + name: string; // 功法体系名称 +} + +export interface MethodSkill { + name: string; // 功法技能名称 +} diff --git a/src/app/pages/method/method.component.html b/src/app/pages/method/method.component.html index 1ea5462..648474c 100644 --- a/src/app/pages/method/method.component.html +++ b/src/app/pages/method/method.component.html @@ -1 +1,7 @@ -

method works!

+@for (item of mothodConfig.methods; track $index) { + +
+ {{ item }} +
+
+} diff --git a/src/app/pages/method/method.component.ts b/src/app/pages/method/method.component.ts index 4939d09..6754661 100644 --- a/src/app/pages/method/method.component.ts +++ b/src/app/pages/method/method.component.ts @@ -1,10 +1,18 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { MethodBook, MethodConfig } from '@models'; +import { NzCardModule } from 'ng-zorro-antd/card'; @Component({ selector: 'app-method', standalone: true, - imports: [], + imports: [NzCardModule], templateUrl: './method.component.html', styleUrl: './method.component.less' }) -export class MethodComponent {} +export class MethodComponent implements OnInit { + mothodConfig: MethodConfig = { + methods: new Map() + }; + + ngOnInit() {} +} diff --git a/src/app/services/character.service.ts b/src/app/services/character.service.ts index 21b067a..d5bcef6 100644 --- a/src/app/services/character.service.ts +++ b/src/app/services/character.service.ts @@ -1,7 +1,7 @@ import { inject, Injectable } from '@angular/core'; import { delay, Observable, of } from 'rxjs'; -import { BaseInfo, Character, LogLevel, LogType, SkillInfo, StatusInfo, LevelInfo, AttrInfo } from '../models'; +import { BaseInfo, Character, LogLevel, LogType, InnateInfo, StatusInfo, LevelInfo, AttrInfo } from '../models'; import { CharacterEventOperate, Event, EventRes } from '../models/event.model'; import { StatisticsService } from '../storages/statistics.service'; import { EnvService } from './env.service'; @@ -35,7 +35,7 @@ export class CharacterService { power: 0, level: 0 }; - skillInfo: SkillInfo = { + innateInfo: InnateInfo = { hp: 0, mp: 0, attack: 0, @@ -112,16 +112,16 @@ export class CharacterService { level: level + 1 }); this.logSrv.log({ - msg: `恭喜你,获得了${this.skillInfo.hp}点生命,${this.skillInfo.mp}点灵力,${this.skillInfo.attack}点攻击,${this.skillInfo.defence}点防御和${this.skillInfo.speed}点敏捷\n`, + msg: `恭喜你,获得了${this.innateInfo.hp}点生命,${this.innateInfo.mp}点灵力,${this.innateInfo.attack}点攻击,${this.innateInfo.defence}点防御和${this.innateInfo.speed}点敏捷\n`, type: LogType.Character, level: LogLevel.Info }); this.setAttrInfo({ - hp: this.attrInfo.hp + this.skillInfo.hp, - mp: this.attrInfo.mp + this.skillInfo.mp, - attack: this.attrInfo.attack + this.skillInfo.attack, - defence: this.attrInfo.defence + this.skillInfo.defence, - speed: this.attrInfo.speed + this.skillInfo.speed + hp: this.attrInfo.hp + this.innateInfo.hp, + mp: this.attrInfo.mp + this.innateInfo.mp, + attack: this.attrInfo.attack + this.innateInfo.attack, + defence: this.attrInfo.defence + this.innateInfo.defence, + speed: this.attrInfo.speed + this.innateInfo.speed }); this.canUpgrade = false; } @@ -142,7 +142,7 @@ export class CharacterService { baseInfo: this.baseInfo, statusInfo: this.statusInfo, levelInfo: this.levelInfo, - skillInfo: this.skillInfo, + innateInfo: this.innateInfo, attrInfo: this.attrInfo }; } @@ -151,7 +151,7 @@ export class CharacterService { character.id && (this.id = character.id); character.baseInfo && this.setBaseInfo(character.baseInfo); character.statusInfo && this.setStatusInfo(character.statusInfo); - character.skillInfo && this.setSkillInfo(character.skillInfo); + character.innateInfo && this.setInnateInfo(character.innateInfo); character.attrInfo && this.setAttrInfo(character.attrInfo); character.levelInfo && this.setLevelInfo(character.levelInfo); } @@ -190,8 +190,8 @@ export class CharacterService { this.levelInfo = { ...this.levelInfo, ...levelInfo }; } - setSkillInfo(skillInfo: Partial) { - this.skillInfo = { ...this.skillInfo, ...skillInfo }; + setInnateInfo(innateInfo: Partial) { + this.innateInfo = { ...this.innateInfo, ...innateInfo }; this.updatePower(); } diff --git a/src/app/utils/generate.spec.ts b/src/app/utils/generate.spec.ts index abd8de5..f417f3f 100644 --- a/src/app/utils/generate.spec.ts +++ b/src/app/utils/generate.spec.ts @@ -23,11 +23,11 @@ describe('Util Generate', () => { expect(character.baseInfo.gender).toMatch(/^(男|女)$/); expect(character.baseInfo.age).toBeGreaterThanOrEqual(12); expect(character.baseInfo.talent).toEqual(jasmine.any(Array)); - expect(character.skillInfo.hp).toBeGreaterThanOrEqual(100); - expect(character.skillInfo.mp).toBeGreaterThanOrEqual(100); - expect(character.skillInfo.attack).toBeGreaterThanOrEqual(20); - expect(character.skillInfo.defence).toBeGreaterThanOrEqual(20); - expect(character.skillInfo.speed).toBeGreaterThanOrEqual(0); + expect(character.innateInfo.hp).toBeGreaterThanOrEqual(100); + expect(character.innateInfo.mp).toBeGreaterThanOrEqual(100); + expect(character.innateInfo.attack).toBeGreaterThanOrEqual(20); + expect(character.innateInfo.defence).toBeGreaterThanOrEqual(20); + expect(character.innateInfo.speed).toBeGreaterThanOrEqual(0); }); }); }); diff --git a/src/app/utils/generate.ts b/src/app/utils/generate.ts index 9ead66d..c1043c1 100644 --- a/src/app/utils/generate.ts +++ b/src/app/utils/generate.ts @@ -1,15 +1,14 @@ +import LEVELMAP from '@assets/data/level-map.json'; +import METHODS_SUITS from '@assets/data/method-suit.json'; +import NAMES from '@assets/data/names.json'; +import SURNAMES from '@assets/data/surnames.json'; +import TALENTS from '@assets/data/talents.json'; +import WORLDS from '@assets/data/worlds.json'; +import { BattleCharacter, CharacterTalent, Env, EnvType, InitCharacter, MethodSuit } from '@models'; import { v4 as uuidv4 } from 'uuid'; -import LEVELMAP from '../assets/data/level-map.json'; -import NAMES from '../assets/data/names.json'; -import SURNAMES from '../assets/data/surnames.json'; -import TALENTS from '../assets/data/talents.json'; -import WORLDS from '../assets/data/worlds.json'; -import { BattleCharacter, CharacterTalent, Env, EnvType, InitCharacter } from '../models'; - const SURNAMES_LEN = SURNAMES.length; const NAMES_LEN = NAMES.length; -const WORLDS_LEN = WORLDS.length; const TALENTS_LEN = TALENTS.length; /** @@ -34,7 +33,7 @@ export class Generate { age: Math.floor(Math.random() * 10) * 2 + 12, talent: getCharacterTalent(1) }, - skillInfo: { + innateInfo: { hp: Math.round(Math.random() * 40) + 100, mp: Math.round(Math.random() * 40) + 100, attack: Math.round(Math.random() * 40) + 20, @@ -46,7 +45,7 @@ export class Generate { static enemys(length: number, level: number = 0): BattleCharacter[] { return Array.from({ length }, (_, i) => { - const skillInfo = { + const innateInfo = { hp: Math.round(Math.random() * 40) + 100, mp: Math.round(Math.random() * 40) + 100, attack: Math.round(Math.random() * 40) + 20, @@ -54,11 +53,11 @@ export class Generate { speed: Math.round(Math.random() * 40) }; const attrInfo = { - hp: (1 + level) * skillInfo.hp, - mp: (1 + level) * skillInfo.mp, - attack: (1 + level) * skillInfo.attack, - defence: (1 + level) * skillInfo.defence, - speed: (1 + level) * skillInfo.speed, + hp: (1 + level) * innateInfo.hp, + mp: (1 + level) * innateInfo.mp, + attack: (1 + level) * innateInfo.attack, + defence: (1 + level) * innateInfo.defence, + speed: (1 + level) * innateInfo.speed, critRate: Math.round(Math.random() * 5) + 2, critDamage: Math.round(Math.random() * 20) + 10 }; @@ -107,20 +106,33 @@ export class Generate { envs: Array.from({ length }, (_, i) => { const weight: number = Number((Math.random() * 0.5 + 0.75).toFixed(2)); const type: EnvType = Object.values(EnvType)[Math.floor(Math.random() * Object.keys(EnvType).length)]; + const WORLDS_NAMES = WORLDS[type]; + const WORLDS_LEN = WORLDS_NAMES.length; return { id: `env-${uuidv4()}`, - name: WORLDS[Math.floor(Math.random() * WORLDS_LEN)], + name: WORLDS_NAMES[Math.floor(Math.random() * WORLDS_LEN)], type, galaxiesId, levelMap: LEVELMAP[type][0], weight, // TODO: 测试用数据,调低了最大经验 - maxExp: Math.round((Math.random() * 0.4 + 0.8) * weight * 10000) + maxExp: Math.round((Math.random() * 0.4 + 0.8) * weight * 10000), + methodSuits: this.methods(2, type) }; }), galaxiesId }; } + + static methods(length: number, type: EnvType): MethodSuit[] { + const METHODS_SUITS_NAMES = METHODS_SUITS[type]; + const METHODS_SUITS_LEN = METHODS_SUITS_NAMES.length; + return Array.from({ length }, (_, i) => { + return { + name: METHODS_SUITS_NAMES[Math.floor(Math.random() * METHODS_SUITS_LEN)] + }; + }); + } } /**