Skip to content

Commit

Permalink
修正快速配置的一些问题
Browse files Browse the repository at this point in the history
  • Loading branch information
slime7 committed Apr 27, 2019
1 parent 6cff3ce commit 5fb6072
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 24 deletions.
10 changes: 9 additions & 1 deletion kancolle.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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`

| 参数 | 说明 |
Expand Down
72 changes: 58 additions & 14 deletions src/components/Command.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
// 装备
Expand All @@ -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},\
Expand All @@ -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,
});
}
}
});
Expand Down Expand Up @@ -411,7 +455,7 @@ export default {
...mapMutations([
'selectEditingRequest',
'clearLastRequests',
'shipPreUnset',
'shipPreEquip',
'setGameLink',
]),
},
Expand Down
6 changes: 6 additions & 0 deletions src/components/Result.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
: '-'
}}
</div>
<div>
data: {{
lastRequests[resultIndex] ?
lastRequests[resultIndex].data : '-'
}}
</div>
<div>
result: {{
lastRequests[resultIndex] && !lastRequests[resultIndex].error ?
Expand Down
45 changes: 36 additions & 9 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 5fb6072

Please sign in to comment.