插件转为es模块

This commit is contained in:
unanmed 2023-04-16 17:05:47 +08:00
parent d56e54135a
commit 81f6815429
25 changed files with 3265 additions and 3391 deletions

View File

@ -35,7 +35,7 @@
### 通用 ### 通用
- 实时天气 - 实时天气
- 成就系统 - 成就系统(完成)
- 装备合成、装备(孔)强化 - 装备合成、装备(孔)强化
- 宝石目标设定 - 宝石目标设定
- 自动宝物规划,选中两个或更多宝物后自动在本地图中规划出最优拾取路线,原则是尽量减少其余宝物的捡拾,自动切换主动技能,怪物造成的伤害最低的路线 - 自动宝物规划,选中两个或更多宝物后自动在本地图中规划出最优拾取路线,原则是尽量减少其余宝物的捡拾,自动切换主动技能,怪物造成的伤害最低的路线

View File

@ -5,9 +5,9 @@
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vue-tsc && vite build && ts-node-esm script/compress.ts", "build": "vue-tsc && vite build && ts-node-esm script/build.ts",
"build-gh": "vue-tsc && vite build --base=/HumanBreak/ && ts-node-esm script/compress.ts", "build-gh": "vue-tsc && vite build --base=/HumanBreak/ && ts-node-esm script/build.ts",
"build-local": "vue-tsc && vite build --base=/ && ts-node-esm script/compress.ts", "build-local": "vue-tsc && vite build --base=/ && ts-node-esm script/build.ts",
"preview": "vite preview", "preview": "vite preview",
"preview-node": "cd dist && node server.cjs", "preview-node": "cd dist && node server.cjs",
"update": "ts-node-esm script/update.ts", "update": "ts-node-esm script/update.ts",
@ -42,6 +42,7 @@
"form-data": "^4.0.0", "form-data": "^4.0.0",
"fs-extra": "^10.1.0", "fs-extra": "^10.1.0",
"less": "^4.1.3", "less": "^4.1.3",
"rollup": "^3.20.2",
"terser": "^5.16.9", "terser": "^5.16.9",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^4.9.5", "typescript": "^4.9.5",

View File

@ -24,6 +24,7 @@ specifiers:
lodash: ^4.17.21 lodash: ^4.17.21
lz-string: ^1.5.0 lz-string: ^1.5.0
mutate-animate: ^1.1.1 mutate-animate: ^1.1.1
rollup: ^3.20.2
terser: ^5.16.9 terser: ^5.16.9
three: ^0.149.0 three: ^0.149.0
ts-node: ^10.9.1 ts-node: ^10.9.1
@ -61,10 +62,11 @@ devDependencies:
form-data: 4.0.0 form-data: 4.0.0
fs-extra: 10.1.0 fs-extra: 10.1.0
less: 4.1.3 less: 4.1.3
rollup: 3.20.2
terser: 5.16.9 terser: 5.16.9
ts-node: 10.9.1_o6avl3oodj6mwqsx3rm2wfkgv4 ts-node: 10.9.1_o6avl3oodj6mwqsx3rm2wfkgv4
typescript: 4.9.5 typescript: 4.9.5
unplugin-vue-components: 0.22.12_vue@3.2.47 unplugin-vue-components: 0.22.12_rollup@3.20.2+vue@3.2.47
vite: 4.2.1_lu7yuwtv4qfbkrotoux232iypi vite: 4.2.1_lu7yuwtv4qfbkrotoux232iypi
vue-tsc: 1.2.0_typescript@4.9.5 vue-tsc: 1.2.0_typescript@4.9.5
@ -1620,7 +1622,7 @@ packages:
rimraf: 3.0.2 rimraf: 3.0.2
dev: true dev: true
/@rollup/pluginutils/5.0.2: /@rollup/pluginutils/5.0.2_rollup@3.20.2:
resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
peerDependencies: peerDependencies:
@ -1632,6 +1634,7 @@ packages:
'@types/estree': 1.0.0 '@types/estree': 1.0.0
estree-walker: 2.0.2 estree-walker: 2.0.2
picomatch: 2.3.1 picomatch: 2.3.1
rollup: 3.20.2
dev: true dev: true
/@simonwep/pickr/1.8.2: /@simonwep/pickr/1.8.2:
@ -4399,7 +4402,7 @@ packages:
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
dev: true dev: true
/unplugin-vue-components/0.22.12_vue@3.2.47: /unplugin-vue-components/0.22.12_rollup@3.20.2+vue@3.2.47:
resolution: {integrity: sha512-FxyzsuBvMCYPIk+8cgscGBQ345tvwVu+qY5IhE++eorkyvA4Z1TiD/HCiim+Kbqozl10i4K+z+NCa2WO2jexRA==} resolution: {integrity: sha512-FxyzsuBvMCYPIk+8cgscGBQ345tvwVu+qY5IhE++eorkyvA4Z1TiD/HCiim+Kbqozl10i4K+z+NCa2WO2jexRA==}
engines: {node: '>=14'} engines: {node: '>=14'}
peerDependencies: peerDependencies:
@ -4410,7 +4413,7 @@ packages:
optional: true optional: true
dependencies: dependencies:
'@antfu/utils': 0.7.2 '@antfu/utils': 0.7.2
'@rollup/pluginutils': 5.0.2 '@rollup/pluginutils': 5.0.2_rollup@3.20.2
chokidar: 3.5.3 chokidar: 3.5.3
debug: 4.3.4 debug: 4.3.4
fast-glob: 3.2.12 fast-glob: 3.2.12

View File

@ -1,7 +1,6 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict'; export {};
(function () {
// 创建新图层 // 创建新图层
function createCanvas(name, zIndex) { function createCanvas(name, zIndex) {
if (!name) return; if (!name) return;
@ -21,15 +20,7 @@
var bg2Canvas = createCanvas('bg2', 20); var bg2Canvas = createCanvas('bg2', 20);
var fg2Canvas = createCanvas('fg2', 63); var fg2Canvas = createCanvas('fg2', 63);
// 大地图适配 // 大地图适配
core.bigmap.canvas = [ core.bigmap.canvas = ['bg2', 'fg2', 'bg', 'event', 'event2', 'fg', 'damage'];
'bg2',
'fg2',
'bg',
'event',
'event2',
'fg',
'damage'
];
core.initStatus.bg2maps = {}; core.initStatus.bg2maps = {};
core.initStatus.fg2maps = {}; core.initStatus.fg2maps = {};
@ -205,4 +196,3 @@
fg2Array: this._getBgFgMapArray('fg2', floorId) fg2Array: this._getBgFgMapArray('fg2', floorId)
}; };
}; };
})();

View File

@ -1,13 +1,11 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/** /**
* 绘制光环范围 * 绘制光环范围
* @param {CanvasRenderingContext2D} ctx * @param {CanvasRenderingContext2D} ctx
* @param {boolean} onMap * @param {boolean} onMap
*/ */
function drawHalo(ctx, onMap) { export function drawHalo(ctx, onMap) {
if (main.replayChecking) return; if (main.replayChecking) return;
if (!core.getLocalStorage('showHalo', true)) return; if (!core.getLocalStorage('showHalo', true)) return;
const halo = core.status.checkBlock.halo; const halo = core.status.checkBlock.halo;
@ -54,4 +52,3 @@
core.plugin.halo = { core.plugin.halo = {
drawHalo drawHalo
}; };
})();

View File

@ -1,7 +1,5 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/** /**
* 获取勇士在某一点的属性 * 获取勇士在某一点的属性
* @param {keyof HeroStatus | 'all'} name * @param {keyof HeroStatus | 'all'} name
@ -9,11 +7,11 @@
* @param {number} y * @param {number} y
* @param {FloorIds} floorId * @param {FloorIds} floorId
*/ */
function getHeroStatusOn(name, x, y, floorId) { export function getHeroStatusOn(name, x, y, floorId) {
return getRealStatusOf(core.status.hero, name, x, y, floorId); return getHeroStatusOf(core.status.hero, name, x, y, floorId);
} }
function getHeroStatusOf(status, name, x, y, floorId) { export function getHeroStatusOf(status, name, x, y, floorId) {
return getRealStatus(status, name, x, y, floorId); return getRealStatus(status, name, x, y, floorId);
} }
@ -84,4 +82,3 @@
getHeroStatusOf, getHeroStatusOf,
getHeroStatusOn getHeroStatusOn
}; };
})();

View File

@ -1,7 +1,6 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict'; export {};
(function () {
['up', 'down', 'left', 'right'].forEach(one => { ['up', 'down', 'left', 'right'].forEach(one => {
// 指定中间帧动画 // 指定中间帧动画
core.material.icons.hero[one].midFoot = 2; core.material.icons.hero[one].midFoot = 2;
@ -57,4 +56,3 @@
} }
return false; return false;
}; };
})();

View File

@ -1,5 +1,5 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict'; export {};
(function () { (function () {
if (main.mode !== 'play' || main.replayChecking) return; if (main.mode !== 'play' || main.replayChecking) return;

View File

@ -0,0 +1,32 @@
import './fiveLayer';
import './heroFourFrames';
import './hotReload';
import './itemDetail';
import './popup';
import './replay';
import './ui';
import * as halo from './halo';
import * as hero from './hero';
import * as loopMap from './loopMap';
import * as remainEnemy from './remainEnemy';
import * as removeMap from './removeMap';
import * as shop from './shop';
import * as skill from './skills';
import * as skillTree from './skillTree';
import * as study from './study';
import * as towerBoss from './towerBoss';
import * as utils from './utils';
export {
halo,
hero,
loopMap,
remainEnemy,
removeMap,
shop,
skill,
skillTree,
study,
towerBoss,
utils
};

View File

@ -1,7 +1,6 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict'; export {};
(function () {
core.control.updateDamage = function (floorId, ctx) { core.control.updateDamage = function (floorId, ctx) {
floorId = floorId || core.status.floorId; floorId = floorId || core.status.floorId;
if (!floorId || core.status.gameOver || main.mode != 'play') return; if (!floorId || core.status.gameOver || main.mode != 'play') return;
@ -127,4 +126,3 @@
i++; i++;
} }
} }
})();

View File

@ -1,8 +1,6 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict'; import { slide } from './utils';
(function () {
const { slide } = core.plugin.utils;
const list = ['tower6']; const list = ['tower6'];
/** /**
@ -28,7 +26,7 @@
setLoopMap(core.status.hero.loc.x, floorId); setLoopMap(core.status.hero.loc.x, floorId);
} }
function checkLoopMap() { export function checkLoopMap() {
if (isLoopMap(core.status.floorId)) { if (isLoopMap(core.status.floorId)) {
autoSetLoopMap(core.status.floorId); autoSetLoopMap(core.status.floorId);
} }
@ -81,16 +79,10 @@
} else if (data.loc) heroLoc = { x: data.loc[0], y: data.loc[1] }; } else if (data.loc) heroLoc = { x: data.loc[0], y: data.loc[1] };
if (data.direction) heroLoc.direction = data.direction; if (data.direction) heroLoc.direction = data.direction;
if (core.status.event.id != 'action') core.status.event.id = null; if (core.status.event.id != 'action') core.status.event.id = null;
core.changeFloor( core.changeFloor(data.floorId, data.stair, heroLoc, data.time, function () {
data.floorId,
data.stair,
heroLoc,
data.time,
function () {
core.replay(); core.replay();
if (callback) callback(); if (callback) callback();
} });
);
}; };
events.prototype.trigger = function (x, y, callback) { events.prototype.trigger = function (x, y, callback) {
@ -212,16 +204,16 @@
for (var y = 0; y < height; ++y) { for (var y = 0; y < height; ++y) {
if (arr[y] == null) arr[y] = Array(width).fill(0); if (arr[y] == null) arr[y] = Array(width).fill(0);
} }
(core.getFlag('__' + name + 'v__', {})[floorId] || []).forEach( (core.getFlag('__' + name + 'v__', {})[floorId] || []).forEach(function (
function (one) { one
) {
arr[one[1]][one[0]] = one[2] || 0; arr[one[1]][one[0]] = one[2] || 0;
} });
); (core.getFlag('__' + name + 'd__', {})[floorId] || []).forEach(function (
(core.getFlag('__' + name + 'd__', {})[floorId] || []).forEach( one
function (one) { ) {
arr[one[1]][one[0]] = 0; arr[one[1]][one[0]] = 0;
} });
);
if (main.mode == 'editor') { if (main.mode == 'editor') {
for (var x = 0; x < width; x++) { for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) { for (var y = 0; y < height; y++) {
@ -229,12 +221,10 @@
} }
} }
} }
if (core.status[name + 'maps']) if (core.status[name + 'maps']) core.status[name + 'maps'][floorId] = arr;
core.status[name + 'maps'][floorId] = arr;
return arr; return arr;
}; };
core.plugin.loopMap = { core.plugin.loopMap = {
checkLoopMap checkLoopMap
}; };
})();

View File

@ -1,7 +1,6 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict'; export {};
(function () {
// 伤害弹出 // 伤害弹出
// 复写阻激夹域检测 // 复写阻激夹域检测
control.prototype.checkBlock = function (forceMockery) { control.prototype.checkBlock = function (forceMockery) {
@ -18,9 +17,8 @@
); );
core.status.hero.hp -= damage; core.status.hero.hp -= damage;
var text = var text =
Object.keys(core.status.checkBlock.type[loc] || {}).join( Object.keys(core.status.checkBlock.type[loc] || {}).join('') ||
'' '伤害';
) || '伤害';
core.drawTip('受到' + text + damage + '点'); core.drawTip('受到' + text + damage + '点');
core.drawHeroAnimate('zone'); core.drawHeroAnimate('zone');
this._checkBlock_disableQuickShop(); this._checkBlock_disableQuickShop();
@ -66,8 +64,7 @@
const action = []; const action = [];
const [tx, ty] = mockery[0]; const [tx, ty] = mockery[0];
let { x, y } = core.status.hero.loc; let { x, y } = core.status.hero.loc;
const dir = const dir = x > tx ? 'left' : x < tx ? 'right' : y > ty ? 'up' : 'down';
x > tx ? 'left' : x < tx ? 'right' : y > ty ? 'up' : 'down';
const { x: dx, y: dy } = core.utils.scan[dir]; const { x: dx, y: dy } = core.utils.scan[dir];
action.push({ type: 'changePos', direction: dir }); action.push({ type: 'changePos', direction: dir });
@ -121,4 +118,3 @@
core.insertAction(action); core.insertAction(action);
} }
} }
})();

View File

@ -1,12 +1,10 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/** /**
* 检查漏怪 * 检查漏怪
* @param {FloorIds[]} floorIds * @param {FloorIds[]} floorIds
*/ */
function checkRemainEnemy(floorIds) { export function checkRemainEnemy(floorIds) {
/** /**
* @type {Record<FloorIds, {loc: LocArr, id: EnemyIds}[]>} * @type {Record<FloorIds, {loc: LocArr, id: EnemyIds}[]>}
*/ */
@ -15,8 +13,7 @@
core.extractBlocks(v); core.extractBlocks(v);
const blocks = core.status.maps[v].blocks; const blocks = core.status.maps[v].blocks;
blocks.forEach(block => { blocks.forEach(block => {
if (!block.event.cls.startsWith('enemy') || block.disable) if (!block.event.cls.startsWith('enemy') || block.disable) return;
return;
/** /**
* @type {EnemyIds} * @type {EnemyIds}
*/ */
@ -33,7 +30,7 @@
* 获取剩余怪物字符串 * 获取剩余怪物字符串
* @param {FloorIds[]} floorIds * @param {FloorIds[]} floorIds
*/ */
function getRemainEnemyString(floorIds) { export function getRemainEnemyString(floorIds) {
const enemy = checkRemainEnemy(floorIds); const enemy = checkRemainEnemy(floorIds);
const str = []; const str = [];
let now = []; let now = [];
@ -73,4 +70,3 @@
checkRemainEnemy, checkRemainEnemy,
getRemainEnemyString getRemainEnemyString
}; };
})();

View File

@ -1,8 +1,6 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () { export function removeMaps(fromId, toId, force) {
function removeMaps(fromId, toId, force) {
toId = toId || fromId; toId = toId || fromId;
var fromIndex = core.floorIds.indexOf(fromId), var fromIndex = core.floorIds.indexOf(fromId),
toIndex = core.floorIds.indexOf(toId); toIndex = core.floorIds.indexOf(toId);
@ -42,7 +40,7 @@
} }
} }
function deleteFlags(floorId) { export function deleteFlags(floorId) {
delete flags[`jump_${floorId}`]; delete flags[`jump_${floorId}`];
delete flags[`inte_${floorId}`]; delete flags[`inte_${floorId}`];
delete flags[`loop_${floorId}`]; delete flags[`loop_${floorId}`];
@ -53,7 +51,7 @@
// 恢复楼层 // 恢复楼层
// core.plugin.removeMap.resumeMaps("MT1", "MT300") 恢复MT1~MT300之间的全部层 // core.plugin.removeMap.resumeMaps("MT1", "MT300") 恢复MT1~MT300之间的全部层
// core.plugin.removeMap.resumeMaps("MT10") 只恢复MT10层 // core.plugin.removeMap.resumeMaps("MT10") 只恢复MT10层
function resumeMaps(fromId, toId) { export function resumeMaps(fromId, toId) {
toId = toId || fromId; toId = toId || fromId;
var fromIndex = core.floorIds.indexOf(fromId), var fromIndex = core.floorIds.indexOf(fromId),
toIndex = core.floorIds.indexOf(toId); toIndex = core.floorIds.indexOf(toId);
@ -89,7 +87,7 @@
}; };
// 分区砍层 // 分区砍层
function autoRemoveMaps(floorId) { export function autoRemoveMaps(floorId) {
if (main.mode != 'play' || !inAnyPartition(floorId)) return; if (main.mode != 'play' || !inAnyPartition(floorId)) return;
// 根据分区信息自动砍层与恢复 // 根据分区信息自动砍层与恢复
(core.floorPartitions || []).forEach(floor => { (core.floorPartitions || []).forEach(floor => {
@ -115,4 +113,3 @@
resumeMaps, resumeMaps,
autoRemoveMaps autoRemoveMaps
}; };
})();

View File

@ -1,8 +1,7 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () { import { studySkill, canStudySkill } from './study';
const { studySkill, canStudySkill } = core.plugin.study;
const replayableSettings = ['autoSkill']; const replayableSettings = ['autoSkill'];
// 注册修改设置的录像操作 // 注册修改设置的录像操作
@ -88,4 +87,3 @@
core.replay(); core.replay();
return true; return true;
}); });
})();

View File

@ -1,10 +1,8 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
const { openItemShop } = core.plugin.gameUi; const { openItemShop } = core.plugin.gameUi;
function openShop(shopId, noRoute) { export function openShop(shopId, noRoute) {
var shop = core.status.shops[shopId]; var shop = core.status.shops[shopId];
// Step 1: 检查能否打开此商店 // Step 1: 检查能否打开此商店
if (!this.canOpenShop(shopId)) { if (!this.canOpenShop(shopId)) {
@ -21,7 +19,7 @@
} }
/// 是否访问过某个快捷商店 /// 是否访问过某个快捷商店
function isShopVisited(id) { export function isShopVisited(id) {
flags.__shops__ ??= {}; flags.__shops__ ??= {};
var shops = core.getFlag('__shops__'); var shops = core.getFlag('__shops__');
if (!shops[id]) shops[id] = {}; if (!shops[id]) shops[id] = {};
@ -29,7 +27,7 @@
} }
/// 当前应当显示的快捷商店列表 /// 当前应当显示的快捷商店列表
function listShopIds() { export function listShopIds() {
return Object.keys(core.status.shops).filter(id => { return Object.keys(core.status.shops).filter(id => {
return ( return (
core.plugin.shop.isShopVisited(id) || core.plugin.shop.isShopVisited(id) ||
@ -39,7 +37,7 @@
} }
/// 是否能够打开某个商店 /// 是否能够打开某个商店
function canOpenShop(id) { export function canOpenShop(id) {
if (this.isShopVisited(id)) return true; if (this.isShopVisited(id)) return true;
var shop = core.status.shops[id]; var shop = core.status.shops[id];
if (shop.item || shop.commonEvent || shop.mustEnable) return false; if (shop.item || shop.commonEvent || shop.mustEnable) return false;
@ -47,7 +45,7 @@
} }
/// 启用或禁用某个快捷商店 /// 启用或禁用某个快捷商店
function setShopVisited(id, visited) { export function setShopVisited(id, visited) {
if (!core.hasFlag('__shops__')) core.setFlag('__shops__', {}); if (!core.hasFlag('__shops__')) core.setFlag('__shops__', {});
var shops = core.getFlag('__shops__'); var shops = core.getFlag('__shops__');
if (!shops[id]) shops[id] = {}; if (!shops[id]) shops[id] = {};
@ -56,7 +54,7 @@
} }
/// 能否使用快捷商店 /// 能否使用快捷商店
function canUseQuickShop() { export function canUseQuickShop() {
// 如果返回一个字符串,表示不能,字符串为不能使用的提示 // 如果返回一个字符串,表示不能,字符串为不能使用的提示
// 返回null代表可以使用 // 返回null代表可以使用
@ -74,4 +72,3 @@
setShopVisited, setShopVisited,
canUseQuickShop canUseQuickShop
}; };
})();

View File

@ -1,7 +1,5 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/** /**
* @type {number[]} * @type {number[]}
*/ */
@ -199,7 +197,7 @@
core.plugin.skills = skills; core.plugin.skills = skills;
function getSkillFromIndex(index) { export function getSkillFromIndex(index) {
for (const [, skill] of Object.entries(skills)) { for (const [, skill] of Object.entries(skills)) {
const s = skill.find(v => v.index === index); const s = skill.find(v => v.index === index);
if (s) return s; if (s) return s;
@ -210,11 +208,11 @@
* 获取技能等级 * 获取技能等级
* @param {number} skill * @param {number} skill
*/ */
function getSkillLevel(skill) { export function getSkillLevel(skill) {
return (levels[skill] ??= 0); return (levels[skill] ??= 0);
} }
function getSkillConsume(skill) { export function getSkillConsume(skill) {
return eval( return eval(
this.getSkillFromIndex(skill).consume.replace( this.getSkillFromIndex(skill).consume.replace(
/level(:\d+)?/g, /level(:\d+)?/g,
@ -226,7 +224,7 @@
); );
} }
function openTree() { export function openTree() {
if (main.replayChecking) return; if (main.replayChecking) return;
core.plugin.skillTreeOpened.value = true; core.plugin.skillTreeOpened.value = true;
} }
@ -235,7 +233,7 @@
* 能否升级某个技能 * 能否升级某个技能
* @param {number} skill * @param {number} skill
*/ */
function canUpgrade(skill) { export function canUpgrade(skill) {
const consume = core.plugin.skillTree.getSkillConsume(skill); const consume = core.plugin.skillTree.getSkillConsume(skill);
if (consume > core.status.hero.mdef) return false; if (consume > core.status.hero.mdef) return false;
const level = core.plugin.skillTree.getSkillLevel(skill); const level = core.plugin.skillTree.getSkillLevel(skill);
@ -243,8 +241,7 @@
if (level === s.max) return false; if (level === s.max) return false;
const front = s.front; const front = s.front;
for (const [skill, level] of front) { for (const [skill, level] of front) {
if (core.plugin.skillTree.getSkillLevel(skill) < level) if (core.plugin.skillTree.getSkillLevel(skill) < level) return false;
return false;
} }
return true; return true;
} }
@ -253,7 +250,7 @@
* 实际升级效果 * 实际升级效果
* @param {number} skill * @param {number} skill
*/ */
function upgradeSkill(skill) { export function upgradeSkill(skill) {
if (!canUpgrade(skill)) return false; if (!canUpgrade(skill)) return false;
switch (skill) { switch (skill) {
case 0: // 力量 +2攻击 case 0: // 力量 +2攻击
@ -300,11 +297,11 @@
return true; return true;
} }
function saveSkillTree() { export function saveSkillTree() {
return levels.slice(); return levels.slice();
} }
function loadSkillTree(data) { export function loadSkillTree(data) {
levels = data ?? []; levels = data ?? [];
} }
@ -317,4 +314,3 @@
upgradeSkill, upgradeSkill,
openTree openTree
}; };
})();

View File

@ -1,7 +1,5 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
// 所有的主动技能效果 // 所有的主动技能效果
var ignoreInJump = { var ignoreInJump = {
event: ['X20007', 'X20001', 'X20006', 'X20014', 'X20010', 'X20007'], event: ['X20007', 'X20001', 'X20006', 'X20014', 'X20010', 'X20007'],
@ -24,7 +22,7 @@
/** @type {FloorIds[]} */ /** @type {FloorIds[]} */
const jumpIgnoreFloor = ['MT31', 'snowTown']; const jumpIgnoreFloor = ['MT31', 'snowTown'];
// 跳跃 // 跳跃
function jumpSkill() { export function jumpSkill() {
if (core.status.floorId.startsWith('tower')) if (core.status.floorId.startsWith('tower'))
return core.drawTip('当无法使用该技能'); return core.drawTip('当无法使用该技能');
if (jumpIgnoreFloor.includes(core.status.floorId) || flags.onChase) { if (jumpIgnoreFloor.includes(core.status.floorId) || flags.onChase) {
@ -76,8 +74,8 @@
var noPass = core.noPass(checkLoc.x, checkLoc.y); var noPass = core.noPass(checkLoc.x, checkLoc.y);
var id = core.getBlockId(checkLoc.x, checkLoc.y) || ''; var id = core.getBlockId(checkLoc.x, checkLoc.y) || '';
var bgId = var bgId =
core.getBlockByNumber(core.getBgNumber(checkLoc.x, checkLoc.y)) core.getBlockByNumber(core.getBgNumber(checkLoc.x, checkLoc.y)).event
.event.id || ''; .id || '';
// 可以通行 // 可以通行
if ( if (
!noPass || !noPass ||
@ -106,12 +104,7 @@
} }
// 是怪物 // 是怪物
if (cls == 'enemys' || cls == 'enemy48') { if (cls == 'enemys' || cls == 'enemy48') {
var firstNoPass = checkNoPass( var firstNoPass = checkNoPass(direction, checkLoc.x, checkLoc.y, false);
direction,
checkLoc.x,
checkLoc.y,
false
);
if (!firstNoPass) return; if (!firstNoPass) return;
core.autosave(); core.autosave();
if (flags.chapter <= 1) core.status.hero.hp -= 200 * flags.hard; if (flags.chapter <= 1) core.status.hero.hp -= 200 * flags.hard;
@ -160,8 +153,7 @@
var id = core.getBlockId(x, y) || ''; var id = core.getBlockId(x, y) || '';
if (core.getBgNumber(x, y)) if (core.getBgNumber(x, y))
var bgId = var bgId =
core.getBlockByNumber(core.getBgNumber(x, y)).event.id || core.getBlockByNumber(core.getBgNumber(x, y)).event.id || '';
'';
else var bgId = ''; else var bgId = '';
if ( if (
core.noPass(x, y) || core.noPass(x, y) ||
@ -179,4 +171,3 @@
core.plugin.skillEffects = { core.plugin.skillEffects = {
jumpSkill jumpSkill
}; };
})();

View File

@ -1,7 +1,5 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
// 负责勇士技能:学习 // 负责勇士技能:学习
const values = { const values = {
1: ['crit'], 1: ['crit'],
@ -14,7 +12,7 @@
const cannotStudy = [9, 12, 14, 15, 24]; const cannotStudy = [9, 12, 14, 15, 24];
function canStudySkill(number) { export function canStudySkill(number) {
const s = (core.status.hero.special ??= { num: [], last: [] }); const s = (core.status.hero.special ??= { num: [], last: [] });
if (core.plugin.skillTree.getSkillLevel(11) === 0) return false; if (core.plugin.skillTree.getSkillLevel(11) === 0) return false;
if (s.num.length >= 1) return false; if (s.num.length >= 1) return false;
@ -23,7 +21,7 @@
return true; return true;
} }
function studySkill(enemy, number) { export function studySkill(enemy, 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(); const specials = core.getSpecials();
@ -43,7 +41,7 @@
} }
} }
function forgetStudiedSkill(num, i) { export function forgetStudiedSkill(num, i) {
const s = core.status.hero.special; const s = core.status.hero.special;
const index = i !== void 0 && i !== null ? i : s.num.indexOf(num); const index = i !== void 0 && i !== null ? i : s.num.indexOf(num);
if (index === -1) return; if (index === -1) return;
@ -55,12 +53,12 @@
} }
} }
function declineStudiedSkill() { export function declineStudiedSkill() {
const s = (core.status.hero.special ??= { num: [], last: [] }); const s = (core.status.hero.special ??= { num: [], last: [] });
s.last = s.last.map(v => v - 1); s.last = s.last.map(v => v - 1);
} }
function checkStudiedSkill() { export function checkStudiedSkill() {
const s = core.status.hero.special; const s = core.status.hero.special;
for (let i = 0; i < s.last.length; i++) { for (let i = 0; i < s.last.length; i++) {
if (s.last[i] <= 0) { if (s.last[i] <= 0) {
@ -77,4 +75,3 @@
declineStudiedSkill, declineStudiedSkill,
checkStudiedSkill checkStudiedSkill
}; };
})();

View File

@ -1,9 +1,7 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
// 1000多行改不动了 // 1000多行改不动了,原来什么样就什么样吧
(function () {
// 智慧boss // 智慧boss
// 变量们 // 变量们
var stage = 1, var stage = 1,
@ -23,7 +21,7 @@
setTimeout(bossCore, 1000); setTimeout(bossCore, 1000);
} }
// 录像自动修正 // 录像自动修正
function autoFixRouteBoss(isStart) { export function autoFixRouteBoss(isStart) {
var route = core.status.route; var route = core.status.route;
if (isStart) { if (isStart) {
// 开始修正 记录当前录像长度 // 开始修正 记录当前录像长度
@ -101,8 +99,7 @@
y = y || 16; y = y || 16;
time = time || 3000; time = time || 3000;
// 创建画布 // 创建画布
if (!core.dymCanvas.words) if (!core.dymCanvas.words) core.createCanvas('words', x, y, 480, 24, 135);
core.createCanvas('words', x, y, 480, 24, 135);
else core.clearMap('words'); else core.clearMap('words');
if (flags.wordsTimeOut) clearTimeout(flags.wordsTimeOut); if (flags.wordsTimeOut) clearTimeout(flags.wordsTimeOut);
dynamicCurtain(y, y + 24, time / 3); dynamicCurtain(y, y + 24, time / 3);
@ -166,14 +163,7 @@
core.clearMap('wordsBg'); core.clearMap('wordsBg');
style.shadowBlur = 8; style.shadowBlur = 8;
style.shadowOffsetY = 2; style.shadowOffsetY = 2;
core.fillRect( core.fillRect('wordsBg', 0, 0, width, ny - from, [180, 180, 180, 0.7]);
'wordsBg',
0,
0,
width,
ny - from,
[180, 180, 180, 0.7]
);
style.shadowBlur = 3; style.shadowBlur = 3;
style.shadowOffsetY = 0; style.shadowOffsetY = 0;
core.strokeRect( core.strokeRect(
@ -340,10 +330,8 @@
} }
if (stage == 2) { if (stage == 2) {
if (seconds == 4) skipWord('智慧之神:你的确拥有智慧。'); if (seconds == 4) skipWord('智慧之神:你的确拥有智慧。');
if (seconds == 8) if (seconds == 8) skipWord('智慧之神:或许你就是那个未来的救星。');
skipWord('智慧之神:或许你就是那个未来的救星。'); if (seconds == 12) skipWord('智慧之神:不过,这场战斗才刚刚开始');
if (seconds == 12)
skipWord('智慧之神:不过,这场战斗才刚刚开始');
if (seconds == 25) skipWord('提示:方形区域均为危险区域'); if (seconds == 25) skipWord('提示:方形区域均为危险区域');
if (seconds == 15) if (seconds == 15)
setTimeout(() => { setTimeout(() => {
@ -362,8 +350,7 @@
} }
if (stage >= 3) { if (stage >= 3) {
if (seconds == 4) skipWord('智慧之神:拥有智慧就是不一样。'); if (seconds == 4) skipWord('智慧之神:拥有智慧就是不一样。');
if (seconds == 8) if (seconds == 8) skipWord('智慧之神:不过,你还得再过我一关!');
skipWord('智慧之神:不过,你还得再过我一关!');
if (seconds == 12) startStage3(); if (seconds == 12) startStage3();
if (seconds == 15) { if (seconds == 15) {
flags.booming = true; flags.booming = true;
@ -469,14 +456,7 @@
} }
// 箭 // 箭
if (!core.dymCanvas['inteArrow' + loc + direction]) if (!core.dymCanvas['inteArrow' + loc + direction])
core.createCanvas( core.createCanvas('inteArrow' + loc + direction, 0, 0, 544, 544, 65);
'inteArrow' + loc + direction,
0,
0,
544,
544,
65
);
core.clearMap('inteArrow' + loc + direction); core.clearMap('inteArrow' + loc + direction);
if (direction == 'horizon') if (direction == 'horizon')
core.drawImage( core.drawImage(
@ -514,8 +494,7 @@
nloc += speed; nloc += speed;
if (direction == 'horizon') if (direction == 'horizon')
core.relocateCanvas('inteArrow' + loc + direction, nloc, 0); core.relocateCanvas('inteArrow' + loc + direction, nloc, 0);
else else core.relocateCanvas('inteArrow' + loc + direction, 0, nloc);
core.relocateCanvas('inteArrow' + loc + direction, 0, nloc);
if (nloc < -480) { if (nloc < -480) {
core.deleteCanvas('inteArrow' + loc + direction); core.deleteCanvas('inteArrow' + loc + direction);
clearInterval(skill1); clearInterval(skill1);
@ -802,8 +781,7 @@
// 闪一下 // 闪一下
var frame1 = 0, var frame1 = 0,
alpha = 0.5; alpha = 0.5;
if (!core.dymCanvas.flash) if (!core.dymCanvas.flash) core.createCanvas('flash', 0, 0, 480, 480, 160);
core.createCanvas('flash', 0, 0, 480, 480, 160);
else core.clearMap('flash'); else core.clearMap('flash');
var thunderFlash = window.setInterval(() => { var thunderFlash = window.setInterval(() => {
alpha -= 0.05; alpha -= 0.05;
@ -1002,12 +980,10 @@
y = core.status.hero.loc.y; y = core.status.hero.loc.y;
if ( if (
((Math.floor((nx - 16 - 4 * now) / 32) == x || ((Math.floor((nx - 16 - 4 * now) / 32) == x ||
Math.floor((nx - 16 + 4 * now) / 32) == Math.floor((nx - 16 + 4 * now) / 32) == x) &&
x) &&
locs[i][1] == y) || locs[i][1] == y) ||
((Math.floor((ny - 16 - 4 * now) / 32) == y || ((Math.floor((ny - 16 - 4 * now) / 32) == y ||
Math.floor((ny - 16 + 4 * now) / 32) == Math.floor((ny - 16 + 4 * now) / 32) == y) &&
y) &&
locs[i][0] == x) locs[i][0] == x)
) { ) {
damaged[i] = true; damaged[i] = true;
@ -1076,18 +1052,7 @@
} }
core.createCanvas('tower7', 0, 0, 480, 480, 15); core.createCanvas('tower7', 0, 0, 480, 480, 15);
// 画贴图 // 画贴图
core.drawImage( core.drawImage('tower7', 'tower7.jpeg', 360, 0, 32, 480, 0, 0, 32, 480);
'tower7',
'tower7.jpeg',
360,
0,
32,
480,
0,
0,
32,
480
);
core.drawImage( core.drawImage(
'tower7', 'tower7',
'tower7.jpeg', 'tower7.jpeg',
@ -1170,18 +1135,7 @@
} }
core.createCanvas('tower7', 0, 0, 480, 480, 15); core.createCanvas('tower7', 0, 0, 480, 480, 15);
// 画贴图 // 画贴图
core.drawImage( core.drawImage('tower7', 'tower7.jpeg', 360, 0, 64, 480, 0, 0, 64, 480);
'tower7',
'tower7.jpeg',
360,
0,
64,
480,
0,
0,
64,
480
);
core.drawImage( core.drawImage(
'tower7', 'tower7',
'tower7.jpeg', 'tower7.jpeg',
@ -1263,18 +1217,7 @@
} }
core.createCanvas('tower7', 0, 0, 480, 480, 15); core.createCanvas('tower7', 0, 0, 480, 480, 15);
// 画贴图 // 画贴图
core.drawImage( core.drawImage('tower7', 'tower7.jpeg', 360, 0, 96, 480, 0, 0, 96, 480);
'tower7',
'tower7.jpeg',
360,
0,
96,
480,
0,
0,
96,
480
);
core.drawImage( core.drawImage(
'tower7', 'tower7',
'tower7.jpeg', 'tower7.jpeg',
@ -1365,8 +1308,7 @@
function chainAnimate(route) { function chainAnimate(route) {
if (!route) return chainThunder(); if (!route) return chainThunder();
// 画布 // 画布
if (!core.dymCanvas.chain) if (!core.dymCanvas.chain) core.createCanvas('chain', 0, 0, 480, 480, 65);
core.createCanvas('chain', 0, 0, 480, 480, 65);
else core.clearMap('chain'); else core.clearMap('chain');
var style = core.dymCanvas.chain; var style = core.dymCanvas.chain;
style.shadowBlur = 3; style.shadowBlur = 3;
@ -1396,13 +1338,7 @@
); );
// 节点 // 节点
if (now == 0) { if (now == 0) {
core.fillCircle( core.fillCircle('chain', route[0][0], route[0][1], 7, '#ffffff');
'chain',
route[0][0],
route[0][1],
7,
'#ffffff'
);
} }
if ( if (
(route[now + 1][0] - 16) % 32 == 0 && (route[now + 1][0] - 16) % 32 == 0 &&
@ -1449,10 +1385,7 @@
nx += Math.random() * 50 * Math.cos(angle); nx += Math.random() * 50 * Math.cos(angle);
ny += Math.random() * 50 * Math.sin(angle); ny += Math.random() * 50 * Math.sin(angle);
routes.push([nx, ny]); routes.push([nx, ny]);
if ( if (Math.sqrt(Math.pow(ny - ty, 2) + Math.pow(nx - tx, 2)) <= 100) {
Math.sqrt(Math.pow(ny - ty, 2) + Math.pow(nx - tx, 2)) <=
100
) {
routes.push([tx, ty]); routes.push([tx, ty]);
break; break;
} }
@ -1525,14 +1458,7 @@
var angle = (loc[2] * Math.PI) / 50; var angle = (loc[2] * Math.PI) / 50;
// 开始绘制 // 开始绘制
core.fillCircle('boom', x, y, 3, [255, 50, 50, alpha]); core.fillCircle('boom', x, y, 3, [255, 50, 50, alpha]);
core.strokeCircle( core.strokeCircle('boom', x, y, radius, [255, 50, 50, alpha], 2);
'boom',
x,
y,
radius,
[255, 50, 50, alpha],
2
);
// 旋转的线 // 旋转的线
core.drawLine( core.drawLine(
'boom', 'boom',
@ -1556,16 +1482,11 @@
// 炸弹 下落 // 炸弹 下落
if (loc[2] > 70) { if (loc[2] > 70) {
var h = var h =
y - y - (20 * (85 - loc[2]) + 2.8 * Math.pow(85 - loc[2], 2));
(20 * (85 - loc[2]) + 2.8 * Math.pow(85 - loc[2], 2));
core.drawImage('boom', 'boom.png', x - 18, h - 80, 36, 80); core.drawImage('boom', 'boom.png', x - 18, h - 80, 36, 80);
} }
if (loc[2] == 85) { if (loc[2] == 85) {
core.drawAnimate( core.drawAnimate('explosion1', (x - 16) / 32, (y - 16) / 32);
'explosion1',
(x - 16) / 32,
(y - 16) / 32
);
boomLocs.splice(index, 1); boomLocs.splice(index, 1);
if (boomLocs.length == 0) core.deleteCanvas('boom'); if (boomLocs.length == 0) core.deleteCanvas('boom');
// 伤害判定 // 伤害判定
@ -1608,10 +1529,8 @@
var loc1 = [x * 32 - 12, y * 32 + 16], var loc1 = [x * 32 - 12, y * 32 + 16],
loc2 = [x * 32 + 12, y * 32 - 16]; loc2 = [x * 32 + 12, y * 32 - 16];
// 直线方程 y == (y2 - y1) / (x2 - x1) * (x - x1) + y1 // 直线方程 y == (y2 - y1) / (x2 - x1) * (x - x1) + y1
var n1 = var n1 = ((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + y1 - loc1[1],
((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + y1 - loc1[1], n2 = ((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + y1 - loc2[1];
n2 =
((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + y1 - loc2[1];
if (n1 * n2 <= 0) { if (n1 * n2 <= 0) {
core.status.hero.hp -= damage; core.status.hero.hp -= damage;
core.addPop(x * 32 + 16, y * 32 + 16, -damage); core.addPop(x * 32 + 16, y * 32 + 16, -damage);
@ -1630,10 +1549,8 @@
var loc1 = [x * 32 - 12, y * 32 - 16], var loc1 = [x * 32 - 12, y * 32 - 16],
loc2 = [x * 32 + 12, y * 32 + 16]; loc2 = [x * 32 + 12, y * 32 + 16];
// 直线方程 y == (y2 - y1) / (x2 - x1) * (x - x1) + y1 // 直线方程 y == (y2 - y1) / (x2 - x1) * (x - x1) + y1
var n1 = var n1 = ((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + y1 - loc1[1],
((y2 - y1) / (x2 - x1)) * (loc1[0] - x1) + y1 - loc1[1], n2 = ((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + y1 - loc2[1];
n2 =
((y2 - y1) / (x2 - x1)) * (loc2[0] - x1) + y1 - loc2[1];
if (n1 * n2 <= 0) { if (n1 * n2 <= 0) {
core.status.hero.hp -= damage; core.status.hero.hp -= damage;
core.addPop(x * 32 + 16, y * 32 + 16, -damage); core.addPop(x * 32 + 16, y * 32 + 16, -damage);
@ -1655,4 +1572,3 @@
initTowerBoss, initTowerBoss,
autoFixRouteBoss autoFixRouteBoss
}; };
})();

View File

@ -1,5 +1,5 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict'; export {};
(function () { (function () {
if (main.replayChecking) return (core.plugin.gameUi = {}); if (main.replayChecking) return (core.plugin.gameUi = {});

View File

@ -1,13 +1,11 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
'use strict';
(function () {
/** /**
* 滑动数组 * 滑动数组
* @param {any[]} arr * @param {any[]} arr
* @param {number} delta * @param {number} delta
*/ */
function slide(arr, delta) { export function slide(arr, delta) {
if (delta === 0) return arr; if (delta === 0) return arr;
delta %= arr.length; delta %= arr.length;
if (delta > 0) { if (delta > 0) {
@ -20,7 +18,7 @@
} }
} }
function backDir(dir) { export function backDir(dir) {
return { return {
up: 'down', up: 'down',
down: 'up', down: 'up',
@ -29,11 +27,11 @@
}[dir]; }[dir];
} }
function has(v) { export function has(v) {
return v !== null && v !== void 0; return v !== null && v !== void 0;
} }
function maxGameScale(n = 0) { export function maxGameScale(n = 0) {
const index = core.domStyle.availableScale.indexOf(core.domStyle.scale); const index = core.domStyle.availableScale.indexOf(core.domStyle.scale);
core.control.setDisplayScale( core.control.setDisplayScale(
core.domStyle.availableScale.length - 1 - index - n core.domStyle.availableScale.length - 1 - index - n
@ -53,4 +51,3 @@
has, has,
maxGameScale maxGameScale
}; };
})();

View File

@ -2,8 +2,8 @@ import fs from 'fs/promises';
import fss from 'fs'; import fss from 'fs';
import fse from 'fs-extra'; import fse from 'fs-extra';
import Fontmin from 'fontmin'; import Fontmin from 'fontmin';
import { exec } from 'child_process';
import * as babel from '@babel/core'; import * as babel from '@babel/core';
import * as rollup from 'rollup';
(async function () { (async function () {
// 1. 去除未使用的文件 // 1. 去除未使用的文件
@ -40,7 +40,7 @@ import * as babel from '@babel/core';
}) })
); );
await fse.remove('./dist/maps/'); await fse.remove('./dist/maps/');
// 编辑器需要留着吗? // 在线查看什么都看不到,这编辑器难道还需要留着吗?
} catch {} } catch {}
// 2. 压缩字体 // 2. 压缩字体
@ -98,22 +98,23 @@ import * as babel from '@babel/core';
// 3. 压缩js插件 // 3. 压缩js插件
try { try {
exec( const build = await rollup.rollup({
`babel ${data.main.plugin input: 'public/project/plugin/index.js'
.map(v => `./dist/project/plugin/${v}.js`) });
.join(' ')} --out-file ./dist/project/plugin.m.js` const code = await build.generate({
).on('close', async () => { format: 'iife',
name: 'CorePlugin'
});
const compressed = babel.transformSync(code.output[0].code)?.code!;
await fs.writeFile('./dist/project/plugin.m.js', compressed, 'utf-8');
const main = await fs.readFile('./dist/main.js', 'utf-8'); const main = await fs.readFile('./dist/main.js', 'utf-8');
await fs.writeFile(
'./dist/main.js',
main.replace( main.replace(
/this.pluginUseCompress\s*=\s*false\;/, /this.pluginUseCompress\s*=\s*false\;/,
'this.pluginUseCompress = true;' 'this.pluginUseCompress = true;'
)
); );
await fse.remove('./dist/project/plugin/'); await fse.remove('./dist/project/plugin/');
}); } catch (e) {
} catch {
console.log('压缩插件失败'); console.log('压缩插件失败');
} }
@ -124,20 +125,8 @@ import * as babel from '@babel/core';
const endIndex = main.indexOf('// >>>> body end'); const endIndex = main.indexOf('// >>>> body end');
const nonCompress = main.slice(0, endIndex); const nonCompress = main.slice(0, endIndex);
const needCompress = main.slice(endIndex + 17); const needCompress = main.slice(endIndex + 17);
await fs.writeFile('./dist/temp.js', needCompress, 'utf-8'); const compressed = babel.transformSync(needCompress)?.code;
await fs.rm('./dist/main.js'); await fs.writeFile('./dist/main.js', nonCompress + compressed, 'utf-8');
exec('babel ./dist/temp.js --out-file ./dist/main.js').on(
'close',
async () => {
const nowMain = await fs.readFile('./dist/main.js', 'utf-8');
await fs.writeFile(
'./dist/main.js',
nonCompress + nowMain,
'utf-8'
);
await fs.rm('./dist/temp.js');
}
);
} catch { } catch {
console.log('main.js压缩失败'); console.log('main.js压缩失败');
} }

View File

@ -1,5 +1,7 @@
import { ref, watch } from 'vue'; import { ref, watch } from 'vue';
// todo 优化可以考虑改成reactive
/** 打开和关闭ui时是否展示动画 */ /** 打开和关闭ui时是否展示动画 */
export const transition = ref(false); export const transition = ref(false);

View File

@ -1,7 +1,8 @@
import { power } from 'mutate-animate'; import { hyper, power } from 'mutate-animate';
import { Polygon } from './polygon'; import { Polygon } from './polygon';
import { import {
Light, Light,
animateLight,
getAllLights, getAllLights,
moveLight, moveLight,
refreshLight, refreshLight,
@ -27,7 +28,7 @@ export default function init() {
} }
}; };
return { updateShadow, clearShadowCache, setCalShadow, testLight: test }; return { updateShadow, clearShadowCache, setCalShadow };
} }
const shadowInfo: Partial<Record<FloorIds, Light[]>> = { const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
@ -35,11 +36,10 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
{ {
id: 'mt48_1', id: 'mt48_1',
x: 0, x: 0,
y: 0, y: 48,
decay: 0, decay: 0,
r: 300, r: 300,
color: '#0000', color: '#0000'
followHero: true
} }
] ]
}; };
@ -153,7 +153,3 @@ export function setCalShadow(n: boolean) {
calMapShadow = n; calMapShadow = n;
updateShadow(); updateShadow();
} }
function test() {
moveLight('mt48_1', 480, 48, 2000, power(4, 'in-out'));
}