diff --git a/kancolle.md b/kancolle.md index 3d4c684..5a79d49 100644 --- a/kancolle.md +++ b/kancolle.md @@ -27,7 +27,7 @@ | 参数 | 说明 | | --------------------- | --------------------------------------------- | -| `api_unset_idx` | 卸装舰娘装备序号,0 开始,装备栏为打孔时为 0 | +| `api_unset_idx` | 卸装舰娘装备序号,0 开始,装备栏为打孔时也为 0 | | `api_set_slot_kind` | 装备栏种类,0 为普通,1 为打孔 | | `api_unset_slot_kind` | 装备栏种类,0 为普通,1 为打孔 | | `api_unset_ship` | 需卸装舰娘 id | @@ -40,6 +40,14 @@ | -------- | ------- | | `api_id` | 舰娘 id | +交换装备位置 `/kcsapi/api_req_kaisou/slot_exchange_index` + +| 参数 | 说明 | +| ------------- | --------------------- | +| `api_id` | 舰娘 id | +| `api_src_idx` | 移动源位置,从 0 开始 | +| `api_dst_idx` | 移动目标,从 0 开始 | + 装备打孔栏物品 `/kcsapi/api_req_kaisou/slotset_ex` | 参数 | 说明 | diff --git a/src/components/Command.vue b/src/components/Command.vue index a8ec2d2..9f3feb0 100644 --- a/src/components/Command.vue +++ b/src/components/Command.vue @@ -263,12 +263,16 @@ export default { ...this.poislotIds(ship.poi_slot.filter(e => e !== null)), ]; if (JSON.stringify(equipment) !== JSON.stringify(equipmentStat)) { - if (equipment.slice(1).length < ship.api_slotnum) { - // 卸下所有装备 + if (equipment.length - 1 < ship.api_slotnum) { + // 当前常规栏装备数小于目标装备数则卸下所有装备 k.push({ ro: 'unsetslot_all', da: `{"api_id":${ship.api_ship_id}}`, }); + this.shipPreEquip({ + action: 'unsetall', + shipId: ship.api_ship_id, + }); } if (equipment.length) { // 装备 @@ -284,13 +288,15 @@ export default { unsetKind = ueqi > 0 ? 0 : 1; unsetEqi = ueqi > 0 ? ueqi - 1 : 0; } - return +sk !== +shipId && ueqi >= 0; + return ueqi >= 0; }); if (searchEquipedShip) { - // 需要的装备被别的舰娘装备 - k.push({ - ro: 'slot_deprive', - da: JSON.stringify(JSON.parse(`\ + const isSelfEquiped = +searchEquipedShip === +shipId; + if (!isSelfEquiped) { + // 需要的装备被别的舰娘装备 + k.push({ + ro: 'slot_deprive', + da: JSON.stringify(JSON.parse(`\ {\ "api_unset_idx":${unsetEqi},\ "api_set_slot_kind":${eqi === 0 ? 1 : 0},\ @@ -299,24 +305,62 @@ export default { "api_set_idx":${eqi - 1},\ "api_set_ship":${shipId}\ }`)), - }); - this.shipPreUnset({ - shipId: searchEquipedShip, - equipId: eq, - isExSlot: !!unsetKind, - }); + }); + this.shipPreEquip({ + action: 'unset', + shipId: searchEquipedShip, + equipId: eq, + isExSlot: !!unsetKind, + }); + this.shipPreEquip({ + action: 'equip', + shipId, + equipId: eq, + equipInd: eqi - 1, + isExSlot: eqi === 0, + }); + } else { + // 需要的装备被自己装备 + const targetShip = this.poidata.info.ships[searchEquipedShip]; + const dstInd = targetShip.api_slot.indexOf(eq); + if (dstInd >= 0 && dstInd !== eqi - 1) { + k.push({ + ro: 'slot_exchange', + da: `{"api_id":${shipId},"api_src_idx":${dstInd},"api_dst_idx":${eqi - 1}}`, + }); + this.shipPreEquip({ + action: 'exchange', + shipId, + equipInd: eqi - 1, + equipDstInd: dstInd, + }); + } + // 如果要交换 ex 栏和普通栏怎么办? + } } else if (eqi === 0 && +shipStat.api_slot_ex !== +eq) { // 自己没装备此额外装备 k.push({ ro: 'slotset_ex', da: `{"api_id":${shipId},"api_item_id":${eq}}`, }); + this.shipPreEquip({ + action: 'equip', + shipId, + equipId: eq, + isExSlot: true, + }); } else if (eqi > 0 && +shipStat.api_slot[eqi - 1] !== +eq) { // 自己没装备此装备 k.push({ ro: 'slotset', da: `{"api_id":${shipId},"api_item_id":${eq},"api_slot_idx":${eqi - 1}}`, }); + this.shipPreEquip({ + action: 'equip', + shipId, + equipId: eq, + equipInd: eqi - 1, + }); } } }); @@ -411,7 +455,7 @@ export default { ...mapMutations([ 'selectEditingRequest', 'clearLastRequests', - 'shipPreUnset', + 'shipPreEquip', 'setGameLink', ]), }, diff --git a/src/components/Result.vue b/src/components/Result.vue index 3267d29..2784c85 100644 --- a/src/components/Result.vue +++ b/src/components/Result.vue @@ -26,6 +26,12 @@ : '-' }} +
+ data: {{ + lastRequests[resultIndex] ? + lastRequests[resultIndex].data : '-' + }} +
result: {{ lastRequests[resultIndex] && !lastRequests[resultIndex].error ? diff --git a/src/store.js b/src/store.js index 42bef3a..8b5deb1 100644 --- a/src/store.js +++ b/src/store.js @@ -136,15 +136,42 @@ export default new Vuex.Store({ state.tcpLoading = false; state.pluginInstalled = true; }, - shipPreUnset(state, { shipId, equipId, isExSlot = false }) { - if (!isExSlot) { - const oldSlot = JSON.parse(JSON.stringify(state.poidata.info.ships[`${shipId}`].api_slot)); - const equipIndex = oldSlot.indexOf(equipId); - oldSlot.splice(equipIndex, 1); - oldSlot.push(-1); - state.poidata.info.ships[`${shipId}`].api_slot = oldSlot; - } else { - state.poidata.info.ships[`${shipId}`].api_slot_ex = -1; + shipPreEquip(state, { + action, + shipId, + equipId, + equipInd, + equipDstInd, + isExSlot = false, + }) { + const oldSlot = JSON.parse(JSON.stringify(state.poidata.info.ships[`${shipId}`].api_slot)); + switch (action) { + default: + case 'unset': + if (!isExSlot) { + const equipIndex = oldSlot.indexOf(equipId); + oldSlot.splice(equipIndex, 1); + oldSlot.push(-1); + state.poidata.info.ships[`${shipId}`].api_slot = oldSlot; + } else { + state.poidata.info.ships[`${shipId}`].api_slot_ex = -1; + } + break; + case 'unsetall': + state.poidata.info.ships[`${shipId}`].api_slot = Array(oldSlot.length).fill(-1); + break; + case 'equip': + if (!isExSlot) { + oldSlot[equipInd] = equipId; + state.poidata.info.ships[`${shipId}`].api_slot = oldSlot; + } else { + state.poidata.info.ships[`${shipId}`].api_slot_ex = equipId; + } + break; + case 'exchange': + [oldSlot[equipInd], oldSlot[equipDstInd]] = [oldSlot[equipDstInd], oldSlot[equipInd]]; + state.poidata.info.ships[`${shipId}`].api_slot = oldSlot; + break; } }, setPluginStatus(state, { installed }) { diff --git a/src/utils/constant.js b/src/utils/constant.js index e8d47b9..255a084 100644 --- a/src/utils/constant.js +++ b/src/utils/constant.js @@ -40,6 +40,11 @@ export const routes = [ path: '/kcsapi/api_req_kaisou/unsetslot_all', hint: '卸除所有装备', defaultData: '{"api_id":1}', + }, { + name: 'slot_exchange', + path: '/kcsapi/api_req_kaisou/slot_exchange_index', + hint: '交换装备位置', + defaultData: '{"api_id":1,"api_src_idx":0,"api_dst_idx":1}', }, { name: 'slotset_ex', path: '/kcsapi/api_req_kaisou/slotset_ex',