From 9bab089a14293bcde52976b05bb2f7e4c2acdfbb Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 7 Aug 2023 17:57:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E6=80=AA=E7=89=A9=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- idea.md | 1 + public/_server/editor_multi.js | 6 +- public/_server/table/comment.js | 13 +- public/libs/enemys.js | 152 ++---------------- public/libs/events.js | 45 +----- public/project/functions.js | 225 --------------------------- src/core/main/setting.ts | 4 + src/plugin/game/dev/hotReload.js | 2 +- src/plugin/game/enemy/battle.ts | 8 +- src/plugin/game/enemy/remainEnemy.js | 2 + src/plugin/game/enemy/special.ts | 212 +++++++++++++++++++++++++ src/plugin/game/study.ts | 15 -- src/plugin/ui/fixed.ts | 17 +- src/types/enemy.d.ts | 80 +--------- src/types/function.d.ts | 24 --- src/ui/book.vue | 10 -- src/ui/start.vue | 1 + src/ui/studied.vue | 43 +---- 18 files changed, 250 insertions(+), 610 deletions(-) create mode 100644 src/plugin/game/enemy/special.ts diff --git a/idea.md b/idea.md index 7912a27..7eadd5c 100644 --- a/idea.md +++ b/idea.md @@ -83,3 +83,4 @@ dam4.png ---- 存档 59 [] 重写技能控制系统 [] 自定义快捷键 [] 优化 ui 控制系统 +[] 优化游戏进程与渲染进程间的通讯 diff --git a/public/_server/editor_multi.js b/public/_server/editor_multi.js index 8f3b859..daaf274 100644 --- a/public/_server/editor_multi.js +++ b/public/_server/editor_multi.js @@ -103,11 +103,7 @@ editor_multi = function () { "!doc": core.material.items[name].name || "道具" } }); - functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.enemys.getSpecials().forEach(function (one) { - var name = one[1]; - if (name instanceof Function) name = name({}); - coredef.core.enemys.hasSpecial["!doc"] += name + "(" + one[0] + "); "; - }); + Object.keys(core.canvas).forEach(function (name) { coredef.core.canvas[name] = { "!type": "CanvasRenderingContext2D", diff --git a/public/_server/table/comment.js b/public/_server/table/comment.js index 588aa3c..de26e99 100644 --- a/public/_server/table/comment.js +++ b/public/_server/table/comment.js @@ -191,18 +191,9 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_leaf": true, "_type": "popCheckboxSet", "_checkboxSet": function () { - var array = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.enemys.getSpecials() - var b = [], - c = []; - for (var index = 0; index < array.length; index++) { - b.push(array[index][0]) - var name = array[index][1]; - if (name instanceof Function) name = name({}); - c.push(name + "(" + array[index][0] + ")") - } return { - "prefix": c, - "key": b + "prefix": [], + "key": [] } }, "_data": "特殊属性" diff --git a/public/libs/enemys.js b/public/libs/enemys.js index b6aea6d..af08876 100644 --- a/public/libs/enemys.js +++ b/public/libs/enemys.js @@ -9,15 +9,9 @@ function enemys() { ////// 初始化 ////// enemys.prototype._init = function () { this.enemys = enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80; - this.enemydata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.enemys; for (var enemyId in this.enemys) { this.enemys[enemyId].id = enemyId; } - if (main.mode == 'play') { - this.enemydata.hasSpecial = function (a, b) { - return core.enemys.hasSpecial(a, b); - }; - } }; enemys.prototype.getEnemys = function () { @@ -62,143 +56,40 @@ enemys.prototype.getEnemys = function () { ////// 判断是否含有某特殊属性 ////// enemys.prototype.hasSpecial = function (special, test) { - if (special == null) return false; - - if (special instanceof Array) { - return special.indexOf(test) >= 0; - } - - if (typeof special == 'number') { - return special === test; - } - - if (typeof special == 'string') { - return this.hasSpecial(core.material.enemys[special], test); - } - - if (special.special != null) { - return this.hasSpecial(special.special, test); - } - - return false; + // Deprecated. Use `Array.includes` instead. }; enemys.prototype.getSpecials = function () { - return this.enemydata.getSpecials(); + // Deprecated. See src/plugin/game/enemy/special.ts }; ////// 获得所有特殊属性的名称 ////// enemys.prototype.getSpecialText = function (enemy) { - if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - if (!enemy) return []; - var special = enemy.special; - var text = []; - - var specials = this.getSpecials(); - if (specials) { - for (var i = 0; i < specials.length; i++) { - if (this.hasSpecial(special, specials[i][0])) - text.push(this._calSpecialContent(enemy, specials[i][1])); - } - } - return text; + // Deprecated. }; ////// 获得所有特殊属性的颜色 ////// enemys.prototype.getSpecialColor = function (enemy) { - if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - if (!enemy) return []; - var special = enemy.special; - var colors = []; - - var specials = this.getSpecials(); - if (specials) { - for (var i = 0; i < specials.length; i++) { - if (this.hasSpecial(special, specials[i][0])) - colors.push(specials[i][3] || null); - } - } - return colors; + // Deprecated. }; ////// 获得所有特殊属性的额外标记 ////// enemys.prototype.getSpecialFlag = function (enemy) { - if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - if (!enemy) return []; - var special = enemy.special; - var flag = 0; - - var specials = this.getSpecials(); - if (specials) { - for (var i = 0; i < specials.length; i++) { - if (this.hasSpecial(special, specials[i][0])) - flag |= specials[i][4] || 0; - } - } - return flag; + // Deprecated. }; ////// 获得每个特殊属性的说明 ////// enemys.prototype.getSpecialHint = function (enemy, special) { - var specials = this.getSpecials(); - - if (special == null) { - if (specials == null) return []; - var hints = []; - for (var i = 0; i < specials.length; i++) { - if (this.hasSpecial(enemy, specials[i][0])) - hints.push( - '\r[' + - core.arrayToRGBA(specials[i][3] || '#FF6A6A') + - ']\\d' + - this._calSpecialContent(enemy, specials[i][1]) + - ':\\d\r[]' + - this._calSpecialContent(enemy, specials[i][2]) - ); - } - return hints; - } - - if (specials == null) return ''; - for (var i = 0; i < specials.length; i++) { - if (special == specials[i][0]) - return ( - '\r[#FF6A6A]\\d' + - this._calSpecialContent(enemy, specials[i][1]) + - ':\\d\r[]' + - this._calSpecialContent(enemy, specials[i][2]) - ); - } - return ''; + // Deprecated. }; enemys.prototype._calSpecialContent = function (enemy, content) { - if (typeof content == 'string') return content; - if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - if (content instanceof Function) { - return content(enemy); - } - return ''; + // Deprecated. }; ////// 获得某个点上某个怪物的某项属性 ////// enemys.prototype.getEnemyValue = function (enemy, name, x, y, floorId) { - floorId = floorId || core.status.floorId; - if ( - (((flags.enemyOnPoint || {})[floorId] || {})[x + ',' + y] || {})[ - name - ] != null - ) { - return flags.enemyOnPoint[floorId][x + ',' + y][name]; - } - if (enemy == null) { - var block = core.getBlock(x, y, floorId); - if (block == null) return null; - enemy = core.material.enemys[block.event.id]; - } - if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; - if (enemy == null) return null; - return enemy[name]; + // Deprecated. }; ////// 能否获胜 ////// @@ -273,30 +164,5 @@ enemys.prototype._getCurrentEnemys_sort = function (enemys) { }; enemys.prototype.hasEnemyLeft = function (enemyId, floorId) { - if (floorId == null) floorId = core.status.floorId; - if (!(floorId instanceof Array)) floorId = [floorId]; - var enemyMap = {}; - if (enemyId instanceof Array) - enemyId.forEach(function (v) { - enemyMap[v] = true; - }); - else if (enemyId) enemyMap[enemyId] = true; - else enemyMap = null; - for (var i = 0; i < floorId.length; i++) { - core.extractBlocks(floorId[i]); - var mapBlocks = core.status.maps[floorId[i]].blocks; - for (var b = 0; b < mapBlocks.length; b++) { - if ( - !mapBlocks[b].disable && - mapBlocks[b].event.cls.indexOf('enemy') === 0 - ) { - if ( - enemyMap === null || - enemyMap[core.getFaceDownId(mapBlocks[b])] - ) - return true; - } - } - } - return false; + // Deprecated. }; diff --git a/public/libs/events.js b/public/libs/events.js index fee06ae..1873711 100644 --- a/public/libs/events.js +++ b/public/libs/events.js @@ -2203,19 +2203,7 @@ events.prototype._action_setEnemy = function (data, x, y, prefix) { }; events.prototype._action_setEnemyOnPoint = function (data, x, y, prefix) { - var loc = this.__action_getLoc2D(data.loc, x, y, prefix); - loc.forEach(function (one) { - core.setEnemyOnPoint( - one[0], - one[1], - data.floorId, - data.name, - data.value, - data.operator, - prefix, - data.norefresh - ); - }); + // Deprecated. core.doAction(); }; @@ -3545,35 +3533,8 @@ events.prototype.setEnemy = function ( }; ////// 设置某个点上的怪物属性 ////// -events.prototype.setEnemyOnPoint = function ( - x, - y, - floorId, - name, - value, - operator, - prefix, - norefresh -) { - floorId = floorId || core.status.floorId; - var block = core.getBlock(x, y, floorId); - if (block == null) return; - if (block.event.cls.indexOf('enemy') != 0) return; - var enemy = core.material.enemys[block.event.id]; - if (enemy == null) return; - if (typeof value === 'string' && name == 'name') - value = value.replaceAll(/\r/g, '\\r'); - value = this._updateValueByOperator( - core.calValue(value, prefix), - core.getEnemyValue(enemy, name, x, y, floorId), - operator - ); - flags.enemyOnPoint = flags.enemyOnPoint || {}; - flags.enemyOnPoint[floorId] = flags.enemyOnPoint[floorId] || {}; - flags.enemyOnPoint[floorId][x + ',' + y] = - flags.enemyOnPoint[floorId][x + ',' + y] || {}; - flags.enemyOnPoint[floorId][x + ',' + y][name] = value; - if (!norefresh) core.updateStatusBar(); +events.prototype.setEnemyOnPoint = function (x, y) { + // Deprecated. }; ////// 重置某个点上的怪物属性 ////// diff --git a/public/project/functions.js b/public/project/functions.js index e06327a..a9b7da4 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -327,231 +327,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { if (todo.length > 0) core.insertAction(todo, x, y); } }, - enemys: { - getSpecials: function () { - // todo: 重写 - // 获得怪物的特殊属性,每一行定义一个特殊属性。 - // 分为五项,第一项为该特殊属性的数字,第二项为特殊属性的名字,第三项为特殊属性的描述 - // 第四项为该特殊属性的颜色,可以写十六进制 #RRGGBB 或者 [r,g,b,a] 四元数组 - // 第五项为该特殊属性的标记;目前 1 代表是地图类技能(需要进行遍历全图) - // 名字和描述可以直接写字符串,也可以写个function将怪物传进去 - return [ - [ - 1, - '致命一击', - function (enemy) { - return ( - '怪物每5回合触发一次强力攻击,造成' + - (enemy.crit || 100) + - '%的伤害' - ); - }, - '#fc3' - ], - [2, '恶毒', '怪物攻击无视勇士的防御', '#bbb0ff'], - [3, '坚固', '怪物防御不小于勇士攻击-1', '#c0b088'], - [4, '2连击', '怪物每回合攻击2次', '#ffee77'], - [5, '3连击', '怪物每回合攻击3次', '#ffee77'], - [ - 6, - function (enemy) { - return (enemy.n || '') + '连击'; - }, - function (enemy) { - return '怪物每回合攻击' + (enemy.n || 4) + '次'; - }, - '#ffee77' - ], - [ - 7, - '饥渴', - function (enemy) { - return ( - '战斗前,怪物偷取勇士' + - (enemy.hungry || 0) + - '%的攻击加在自己身上(勇士攻击也会降低)' - ); - }, - '#b67' - ], - [ - 8, - '抱团', - function (enemy) { - return ( - '怪物周围5×5范围内每有一个拥有该属性的怪物,该怪物攻防就增加' + - (enemy.together || 0) + - '%(线性叠加)' - ); - }, - '#ffaa44', - 1 - ], - [ - 9, - '绝对防御', - function () { - return '怪物的奇特护甲可以让勇士的额外攻击变为正常攻击(相当于勇士的攻击变为基础攻击+额外攻击)'; - }, - '#80eed6' - ], - [ - 10, - '勇气之刃', - function (enemy) { - return ( - '第一回合造成' + - (enemy.courage || 100) + - '%的伤害,之后正常' - ); - }, - '#b0c0dd' - ], - [ - 11, - '勇气冲锋', - function (enemy) { - return ( - '怪物首先发动冲锋,造成' + - (enemy.charge || 100) + - '%的伤害,并眩晕勇士5回合' - ); - }, - '#ff00d2' - ], - [ - 12, - '追猎', - '当勇士移动到该怪物的水平或竖直方向上时,怪物向勇士移动一格', - '#99ee88', - 2 - ], - [13, '魔攻', '怪物攻击无视勇士防御', '#bbb0ff'], - [ - 14, - '智慧之源', - '困难难度下(简单难度没有效果),战斗后,怪物会吸取勇士30%的智慧(勇士智慧向下取整至整十)加在本层的拥有该属性的怪物攻击上', - '#bbeef0' - ], - [ - 15, - '突刺', - function (enemy) { - return ( - '经过怪物周围' + - (enemy.zoneSquare ? '九宫格' : '十字') + - '范围内' + - (enemy.range || 1) + - '格时怪物会攻击勇士,造成' + - core.formatBigNumber( - Math.max( - (enemy.value || 0) - - core.plugin.hero.getHeroStatusOn('def') - ) - ) + - '点伤害' - ); - }, - '#c677dd' - ], - [ - 16, - '夹击', - '经过两只相同的怪物中间,勇士生命值变成一半', - '#bb99ee' - ], - [17, '先攻', '战斗时怪物首先攻击', '#b0b666'], - [ - 18, - '阻击', - function (enemy) { - return ( - '经过怪物的十字领域时自动减生命' + - (enemy.value || 0) + - '点,同时怪物后退一格' - ); - }, - '#8888e6' - ], - [ - 19, - '电摇嘲讽', - '当勇士移动到怪物同行或同列时,勇士会直接冲向怪物,撞碎路上的所有地形和门,拾取路上的道具,与路上的怪物战斗' + - ',最后与该怪物战斗', - '#ff6666' - ], - [ - 20, - '霜冻', - enemy => - `怪物寒冷的攻击使勇士动作变慢,勇士每回合对怪物造成的伤害减少${enemy.ice}%。装备杰克的衣服后可以免疫。`, - 'cyan' - ], - [ - 21, - '冰封光环', - enemy => - `寒气逼人,使勇士对该怪物周围7*7范围内的怪物伤害减少${enemy.iceHalo}%(线性叠加)`, - 'cyan', - 1 - ], - [ - 22, - '永夜', - enemy => - `战斗后,减少勇士${enemy.night}点攻防,增加本层所有怪物${enemy.night}点攻防,仅在本层有效`, - '#d8a' - ], - [ - 23, - '极昼', - enemy => - `战斗后,减少本层所有怪物${enemy.day}点攻防,增加勇士${enemy.day}点攻防,仅在本层有效`, - '#ffd' - ], - [ - 24, - '射击', - function () { - return '经过怪物同行或同列的可视范围内时受到一次普通攻击的伤害'; - }, - '#dda0dd' - ], - [ - 25, - '融化', - enemy => - `战斗后该怪物会融化,在怪物位置产生一个3*3的范围光环,光环内怪物的攻防增加${enemy.melt}%`, - '#e6e099', - 1 - ], - [ - 26, - '冰封之核', - enemy => - `怪物拥有逼人的寒气,使周围5*5范围内的怪物防御增加${enemy.iceCore}%`, - '#70ffd1', - 1 - ], - [ - 27, - '火焰之核', - enemy => - `怪物拥有灼热的火焰,使周围5*5范围内的怪物攻击增加${enemy.fireCore}%`, - '#ff6f0a', - 1 - ], - [ - 28, - '苍蓝刻', - enemy => - `怪物使用苍蓝之灵的力量,使自身受到的伤害减少${enemy.paleShield}%`, - '#ff6f0a', - 1 - ] - ]; - } - }, actions: { onKeyUp: function (keyCode, altKey) { // 键盘按键处理,可以在这里自定义快捷键列表 diff --git a/src/core/main/setting.ts b/src/core/main/setting.ts index 628ec74..7726386 100644 --- a/src/core/main/setting.ts +++ b/src/core/main/setting.ts @@ -326,6 +326,8 @@ function handleScreenSetting( // 字体大小 core.setLocalStorage('fontSize', n); root.style.fontSize = root2.style.fontSize = `${n}px`; + } else if (key === 'smoothView') { + core.setLocalStorage('smoothView', n); } } @@ -370,6 +372,7 @@ mainSetting .register('antiAlias', '抗锯齿', false) .register('autoScale', '自动放缩', true) .register('fontSize', '字体大小', 16, [8, 28, 1]) + .register('smoothView', '平滑镜头', true) ) .register( 'action', @@ -397,6 +400,7 @@ loading.once('coreInit', () => { 'screen.antiAlias': !!core.getLocalStorage('antiAlias', false), 'screen.autoScale': !!core.getLocalStorage('autoScale', true), 'screen.fontSize': core.getLocalStorage('fontSize', 16), + 'screen.smoothView': !!core.getLocalStorage('smoothView', true), 'action.fixed': !!core.getLocalStorage('fixed', true), 'utils.betterLoad': !!core.getLocalStorage('betterLoad', true) }); diff --git a/src/plugin/game/dev/hotReload.js b/src/plugin/game/dev/hotReload.js index 4ab2de1..04c5a5e 100644 --- a/src/plugin/game/dev/hotReload.js +++ b/src/plugin/game/dev/hotReload.js @@ -75,7 +75,7 @@ export {}; const fns = before[mod]; for (const id in fns) { const fn = fns[id]; - if (typeof fn !== 'function' || id === 'hasSpecial') continue; + if (typeof fn !== 'function') continue; const now = after[mod][id]; if (fn.toString() !== now.toString()) { try { diff --git a/src/plugin/game/enemy/battle.ts b/src/plugin/game/enemy/battle.ts index 8ce9a59..3d48b71 100644 --- a/src/plugin/game/enemy/battle.ts +++ b/src/plugin/game/enemy/battle.ts @@ -96,7 +96,7 @@ core.events.afterBattle = function ( core.status.hero.statistics.battle++; // 智慧之源 - if (core.hasSpecial(special, 14) && flags.hard === 2) { + if (special.includes(14) && flags.hard === 2) { core.addFlag( 'inte_' + floorId, Math.ceil((core.status.hero.mdef / 10) * 0.3) * 10 @@ -106,11 +106,11 @@ core.events.afterBattle = function ( } // 极昼永夜 - if (core.hasSpecial(special, 22)) { + if (special.includes(22)) { flags[`night_${floorId}`] ??= 0; flags[`night_${floorId}`] -= enemy.enemy.night!; } - if (core.hasSpecial(special, 23)) { + if (special.includes(23)) { flags[`night_${floorId}`] ??= 0; flags[`night_${floorId}`] += enemy.enemy.day; } @@ -120,7 +120,7 @@ core.events.afterBattle = function ( // } // 如果是融化怪,需要特殊标记一下 - if (core.hasSpecial(special, 25) && core.has(x) && core.has(y)) { + if (special.includes(25) && core.has(x) && core.has(y)) { flags[`melt_${floorId}`] ??= {}; flags[`melt_${floorId}`][`${x},${y}`] = enemy.enemy.melt; } diff --git a/src/plugin/game/enemy/remainEnemy.js b/src/plugin/game/enemy/remainEnemy.js index ae8a8af..aed64c2 100644 --- a/src/plugin/game/enemy/remainEnemy.js +++ b/src/plugin/game/enemy/remainEnemy.js @@ -1,5 +1,7 @@ /// +// todo: 优化,直接调用 floor.enemy.list 进行计算 + /** * 检查漏怪 * @param {FloorIds[]} floorIds diff --git a/src/plugin/game/enemy/special.ts b/src/plugin/game/enemy/special.ts new file mode 100644 index 0000000..cf48ba0 --- /dev/null +++ b/src/plugin/game/enemy/special.ts @@ -0,0 +1,212 @@ +import { getHeroStatusOn } from '../hero'; + +export interface SpecialDeclaration { + code: number; + name: string | ((enemy: Enemy) => string); + desc: string | ((enemy: Enemy) => string); + color: string; +} + +export const enemySpecials: SpecialDeclaration[] = [ + { + code: 0, + name: '空', + desc: '空', + color: '#fff' + }, + { + code: 1, + name: '致命一击', + desc: enemy => `怪物每5回合触发一次强力攻击,造成${enemy.crit}%的伤害`, + color: '#fc3' + }, + { + code: 2, + name: '恶毒', + desc: '怪物攻击无视勇士的防御', + color: '#bbb0ff' + }, + { + code: 3, + name: '坚固', + desc: '怪物防御不小于勇士攻击-1', + color: '#c0b088' + }, + { + code: 4, + name: '2连击', + desc: '怪物每回合攻击2次', + color: '#fe7' + }, + { + code: 5, + name: '3连击', + desc: '怪物每回合攻击3次', + color: '#fe7' + }, + { + code: 6, + name: enemy => `${enemy.n}连击`, + desc: enemy => `怪物每回合攻击${enemy.n}次`, + color: '#fe7' + }, + { + code: 7, + name: '饥渴', + desc: enemy => + `战斗前,怪物降低勇士${enemy.hungry}%的攻击,并加在自己身上`, + color: '#b67' + }, + { + code: 8, + name: '抱团', + desc: enemy => + `怪物周围5×5范围内每有一个拥有该属性的怪物,自身攻防就增加${enemy.together}%(线性叠加)`, + color: '#fa4' + }, + { + code: 9, + name: '绝对防御', + desc: '怪物的奇特护甲可以让勇士的额外攻击失效,攻击变为基础攻击+额外攻击', + color: '#80eed6' + }, + { + code: 10, + name: '勇气之刃', + desc: enemy => `怪物第一回合造成${enemy.courage}%的伤害`, + color: '#b0c0dd' + }, + { + code: 11, + name: '勇气冲锋', + desc: enemy => + `怪物首先攻击,造成${enemy.charge}%的伤害,并眩晕勇士5回合`, + color: '#ff00d2' + }, + { + code: 12, + name: '追猎', + desc: '当勇士移动到该怪物的水平或竖直方向上时,怪物向勇士移动一格', + color: '#9e8' + }, + { + code: 13, + name: '魔攻', + desc: '怪物攻击无视勇士的防御', + color: '#bbb0ff' + }, + { + code: 14, + name: '智慧之源', + desc: '困难难度下(简单难度没有效果),战斗后,怪物会吸取勇士30%的智慧(勇士智慧向下取整至整十)加在本层的拥有该属性的怪物攻击上', + color: '#bbeef0' + }, + { + code: 15, + name: '突刺', + desc: enemy => + `勇士走到怪物怪物周围四格时,怪物对勇士造成${core.formatBigNumber( + Math.max((enemy.value || 0) - getHeroStatusOn('def')) + )}点伤害`, + color: '#c677dd' + }, + { + code: 16, + name: '空', + desc: '空', + color: '#fff' + }, + { + code: 17, + name: '先攻', + desc: '战斗时,怪物首先攻击', + color: '#b0b666' + }, + { + code: 18, + name: '阻击', + desc: enemy => + `经过怪物十字范围内时怪物后退一格,同时对勇士造成${enemy.value}点伤害`, + color: '#8888e6' + }, + { + code: 19, + name: '电摇嘲讽', + desc: + '当勇士移动到怪物同行或同列时,勇士会直接冲向怪物,撞碎路上的所有地形和门,拾取路上的道具,与路上的怪物战斗' + + ',最后与该怪物战斗', + color: '#ff6666' + }, + { + code: 20, + name: '霜冻', + desc: enemy => + `怪物寒冷的攻击使勇士动作变慢,勇士每回合对怪物造成的伤害减少${enemy.ice}%。装备杰克的衣服后可以免疫。`, + color: 'cyan' + }, + { + code: 21, + name: '冰封光环', + desc: enemy => + `寒气逼人,使勇士对该怪物周围7*7范围内的怪物伤害减少${enemy.iceHalo}%(线性叠加)`, + color: 'cyan' + }, + { + code: 22, + name: '永夜', + desc: enemy => + `战斗后,减少勇士${enemy.night}点攻防,增加本层所有怪物${enemy.night}点攻防,仅在本层有效`, + color: '#d8a' + }, + { + code: 23, + name: '极昼', + desc: enemy => + `战斗后,减少本层所有怪物${enemy.day}点攻防,增加勇士${enemy.day}点攻防,仅在本层有效`, + color: '#ffd' + }, + { + code: 24, + name: '射击', + desc: function () { + return '经过怪物同行或同列的可视范围内时受到一次普通攻击的伤害'; + }, + color: '#dda0dd' + }, + { + code: 25, + name: '融化', + desc: enemy => + `战斗后该怪物会融化,在怪物位置产生一个3*3的范围光环,光环内怪物的攻防增加${enemy.melt}%`, + color: '#e6e099' + }, + { + code: 26, + name: '冰封之核', + desc: enemy => + `怪物拥有逼人的寒气,使周围5*5范围内的怪物防御增加${enemy.iceCore}%`, + color: '#70ffd1' + }, + { + code: 27, + name: '火焰之核', + desc: enemy => + `怪物拥有灼热的火焰,使周围5*5范围内的怪物攻击增加${enemy.fireCore}%`, + color: '#ff6f0a' + }, + { + code: 28, + name: '苍蓝刻', + desc: enemy => + `怪物使用苍蓝之灵的力量,使自身受到的伤害减少${enemy.paleShield}%`, + color: '#ff6f0a' + } +]; + +declare global { + interface PluginDeclaration { + special: SpecialDeclaration[]; + } +} + +core.plugin.special = enemySpecials; diff --git a/src/plugin/game/study.ts b/src/plugin/game/study.ts index fd59ed3..8a5e533 100644 --- a/src/plugin/game/study.ts +++ b/src/plugin/game/study.ts @@ -22,21 +22,6 @@ export function canStudySkill(number: number) { export function studySkill(enemy: any, number: number) { core.status.hero.special ??= { num: [], last: [] }; const s = core.status.hero.special; - const specials = core.getSpecials(); - let special = specials[number - 1][1]; - if (special instanceof Function) special = special(enemy); - if (!canStudySkill(number)) { - if (!main.replayChecking) { - ancTe.plugin.utils.tip('error', `无法学习${special}`); - } - return; - } - s.num.push(number); - s.last.push(core.plugin.skillTree.getSkillLevel(11) * 3 + 2); - const value = values[number] ?? []; - for (const key of value) { - s[key] = enemy[key]; - } } export function forgetStudiedSkill(num: number, i: number) { diff --git a/src/plugin/ui/fixed.ts b/src/plugin/ui/fixed.ts index 874730c..3aee28d 100644 --- a/src/plugin/ui/fixed.ts +++ b/src/plugin/ui/fixed.ts @@ -56,15 +56,6 @@ export function getDetailedEnemy( enemy: DamageEnemy, floorId: FloorIds = core.status.floorId ): ToShowEnemy { - const specials = Object.fromEntries( - core.getSpecials().map(v => { - return [v[0], v.slice(1)]; - }) - ) as Record< - string, - EnemySpecialDeclaration extends [number, ...infer F] ? F : never - >; - const ratio = core.status.maps[floorId].ratio; const dam = enemy.calDamage().damage; @@ -81,11 +72,11 @@ export function getDetailedEnemy( return typeof func === 'string' ? func : func(enemy); }; const special: [string, string, string][] = enemy.enemy.special.map(vv => { - const s = specials[vv]; + const s = core.plugin.special[vv]; return [ - fromFunc(s[0], enemy.enemy), - fromFunc(s[1], enemy.enemy), - s[2] as string + fromFunc(s.name, enemy.enemy), + fromFunc(s.desc, enemy.enemy), + s.color as string ]; }); const l = isMobile ? 1 : 2; diff --git a/src/types/enemy.d.ts b/src/types/enemy.d.ts index c5b11d9..ed71c57 100644 --- a/src/types/enemy.d.ts +++ b/src/types/enemy.d.ts @@ -242,7 +242,7 @@ interface BookEnemyInfo extends Enemy, EnemyInfo { /** * 怪物模块 */ -interface Enemys extends EnemyData { +interface Enemys { /** * 所有的怪物信息 */ @@ -250,11 +250,6 @@ interface Enemys extends EnemyData { [P in EnemyIds]: Enemy

; }; - /** - * 脚本编辑的怪物相关 - */ - readonly enemydata: EnemyData; - /** * 获得所有怪物原始数据的一个副本 */ @@ -262,51 +257,6 @@ interface Enemys extends EnemyData { [P in EnemyIds]: Enemy

; }; - /** - * 获得某种敌人的全部特殊属性名称 - * @example core.getSpecialText('greenSlime') // ['先攻', '3连击', '破甲', '反击'] - * @param enemy 敌人id或敌人对象,如core.material.enemys.greenSlime - * @returns 字符串数组 - */ - getSpecialText(enemy: EnemyIds | Enemy): string[]; - - /** - * 获得所有特殊属性的颜色 - * @param enemy 敌人id或敌人对象,如core.material.enemys.greenSlime - */ - getSpecialColor(enemy: EnemyIds | Enemy): Color[]; - - /** - * 获得所有特殊属性的额外标记 - * @param enemy 敌人id或敌人对象,如core.material.enemys.greenSlime - */ - getSpecialFlag(enemy: EnemyIds | Enemy): number[]; - - /** - * 获得某种敌人的某种特殊属性的介绍 - * @example core.getSpecialHint('bat', 1) // '先攻:怪物首先攻击' - * @param enemy 敌人id或敌人对象,用于确定属性的具体数值 - * @param special 属性编号,可以是该敌人没有的属性 - * @returns 属性的介绍,以属性名加中文冒号开头 - */ - getSpecialHint(enemy: EnemyIds | Enemy, special: number): string; - - /** - * 获得某个敌人的某项属性值 - * @param enemy 敌人id或敌人对象 - * @param name 获取的敌人属性 - * @param x 敌人的横坐标 - * @param y 敌人的纵坐标 - * @param floorId 敌人所在楼层 - */ - getEnemyValue( - enemy: EnemyIds | Enemy, - name: K, - x?: number, - y?: number, - floorId?: FloorIds - ): Enemy[K]; - /** * 判定主角当前能否打败某只敌人 * @example core.canBattle('greenSlime',0,0,'MT0') // 能否打败主塔0层左上角的绿头怪(假设有) @@ -322,34 +272,6 @@ interface Enemys extends EnemyData { floorId?: FloorIds, dir?: Dir | 'none' | (Dir | 'none')[] ): boolean; - - /** - * 获得某只敌人对主角的总伤害 - * @example core.getDamage('greenSlime',0,0,'MT0') // 绿头怪的总伤害 - * @param enemy 敌人id或敌人对象 - * @param x 敌人的横坐标 - * @param y 敌人的纵坐标 - * @param floorId 敌人所在的地图 - * @returns 总伤害,如果因为没有破防或无敌怪等其他原因无法战斗,则返回null - */ - getDamage( - enemy: EnemyIds | Enemy, - x?: number, - y?: number, - floorId?: FloorIds - ): number; - - /** - * 检查某些楼层是否还有漏打的(某种)敌人 - * @example core.hasEnemyLeft('greenSlime', ['sample0', 'sample1']) // 样板0层和1层是否有漏打的绿头怪 - * @param enemyId 敌人id,可选,默认为任意敌人 - * @param floorId 地图id或其数组,可选,默认为当前地图 - * @returns true表示有敌人被漏打,false表示敌人已死光 - */ - hasEnemyLeft( - enemyId?: EnemyIds | EnemyIds[], - floorId?: FloorIds | FloorIds[] - ): boolean; } declare const enemys: new () => Enemys; diff --git a/src/types/function.d.ts b/src/types/function.d.ts index 8bafbfd..647af35 100644 --- a/src/types/function.d.ts +++ b/src/types/function.d.ts @@ -52,25 +52,6 @@ interface ControlData { parallelDo(time: number): void; } -interface EnemyData { - /** - * 获得所有特殊属性定义 - */ - getSpecials(): EnemySpecialDeclaration[]; - - /** - * 判定某种特殊属性的有无 - * @example core.hasSpecial('greenSlime', 1) // 判定绿头怪有无先攻属性 - * @param special 敌人id或敌人对象或正整数数组或自然数 - * @param test 待检查的属性编号 - * @returns 若special为数组或数且含有test或相等、或special为敌人id或对象且具有此属性,则返回true - */ - hasSpecial( - special: number | number[] | EnemyIds | Enemy, - test: number - ): boolean; -} - interface UiData { /** * 数据统计界面统计的道具数量 @@ -184,11 +165,6 @@ interface FunctionsData { */ control: ControlData; - /** - * 怪物信息 - */ - enemys: EnemyData; - /** * ui信息 */ diff --git a/src/ui/book.vue b/src/ui/book.vue index f9a61c0..1099dcf 100644 --- a/src/ui/book.vue +++ b/src/ui/book.vue @@ -48,22 +48,12 @@ import { LeftOutlined } from '@ant-design/icons-vue'; import { KeyCode } from '../plugin/keyCodes'; import { noClosePanel } from '../plugin/uiController'; import { ToShowEnemy, detailInfo } from '../plugin/ui/book'; -import { isMobile } from '../plugin/use'; import { getDetailedEnemy } from '../plugin/ui/fixed'; const floorId = // @ts-ignore core.floorIds[core.status.event?.ui?.index] ?? core.status.floorId; -const specials = Object.fromEntries( - core.getSpecials().map(v => { - return [v[0], v.slice(1)]; - }) -) as Record< - string, - EnemySpecialDeclaration extends [number, ...infer F] ? F : never ->; - const enemy = core.getCurrentEnemys(floorId); const toShow: ToShowEnemy[] = enemy.map(v => getDetailedEnemy(v.enemy, floorId) diff --git a/src/ui/start.vue b/src/ui/start.vue index 42b90c5..dc09e0b 100644 --- a/src/ui/start.vue +++ b/src/ui/start.vue @@ -154,6 +154,7 @@ async function clickStartButton(id: string) { } function onmove(e: MouseEvent) { + if (!window.core) return; const { offsetX, offsetY } = e; const ele = e.target as HTMLDivElement; const style = getComputedStyle(ele); diff --git a/src/ui/studied.vue b/src/ui/studied.vue index 5b09696..ffe2cd2 100644 --- a/src/ui/studied.vue +++ b/src/ui/studied.vue @@ -10,26 +10,11 @@ >

-
-
- - {{ i }}. {{ skills[i] }},剩余{{ - last[i] - }}场战斗 -
-
- {{ hint(num) }} -
-
-
+
@@ -61,24 +46,6 @@ const last = computed(() => { return core.status.hero.special?.last ?? []; }); -const skills = computed(() => { - const specials = core.getSpecials(); - return studied.value.map(v => { - const s = specials[v - 1][1]; - // @ts-ignore - if (s instanceof Function) return s(core.status.hero.special); - else return s; - }); -}); - -function hint(number: number) { - const specials = core.getSpecials(); - const s = specials[number - 1][2]; - // @ts-ignore - if (s instanceof Function) return s(core.status.hero.special); - else return s; -} - async function calHeight() { await new Promise(resolve => { requestAnimationFrame(() => {