From 314cf0626c7685e335e6cf14ee4d05ffb98374d1 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 2 Mar 2024 00:00:41 +0800 Subject: [PATCH] fix: bugs --- .prettierignore | 3 ++- .prettierrc | 3 +-- public/libs/events.js | 6 ++++-- public/libs/ui.js | 4 +--- public/project/functions.js | 5 +++-- src/components/box.vue | 2 -- src/core/main/custom/ui.ts | 8 ++++---- src/core/main/init/ui.ts | 10 ++++++---- src/plugin/game/shop.ts | 14 ++++++++++---- src/plugin/ui/equipbox.tsx | 13 +++++++------ src/plugin/utils.ts | 4 ++-- src/ui/fly.vue | 6 +++++- src/ui/toolbox.vue | 2 +- vite.config.ts | 4 ++-- 14 files changed, 48 insertions(+), 36 deletions(-) diff --git a/.prettierignore b/.prettierignore index 4998941..6c98a7c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,4 +8,5 @@ public/project/maps.js public/_server/**/*.js script/**/*.js public/editor.html -keyCodes.ts \ No newline at end of file +keyCodes.ts +*.md \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index 957ed81..6ff0062 100644 --- a/.prettierrc +++ b/.prettierrc @@ -9,6 +9,5 @@ "vueIndentScriptAndStyle": false, "arrowParens": "avoid", "trailingComma": "none", - "endOfLine": "auto", - "embeddedLanguageFormatting": "off" + "endOfLine": "auto" } \ No newline at end of file diff --git a/public/libs/events.js b/public/libs/events.js index cb2e312..3ee48cf 100644 --- a/public/libs/events.js +++ b/public/libs/events.js @@ -174,6 +174,7 @@ events.prototype._gameOver_confirmUpload = function (ending, norank) { core.ui.drawConfirmBox( '你想记录你的ID和成绩吗?', function () { + console.log(2); if (main.isCompetition) { core.events._gameOver_doUpload('', ending, norank); } else { @@ -191,6 +192,7 @@ events.prototype._gameOver_confirmUpload = function (ending, norank) { } }, function () { + console.log(1); if (main.isCompetition) core.events._gameOver_confirmDownload(ending); else core.events._gameOver_doUpload(null, ending, norank); @@ -627,7 +629,7 @@ events.prototype._openDoor_animate = function (block, x, y, callback) { core.maps._removeBlockFromMap(core.status.floorId, block); if (!locked) core.unlockControl(); core.status.replay.animate = false; - Mota.require('var', 'hook').emit('afterOpenDoor', block.event.id, x, y); + core.events.afterOpenDoor(block.event.id, x, y); if (callback) callback(); }; @@ -707,7 +709,7 @@ events.prototype.getItem = function (id, num, x, y, isGentleClick, callback) { itemHint.push(id); } - Mota.require('var', 'hook').emit('afterGetItem', id, x, y, isGentleClick); + this.afterGetItem(id, x, y, isGentleClick); if (callback) callback(); }; diff --git a/public/libs/ui.js b/public/libs/ui.js index 68c0621..a34fd3e 100644 --- a/public/libs/ui.js +++ b/public/libs/ui.js @@ -918,9 +918,7 @@ ui.prototype.closePanel = function () { this.clearUI(); core.maps.generateGroundPattern(); core.updateStatusBar(true); - setTimeout(() => { - core.unlockControl(); - }, 0); + core.unlockControl(); core.status.event.data = null; core.status.event.id = null; core.status.event.selection = null; diff --git a/public/project/functions.js b/public/project/functions.js index 24d373d..6abc5c3 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -96,6 +96,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { core.drawText( ['\t[' + (reason || '结局1') + ']你死了。\n如题。'], function () { + console.log(core.status.lockControl); core.events.gameOver(null, replaying); } ); @@ -241,7 +242,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { return true; }, - afterGetItem: function () { + afterGetItem: function (itemId, x, y, isGentleClick) { // 获得一个道具后触发的事件 // itemId:获得的道具ID;x和y是该道具所在的坐标 // isGentleClick:是否是轻按触发的 @@ -272,7 +273,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { if (todo.length > 0) core.insertAction(todo, x, y); }, - afterOpenDoor: function () { + afterOpenDoor: function (x, y) { // 开一个门后触发的事件 const todo = []; // 检查该点的获得开门后事件。 diff --git a/src/components/box.vue b/src/components/box.vue index 762996e..01844f6 100644 --- a/src/components/box.vue +++ b/src/components/box.vue @@ -89,8 +89,6 @@ watch(width, n => emits('update:width', n)); watch(height, n => emits('update:height', n)); async function click() { - console.log(1); - moveSelected.value = true; moveTimeout = window.setTimeout(() => { moveSelected.value = false; diff --git a/src/core/main/custom/ui.ts b/src/core/main/custom/ui.ts index f510dd7..733d948 100644 --- a/src/core/main/custom/ui.ts +++ b/src/core/main/custom/ui.ts @@ -161,7 +161,7 @@ interface IndexedGameUi extends ShowableGameUi { } interface HoldOnController { - end(): void; + end(noClosePanel?: boolean): void; } export class UiController extends Focus { @@ -180,7 +180,7 @@ export class UiController extends Focus { v.ui.emit('close'); }); if (this.stack.length === 0) { - if (!this.hold) this.emit('end'); + if (!this.hold) this.emit('end', false); this.hold = false; } }); @@ -225,8 +225,8 @@ export class UiController extends Focus { this.hold = true; return { - end: () => { - this.emit('end'); + end: (noClosePanel: boolean = false) => { + this.emit('end', noClosePanel); } }; } diff --git a/src/core/main/init/ui.ts b/src/core/main/init/ui.ts index 64848db..f5249b1 100644 --- a/src/core/main/init/ui.ts +++ b/src/core/main/init/ui.ts @@ -41,11 +41,13 @@ hook.once('mounted', () => { ui.style.display = 'flex'; core.lockControl(); }); - mainUi.on('end', () => { + mainUi.on('end', noClosePanel => { ui.style.display = 'none'; - try { - core.closePanel(); - } catch {} + if (!noClosePanel) { + try { + core.closePanel(); + } catch {} + } }); fixedUi.on('start', () => { fixed.style.display = 'block'; diff --git a/src/plugin/game/shop.ts b/src/plugin/game/shop.ts index 7ff5a4d..66f5991 100644 --- a/src/plugin/game/shop.ts +++ b/src/plugin/game/shop.ts @@ -53,13 +53,16 @@ function _convertShop(shop: any) { // 检测能否访问该商店 { type: 'if', - condition: "core.isShopVisited('" + shop.id + "')", + condition: + "Mota.Plugin.require('shop_g').isShopVisited('" + + shop.id + + "')", true: [ // 可以访问,直接插入执行效果 { type: 'function', function: - "function() { core.plugin._convertShop_replaceChoices('" + + "function() { Mota.Plugin.require('shop_g')._convertShop_replaceChoices('" + shop.id + "', false) }" } @@ -84,7 +87,7 @@ function _convertShop(shop: any) { { type: 'function', function: - "function() { core.plugin._convertShop_replaceChoices('" + + "function() { Mota.Plugin.require('shop_g')._convertShop_replaceChoices('" + shop.id + "', true) }" } @@ -101,7 +104,10 @@ function _convertShop(shop: any) { ]; } -function _convertShop_replaceChoices(shopId: string, previewMode: boolean) { +export function _convertShop_replaceChoices( + shopId: string, + previewMode: boolean +) { var shop = core.status.shops[shopId] as any; var choices = (shop.choices || []) .filter(function (choice: any) { diff --git a/src/plugin/ui/equipbox.tsx b/src/plugin/ui/equipbox.tsx index 627e30b..badcc08 100644 --- a/src/plugin/ui/equipbox.tsx +++ b/src/plugin/ui/equipbox.tsx @@ -23,7 +23,8 @@ export function getAddStatus(equip: Equip) { {keys.map(v => { const value = Math.floor( (equip.value[v] ?? 0) * core.getBuff(v) + - (core.status.hero[v] * (equip.percentage[v] ?? 0)) / 100 + (core.status.hero[v] * (equip.percentage?.[v] ?? 0)) / + 100 ); return ( @@ -71,12 +72,12 @@ export function getNowStatus(nowEquip?: Equip, onCol: boolean = false) { let add = 0; if (has(nowEquip)) { add += Math.floor( - (nowEquip.value[v] ?? 0) * core.getBuff(v) + (nowEquip.value?.[v] ?? 0) * core.getBuff(v) ); - const per = Math.floor( - (nowEquip.percentage[v] * core.getStatus(v)) / 100 - ); - add += isNaN(per) ? 0 : per; + // const per = Math.floor( + // (nowEquip.percentage?.[v] * getHeroStatusOn(v)) / 100 + // ); + // add += isNaN(per) ? 0 : per; } if (onCol) add = -add; diff --git a/src/plugin/utils.ts b/src/plugin/utils.ts index 24f73d1..30498f5 100644 --- a/src/plugin/utils.ts +++ b/src/plugin/utils.ts @@ -312,10 +312,10 @@ export function getStatusLabel(name: string) { hpmax: '生命回复', hp: '生命', manamax: '魔力上限', - mana: '额外攻击', + mana: '魔力', atk: '攻击', def: '防御', - mdef: '智慧', + mdef: '护盾', money: '金币', exp: '经验', point: '加点', diff --git a/src/ui/fly.vue b/src/ui/fly.vue index 11c62f4..915c45a 100644 --- a/src/ui/fly.vue +++ b/src/ui/fly.vue @@ -56,7 +56,7 @@ :type="isMobile ? 'horizontal' : 'vertical'" >
- +
area[v].includes(id))!; } diff --git a/src/ui/toolbox.vue b/src/ui/toolbox.vue index 9e16fe7..bd5d27e 100644 --- a/src/ui/toolbox.vue +++ b/src/ui/toolbox.vue @@ -184,7 +184,7 @@ function use(id: ShowItemIds) { nextTick(() => { core.useItem(id, false, () => { if (mainUi.stack.length === 0) { - hold.end(); + hold.end(core.status.event.id !== 'toolbox'); } }); }); diff --git a/vite.config.ts b/vite.config.ts index 108f495..d5424e9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -61,14 +61,14 @@ export default defineConfig({ target: FSHOST, changeOrigin: true, rewrite(path) { - return path.replace(/^\/all/, ''); + return './' + path.replace(/^\/all/, ''); }, }, '^/forceTem/.*': { target: FSHOST, changeOrigin: true, rewrite(path) { - return path.replace(/^\/forceTem/, ''); + return './' + path.replace(/^\/forceTem/, ''); }, } },