From d11699e06e72f38078fe2a8ff13d3d3d924e6e00 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 28 Sep 2024 18:04:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=AD=A6=E4=B9=A0?= =?UTF-8?q?=E4=B8=8E=E8=83=9C=E5=88=A9=E4=B9=8B=E5=8F=B7=E6=8A=80=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/project/floors/MT50.js | 4 +- public/project/floors/MT92.js | 26 ++++---- src/plugin/game/skillTree.ts | 108 +++++++++++++++++++--------------- src/ui/skillTree.vue | 18 ++---- src/ui/statusBar.vue | 14 ++++- 5 files changed, 93 insertions(+), 77 deletions(-) diff --git a/public/project/floors/MT50.js b/public/project/floors/MT50.js index 958ee1f..6cbc0cb 100644 --- a/public/project/floors/MT50.js +++ b/public/project/floors/MT50.js @@ -43,7 +43,9 @@ main.floors.MT50= "打完左下角和右下角的boss之后,开四个机关门", "注意不要忘记购买装备,到了下一章之后本章的商店将不能到达,不过快捷商店还会保留。这些装备在下一章都会有向上合成", "本区域可以使用跳跃技能,不要忘记了。", - "注意火炬可通行,而且跳跃时会跳过火炬,不会跳到火炬上。" + "注意火炬可通行,而且跳跃时会跳过火炬,不会跳到火炬上。", + "三章及以后还会有魔攻怪,因此魔法防御技能的长期收益会较大", + "本区请至少留下一个红钥匙" ] }, "changeFloor": { diff --git a/public/project/floors/MT92.js b/public/project/floors/MT92.js index 914f9cb..742cc96 100644 --- a/public/project/floors/MT92.js +++ b/public/project/floors/MT92.js @@ -42,19 +42,19 @@ main.floors.MT92= "cannotMoveIn": {}, "map": [ [648,648,648,648,648,648,648, 91,648,648,648,648,648,648,648], - [648, 0, 0, 0, 0, 0, 0, 0, 0,648, 0, 0,648, 0,648], - [648, 0,648,648,648, 0,648,648,648,648,658,648,648, 0,648], - [648, 0, 0,648, 0, 0,648, 0,494, 0, 0, 0,232, 0,648], - [648, 0, 0,648, 0, 0, 0, 0,648,648,648,648,648, 0,648], - [648,648,648,648, 0,648,648, 0,648, 0,644, 0,648, 0,648], - [648, 0, 0,648, 0,648, 0, 0,648, 0,648, 0,677, 0,648], - [ 92, 0, 0, 0, 0, 0, 0, 0,648, 0,648,648,648,648,648], - [648,513,648,648,648,648,648,492,648, 0,679, 0, 0, 0,648], - [648, 0,648, 0,578, 0, 0, 0,648,648,648,648,648,677,648], - [648, 0,648, 0,648,648,648,682,648, 0,538, 0,648, 0,648], - [648, 0,249, 0,648, 0, 0, 0,648, 0,648, 0,648, 0,648], - [648,648,648,648,648,657,648,648,648, 0,648,658,648,682,648], - [648, 0, 0, 0,618, 0, 0, 0,513, 0,648, 0,682, 0,648], + [648,376, 0,491,679, 0,484, 0, 0,648, 0,381,648, 0,648], + [648,671,648,648,648,682,648,648,648,648,658,648,648, 0,648], + [648,381,484,648,484, 0,648,482,494, 0, 0, 0,232, 0,648], + [648,484,378,648, 0, 28,657, 0,648,648,648,648,648, 0,648], + [648,648,648,648,658,648,648,492,648, 0,644, 0,648, 0,648], + [648, 0,482,648,491,648, 28, 0,648,491,648,484,677, 0,648], + [ 92, 0, 0,682, 0,658, 0,484,648,378,648,648,648,648,648], + [648,513,648,648,648,648,648,492,648, 0,679,491, 0, 27,648], + [648, 27,648,484,578,484, 0,381,648,648,648,648,648,677,648], + [648, 0,648, 0,648,648,648,682,648, 27,538,376,648,378,648], + [648,484,249, 28,648, 28, 0,482,648, 0,648,484,648,484,648], + [648,648,648,648,648,657,648,648,648,484,648,658,648,682,648], + [648,487,376,378,618, 0,491, 0,513, 0,648, 0,682, 0,648], [648,648,648,648,648,648,648,648,648,648,648,648,648,648,648] ], "bgmap": [ diff --git a/src/plugin/game/skillTree.ts b/src/plugin/game/skillTree.ts index a619c00..a590a68 100644 --- a/src/plugin/game/skillTree.ts +++ b/src/plugin/game/skillTree.ts @@ -1,5 +1,18 @@ let levels: number[] = []; +export type Chapter = 'chapter1' | 'chapter2'; + +export interface Skill { + index: number; + title: string; + desc: string[]; + consume: (level: number) => number; + front: [skill: number, level: number][]; + loc: LocArr; + max: number; + effect: (level: number) => string[]; +} + /** * @type {Record} */ @@ -9,21 +22,21 @@ export const skills: Record = { index: 0, title: '力量', desc: ['力量就是根本!可以通过智慧增加力量,每级增加2点攻击。'], - consume: '10 * level + 10', + consume: level => 10 * level + 10, front: [], loc: [1, 2], max: 10, - effect: ['攻击 + ${level * 2}'] + effect: level => [`攻击 + ${level * 2}`] }, { index: 1, title: '致命一击', desc: ['爆发出全部力量攻击敌人,每级增加5点额外攻击。'], - consume: '30 * level + 30', + consume: level => 30 * level + 30, front: [[0, 5]], loc: [2, 1], max: 10, - effect: ['额外攻击 + ${level * 5}'] + effect: level => [`额外攻击 + ${level * 5}`] }, { index: 2, @@ -32,31 +45,31 @@ export const skills: Record = { '主动技能,快捷键1,', '开启后会在战斗时会额外增加一定量的攻击,但同时减少一定量的防御。' ], - consume: '200 * level + 400', + consume: level => 200 * level + 400, front: [[1, 5]], loc: [4, 1], max: 5, - effect: ['增加${level * 10}%攻击,减少${level * 10}%防御'] + effect: level => [`增加${level * 10}%攻击,减少${level * 10}%防御`] }, { index: 3, title: '坚韧', desc: ['由智慧转化出坚韧!每级增加2点防御'], - consume: '10 * level + 10', + consume: level => 10 * level + 10, front: [], loc: [1, 4], max: 10, - effect: ['防御 + ${level * 2}'] + effect: level => [`防御 + ${level * 2}`] }, { index: 4, title: '回春', desc: ['让智慧化为治愈之泉水!每级增加1点生命回复'], - consume: '20 * level + 20', + consume: level => 20 * level + 20, front: [[3, 5]], loc: [2, 5], max: 25, - effect: ['生命回复 + ${level}'] + effect: level => [`生命回复 + ${level}`] }, { index: 5, @@ -64,21 +77,21 @@ export const skills: Record = { desc: [ '让生命变得更多一些吧!每吃50瓶血瓶就增加当前生命回复10%的生命回复' ], - consume: '1500', + consume: () => 1500, front: [[4, 25]], loc: [4, 5], max: 1, - effect: ['50瓶血10%生命回复'] + effect: () => [`50瓶血10%生命回复`] }, { index: 6, title: '坚固之盾', desc: ['让护甲更加坚硬一些吧!每级增加10点防御'], - consume: '50 + level * 50', + consume: level => 50 + level * 50, front: [[3, 5]], loc: [2, 3], max: 10, - effect: ['防御 + ${level * 10}'] + effect: level => [`防御 + ${level * 10}`] }, { index: 7, @@ -86,7 +99,7 @@ export const skills: Record = { desc: [ '第一章终极技能,战斗时智慧的 1/10 会充当等量护盾。' ], - consume: '2500', + consume: () => 2500, front: [ [6, 10], [5, 1], @@ -94,7 +107,7 @@ export const skills: Record = { ], loc: [5, 3], max: 1, - effect: ['战斗时智慧会充当护盾'] + effect: () => [`战斗时智慧会充当护盾`] } ], chapter2: [ @@ -102,21 +115,21 @@ export const skills: Record = { index: 8, title: '锋利', desc: ['让剑变得更加锋利!每级使攻击增加1%(buff式增加)'], - consume: 'level > 5 ? 50 * level ** 2 : 250 * level + 250', + consume: level => (level > 5 ? 50 * level ** 2 : 250 * level + 250), front: [], loc: [1, 2], max: 15, - effect: ['攻击增加${level}%'] + effect: level => [`攻击增加${level}%`] }, { index: 9, title: '坚硬', desc: ['让盾牌变得更加坚固!每级使防御增加1%(buff式增加)'], - consume: 'level > 5 ? 50 * level ** 2 : 250 * level + 250', + consume: level => (level > 5 ? 50 * level ** 2 : 250 * level + 250), front: [], loc: [1, 4], max: 15, - effect: ['防御增加${level}%'] + effect: level => [`防御增加${level}%`] }, { index: 10, @@ -125,59 +138,60 @@ export const skills: Record = { '主动技能,快捷键3,', '减少一定的攻击,增加一定的防御' ], - consume: '1000 * level ** 2 + 1000', + consume: level => 1000 * level ** 2 + 1000, front: [[9, 5]], loc: [2, 5], max: 5, - effect: ['增加${level * 10}%的防御,减少${level * 10}%的攻击'] + effect: level => [ + `增加${level * 10}%的防御,减少${level * 10}%的攻击` + ] }, { index: 11, - title: '学习', - desc: [ - '主动技能,可以消耗500智慧学习一个怪物的技能,', - '持续5场战斗,每学习一次消耗的智慧点增加250,每次升级使持续的战斗次数增加3次。更多信息可在学习后在百科全书查看。' - ], - consume: '2500 * 2 ** level + 5000', + title: '魔法盾', + desc: ['为主角提供魔法防御,每级增加100点魔法防御'], + consume: level => 5000 * level + 5000, front: [ [8, 10], [12, 10] ], loc: [4, 1], - max: 6, - effect: ['学习怪物技能,持续${level * 3 + 2}场战斗'] + max: 10, + effect: level => [`学习怪物技能,持续${level * 3 + 2}场战斗`] }, { index: 12, title: '聪慧', desc: ['使主角变得更加聪明,每级使绿宝石增加的智慧点上升5%'], - consume: 'level > 5 ? 100 * level ** 2 : 250 * level + 1250', + consume: level => + level > 5 ? 100 * level ** 2 : 250 * level + 1250, front: [ [8, 10], [9, 10] ], loc: [3, 3], max: 20, - effect: ['增加${level * 5}%绿宝石效果'] + effect: level => [`增加${level * 5}%绿宝石效果`] }, { index: 13, title: '治愈', desc: ['使主角能够更好地回复生命,每级使血瓶的加血量增加2%'], - consume: 'level > 5 ? 100 * level ** 2 : 250 * level + 1250', + consume: level => + level > 5 ? 100 * level ** 2 : 250 * level + 1250, front: [[10, 3]], loc: [4, 5], max: 20, - effect: ['增加${level * 2}%的血瓶回血量'] + effect: level => [`增加${level * 2}%的血瓶回血量`] }, { index: 14, title: '胜利之号', desc: [ '第二章终极技能,', - '每打一个怪物,勇士在本楼层对怪物造成的伤害便增加1%' + '勇士攻防增加10%(buff式增加)' ], - consume: '25000', + consume: () => 25000, front: [ [13, 10], [12, 10], @@ -185,7 +199,7 @@ export const skills: Record = { ], loc: [5, 3], max: 1, - effect: ['每打一个怪,勇士造成的伤害增加1%'] + effect: () => [`攻防增加10%`] } ] }; @@ -210,17 +224,9 @@ export function getSkillLevel(skill: number) { } export function getSkillConsume(skill: number) { - return eval( - getSkillFromIndex(skill)?.consume.replace( - /level(:\d+)?/g, - (str, $1) => { - if ($1) - return `Mota.Plugin.require('skillTree_g').getSkillLevel(${$1})`; - else - return `Mota.Plugin.require('skillTree_g').getSkillLevel(${skill})`; - } - ) ?? '' - ); + const s = getSkillFromIndex(skill); + if (!s) return 0; + return s.consume(getSkillLevel(skill)); } export function openTree() { @@ -285,7 +291,11 @@ export function upgradeSkill(skill: number) { core.setFlag('shieldOn', true); break; case 11: // 学习 - core.setItem('I565', 1); + core.status.hero.magicDef += 100; + break; + case 12: + core.addBuff('atk', 0.1); + core.addBuff('def', 0.1); break; } const consume = getSkillConsume(skill); diff --git a/src/ui/skillTree.vue b/src/ui/skillTree.vue index 216cdb2..7f9c5d1 100644 --- a/src/ui/skillTree.vue +++ b/src/ui/skillTree.vue @@ -87,6 +87,7 @@ import { sleep } from 'mutate-animate'; import { gameKey } from '@/core/main/custom/hotkey'; import { GameUi } from '@/core/main/custom/ui'; import { mainUi } from '@/core/main/init/ui'; +import type { Chapter } from '@/plugin/game/skillTree'; const props = defineProps<{ num: number; @@ -143,19 +144,10 @@ const desc = computed(() => { const effect = computed(() => { return [0, 1].map(v => { - return eval( - '`' + - `${v === 0 ? '当前效果:' : '下一级效果:'}` + - skill.value.effect - .join('') - .replace(/level(:\d+)?/g, (str, $1) => { - if ($1) - return `(skillTree.getSkillLevel(${$1}) + ${v})`; - else - return `(skillTree.getSkillLevel(${skill.value.index}) + ${v})`; - }) + - '`' - ); + const prefix = v === 0 ? '当前效果:' : '下一级效果:'; + const level = skillTree.getSkillLevel(skill.value.index); + const content = skill.value.effect(level); + return prefix + content.join(''); }) as [string, string]; }); diff --git a/src/ui/statusBar.vue b/src/ui/statusBar.vue index 10b7b4a..4b68123 100644 --- a/src/ui/statusBar.vue +++ b/src/ui/statusBar.vue @@ -62,6 +62,12 @@
{{ format(hero.def!) }} + +{{ format(hero.magicDef!) }}
@@ -167,7 +173,8 @@ const toShow: (keyof NumbericHeroStatus)[] = [ 'mana', // 额外攻击 'money', // 金币 'exp', // 经验 - 'lv' // 等级 + 'lv', // 等级 + 'magicDef' // 魔法防御 ]; watch(status, update); @@ -326,6 +333,11 @@ onUnmounted(() => { color: rgb(255, 211, 211); } +#status-magic-def { + line-height: 0; + color: rgb(176, 189, 255); +} + #status-hpmax { line-height: 0; color: rgb(167, 255, 167);