chore:flag改localStorage

This commit is contained in:
ShakeFlower 2025-08-13 22:52:32 +08:00
parent 656539c0b7
commit de8c24f71c
3 changed files with 9 additions and 9 deletions

View File

@ -659,7 +659,7 @@ control.prototype.moveAction = function (callback) {
var noPass = core.noPass(core.nextX(), core.nextY()), canMove = core.canMoveHero(); var noPass = core.noPass(core.nextX(), core.nextY()), canMove = core.canMoveHero();
// 下一个点如果不能走 // 下一个点如果不能走
if (noPass || !canMove) return this._moveAction_noPass(canMove, callback); if (noPass || !canMove) return this._moveAction_noPass(canMove, callback);
if (core.hasFlag("autoSaveAfterItem")) { if (core.getLocalStorage("autoSaveAfterItem")) { // 即将进入滑冰前触发自动存档
const nextbgNumber = core.maps.getBgNumber(core.nextX(), core.nextY(), core.status.floorId); const nextbgNumber = core.maps.getBgNumber(core.nextX(), core.nextY(), core.status.floorId);
if (core.onSki(nextbgNumber)) { if (core.onSki(nextbgNumber)) {
core.control.autosave(); core.control.autosave();
@ -1186,7 +1186,7 @@ control.prototype.checkBlock = function () {
if (currChase && currChase.length > 0) { if (currChase && currChase.length > 0) {
core.push(actions, { "type": "function", "async": true, "function": "function(){\ncore.checkBlock_adjacentChase(true);\n}" }); core.push(actions, { "type": "function", "async": true, "function": "function(){\ncore.checkBlock_adjacentChase(true);\n}" });
} }
if (ambushAction.length > 0 && core.hasFlag("autoSaveAfterItem")) { if (ambushAction.length > 0 && core.getLocalStorage("autoSaveAfterItem")) {
core.push(actions, { "type": "autoSave" }); // 捕捉触发后自动存档 core.push(actions, { "type": "autoSave" }); // 捕捉触发后自动存档
} }

View File

@ -418,7 +418,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "tools", "cls": "tools",
"name": "破墙镐", "name": "破墙镐",
"text": "可以破坏勇士面前的墙", "text": "可以破坏勇士面前的墙",
"useItemEffect": "(function () {\n\tvar canBreak = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable) return false;\n\t\treturn block.event.canBreak;\n\t};\n\n\tvar success = false;\n\tvar pickaxeFourDirections = false; // 是否多方向破如果是将其改成true\n\tif (pickaxeFourDirections) {\n\t\tlet hasAutoSaved = false;\n\t\t// 多方向破\n\t\tfor (var direction in core.utils.scan) { // 多方向破默认四方向如需改成八方向请将这两个scan改为scan2\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBreak(nx, ny)) {\n\t\t\t\tif (core.hasFlag(\"autoSaveAfterItem\")) {\n\t\t\t\t\tif (!hasAutoSaved) core.control.autosave();\n\t\t\t\t\thasAutoSaved = true;\n\t\t\t\t}\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t\tsuccess = true;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅破当前\n\t\tif (canBreak(core.nextX(), core.nextY())) {\n\t\t\tif (core.hasFlag(\"autoSaveAfterItem\")) {\n\t\t\t\tcore.control.autosave();\n\t\t\t}\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t\tsuccess = true;\n\t\t}\n\t}\n\n\tif (success) {\n\t\tcore.playSound('破墙镐');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功', itemId);\n\t} else {\n\t\t// 无法使用\n\t\tcore.playSound('操作失败');\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name, itemId);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();", "useItemEffect": "(function () {\n\tvar canBreak = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable) return false;\n\t\treturn block.event.canBreak;\n\t};\n\n\tvar success = false;\n\tvar pickaxeFourDirections = false; // 是否多方向破如果是将其改成true\n\tif (pickaxeFourDirections) {\n\t\tlet hasAutoSaved = false;\n\t\t// 多方向破\n\t\tfor (var direction in core.utils.scan) { // 多方向破默认四方向如需改成八方向请将这两个scan改为scan2\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (canBreak(nx, ny)) {\n\t\t\t\tif (core.getLocalStorage(\"autoSaveAfterItem\")) {\n\t\t\t\t\tif (!hasAutoSaved) core.control.autosave();\n\t\t\t\t\thasAutoSaved = true;\n\t\t\t\t}\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t\tsuccess = true;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅破当前\n\t\tif (canBreak(core.nextX(), core.nextY())) {\n\t\t\tif (core.getLocalStorage(\"autoSaveAfterItem\")) {\n\t\t\t\tcore.control.autosave();\n\t\t\t}\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t\tsuccess = true;\n\t\t}\n\t}\n\n\tif (success) {\n\t\tcore.playSound('破墙镐');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功', itemId);\n\t} else {\n\t\t// 无法使用\n\t\tcore.playSound('操作失败');\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name, itemId);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
"icePickaxe": { "icePickaxe": {
@ -432,14 +432,14 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "tools", "cls": "tools",
"name": "炸弹", "name": "炸弹",
"text": "可以炸掉勇士面前的怪物", "text": "可以炸掉勇士面前的怪物",
"useItemEffect": "(function () {\n\tconst bombList = []; // 炸掉的怪物坐标列表\n\tconst todo = []; // 炸弹后事件\n\tlet money = 0,\n\t\texp = 0; // 炸弹获得的金币和经验\n\n\tconst canBomb = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable || block.event.cls.indexOf('enemy') != 0) return false;\n\t\tvar enemy = core.getEnemyValue(block.event.id, null, x, y);\n\t\treturn { enemy, notBomb: enemy.notBomb };\n\t};\n\n\tlet hasAutoSaved = false;\n\n\tconst bomb = function (x, y) {\n\t\tconst { enemy, notBomb } = canBomb(x, y);\n\t\tif (!enemy) {\n\t\t\tcore.drawFailTip('该点不是敌人!');\n\t\t\treturn;\n\t\t}\n\t\tif (notBomb) {\n\t\t\tcore.drawFailTip('该点敌人不可炸!');\n\t\t\treturn;\n\t\t}\n\t\tif (core.hasFlag(\"autoSaveAfterItem\")) {\n\t\t\tif (!hasAutoSaved) core.control.autosave();\n\t\t\thasAutoSaved = true;\n\t\t}\n\t\tbombList.push([x, y]);\n\t\tmoney += enemy.money || 0;\n\t\texp += enemy.exp || 0;\n\t\tcore.push(todo, core.floors[core.status.floorId].afterBattle[x + \",\" + y]);\n\t\tcore.push(todo, enemy.afterBattle);\n\t\tcore.removeBlock(x, y);\n\t}\n\n\t// 如果要多方向可炸把这里的false改成true\n\tif (false) {\n\t\tvar scan = core.utils.scan; // 多方向炸时默认四方向,如果要改成八方向炸可以改成 core.utils.scan2\n\t\tfor (var direction in scan) {\n\t\t\tvar delta = scan[direction];\n\t\t\tbomb(core.getHeroLoc('x') + delta.x, core.getHeroLoc('y') + delta.y);\n\t\t}\n\t} else {\n\t\t// 仅炸当前\n\t\tbomb(core.nextX(), core.nextY());\n\t}\n\n\tif (bombList.length == 0) {\n\t\tcore.playSound('操作失败');\n\t\tcore.drawTip('当前无法使用' + core.material.items[itemId].name, itemId);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n\n\tcore.playSound('炸弹');\n\tcore.drawTip(core.material.items[itemId].name + '使用成功', itemId);\n\n\t// 取消这里的注释可以炸弹后获得金币和经验\n\t// core.status.hero.money += money;\n\t// core.status.hero.exp += exp;\n\n\t// 取消这里的注释可以炸弹引发战后事件\n\t// if (todo.length > 0) core.insertAction(todo);\n\n})();", "useItemEffect": "(function () {\n\tconst bombList = []; // 炸掉的怪物坐标列表\n\tconst todo = []; // 炸弹后事件\n\tlet money = 0,\n\t\texp = 0; // 炸弹获得的金币和经验\n\n\tconst canBomb = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.disable || block.event.cls.indexOf('enemy') != 0) return false;\n\t\tvar enemy = core.getEnemyValue(block.event.id, null, x, y);\n\t\treturn { enemy, notBomb: enemy.notBomb };\n\t};\n\n\tlet hasAutoSaved = false;\n\n\tconst bomb = function (x, y) {\n\t\tconst { enemy, notBomb } = canBomb(x, y);\n\t\tif (!enemy) {\n\t\t\tcore.drawFailTip('该点不是敌人!');\n\t\t\treturn;\n\t\t}\n\t\tif (notBomb) {\n\t\t\tcore.drawFailTip('该点敌人不可炸!');\n\t\t\treturn;\n\t\t}\n\t\tif (core.getLocalStorage(\"autoSaveAfterItem\")) {\n\t\t\tif (!hasAutoSaved) core.control.autosave();\n\t\t\thasAutoSaved = true;\n\t\t}\n\t\tbombList.push([x, y]);\n\t\tmoney += enemy.money || 0;\n\t\texp += enemy.exp || 0;\n\t\tcore.push(todo, core.floors[core.status.floorId].afterBattle[x + \",\" + y]);\n\t\tcore.push(todo, enemy.afterBattle);\n\t\tcore.removeBlock(x, y);\n\t}\n\n\t// 如果要多方向可炸把这里的false改成true\n\tif (false) {\n\t\tvar scan = core.utils.scan; // 多方向炸时默认四方向,如果要改成八方向炸可以改成 core.utils.scan2\n\t\tfor (var direction in scan) {\n\t\t\tvar delta = scan[direction];\n\t\t\tbomb(core.getHeroLoc('x') + delta.x, core.getHeroLoc('y') + delta.y);\n\t\t}\n\t} else {\n\t\t// 仅炸当前\n\t\tbomb(core.nextX(), core.nextY());\n\t}\n\n\tif (bombList.length == 0) {\n\t\tcore.playSound('操作失败');\n\t\tcore.drawTip('当前无法使用' + core.material.items[itemId].name, itemId);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n\n\tcore.playSound('炸弹');\n\tcore.drawTip(core.material.items[itemId].name + '使用成功', itemId);\n\n\t// 取消这里的注释可以炸弹后获得金币和经验\n\t// core.status.hero.money += money;\n\t// core.status.hero.exp += exp;\n\n\t// 取消这里的注释可以炸弹引发战后事件\n\t// if (todo.length > 0) core.insertAction(todo);\n\n})();",
"canUseItemEffect": "true" "canUseItemEffect": "true"
}, },
"centerFly": { "centerFly": {
"cls": "tools", "cls": "tools",
"name": "中心对称飞行器", "name": "中心对称飞行器",
"text": "可以飞向当前楼层中心对称的位置", "text": "可以飞向当前楼层中心对称的位置",
"useItemEffect": "if (core.hasFlag(\"autoSaveAfterItem\")) {\n\tcore.control.autosave();\n}\ncore.playSound('centerFly.mp3');\ncore.clearMap('hero');\ncore.setHeroLoc('x', core.bigmap.width - 1 - core.getHeroLoc('x'));\ncore.setHeroLoc('y', core.bigmap.height - 1 - core.getHeroLoc('y'));\ncore.drawHero();\ncore.drawTip(core.material.items[itemId].name + '使用成功');", "useItemEffect": "if (core.getLocalStorage(\"autoSaveAfterItem\")) {\n\tcore.control.autosave();\n}\ncore.playSound('centerFly.mp3');\ncore.clearMap('hero');\ncore.setHeroLoc('x', core.bigmap.width - 1 - core.getHeroLoc('x'));\ncore.setHeroLoc('y', core.bigmap.height - 1 - core.getHeroLoc('y'));\ncore.drawHero();\ncore.drawTip(core.material.items[itemId].name + '使用成功');",
"canUseItemEffect": "(function () {\n\tvar toX = core.bigmap.width - 1 - core.getHeroLoc('x'),\n\t\ttoY = core.bigmap.height - 1 - core.getHeroLoc('y');\n\tvar id = core.getBlockId(toX, toY);\n\treturn id == null;\n})();" "canUseItemEffect": "(function () {\n\tvar toX = core.bigmap.width - 1 - core.getHeroLoc('x'),\n\t\ttoY = core.bigmap.height - 1 - core.getHeroLoc('y');\n\tvar id = core.getBlockId(toX, toY);\n\treturn id == null;\n})();"
}, },
"upFly": { "upFly": {
@ -500,7 +500,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"cls": "tools", "cls": "tools",
"name": "跳跃靴", "name": "跳跃靴",
"text": "能跳跃到前方两格处", "text": "能跳跃到前方两格处",
"useItemEffect": "if (core.hasFlag(\"autoSaveAfterItem\")) {\n\tcore.control.autosave();\n}\ncore.playSound(\"跳跃\");\ncore.insertAction({ \"type\": \"jumpHero\", \"loc\": [core.nextX(2), core.nextY(2)] });", "useItemEffect": "if (core.getLocalStorage(\"autoSaveAfterItem\")) {\n\tcore.control.autosave();\n}\ncore.playSound(\"跳跃\");\ncore.insertAction({ \"type\": \"jumpHero\", \"loc\": [core.nextX(2), core.nextY(2)] });",
"canUseItemEffect": "(function () {\n\tvar nx = core.nextX(2),\n\t\tny = core.nextY(2);\n\treturn nx >= 0 && nx < core.bigmap.width && ny >= 0 && ny < core.bigmap.height && core.getBlockId(nx, ny) == null;\n})();" "canUseItemEffect": "(function () {\n\tvar nx = core.nextX(2),\n\t\tny = core.nextY(2);\n\treturn nx >= 0 && nx < core.bigmap.width && ny >= 0 && ny < core.bigmap.height && core.getBlockId(nx, ny) == null;\n})();"
}, },
"wand": { "wand": {

View File

@ -4822,12 +4822,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
replay: true, replay: true,
}, },
autoSaveAfterItem: { autoSaveAfterItem: {
getName: () => '破炸飞跳自动保存:' + (core.hasFlag('autoSaveAfterItem') ? '开' : '关'), getName: () => '破炸飞跳自动保存:' + (core.getLocalStorage('autoSaveAfterItem') ? '开' : '关'),
effect: () => { effect: () => {
invertFlag('autoSaveAfterItem'); invertLocalStorage('autoSaveAfterItem');
}, },
text: '使用破、炸、飞、跳等特定道具前,以及即将走入滑冰、触发捕捉时自动存档。', text: '使用破、炸、飞、跳等特定道具前,以及即将走入滑冰、触发捕捉时自动存档。',
replay: true, replay: false,
} }
} }