更新热重载服务

This commit is contained in:
unanmed 2023-07-28 10:36:33 +08:00
parent a61952034a
commit 9b5b212828
14 changed files with 685 additions and 742 deletions

View File

@ -18,20 +18,20 @@
"@ant-design/icons-vue": "^6.1.0",
"ant-design-vue": "^3.2.20",
"axios": "^1.4.0",
"chart.js": "^4.3.0",
"chart.js": "^4.3.2",
"jszip": "^3.10.1",
"lodash-es": "^4.17.21",
"lz-string": "^1.5.0",
"mutate-animate": "^1.1.3",
"mutate-animate": "^1.2.3",
"three": "^0.149.0",
"vue": "^3.3.4"
},
"devDependencies": {
"@babel/cli": "^7.22.5",
"@babel/core": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/cli": "^7.22.9",
"@babel/core": "^7.22.9",
"@babel/preset-env": "^7.22.9",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-commonjs": "^25.0.3",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.3",
@ -39,10 +39,10 @@
"@types/babel__core": "^7.20.1",
"@types/fontmin": "^0.9.0",
"@types/fs-extra": "^9.0.13",
"@types/lodash-es": "^4.17.7",
"@types/node": "^18.16.19",
"@types/lodash-es": "^4.17.8",
"@types/node": "^18.17.1",
"@types/ws": "^8.5.5",
"@vitejs/plugin-legacy": "^4.0.5",
"@vitejs/plugin-legacy": "^4.1.1",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"chokidar": "^3.5.3",
@ -51,13 +51,13 @@
"form-data": "^4.0.0",
"fs-extra": "^10.1.0",
"less": "^4.1.3",
"rollup": "^3.26.0",
"terser": "^5.18.2",
"rollup": "^3.26.3",
"terser": "^5.19.2",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
"unplugin-vue-components": "^0.22.12",
"vite": "^4.3.9",
"vue-tsc": "^1.8.3",
"vite": "^4.4.7",
"vue-tsc": "^1.8.8",
"ws": "^8.13.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -287,16 +287,7 @@ control.prototype._animationFrame_animate = function (timestamp) {
};
control.prototype._animationFrame_heroMoving = function (timestamp) {
if (core.status.heroMoving <= 0) return;
// 换腿
if (timestamp - core.animateFrame.moveTime > core.values.moveSpeed) {
core.animateFrame.leftLeg = !core.animateFrame.leftLeg;
core.animateFrame.moveTime = timestamp;
}
core.drawHero(
core.animateFrame.leftLeg ? 'leftFoot' : 'rightFoot',
4 * core.status.heroMoving
);
// Deprecated. See src/plugin/game/heroFourFrames.js
};
control.prototype._animationFrame_weather = function (timestamp) {

View File

@ -1024,9 +1024,9 @@ maps.prototype._canMoveDirectly_checkNextPoint = function (blocksObj, x, y) {
}
// 是否存在阻激夹域伤害
// 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;
// if (core.status.checkBlock.damage[index]) return false;
// if (core.status.checkBlock.repulse[index]) return false;
// if (core.status.checkBlock.mockery[index]) return false;
return true;
};
@ -1123,8 +1123,8 @@ maps.prototype._automaticRoute_deepAdd = function (x, y, blocks) {
}
// 绕过存在伤害的地方
// todo: 不使用 core.status.checkBlock
deepAdd += (core.status.checkBlock.damage[x + ',' + y] || 0) * 100;
deepAdd += core.status.checkBlock.mockery[`${x},${y}`] ? 1000 : 0;
// deepAdd += (core.status.checkBlock.damage[x + ',' + y] || 0) * 100;
// deepAdd += core.status.checkBlock.mockery[`${x},${y}`] ? 1000 : 0;
return deepAdd;
};

View File

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

View File

@ -1368,8 +1368,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = {
core.statusBar.hard.setAttribute('_style', hardColor);
}
// 更新阻激夹域的伤害值
core.updateCheckBlock();
// 更新全地图显伤
core.updateDamage();
@ -1845,8 +1843,6 @@ 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

@ -569,24 +569,17 @@ function setupSocket(socket: WebSocket) {
watchProject();
}
async function startWsServer(port: number = 8080) {
const tryNext = () => {
return new Promise<WebSocketServer>(res => {
const server = new WebSocketServer({
port: port++
});
server.on('error', async () => {
res(await tryNext());
});
server.on('connection', socket => {
setupSocket(socket);
res(server);
});
async function startWsServer(http: Server) {
return new Promise<WebSocketServer>(res => {
const server = new WebSocketServer({
server: http
});
};
return tryNext();
server.on('connection', socket => {
setupSocket(socket);
res(server);
});
});
}
(async function () {
@ -596,8 +589,8 @@ async function startWsServer(port: number = 8080) {
console.log(`游戏地址http://localhost:5173/games/${config.name}/`);
// 2. 启动样板http服务
await startHttpServer();
const server = await startHttpServer(3000);
// 3. 启动样板ws热重载服务
await startWsServer();
await startWsServer(server);
})();

View File

@ -117,7 +117,8 @@ maps.prototype._loadFloor_doNotCopy = function () {
'afterBattle',
'afterGetItem',
'afterOpenDoor',
'cannotMove'
'cannotMove',
'enemy'
];
};
////// 绘制背景和前景层 //////

View File

@ -159,7 +159,7 @@ export {};
console.log(`Data hot reload: ${data}`);
}
const ws = new WebSocket('ws://127.0.0.1:8080');
const ws = new WebSocket('ws://127.0.0.1:3000');
ws.addEventListener('open', () => {
console.log(`Web socket connect successfully`);
});

View File

@ -1,4 +1,4 @@
export {};
import { ensureFloorDamage } from './damage';
core.control.updateDamage = function (floorId = core.status.floorId, ctx) {
if (!floorId || core.status.gameOver || main.mode !== 'play') return;
@ -16,7 +16,7 @@ core.control.updateDamage = function (floorId = core.status.floorId, ctx) {
if (width * height > core.bigmap.threshold) return;
}
// 计算伤害
core.plugin.damage.ensureFloorDamage(floorId);
ensureFloorDamage(floorId);
floor.enemy.calDamage(true, onMap);
floor.enemy.calMapDamage();

View File

@ -8,7 +8,7 @@ control.prototype.checkBlock = function (forceMockery) {
var x = core.getHeroLoc('x'),
y = core.getHeroLoc('y'),
loc = x + ',' + y;
var damage = core.status.checkBlock.damage[loc];
var damage = 0;
if (damage) {
if (!main.replayChecking)
core.addPop(
@ -33,8 +33,8 @@ control.prototype.checkBlock = function (forceMockery) {
core.updateStatusBar();
}
}
this._checkBlock_repulse(core.status.checkBlock.repulse[loc]);
checkMockery(loc, forceMockery);
// this._checkBlock_repulse(core.status.checkBlock.repulse[loc]);
// checkMockery(loc, forceMockery);
};
/**
@ -147,9 +147,9 @@ control.prototype.moveHero = function (direction, callback) {
const nx = core.nextX();
const ny = core.nextY();
if (core.status.checkBlock.mockery[`${nx},${ny}`]) {
core.autosave();
}
// if (core.status.checkBlock.mockery[`${nx},${ny}`]) {
// core.autosave();
// }
if (callback) return this.moveAction(callback);
this._moveHero_moving();

View File

@ -154,6 +154,7 @@ export function boundary(arr: any, key?: any) {
return [min, max];
}
}
declare global {
interface GamePluginUtils {
ofDir: typeof ofDir;

6
src/types/core.d.ts vendored
View File

@ -238,7 +238,7 @@ interface AnimateFrame {
/**
*
*/
readonly moveTime: number;
moveTime: number;
/**
* @deprecated
@ -249,7 +249,7 @@ interface AnimateFrame {
/**
* 使
*/
readonly leftLeg: boolean;
leftLeg: boolean;
/**
*
@ -965,7 +965,7 @@ interface Core extends Pick<Main, CoreDataFromMain> {
/**
*
*/
readonly bigmap: Readonly<CoreBigmap>;
readonly bigmap: CoreBigmap;
/**
*

View File

@ -53,11 +53,6 @@ import { noClosePanel } from '../plugin/uiController';
const floorId =
// @ts-ignore
core.floorIds[core.status.event?.ui?.index] ?? core.status.floorId;
//
if (floorId !== core.status.floorId && core.status.checkBlock) {
// @ts-ignore
core.status.checkBlock.cache = {};
}
const enemy = core.getCurrentEnemys(floorId);