diff --git a/public/project/floors/MT32.js b/public/project/floors/MT32.js index 7eb68ea..d147a65 100644 --- a/public/project/floors/MT32.js +++ b/public/project/floors/MT32.js @@ -1,128 +1,127 @@ -main.floors.MT32 = { - floorId: 'MT32', - title: '冰封雪原', - name: '冰封雪原', - width: 15, - height: 15, - canFlyTo: true, - canFlyFrom: true, - canUseQuickShop: true, - cannotViewMap: false, - images: [], - ratio: 8, - defaultGround: 'T580', - bgm: 'winter.mp3', - firstArrive: [ +main.floors.MT32= +{ + "floorId": "MT32", + "title": "冰封雪原", + "name": "冰封雪原", + "width": 15, + "height": 15, + "canFlyTo": true, + "canFlyFrom": true, + "canUseQuickShop": true, + "cannotViewMap": false, + "images": [], + "ratio": 8, + "defaultGround": "T580", + "bgm": "winter.mp3", + "firstArrive": [ { - type: 'function', - function: "function(){\ncore.removeMaps('MT17', 'MT21', true)\n}" + "type": "function", + "function": "function(){\ncore.removeMaps('MT17', 'MT21', true)\n}" } ], - eachArrive: [], - parallelDo: '', - events: { - '0,7': [ + "eachArrive": [], + "parallelDo": "", + "events": { + "0,7": [ { - type: 'if', - condition: '(flag:inWinter2===true)', - true: ['\t[低级智人]\b[up,hero]没必要回去了'], - false: [ + "type": "if", + "condition": "(flag:inWinter2===true)", + "true": [ + "\t[低级智人]\b[up,hero]没必要回去了" + ], + "false": [ { - type: 'changeFloor', - floorId: 'MT31', - loc: [14, 7] + "type": "changeFloor", + "floorId": "MT31", + "loc": [ + 14, + 7 + ] } ] } ], - '1,6': ['宝石血瓶的加成已提升至8倍'], - '1,8': [ - '衣服是个装备,记得穿上', - '光环会在地图上显示,如果不想要可以在背包里面的系统设置里面关闭', - '每张地图会保证极昼怪的数量与永夜怪的数量相同', - '注意打过永夜怪或者极昼怪之后或者有光环的时候,怪物标记可能与当前地图不符,因为标记怪物是标记的某一类怪物而不是某一点的怪物', - '怪物手册显示的怪物是不经过光环加成的怪物,而定点查看则是经过各种加成的怪物。你可以将鼠标移动到怪物上,按下e或c使用定点查看功能' + "1,6": [ + "宝石血瓶的加成已提升至8倍" + ], + "1,8": [ + "衣服是个装备,记得穿上", + "光环会在地图上显示,如果不想要可以在背包里面的系统设置里面关闭", + "注意打过永夜怪或者极昼怪之后或者有光环的时候,怪物标记可能与当前地图不符,因为标记怪物是标记的某一类怪物而不是某一点的怪物", + "怪物手册显示的怪物是不经过光环加成的怪物,而定点查看则是经过各种加成的怪物。你可以将鼠标移动到怪物上,按下e或c使用定点查看功能" ] }, - changeFloor: { - '14,6': { - floorId: 'MT33', - loc: [0, 6] + "changeFloor": { + "14,6": { + "floorId": "MT33", + "loc": [ + 0, + 6 + ] } }, - beforeBattle: {}, - afterBattle: {}, - afterGetItem: {}, - afterOpenDoor: {}, - autoEvent: {}, - cannotMove: {}, - cannotMoveIn: {}, - map: [ - [ - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147 - ], - [147, 0, 482, 441, 274, 0, 28, 147, 34, 0, 603, 0, 0, 0, 147], - [147, 595, 147, 147, 147, 32, 0, 590, 0, 34, 587, 0, 147, 147, 147], - [147, 0, 403, 0, 147, 602, 587, 586, 587, 587, 587, 21, 147, 381, 147], - [147, 28, 33, 27, 492, 34, 34, 586, 34, 390, 588, 0, 592, 34, 147], - [ - 147, 147, 494, 147, 147, 585, 492, 585, 595, 588, 588, 590, 147, - 492, 147 - ], - [147, 129, 0, 21, 147, 32, 0, 602, 0, 586, 0, 0, 34, 0, 94], - [92, 0, 589, 0, 492, 0, 32, 584, 27, 590, 0, 587, 0, 28, 147], - [147, 129, 0, 22, 147, 590, 492, 584, 29, 586, 587, 587, 492, 147, 147], - [147, 147, 494, 147, 147, 0, 0, 603, 0, 586, 0, 32, 32, 0, 147], - [ - 147, 27, 33, 28, 147, 147, 147, 147, 494, 585, 585, 585, 584, 602, - 147 - ], - [147, 0, 403, 0, 492, 34, 34, 147, 0, 0, 381, 381, 0, 0, 147], - [ - 147, 595, 147, 147, 147, 603, 147, 147, 147, 147, 274, 147, 147, - 590, 147 - ], - [147, 0, 21, 27, 0, 0, 0, 0, 28, 33, 0, 492, 0, 0, 147], - [ - 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, - 147, 147 - ] - ], - bgmap: [ - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 145, 145, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 145, 145, 145, 145, 145], - [145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 0, 145, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 145, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0], - [0, 145, 0, 0, 0, 0, 0, 0, 0, 0, 145, 145, 145, 145, 0], - [0, 145, 0, 0, 0, 0, 0, 0, 0, 0, 145, 0, 0, 0, 0], - [0, 145, 145, 145, 145, 145, 145, 145, 145, 145, 145, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - ], - fgmap: [], - bg2map: [ - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 146, 146, 146, 0, 0, 0, 0, 146, 146, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 146, 146, 146, 0, 0, 0, 582, 0, 0, 0, 0, 146, 146, 0], - [0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 146, 146, 0], - [0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 581, 581, 582, 0, 0, 0, 0, 0, 0, 0], - [0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 146, 146, 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - ], - fg2map: [] -}; + "beforeBattle": {}, + "afterBattle": {}, + "afterGetItem": {}, + "afterOpenDoor": {}, + "autoEvent": {}, + "cannotMove": {}, + "cannotMoveIn": {}, + "map": [ + [147,147,147,147,147,147,147,147,147,147,147,147,147,147,147], + [147, 0,482,441,274, 0, 28,147, 34, 0,603, 0, 0, 0,147], + [147,595,147,147,147, 32, 0,590, 0, 34,587, 0,147,147,147], + [147, 0,403, 0,147,602,587,586,587,587,587, 21,147,381,147], + [147, 28, 33, 27,492, 34, 34,586, 34,390,588, 0,592, 34,147], + [147,147,494,147,147,585,492,585,595,588,588,590,147,492,147], + [147,129, 0, 21,147, 32, 0,602, 0,586, 0, 0, 34, 0, 94], + [ 92, 0,589, 0,492, 0, 32,584, 27,590, 0,587, 0, 28,147], + [147,129, 0, 22,147,590,492,584, 29,586,587,587,492,147,147], + [147,147,494,147,147, 0, 0,603, 0,586, 0, 32, 32, 0,147], + [147, 27, 33, 28,147,147,147,147,494,585,585,585,584,602,147], + [147, 0,403, 0,492, 34, 34,147, 0, 0,381,381, 0, 0,147], + [147,595,147,147,147,603,147,147,147,147,274,147,147,590,147], + [147, 0, 21, 27, 0, 0, 0, 0, 28, 33, 0,492, 0, 0,147], + [147,147,147,147,147,147,147,147,147,147,147,147,147,147,147] +], + "bgmap": [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0,145,145, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0,145, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0,145, 0,145,145,145,145,145], + [145,145,145,145,145,145,145,145,145,145,145, 0,145, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,145, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,145,145, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,145, 0], + [ 0,145, 0, 0, 0, 0, 0, 0, 0, 0,145,145,145,145, 0], + [ 0,145, 0, 0, 0, 0, 0, 0, 0, 0,145, 0, 0, 0, 0], + [ 0,145,145,145,145,145,145,145,145,145,145, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] +], + "fgmap": [ + +], + "bg2map": [ + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0,146,146,146, 0, 0, 0, 0,146,146, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0,146,146,146, 0, 0, 0,582, 0, 0, 0, 0,146,146, 0], + [ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0,146,146, 0], + [ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0,581,581,582, 0, 0, 0, 0, 0, 0, 0], + [ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0,146,146,146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] +], + "fg2map": [ + +] +} \ No newline at end of file diff --git a/public/project/functions.js b/public/project/functions.js index b352e8a..98166f4 100644 --- a/public/project/functions.js +++ b/public/project/functions.js @@ -1122,29 +1122,19 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { return damageInfo; } - if (toMap.length <= 1) { - // 单个与多个分开计算,有助于提高性能表现 + const dirDamage = []; + for (const dir of toMap) { + damage = Infinity; + damageInfo = null; autoSkill(); - if (damageInfo) { - return Object.assign(damageInfo, { - dir: [toMap[0]?.[0] ?? 'none', damage] - }); - } else return null; - } else { - const dirDamage = []; - for (const dir of toMap) { - damage = Infinity; - damageInfo = null; - autoSkill(); - dirDamage.push([dir, damage]); - if (damage < dirMinDamage) { - dirMinDamage = damage; - dirDamageInfo = damageInfo; - } - if (dirDamageInfo) { - return Object.assign(dirDamageInfo, { dir: dirDamage }); - } else return null; + dirDamage.push([dir, damage]); + if (damage < dirMinDamage) { + dirMinDamage = damage; + dirDamageInfo = damageInfo; } + if (dirDamageInfo) { + return Object.assign(dirDamageInfo, { dir: dirDamage }); + } else return null; } } }, diff --git a/public/project/items.js b/public/project/items.js index ceb4d8d..42a829b 100644 --- a/public/project/items.js +++ b/public/project/items.js @@ -160,9 +160,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "itemEffectTip": ",攻击+10" }, "sword2": { - "cls": "items", + "cls": "equips", "name": "铁剑", - "text": "真的是一把很普通的银剑,哦不,铁剑", + "text": "真的是一把很普通的银剑,哦不,铁剑。攻击+180,额外攻击+50", "equip": { "type": 0, "animate": "sword", @@ -246,17 +246,16 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "itemEffectTip": ",防御+10" }, "shield2": { - "cls": "items", - "name": "银盾", - "text": "一个真的很普通的铁盾,这次没错了,就是铁盾!", + "cls": "equips", + "name": "铁盾", + "text": "一个真的很普通的铁盾,这次没错了,就是铁盾!防御+120,生命回复+30", "equip": { "type": 1, "value": { + "hpmax": 30, "def": 120 }, - "percentage": { - "hpmax": 30 - } + "percentage": {} }, "itemEffect": "core.status.hero.def += 20", "itemEffectTip": ",防御+20" @@ -1349,7 +1348,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "cls": "equips", "name": "寒冰护符", "canUseItemEffect": "true", - "text": "与寒冰没有任何关系,但是为什么叫寒冰护符呢?攻击和额外攻击各增加5%", + "text": "!!html饰品。与寒冰没有任何关系,但是为什么叫寒冰护符呢?攻击和额外攻击各增加5%", "equip": { "type": 0, "value": {}, diff --git a/public/project/plugins.js b/public/project/plugins.js index 62edd0f..2faae1d 100644 --- a/public/project/plugins.js +++ b/public/project/plugins.js @@ -384,7 +384,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { /// 是否访问过某个快捷商店 this.isShopVisited = function (id) { - if (!core.hasFlag('__shops__')) core.setFlag('__shops__', {}); + flags.__shops__ ??= {}; var shops = core.getFlag('__shops__'); if (!shops[id]) shops[id] = {}; return shops[id].visited; @@ -864,431 +864,11 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { }; }, itemShop: function () { - // 道具商店相关的插件 - // 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找) - - var shopId = null; // 当前商店ID - var type = 0; // 当前正在选中的类型,0买入1卖出 - var selectItem = 0; // 当前正在选中的道具 - var selectCount = 0; // 当前已经选中的数量 - var page = 0; - var totalPage = 0; - var totalMoney = 0; - var list = []; - var shopInfo = null; // 商店信息 - var choices = []; // 商店选项 - var use = 'money'; - var useText = '金币'; - - var bigFont = core.ui._buildFont(20, false), - middleFont = core.ui._buildFont(18, false); - - this._drawItemShop = function () { - // 绘制道具商店 - - // Step 1: 背景和固定的几个文字 - core.ui._createUIEvent(); - core.clearMap('ui'); - core.ui.clearUIEventSelector(); - core.setTextAlign('ui', 'left'); - core.setTextBaseline('ui', 'top'); - core.fillRect('ui', 0, 0, 480, 480, 'black'); - core.drawWindowSkin('winskin.png', 'ui', 0, 0, 480, 64); - core.drawWindowSkin('winskin.png', 'ui', 0, 64, 360, 64); - core.drawWindowSkin('winskin.png', 'ui', 0, 128, 360, 352); - core.drawWindowSkin('winskin.png', 'ui', 360, 64, 120, 64); - core.drawWindowSkin('winskin.png', 'ui', 360, 128, 120, 352); - core.setFillStyle('ui', 'white'); - core.setStrokeStyle('ui', 'white'); - core.fillText('ui', '购买', 32, 84, 'white', bigFont); - core.fillText('ui', '卖出', 152, 84); - core.fillText('ui', '离开', 272, 84); - core.fillText('ui', '当前' + useText, 374, 75, null, middleFont); - core.setTextAlign('ui', 'right'); - core.fillText( - 'ui', - core.formatBigNumber(core.status.hero.money), - 466, - 100 - ); - core.setTextAlign('ui', 'left'); - core.ui.drawUIEventSelector( - 1, - 'winskin.png', - 22 + 120 * type, - 76, - 60, - 33 - ); - if (selectItem != null) { - core.setTextAlign('ui', 'center'); - core.fillText( - 'ui', - type == 0 ? '买入个数' : '卖出个数', - 420, - 360, - null, - bigFont - ); - core.fillText('ui', '< ' + selectCount + ' >', 420, 390); - core.fillText('ui', '确定', 420, 420); - } - - // Step 2:获得列表并展示 - list = choices.filter(one => { - if (one.condition != null && one.condition != '') { - try { - if (!core.calValue(one.condition)) return false; - } catch (e) {} - } - return ( - (type == 0 && one.money != null) || - (type == 1 && one.sell != null) - ); - }); - var per_page = 7; - totalPage = Math.ceil(list.length / per_page); - page = Math.floor((selectItem || 0) / per_page) + 1; - - // 绘制分页 - if (totalPage > 1) { - var half = 180; - core.setTextAlign('ui', 'center'); - core.fillText( - 'ui', - page + ' / ' + totalPage, - half, - 450, - null, - middleFont - ); - if (page > 1) core.fillText('ui', '上一页', half - 80, 450); - if (page < totalPage) - core.fillText('ui', '下一页', half + 80, 450); - } - core.setTextAlign('ui', 'left'); - - // 绘制每一项 - var start = (page - 1) * per_page; - for (var i = 0; i < per_page; ++i) { - var curr = start + i; - if (curr >= list.length) break; - var item = list[curr]; - core.drawIcon('ui', item.id, 10, 141 + i * 40); - core.setTextAlign('ui', 'left'); - core.fillText( - 'ui', - core.material.items[item.id].name, - 50, - 148 + i * 40, - null, - bigFont - ); - core.setTextAlign('ui', 'right'); - core.fillText( - 'ui', - (type == 0 - ? core.calValue(item.money) - : core.calValue(item.sell)) + - useText + - '/个', - 340, - 149 + i * 40, - null, - middleFont - ); - core.setTextAlign('ui', 'left'); - if (curr == selectItem) { - // 绘制描述,文字自动放缩 - var text = - core.material.items[item.id].text || '该道具暂无描述'; - try { - text = core.replaceText(text); - } catch (e) {} - for (var fontSize = 20; fontSize >= 8; fontSize -= 2) { - var config = { - left: 10, - fontSize: fontSize, - maxWidth: 467 - }; - var height = core.getTextContentHeight(text, config); - if (height <= 60) { - config.top = (64 - height) / 2; - core.drawTextContent('ui', text, config); - break; - } - } - core.ui.drawUIEventSelector( - 2, - 'winskin.png', - 8, - 137 + i * 40, - 343, - 40 - ); - if (type == 0 && item.number != null) { - core.fillText('ui', '存货', 370, 152, null, bigFont); - core.setTextAlign('ui', 'right'); - core.fillText( - 'ui', - item.number, - 470, - 152, - null, - null, - 60 - ); - } else if (type == 1) { - core.fillText('ui', '数量', 370, 152, null, bigFont); - core.setTextAlign('ui', 'right'); - core.fillText( - 'ui', - core.itemCount(item.id), - 470, - 152, - null, - null, - 40 - ); - } - core.setTextAlign('ui', 'left'); - core.fillText('ui', '预计' + useText, 370, 280); - core.setTextAlign('ui', 'right'); - totalMoney = - selectCount * - (type == 0 - ? core.calValue(item.money) - : core.calValue(item.sell)); - core.fillText( - 'ui', - core.formatBigNumber(totalMoney), - 470, - 310 - ); - - core.setTextAlign('ui', 'left'); - core.fillText( - 'ui', - type == 0 ? '已购次数' : '已卖次数', - 370, - 190 - ); - core.setTextAlign('ui', 'right'); - core.fillText( - 'ui', - (type == 0 ? item.money_count : item.sell_count) || 0, - 470, - 220 - ); - } - } - - core.setTextAlign('ui', 'left'); - core.setTextBaseline('ui', 'alphabetic'); - }; - - var _add = (item, delta) => { - if (item == null) return; - selectCount = core.clamp( - selectCount + delta, - 0, - Math.min( - type == 0 - ? Math.floor( - core.status.hero[use] / core.calValue(item.money) - ) - : core.itemCount(item.id), - type == 0 && item.number != null - ? item.number - : Number.MAX_SAFE_INTEGER - ) - ); - }; - - var _confirm = item => { - if (item == null || selectCount == 0) return; - if (type == 0) { - core.status.hero[use] -= totalMoney; - core.getItem(item.id, selectCount); - if (item.number != null) item.number -= selectCount; - item.money_count = (item.money_count || 0) + selectCount; - } else { - core.status.hero[use] += totalMoney; - core.removeItem(item.id, selectCount); - core.drawTip( - '成功卖出' + - selectCount + - '个' + - core.material.items[item.id].name, - item.id - ); - if (item.number != null) item.number += selectCount; - item.sell_count = (item.sell_count || 0) + selectCount; - } - selectCount = 0; - }; - - this._performItemShopKeyBoard = function (keycode) { - var item = list[selectItem] || null; - // 键盘操作 - switch (keycode) { - case 38: // up - if (selectItem == null) break; - if (selectItem == 0) selectItem = null; - else selectItem--; - selectCount = 0; - break; - case 37: // left - if (selectItem == null) { - if (type > 0) type--; - break; - } - _add(item, -1); - break; - case 39: // right - if (selectItem == null) { - if (type < 2) type++; - break; - } - _add(item, 1); - break; - case 40: // down - if (selectItem == null) { - if (list.length > 0) selectItem = 0; - break; - } - if (list.length == 0) break; - selectItem = Math.min(selectItem + 1, list.length - 1); - selectCount = 0; - break; - case 13: - case 32: // Enter/Space - if (selectItem == null) { - if (type == 2) core.insertAction({ type: 'break' }); - else if (list.length > 0) selectItem = 0; - break; - } - _confirm(item); - break; - case 27: // ESC - if (selectItem == null) { - core.insertAction({ type: 'break' }); - break; - } - selectItem = null; - break; - } - }; - - this._performItemShopClick = function (px, py) { - var item = list[selectItem] || null; - // 鼠标操作 - if (px >= 22 && px <= 82 && py >= 81 && py <= 112) { - // 买 - if (type != 0) { - type = 0; - selectItem = null; - selectCount = 0; - } - return; - } - if (px >= 142 && px <= 202 && py >= 81 && py <= 112) { - // 卖 - if (type != 1) { - type = 1; - selectItem = null; - selectCount = 0; - } - return; - } - if (px >= 262 && px <= 322 && py >= 81 && py <= 112) - // 离开 - return core.insertAction({ type: 'break' }); - // <,> - if (px >= 370 && px <= 395 && py >= 392 && py <= 415) - return _add(item, -1); - if (px >= 445 && px <= 470 && py >= 302 && py <= 415) - return _add(item, 1); - // 确定 - if (px >= 392 && px <= 443 && py >= 421 && py <= 446) - return _confirm(item); - - // 上一页/下一页 - if (px >= 70 && px <= 130 && py >= 450) { - if (page > 1) { - selectItem -= 7; - selectCount = 0; - } - return; - } - if (px >= 230 && px <= 290 && py >= 450) { - if (page < totalPage) { - selectItem = Math.min(selectItem + 7, list.length - 1); - selectCount = 0; - } - return; - } - - // 实际区域 - if (px >= 9 && px <= 351 && py >= 142 && py < 422) { - if (list.length == 0) return; - var index = parseInt((py - 142) / 40); - var newItem = 7 * (page - 1) + index; - if (newItem >= list.length) newItem = list.length - 1; - if (newItem != selectItem) { - selectItem = newItem; - selectCount = 0; - } - return; - } - }; - - this._performItemShopAction = function () { - if (flags.type == 0) - return this._performItemShopKeyBoard(flags.keycode); - else return this._performItemShopClick(flags.px, flags.py); - }; - this.openItemShop = function (itemShopId) { - shopId = itemShopId; - type = 0; - page = 0; - selectItem = null; - selectCount = 0; - core.isShopVisited(itemShopId); - shopInfo = flags.__shops__[shopId]; - if (shopInfo.choices == null) - shopInfo.choices = core.clone( - core.status.shops[shopId].choices - ); - choices = shopInfo.choices; - use = core.status.shops[shopId].use; - if (use != 'exp') use = 'money'; - useText = use == 'money' ? '金币' : '经验'; - - core.insertAction([ - { - type: 'while', - condition: 'true', - data: [ - { - type: 'function', - function: '() => { core.plugin._drawItemShop(); }' - }, - { type: 'wait' }, - { - type: 'function', - function: - '() => { core.plugin._performItemShopAction(); }' - } - ] - }, - { - type: 'function', - function: - "() => { core.deleteCanvas('ui'); core.ui.clearUIEventSelector(); }" - } - ]); + if (!main.replayChecking) { + core.plugin.openedShopId = itemShopId; + core.plugin.shopOpened.value = true; + } }; }, heroFourFrames: function () { @@ -3932,6 +3512,53 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { core.studySkill(enemy, num); return true; }); + + // 商店 + let shopOpened = false; + let openedShopId = ''; + core.registerReplayAction('openShop', name => { + if (!name.startsWith('openShop:')) return false; + openedShopId = name.slice(9); + shopOpened = true; + return true; + }); + + core.registerReplayAction('buy', name => { + if (!name.startsWith('buy:') && !name.startsWith('sell:')) + return false; + if (!shopOpened) return false; + if (!openedShopId) return false; + const [type, id, num] = name + .split(':') + .map(v => (/^\d+$/.test(v) ? parseInt(v) : v)); + const shop = core.status.shops[id]; + const item = shop.choices.find(v => v.id === id); + if (!item) return false; + flags.itemShop ??= {}; + flags.itemShop[openedShopId] ??= {}; + flags.itemShop[openedShopId][id] ??= 0; + if (num > item.number - flags.itemShop[openedShopId][id]) { + return false; + } + let cost = 0; + if (type === 'buy') { + cost = item.money * num; + } else { + cost = -item.sell * num; + } + if (cost > core.status.hero.money) return false; + core.status.hero.money -= cost; + flags.itemShop[openedShopId][id] += type === 'buy' ? num : -num; + return true; + }); + + core.registerReplayAction('closeShop', name => { + if (name !== 'closeShop') return false; + if (!shopOpened) return false; + shopOpened = false; + openedShopId = ''; + return true; + }); }, skillTree: function () { /** diff --git a/src/plugin/mark.ts b/src/plugin/mark.ts index 7a043c0..7e32c14 100644 --- a/src/plugin/mark.ts +++ b/src/plugin/mark.ts @@ -66,7 +66,7 @@ export function getMarkInfo(id: EnemyIds, noMessage: boolean = false) { tip('success', `踩到了${core.material.enemys[id].name}的临界!`); } reached[info.nextCritical] = true; - const n = core.nextCriticals(id, 1)[0]?.[0]; + const n = core.nextCriticals(id, 1, void 0, void 0, 'empty')[0]?.[0]; const next = (n ?? 0) + core.status.hero.atk; info.nextCritical = next; } @@ -80,37 +80,40 @@ export function checkMarkedEnemy(noMessage: boolean = false) { const hp = core.status.hero.hp; getMarkedEnemy().forEach(v => { getMarkInfo(v); - const damage = core.getDamageInfo(v)?.damage ?? -1; + const damage = + core.getDamageInfo(v, void 0, void 0, void 0, 'empty')?.damage ?? + -1; if (damage === -1) return; const info = enemyDamageInfo[v]!; const name = core.material.enemys[v].name; + let res = 0; if (damage <= 0) { if (!noMessage) tip('success', `${name}已经零伤了!`); } else if (damage < hp / 3) { if (!info[3] && !noMessage) { tip('success', `${name}的伤害已降至勇士生命值的1/3!`); } - info[1] = true; - info[2] = true; - info[3] = true; + res = 0b111; } else if (damage < (hp / 3) * 2) { if (!info[2] && !noMessage) { tip('success', `${name}的伤害已降至勇士生命值的2/3!`); } - info[1] = true; - info[2] = true; - info[3] = false; + res = 0b110; } else if (damage < hp) { if (!info[1] && !noMessage) { tip('success', `你已经能打过${name}了!`); } + res = 0b100; + } + info[1] = info[2] = info[3] = false; + if (res & 0b100) { info[1] = true; - info[2] = false; - info[3] = false; - } else { - info[1] = false; - info[2] = false; - info[3] = false; + } + if (res & 0b010) { + info[2] = true; + } + if (res & 0b001) { + info[3] = true; } }); } diff --git a/src/plugin/uiController.ts b/src/plugin/uiController.ts index 43e4fbb..603785d 100644 --- a/src/plugin/uiController.ts +++ b/src/plugin/uiController.ts @@ -9,6 +9,7 @@ import Skill from '../ui/skill.vue'; import SkillTree from '../ui/skillTree.vue'; import Fly from '../ui/fly.vue'; import FixedDetail from '../ui/fixedDetail.vue'; +import Shop from '../ui/shop.vue'; export const bookOpened = ref(false); export const toolOpened = ref(false); @@ -21,6 +22,7 @@ export const skillTreeOpened = ref(false); export const flyOpened = ref(false); export const showStudiedSkill = ref(false); export const fixedDetailOpened = ref(false); +export const shopOpened = ref(false); export const transition = ref(true); export const noClosePanel = ref(false); @@ -37,7 +39,8 @@ const UI_LIST: [Ref, Component][] = [ [skillOpened, Skill], [skillTreeOpened, SkillTree], [flyOpened, Fly], - [fixedDetailOpened, FixedDetail] + [fixedDetailOpened, FixedDetail], + [shopOpened, Shop] ]; /** ui栈 */ @@ -74,7 +77,8 @@ export default function init() { skillTreeOpened, flyOpened, showStudiedSkill, - fixedDetailOpened + fixedDetailOpened, + shopOpened }; } diff --git a/src/source/items.d.ts b/src/source/items.d.ts index ba97467..741685e 100644 --- a/src/source/items.d.ts +++ b/src/source/items.d.ts @@ -12,13 +12,13 @@ interface ItemDeclaration { greenPotion: 'items'; sword0: 'items'; sword1: 'equips'; - sword2: 'items'; + sword2: 'equips'; sword3: 'items'; sword4: 'items'; sword5: 'items'; shield0: 'items'; shield1: 'equips'; - shield2: 'items'; + shield2: 'equips'; shield3: 'items'; shield4: 'items'; shield5: 'items'; diff --git a/src/styles.less b/src/styles.less index f04fe0c..384e6f6 100644 --- a/src/styles.less +++ b/src/styles.less @@ -25,6 +25,7 @@ transition: color 0.2s linear; } +.button-text[active='true'], .button-text:hover { color: aqua; } @@ -33,6 +34,19 @@ color: aquamarine; } +.button-text[danger='true'][danger-display='true'] { + color: rgb(255, 47, 47); +} + +.button-text[danger='true']:hover, +.button-text[danger='true'][active='true'] { + color: rgb(255, 120, 120); +} + +.button-text[danger='true']:active { + color: rgb(255, 182, 182); +} + .selectable { border: #0000 0.5px solid; padding: 1% 3% 1% 3%; diff --git a/src/types/plugin.d.ts b/src/types/plugin.d.ts index 9474b1e..164cb93 100644 --- a/src/types/plugin.d.ts +++ b/src/types/plugin.d.ts @@ -152,6 +152,9 @@ interface PluginUis { /** 定点查看的界面,特殊属性还是临界 */ fixedDetailPanel: 'special' | 'critical'; + /** 打开的商店id */ + openedShopId: string; + /** ui是否使用渐变 */ readonly transition: Ref; @@ -200,6 +203,9 @@ interface PluginUis { /** 是否展示移动鼠标显示怪物信息的盒子 */ readonly showFixed: Ref; + /** 商店是否打开 */ + readonly shopOpened: Ref; + /** ui栈 */ readonly uiStack: Ref; diff --git a/src/ui/shop.vue b/src/ui/shop.vue new file mode 100644 index 0000000..eff4f6b --- /dev/null +++ b/src/ui/shop.vue @@ -0,0 +1,450 @@ + + + + +