重构怪物属性定义

This commit is contained in:
unanmed 2023-08-07 17:57:51 +08:00
parent 93fad2f637
commit 9bab089a14
18 changed files with 250 additions and 610 deletions

View File

@ -83,3 +83,4 @@ dam4.png ---- 存档 59
[] 重写技能控制系统 [] 重写技能控制系统
[] 自定义快捷键 [] 自定义快捷键
[] 优化 ui 控制系统 [] 优化 ui 控制系统
[] 优化游戏进程与渲染进程间的通讯

View File

@ -103,11 +103,7 @@ editor_multi = function () {
"!doc": core.material.items[name].name || "道具" "!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) { Object.keys(core.canvas).forEach(function (name) {
coredef.core.canvas[name] = { coredef.core.canvas[name] = {
"!type": "CanvasRenderingContext2D", "!type": "CanvasRenderingContext2D",

View File

@ -191,18 +191,9 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_leaf": true, "_leaf": true,
"_type": "popCheckboxSet", "_type": "popCheckboxSet",
"_checkboxSet": function () { "_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 { return {
"prefix": c, "prefix": [],
"key": b "key": []
} }
}, },
"_data": "特殊属性" "_data": "特殊属性"

View File

@ -9,15 +9,9 @@ function enemys() {
////// 初始化 ////// ////// 初始化 //////
enemys.prototype._init = function () { enemys.prototype._init = function () {
this.enemys = enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80; this.enemys = enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80;
this.enemydata = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.enemys;
for (var enemyId in this.enemys) { for (var enemyId in this.enemys) {
this.enemys[enemyId].id = enemyId; 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 () { enemys.prototype.getEnemys = function () {
@ -62,143 +56,40 @@ enemys.prototype.getEnemys = function () {
////// 判断是否含有某特殊属性 ////// ////// 判断是否含有某特殊属性 //////
enemys.prototype.hasSpecial = function (special, test) { enemys.prototype.hasSpecial = function (special, test) {
if (special == null) return false; // Deprecated. Use `Array.includes` instead.
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;
}; };
enemys.prototype.getSpecials = function () { enemys.prototype.getSpecials = function () {
return this.enemydata.getSpecials(); // Deprecated. See src/plugin/game/enemy/special.ts
}; };
////// 获得所有特殊属性的名称 ////// ////// 获得所有特殊属性的名称 //////
enemys.prototype.getSpecialText = function (enemy) { enemys.prototype.getSpecialText = function (enemy) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; // Deprecated.
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;
}; };
////// 获得所有特殊属性的颜色 ////// ////// 获得所有特殊属性的颜色 //////
enemys.prototype.getSpecialColor = function (enemy) { enemys.prototype.getSpecialColor = function (enemy) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; // Deprecated.
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;
}; };
////// 获得所有特殊属性的额外标记 ////// ////// 获得所有特殊属性的额外标记 //////
enemys.prototype.getSpecialFlag = function (enemy) { enemys.prototype.getSpecialFlag = function (enemy) {
if (typeof enemy == 'string') enemy = core.material.enemys[enemy]; // Deprecated.
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;
}; };
////// 获得每个特殊属性的说明 ////// ////// 获得每个特殊属性的说明 //////
enemys.prototype.getSpecialHint = function (enemy, special) { enemys.prototype.getSpecialHint = function (enemy, special) {
var specials = this.getSpecials(); // Deprecated.
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 '';
}; };
enemys.prototype._calSpecialContent = function (enemy, content) { enemys.prototype._calSpecialContent = function (enemy, content) {
if (typeof content == 'string') return content; // Deprecated.
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
if (content instanceof Function) {
return content(enemy);
}
return '';
}; };
////// 获得某个点上某个怪物的某项属性 ////// ////// 获得某个点上某个怪物的某项属性 //////
enemys.prototype.getEnemyValue = function (enemy, name, x, y, floorId) { enemys.prototype.getEnemyValue = function (enemy, name, x, y, floorId) {
floorId = floorId || core.status.floorId; // Deprecated.
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];
}; };
////// 能否获胜 ////// ////// 能否获胜 //////
@ -273,30 +164,5 @@ enemys.prototype._getCurrentEnemys_sort = function (enemys) {
}; };
enemys.prototype.hasEnemyLeft = function (enemyId, floorId) { enemys.prototype.hasEnemyLeft = function (enemyId, floorId) {
if (floorId == null) floorId = core.status.floorId; // Deprecated.
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;
}; };

View File

@ -2203,19 +2203,7 @@ events.prototype._action_setEnemy = function (data, x, y, prefix) {
}; };
events.prototype._action_setEnemyOnPoint = function (data, x, y, prefix) { events.prototype._action_setEnemyOnPoint = function (data, x, y, prefix) {
var loc = this.__action_getLoc2D(data.loc, x, y, prefix); // Deprecated.
loc.forEach(function (one) {
core.setEnemyOnPoint(
one[0],
one[1],
data.floorId,
data.name,
data.value,
data.operator,
prefix,
data.norefresh
);
});
core.doAction(); core.doAction();
}; };
@ -3545,35 +3533,8 @@ events.prototype.setEnemy = function (
}; };
////// 设置某个点上的怪物属性 ////// ////// 设置某个点上的怪物属性 //////
events.prototype.setEnemyOnPoint = function ( events.prototype.setEnemyOnPoint = function (x, y) {
x, // Deprecated.
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();
}; };
////// 重置某个点上的怪物属性 ////// ////// 重置某个点上的怪物属性 //////

View File

@ -327,231 +327,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
if (todo.length > 0) core.insertAction(todo, x, y); 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: { actions: {
onKeyUp: function (keyCode, altKey) { onKeyUp: function (keyCode, altKey) {
// 键盘按键处理,可以在这里自定义快捷键列表 // 键盘按键处理,可以在这里自定义快捷键列表

View File

@ -326,6 +326,8 @@ function handleScreenSetting<T extends number | boolean>(
// 字体大小 // 字体大小
core.setLocalStorage('fontSize', n); core.setLocalStorage('fontSize', n);
root.style.fontSize = root2.style.fontSize = `${n}px`; 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('antiAlias', '抗锯齿', false)
.register('autoScale', '自动放缩', true) .register('autoScale', '自动放缩', true)
.register('fontSize', '字体大小', 16, [8, 28, 1]) .register('fontSize', '字体大小', 16, [8, 28, 1])
.register('smoothView', '平滑镜头', true)
) )
.register( .register(
'action', 'action',
@ -397,6 +400,7 @@ loading.once('coreInit', () => {
'screen.antiAlias': !!core.getLocalStorage('antiAlias', false), 'screen.antiAlias': !!core.getLocalStorage('antiAlias', false),
'screen.autoScale': !!core.getLocalStorage('autoScale', true), 'screen.autoScale': !!core.getLocalStorage('autoScale', true),
'screen.fontSize': core.getLocalStorage('fontSize', 16), 'screen.fontSize': core.getLocalStorage('fontSize', 16),
'screen.smoothView': !!core.getLocalStorage('smoothView', true),
'action.fixed': !!core.getLocalStorage('fixed', true), 'action.fixed': !!core.getLocalStorage('fixed', true),
'utils.betterLoad': !!core.getLocalStorage('betterLoad', true) 'utils.betterLoad': !!core.getLocalStorage('betterLoad', true)
}); });

View File

@ -75,7 +75,7 @@ export {};
const fns = before[mod]; const fns = before[mod];
for (const id in fns) { for (const id in fns) {
const fn = fns[id]; const fn = fns[id];
if (typeof fn !== 'function' || id === 'hasSpecial') continue; if (typeof fn !== 'function') continue;
const now = after[mod][id]; const now = after[mod][id];
if (fn.toString() !== now.toString()) { if (fn.toString() !== now.toString()) {
try { try {

View File

@ -96,7 +96,7 @@ core.events.afterBattle = function (
core.status.hero.statistics.battle++; core.status.hero.statistics.battle++;
// 智慧之源 // 智慧之源
if (core.hasSpecial(special, 14) && flags.hard === 2) { if (special.includes(14) && flags.hard === 2) {
core.addFlag( core.addFlag(
'inte_' + floorId, 'inte_' + floorId,
Math.ceil((core.status.hero.mdef / 10) * 0.3) * 10 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}`] ??= 0;
flags[`night_${floorId}`] -= enemy.enemy.night!; flags[`night_${floorId}`] -= enemy.enemy.night!;
} }
if (core.hasSpecial(special, 23)) { if (special.includes(23)) {
flags[`night_${floorId}`] ??= 0; flags[`night_${floorId}`] ??= 0;
flags[`night_${floorId}`] += enemy.enemy.day; 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}`] ??= {};
flags[`melt_${floorId}`][`${x},${y}`] = enemy.enemy.melt; flags[`melt_${floorId}`][`${x},${y}`] = enemy.enemy.melt;
} }

View File

@ -1,5 +1,7 @@
///<reference path="../../../../src/types/core.d.ts" /> ///<reference path="../../../../src/types/core.d.ts" />
// todo: 优化,直接调用 floor.enemy.list 进行计算
/** /**
* 检查漏怪 * 检查漏怪
* @param {FloorIds[]} floorIds * @param {FloorIds[]} floorIds

View File

@ -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;

View File

@ -22,21 +22,6 @@ export function canStudySkill(number: number) {
export function studySkill(enemy: any, number: number) { export function studySkill(enemy: any, number: number) {
core.status.hero.special ??= { num: [], last: [] }; core.status.hero.special ??= { num: [], last: [] };
const s = core.status.hero.special; 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) { export function forgetStudiedSkill(num: number, i: number) {

View File

@ -56,15 +56,6 @@ export function getDetailedEnemy(
enemy: DamageEnemy, enemy: DamageEnemy,
floorId: FloorIds = core.status.floorId floorId: FloorIds = core.status.floorId
): ToShowEnemy { ): 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 ratio = core.status.maps[floorId].ratio;
const dam = enemy.calDamage().damage; const dam = enemy.calDamage().damage;
@ -81,11 +72,11 @@ export function getDetailedEnemy(
return typeof func === 'string' ? func : func(enemy); return typeof func === 'string' ? func : func(enemy);
}; };
const special: [string, string, string][] = enemy.enemy.special.map(vv => { const special: [string, string, string][] = enemy.enemy.special.map(vv => {
const s = specials[vv]; const s = core.plugin.special[vv];
return [ return [
fromFunc(s[0], enemy.enemy), fromFunc(s.name, enemy.enemy),
fromFunc(s[1], enemy.enemy), fromFunc(s.desc, enemy.enemy),
s[2] as string s.color as string
]; ];
}); });
const l = isMobile ? 1 : 2; const l = isMobile ? 1 : 2;

80
src/types/enemy.d.ts vendored
View File

@ -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<P>; [P in EnemyIds]: Enemy<P>;
}; };
/**
*
*/
readonly enemydata: EnemyData;
/** /**
* *
*/ */
@ -262,51 +257,6 @@ interface Enemys extends EnemyData {
[P in EnemyIds]: Enemy<P>; [P in EnemyIds]: Enemy<P>;
}; };
/**
*
* @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<K extends keyof Enemy>(
enemy: EnemyIds | Enemy,
name: K,
x?: number,
y?: number,
floorId?: FloorIds
): Enemy[K];
/** /**
* *
* @example core.canBattle('greenSlime',0,0,'MT0') // 能否打败主塔0层左上角的绿头怪假设有 * @example core.canBattle('greenSlime',0,0,'MT0') // 能否打败主塔0层左上角的绿头怪假设有
@ -322,34 +272,6 @@ interface Enemys extends EnemyData {
floorId?: FloorIds, floorId?: FloorIds,
dir?: Dir | 'none' | (Dir | 'none')[] dir?: Dir | 'none' | (Dir | 'none')[]
): boolean; ): 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; declare const enemys: new () => Enemys;

View File

@ -52,25 +52,6 @@ interface ControlData {
parallelDo(time: number): void; 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 { interface UiData {
/** /**
* *
@ -184,11 +165,6 @@ interface FunctionsData {
*/ */
control: ControlData; control: ControlData;
/**
*
*/
enemys: EnemyData;
/** /**
* ui信息 * ui信息
*/ */

View File

@ -48,22 +48,12 @@ import { LeftOutlined } from '@ant-design/icons-vue';
import { KeyCode } from '../plugin/keyCodes'; import { KeyCode } from '../plugin/keyCodes';
import { noClosePanel } from '../plugin/uiController'; import { noClosePanel } from '../plugin/uiController';
import { ToShowEnemy, detailInfo } from '../plugin/ui/book'; import { ToShowEnemy, detailInfo } from '../plugin/ui/book';
import { isMobile } from '../plugin/use';
import { getDetailedEnemy } from '../plugin/ui/fixed'; import { getDetailedEnemy } from '../plugin/ui/fixed';
const floorId = const floorId =
// @ts-ignore // @ts-ignore
core.floorIds[core.status.event?.ui?.index] ?? core.status.floorId; 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 enemy = core.getCurrentEnemys(floorId);
const toShow: ToShowEnemy[] = enemy.map(v => const toShow: ToShowEnemy[] = enemy.map(v =>
getDetailedEnemy(v.enemy, floorId) getDetailedEnemy(v.enemy, floorId)

View File

@ -154,6 +154,7 @@ async function clickStartButton(id: string) {
} }
function onmove(e: MouseEvent) { function onmove(e: MouseEvent) {
if (!window.core) return;
const { offsetX, offsetY } = e; const { offsetX, offsetY } = e;
const ele = e.target as HTMLDivElement; const ele = e.target as HTMLDivElement;
const style = getComputedStyle(ele); const style = getComputedStyle(ele);

View File

@ -10,26 +10,11 @@
> >
<Scroll :no-scroll="true" style="height: 100%"> <Scroll :no-scroll="true" style="height: 100%">
<div id="studied-main"> <div id="studied-main">
<div v-for="(num, i) of studied" :key="i"> <div
<div id="studied-rough"> v-for="(num, i) of studied"
<right-outlined :key="i"
:class="folded[i] ? 'folded' : ''" ></div></div></Scroll
@click="folded[i] = !folded[i]" ></Box>
id="studied-fold"
/>
<span
>{{ i }}. {{ skills[i] }}剩余{{
last[i]
}}场战斗</span
>
</div>
<div id="studied-detail" v-if="!folded[i]">
{{ hint(num) }}
</div>
</div>
</div></Scroll
></Box
>
</div> </div>
</template> </template>
@ -61,24 +46,6 @@ const last = computed(() => {
return core.status.hero.special?.last ?? []; 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() { async function calHeight() {
await new Promise<void>(resolve => { await new Promise<void>(resolve => {
requestAnimationFrame(() => { requestAnimationFrame(() => {