标记要重写的部分,并在libs中删除被复写函数

This commit is contained in:
unanmed 2023-06-29 21:52:16 +08:00
parent 06fc4c4940
commit 3bdb668c5f
16 changed files with 48 additions and 307 deletions

View File

@ -894,12 +894,7 @@ control.prototype._moveAction_popAutomaticRoute = function () {
////// 让勇士开始移动 //////
control.prototype.moveHero = function (direction, callback) {
// 如果正在移动直接return
if (core.status.heroMoving != 0) return;
if (core.isset(direction)) core.setHeroLoc('direction', direction);
if (callback) return this.moveAction(callback);
this._moveHero_moving();
// see src/plugin/game/popup.js
};
control.prototype._moveHero_moving = function () {
@ -1455,34 +1450,12 @@ control.prototype._moveDirectyFollowers = function (x, y) {
////// 更新领域、夹击、阻击的伤害地图 //////
control.prototype.updateCheckBlock = function (floorId) {
return this.controldata.updateCheckBlock(floorId);
throw new Error(`This function has been deprecated.`);
};
////// 检查并执行领域、夹击、阻击事件 //////
control.prototype.checkBlock = function () {
var x = core.getHeroLoc('x'),
y = core.getHeroLoc('y'),
loc = x + ',' + y;
var damage = core.status.checkBlock.damage[loc];
if (damage) {
core.status.hero.hp -= damage;
var text =
Object.keys(core.status.checkBlock.type[loc] || {}).join('') ||
'伤害';
core.drawTip('受到' + text + damage + '点');
core.drawHeroAnimate('zone');
this._checkBlock_disableQuickShop();
core.status.hero.statistics.extraDamage += damage;
if (core.status.hero.hp <= 0) {
core.status.hero.hp = 0;
core.updateStatusBar(false, true);
core.events.lose();
return;
} else {
core.updateStatusBar(false, true);
}
}
this._checkBlock_repulse(core.status.checkBlock.repulse[loc]);
// see src/plugin/game/popup.js
};
control.prototype._checkBlock_disableQuickShop = function () {
@ -1514,23 +1487,7 @@ control.prototype._checkBlock_repulse = function (repulse) {
////// 更新全地图显伤 //////
control.prototype.updateDamage = function (floorId, ctx) {
floorId = floorId || core.status.floorId;
if (!floorId || core.status.gameOver || main.mode != 'play') return;
var onMap = ctx == null;
// 没有怪物手册
if (!core.hasItem('book')) return;
core.status.damage.posX = core.bigmap.posX;
core.status.damage.posY = core.bigmap.posY;
if (!onMap) {
var width = core.floors[floorId].width,
height = core.floors[floorId].height;
// 地图过大的缩略图不绘制显伤
if (width * height > core.bigmap.threshold) return;
}
this._updateDamage_damage(floorId, onMap);
this._updateDamage_extraDamage(floorId, onMap);
this.drawDamage(ctx);
// see src/plugin/game/itemDetail.js
};
control.prototype._updateDamage_damage = function (floorId, onMap) {
@ -1596,6 +1553,7 @@ control.prototype._updateDamage_damage = function (floorId, onMap) {
};
control.prototype._updateDamage_extraDamage = function (floorId, onMap) {
// todo: 不使用 core.status.checkBlock
core.status.damage.extraData = [];
if (!core.flags.displayExtraDamage) return;
@ -3677,15 +3635,7 @@ control.prototype.updateStatusBar = function (doNotCheckAutoEvents, immediate) {
};
control.prototype.updateStatusBar_update = function () {
core.control.updateNextFrame = false;
if (!core.isPlaying() || core.hasFlag('__statistics__')) {
return;
}
core.control.controldata.updateStatusBar();
if (!core.control.noAutoEvents) core.checkAutoEvents();
core.control._updateStatusBar_setToolboxIcon();
core.clearRouteFolding();
core.control.noAutoEvents = true;
// see src/plugin/game/ui.js
};
control.prototype._updateStatusBar_setToolboxIcon = function () {
@ -3730,44 +3680,11 @@ control.prototype._updateStatusBar_setToolboxIcon = function () {
};
control.prototype.showStatusBar = function () {
if (main.mode == 'editor') return;
if (core.domStyle.showStatusBar) return;
var statusItems = core.dom.status;
core.domStyle.showStatusBar = true;
core.removeFlag('hideStatusBar');
// 显示
for (var i = 0; i < statusItems.length; ++i)
statusItems[i].style.opacity = 1;
this.setToolbarButton(false);
core.dom.tools.hard.style.display = 'block';
core.dom.toolBar.style.display = 'block';
// see src/plugin/game/ui.js
};
control.prototype.hideStatusBar = function (showToolbox) {
if (main.mode == 'editor') return;
// 如果原本就是隐藏的,则先显示
if (!core.domStyle.showStatusBar) this.showStatusBar();
if (core.isReplaying()) showToolbox = true;
var statusItems = core.dom.status,
toolItems = core.dom.tools;
core.domStyle.showStatusBar = false;
core.setFlag('hideStatusBar', true);
core.setFlag('showToolbox', showToolbox || null);
// 隐藏
for (var i = 0; i < statusItems.length; ++i)
statusItems[i].style.opacity = 0;
if (
(!core.domStyle.isVertical && !core.flags.extendToolbar) ||
!showToolbox
) {
for (var i = 0; i < toolItems.length; ++i)
toolItems[i].style.display = 'none';
}
if (!core.domStyle.isVertical && !core.flags.extendToolbar) {
core.dom.toolBar.style.display = 'none';
}
// see src/plugin/game/ui.js
};
////// 改变工具栏为按钮1-8 //////

View File

@ -235,6 +235,7 @@ enemys.prototype.getDamageString = function (enemy, x, y, floorId, hero) {
////// 接下来N个临界值和临界减伤计算 //////
enemys.prototype.nextCriticals = function (enemy, number, x, y, floorId, hero) {
// todo: 删除 getDamageInfo
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
number = number || 1;
@ -281,6 +282,7 @@ enemys.prototype._nextCriticals_overAtk = function (
floorId,
hero
) {
// todo: 删除 getDamageInfo
var calNext = function (currAtk, maxAtk) {
var start = currAtk,
end = maxAtk;
@ -338,6 +340,7 @@ enemys.prototype._nextCriticals_useBinarySearch = function (
floorId,
hero
) {
// todo: 删除 getDamageInfo
var mon_hp = info.mon_hp,
hero_atk = core.getStatusOrDefault(hero, 'atk'),
mon_def = info.mon_def,
@ -411,17 +414,12 @@ enemys.prototype.getDefDamage = function (enemy, k, x, y, floorId, hero) {
};
enemys.prototype.getEnemyInfo = function (enemy, hero, x, y, floorId) {
if (enemy == null) return null;
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
return this.enemydata.getEnemyInfo(enemy, hero, x, y, floorId);
throw new Error(`This function has been deprecated.`);
};
////// 获得战斗伤害信息(实际伤害计算函数) //////
enemys.prototype.getDamageInfo = function (enemy, hero, x, y, floorId) {
if (enemy == null) return null;
// 移动到了脚本编辑 - getDamageInfo中
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
return this.enemydata.getDamageInfo(enemy, hero, x, y, floorId);
throw new Error(`This function has been deprecated.`);
};
////// 获得在某个勇士属性下怪物伤害 //////
@ -430,6 +428,7 @@ enemys.prototype.getDamage = function (enemy, x, y, floorId, hero) {
};
enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) {
// todo: 删除 getDamageInfo
if (enemy == null) enemy = core.getBlockId(x, y, floorId);
if (typeof enemy == 'string') enemy = core.material.enemys[enemy];
if (enemy == null) return null;
@ -442,6 +441,7 @@ enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) {
////// 获得当前楼层的怪物列表 //////
enemys.prototype.getCurrentEnemys = function (floorId) {
// todo: 删除getEnemyInfo - _getCurrentEnemys_addEnemy
floorId = floorId || core.status.floorId;
var enemys = [],
used = {};

View File

@ -370,73 +370,7 @@ events.prototype.doSystemEvent = function (type, data, callback) {
////// 触发(x,y)点的事件 //////
events.prototype.trigger = function (x, y, callback) {
var _executeCallback = function () {
// 因为trigger之后还有可能触发其他同步脚本比如阻激夹域检测
// 所以这里强制callback被异步触发
if (callback) {
setTimeout(callback, 1); // +1是为了录像检测系统
}
return;
};
if (core.status.gameOver) return _executeCallback();
if (core.status.event.id == 'action') {
core.insertAction(
{
type: 'function',
function:
'function () { core.events._trigger_inAction(' +
x +
',' +
y +
'); }',
async: true
},
null,
null,
null,
true
);
return _executeCallback();
}
if (core.status.event.id) return _executeCallback();
var block = core.getBlock(x, y);
if (block == null) return _executeCallback();
// 执行该点的脚本
if (block.event.script) {
core.clearRouteFolding();
try {
eval(block.event.script);
} catch (ee) {
console.error(ee);
}
}
// 碰触事件
if (block.event.event) {
core.clearRouteFolding();
core.insertAction(block.event.event, block.x, block.y);
// 不再执行该点的系统事件
return _executeCallback();
}
if (block.event.trigger && block.event.trigger != 'null') {
var noPass = block.event.noPass,
trigger = block.event.trigger;
if (noPass) core.clearAutomaticRouteNode(x, y);
// 转换楼层能否穿透
if (
trigger == 'changeFloor' &&
!noPass &&
this._trigger_ignoreChangeFloor(block)
)
return _executeCallback();
core.status.automaticRoute.moveDirectly = false;
this.doSystemEvent(trigger, block);
}
return _executeCallback();
// see src/plugin/game/loopMap.js
};
events.prototype._trigger_inAction = function (x, y) {
@ -801,15 +735,7 @@ events.prototype._getNextItem = function (direction, noRoute) {
};
events.prototype._sys_changeFloor = function (data, callback) {
data = data.event.data;
var heroLoc = {};
if (data.loc) heroLoc = { x: data.loc[0], y: data.loc[1] };
if (data.direction) heroLoc.direction = data.direction;
if (core.status.event.id != 'action') core.status.event.id = null;
core.changeFloor(data.floorId, data.stair, heroLoc, data.time, function () {
core.replay();
if (callback) callback();
});
// see src/plugin/game/loopMap.js
};
////// 楼层切换 //////
@ -4487,40 +4413,7 @@ events.prototype.eventMoveHero = function (steps, time, callback) {
};
events.prototype._eventMoveHero_moving = function (step, moveSteps) {
var curr = moveSteps[0];
var direction = curr[0],
x = core.getHeroLoc('x'),
y = core.getHeroLoc('y');
// ------ 前进/后退
var o = direction == 'backward' ? -1 : 1;
if (direction == 'forward' || direction == 'backward')
direction = core.getHeroLoc('direction');
var faceDirection = direction;
if (direction == 'leftup' || direction == 'leftdown')
faceDirection = 'left';
if (direction == 'rightup' || direction == 'rightdown')
faceDirection = 'right';
core.setHeroLoc('direction', direction);
if (curr[1] <= 0) {
core.setHeroLoc('direction', faceDirection);
moveSteps.shift();
return true;
}
if (step <= 4) {
core.drawHero('leftFoot', 4 * o * step);
} else if (step <= 8) {
core.drawHero('rightFoot', 4 * o * step);
}
if (step == 8) {
core.setHeroLoc('x', x + o * core.utils.scan2[direction].x, true);
core.setHeroLoc('y', y + o * core.utils.scan2[direction].y, true);
core.updateFollowers();
curr[1]--;
if (curr[1] <= 0) moveSteps.shift();
core.setHeroLoc('direction', faceDirection);
return true;
}
return false;
// see src/plugin/game/heroFourFrames.js
};
////// 勇士跳跃事件 //////

View File

@ -75,23 +75,7 @@ maps.prototype.loadFloor = function (floorId, map) {
};
maps.prototype._loadFloor_doNotCopy = function () {
return [
'firstArrive',
'eachArrive',
'blocks',
'parallelDo',
'map',
'bgmap',
'fgmap',
'events',
'changeFloor',
'beforeBattle',
'afterBattle',
'afterGetItem',
'afterOpenDoor',
'cannotMove',
'cannotMoveIn'
];
// see src/plugin/game/fiveLayer.js
};
/// 根据需求解析出blocks
@ -714,44 +698,7 @@ maps.prototype.getMapBlocksObj = function (floorId, noCache) {
////// 将背景前景层变成二维数组的形式 //////
maps.prototype._getBgFgMapArray = function (name, floorId, noCache) {
floorId = floorId || core.status.floorId;
if (!floorId) return [];
var width = core.floors[floorId].width;
var height = core.floors[floorId].height;
if (!noCache && core.status[name + 'maps'][floorId])
return core.status[name + 'maps'][floorId];
var arr =
main.mode == 'editor' &&
!(window.editor && editor.uievent && editor.uievent.isOpen)
? core.cloneArray(editor[name + 'map'])
: null;
if (arr == null)
arr = core.cloneArray(core.floors[floorId][name + 'map'] || []);
for (var y = 0; y < height; ++y) {
if (arr[y] == null) arr[y] = Array(width).fill(0);
}
(core.getFlag('__' + name + 'v__', {})[floorId] || []).forEach(function (
one
) {
arr[one[1]][one[0]] = one[2] || 0;
});
(core.getFlag('__' + name + 'd__', {})[floorId] || []).forEach(function (
one
) {
arr[one[1]][one[0]] = 0;
});
if (main.mode == 'editor') {
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
arr[y][x] = arr[y][x].idnum || arr[y][x] || 0;
}
}
}
if (core.status[name + 'maps']) core.status[name + 'maps'][floorId] = arr;
return arr;
// see src/plugin/game/loopMap.js
};
maps.prototype.getBgMapArray = function (floorId) {
@ -825,11 +772,7 @@ maps.prototype.generateMovableArray = function (floorId) {
};
maps.prototype._generateMovableArray_arrays = function (floorId) {
return {
bgArray: this.getBgMapArray(floorId),
fgArray: this.getFgMapArray(floorId),
eventArray: this.getMapArray(floorId)
};
// see src/plugin/game/fiveLayer.js
};
////// 勇士能否前往某方向 //////
@ -902,6 +845,7 @@ maps.prototype._canMoveHero_checkPoint = function (
return false;
// 4. 检查是否能进将死的领域
// todo: 不使用 core.status.checkBlock
if (
floorId == core.status.floorId &&
!core.flags.canGoDeadZone &&
@ -995,6 +939,7 @@ maps.prototype._canMoveDirectly_checkGlobal = function () {
};
maps.prototype._canMoveDirectly_checkStartPoint = function (sx, sy) {
// todo: 不使用 core.status.checkBlock
if (core.status.checkBlock.damage[sx + ',' + sy]) return false;
var block = core.getBlock(sx, sy);
if (block != null) {
@ -1079,6 +1024,7 @@ maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) {
if (!ignore) return false;
}
// 是否存在阻激夹域伤害
// todo: 不使用 core.status.checkBlock
if (core.status.checkBlock.damage[index]) return false;
if (core.status.checkBlock.repulse[index]) return false;
if (core.status.checkBlock.mockery[index]) return false;
@ -1177,6 +1123,7 @@ maps.prototype._automaticRoute_deepAdd = function (x, y, blocks) {
// if (block.event.trigger == 'changeFloor') deepAdd+=10;
}
// 绕过存在伤害的地方
// todo: 不使用 core.status.checkBlock
deepAdd += (core.status.checkBlock.damage[x + ',' + y] || 0) * 100;
deepAdd += core.status.checkBlock.mockery[`${x},${y}`] ? 1000 : 0;
return deepAdd;
@ -1668,26 +1615,7 @@ maps.prototype.drawBg = function (floorId, config) {
};
maps.prototype._drawBg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
config.ctx = cacheCtx;
core.maps._drawBg_drawBackground(floorId, config);
// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制背景图块;后绘制的覆盖先绘制的。
core.maps._drawFloorImages(
floorId,
config.ctx,
'bg',
null,
null,
config.onMap
);
core.maps._drawBgFgMap(floorId, 'bg', config);
if (config.onMap)
core.drawImage(
toDrawCtx,
cacheCtx.canvas,
core.bigmap.v2 ? -32 : 0,
core.bigmap.v2 ? -32 : 0
);
config.ctx = toDrawCtx;
// see src/plugin/game/fiveLayer.js
};
maps.prototype._drawBg_drawBackground = function (floorId, config) {
@ -1841,25 +1769,7 @@ maps.prototype.drawFg = function (floorId, config) {
};
maps.prototype._drawFg_draw = function (floorId, toDrawCtx, cacheCtx, config) {
config.ctx = cacheCtx;
// ------ 调整这两行的顺序来控制是先绘制贴图还是先绘制前景图块;后绘制的覆盖先绘制的。
core.maps._drawFloorImages(
floorId,
config.ctx,
'fg',
null,
null,
config.onMap
);
core.maps._drawBgFgMap(floorId, 'fg', config);
if (config.onMap)
core.drawImage(
toDrawCtx,
cacheCtx.canvas,
core.bigmap.v2 ? -32 : 0,
core.bigmap.v2 ? -32 : 0
);
config.ctx = toDrawCtx;
// see src/plugin/game/fiveLayer.js
};
////// 实际的背景/前景图块的绘制 //////
@ -2679,6 +2589,7 @@ maps.prototype._drawThumbnail_realDrawTempCanvas = function (
options.ctx.imageSmoothingEnabled = true;
// 缩略图:显伤
if (options.damage && core.hasItem('book')) {
// todo: 删除 updateCheckBlock
core.updateCheckBlock(floorId);
core.control.updateDamage(floorId, options.ctx);
}

View File

@ -3301,6 +3301,7 @@ ui.prototype._drawViewMaps = function (index, x, y) {
this.clearUI();
if (index == null) return this._drawViewMaps_drawHint();
core.animateFrame.tip = null;
// todo: 不使用 core.status.checkBlock
core.status.checkBlock.cache = {};
var data = this._drawViewMaps_buildData(index, x, y);
core.fillRect('ui', 0, 0, core._PX_, core._PY_, '#000000');

View File

@ -263,6 +263,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
return true;
},
beforeBattle: function (enemyId, x, y) {
// todo: 不使用 core.status.checkBlock
// 战斗前触发的事件,可以加上一些战前特效(详见下面支援的例子)
// 此函数在“检测能否战斗和自动存档”【之后】执行。如果需要更早的战前事件,请在插件中覆重写 core.events.doSystemEvent 函数。
// 返回true则将继续战斗返回false将不再战斗。
@ -713,6 +714,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
];
},
getEnemyInfo: function (enemy, hero, x, y, floorId) {
// todo: 删除这个函数
// 获得某个怪物变化后的数据;该函数将被伤害计算和怪物手册使用
// 例如:坚固、模仿、仿攻等等
//
@ -1379,6 +1381,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
);
},
updateStatusBar: function () {
// todo: 删除 updateCheckBlock
// 更新状态栏
// 检查等级
@ -1737,6 +1740,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
checkLoopMap();
// 追猎
// todo: 重写
if (
core.status.checkBlock.haveHunt &&
!core
@ -1872,6 +1876,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
// 判定能否瞬移到该点
if (ignoreSteps == null) ignoreSteps = core.canMoveDirectly(x, y);
// todo: 删除这个判断
if (core.status.checkBlock.haveHunt) return false;
if (ignoreSteps >= 0) {
core.clearMap('hero');

View File

@ -94,6 +94,8 @@ import { has, setCanvasSize } from '../plugin/utils';
import { debounce } from 'lodash-es';
import { isMobile } from '../plugin/use';
// todo: getDamageInfo
const props = defineProps<{
fromBook?: boolean;
}>();

View File

@ -58,6 +58,7 @@ export class EnemyCollection implements RangeCollection<DamageEnemy> {
constructor(floorId: FloorIds) {
this.floorId = floorId;
this.extract();
}
/**

View File

@ -8,6 +8,7 @@
export function drawHalo(ctx, onMap) {
if (main.replayChecking) return;
if (!core.getLocalStorage('showHalo', true)) return;
// todo: 不使用 core.status.checkBlock
const halo = core.status.checkBlock.halo;
ctx.save();
for (const [loc, range] of Object.entries(halo)) {

View File

@ -4,6 +4,7 @@ export {};
// 伤害弹出
// 复写阻激夹域检测
control.prototype.checkBlock = function (forceMockery) {
// todo: 不使用 core.status.checkBlock
var x = core.getHeroLoc('x'),
y = core.getHeroLoc('y'),
loc = x + ',' + y;
@ -37,6 +38,7 @@ control.prototype.checkBlock = function (forceMockery) {
};
control.prototype.moveHero = function (direction, callback) {
// todo: 不使用 core.status.checkBlock
// 如果正在移动直接return
if (core.status.heroMoving != 0) return;
if (core.isset(direction)) core.setHeroLoc('direction', direction);
@ -57,6 +59,7 @@ control.prototype.moveHero = function (direction, callback) {
* @param {boolean} force
*/
function checkMockery(loc, force) {
// todo: 不使用 core.status.checkBlock
if (core.status.lockControl && !force) return;
const mockery = core.status.checkBlock.mockery[loc];
if (mockery) {

View File

@ -45,6 +45,7 @@ core.registerReplayAction('upgradeSkill', name => {
});
core.registerReplayAction('study', name => {
// todo: 删除getEnemyInfo
if (!name.startsWith('study:')) return false;
const [num, x, y] = name
.slice(6)

View File

@ -81,6 +81,7 @@ export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) {
*
*/
export function checkMarkedEnemy(noMessage: boolean = false) {
// todo: 删除 getDamageInfo
checkMarkedStatus.value = !checkMarkedStatus.value;
const hp = core.status.hero.hp;
getMarkedEnemy().forEach(v => {

View File

@ -53,6 +53,7 @@ export function getDefDamage(
y?: number,
floorId?: FloorIds
) {
// todo: 删除 getDamageInfo
const ratio = core.status.thisMap.ratio;
const res: [number, number][] = [];
@ -102,6 +103,7 @@ export function getCriticalDamage(
y?: number,
floorId?: FloorIds
): [number, number][] {
// todo: 删除 getDamageInfo
const ratio = core.status.thisMap.ratio;
const res: [number, number][] = [];

View File

@ -53,6 +53,7 @@ export function getDetailedEnemy<I extends EnemyIds>(
y: number,
floorId: FloorIds = core.status.floorId
): DetailedEnemy<I> {
// todo: 删除 getDamageInfo
const ratio = core.status.maps[floorId].ratio;
const enemyInfo = Object.assign(
{},

View File

@ -49,6 +49,7 @@ import { LeftOutlined } from '@ant-design/icons-vue';
import { KeyCode } from '../plugin/keyCodes';
import { noClosePanel } from '../plugin/uiController';
// todo: 使 core.status.checkBlock
const floorId =
// @ts-ignore
core.floorIds[core.status.event?.ui?.index] ?? core.status.floorId;

View File

@ -102,6 +102,7 @@ function getName(id: EnemyIds) {
}
function getDamage(id: EnemyIds) {
// todo: getDamageInfo
return (
core.formatBigNumber(
core.getDamageInfo(id, void 0, void 0, void 0, 'empty')?.damage