Skip to content

Commit

Permalink
feat: import LMD and battle record data from Skland
Browse files Browse the repository at this point in the history
close #285
  • Loading branch information
Tsuk1ko committed Dec 7, 2024
1 parent 1a6ee91 commit e917fad
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 25 deletions.
10 changes: 9 additions & 1 deletion src/components/material/ImportConfirmDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ import { MduiDialogMixin } from '@/mixins/mduiDialog';
import ArknNumItem from '@/components/ArknNumItem.vue';
import { useDataStore } from '@/store/data';
const levelItemsSortId = {
2001: 70004,
2002: 70003,
2003: 70002,
2004: 70001,
4001: 10004,
};
export default defineComponent({
name: 'import-confirm-dialog',
mixins: [MduiDialogMixin],
Expand All @@ -57,7 +65,7 @@ export default defineComponent({
displayItems() {
return _.sortBy(
Object.entries(this.items),
([key]) => this.materialTable[key].sortId[this.$root.server],
([key]) => this.materialTable[key]?.sortId[this.$root.server] ?? levelItemsSortId[key] ?? 0,
);
},
},
Expand Down
7 changes: 7 additions & 0 deletions src/data/changelog.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"time": "2024-12-07",
"changes": [
"【精英材料计算】支持从森空岛导入龙门币和狗粮数量到干员升级计算",
"【干员升级计算】修复更改精英化阶段时UI异常的问题"
]
},
{
"time": "2024-11-06",
"changes": [
Expand Down
7 changes: 7 additions & 0 deletions src/locales/cn/material.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"2001": "@:item.2001",
"2002": "@:item.2002",
"2003": "@:item.2003",
"2004": "@:item.2004",
"4001": "@:item.4001"
}
7 changes: 7 additions & 0 deletions src/locales/jp/material.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"2001": "@:item.2001",
"2002": "@:item.2002",
"2003": "@:item.2003",
"2004": "@:item.2004",
"4001": "@:item.4001"
}
7 changes: 7 additions & 0 deletions src/locales/kr/material.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"2001": "@:item.2001",
"2002": "@:item.2002",
"2003": "@:item.2003",
"2004": "@:item.2004",
"4001": "@:item.4001"
}
7 changes: 7 additions & 0 deletions src/locales/tw/material.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"2001": "@:item.2001",
"2002": "@:item.2002",
"2003": "@:item.2003",
"2004": "@:item.2004",
"4001": "@:item.4001"
}
7 changes: 7 additions & 0 deletions src/locales/us/material.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"2001": "@:item.2001",
"2002": "@:item.2002",
"2003": "@:item.2003",
"2004": "@:item.2004",
"4001": "@:item.4001"
}
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ new Vue({
followSystem: 2,
},
importItemsListening: false,
importLevelItemsListening: false,
},
watch: {
setting: {
Expand Down
56 changes: 33 additions & 23 deletions src/views/Level.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<table id="input-table" class="mdui-table tag-table" style="overflow-x: hidden">
<tbody>
<template v-for="(item, i) in inputs.list">
<tr :data-index="i" :key="`${i}-0`">
<tr :key="`${i}-0`">
<td width="1"></td>
<td class="mdui-valign">
<div class="number-select with-label mdui-m-r-3">
Expand All @@ -16,7 +16,7 @@
:options="$_.range(6, 0)"
:mdui-options="{ gutter: 72 }"
v-model="item.star"
@change="updateSelect(item, i)"
@change="updateSelect(item)"
/>
</div>
<div class="with-label mdui-m-r-3">
Expand All @@ -29,7 +29,7 @@
</div>
</td>
</tr>
<tr :data-index="i" :key="`${i}-1`">
<tr :key="`${i}-1`">
<td width="1"
><button
class="mdui-btn mdui-btn-dense no-pe tag-btn tag-table-header"
Expand All @@ -41,7 +41,7 @@
<div class="number-select with-label mdui-m-r-3">
<label class="mdui-textfield-label">{{ $t('common.promotion') }}</label>
<mdui-select-num
class="mdui-select-width-100p select-need-update"
class="mdui-select-width-100p"
:options="$_.range(0, maxElite[item.star - 1] + 1)"
v-model="item.current.elite"
@change="updateSelect(item, i)"
Expand All @@ -66,7 +66,7 @@
>
</td>
</tr>
<tr :data-index="i" :key="`${i}-2`">
<tr :key="`${i}-2`">
<td width="1"
><button
class="mdui-btn mdui-btn-dense no-pe tag-btn tag-table-header"
Expand All @@ -78,7 +78,7 @@
<div class="number-select with-label mdui-m-r-3">
<label class="mdui-textfield-label">{{ $t('common.promotion') }}</label>
<mdui-select-num
class="mdui-select-width-100p select-need-update"
class="mdui-select-width-100p"
:options="$_.range(item.current.elite, maxElite[item.star - 1] + 1)"
v-model="item.target.elite"
@change="updateSelect(item, i)"
Expand Down Expand Up @@ -135,12 +135,9 @@
</div>
<div class="mdui-m-r-2 mdui-m-b-1 mdui-valign">
<ArknItem name="4001" />
<mdui-number-input
class="exp-input"
v-model.number="inputs.money"
style="width: 80px"
>{{ $t('item.4001') }}</mdui-number-input
>
<mdui-number-input class="lmd-input" v-model.number="inputs.money">{{
$t('item.4001')
}}</mdui-number-input>
</div>
</td>
</tr>
Expand Down Expand Up @@ -492,39 +489,46 @@ export default defineComponent({
getMaxLevel(star, elite) {
return this.level.maxLevel[star - 1][elite];
},
updateSelect({ star, current, target }, i) {
updateSelect({ star, current, target }) {
// 更新值
const maxElite = this.maxElite[star - 1];
if (current.elite > maxElite) current.elite = maxElite;
if (target.elite > maxElite) target.elite = maxElite;
if (current.elite > target.elite) target.elite = current.elite;
// 更新下拉选择
this.$nextTick(() =>
this.$$(`tr[data-index='${i}'] .select-need-update`).each((i, ele) =>
new this.$Select(ele).handleUpdate(),
),
);
},
reset() {
this.inputs = _.cloneDeep(defaultInputs);
this.$nextTick(() =>
this.$$('.select-need-update').each((i, ele) => new this.$Select(ele).handleUpdate()),
);
},
k2i(id) {
return String(id + 1999);
},
addItem(i) {
this.inputs.list.splice(i + 1, 0, _.cloneDeep(defaultItemInputs));
this.$mutationNextTick(`tr[data-index='${i + 1}']`);
},
removeItem(i) {
this.inputs.list.splice(i, 1);
},
handleImportItemsEvent(data) {
if (!data) return;
this.inputs.money = data[4001] || 0;
this.inputs.have = {
5: data[2004] || 0,
4: data[2003] || 0,
3: data[2002] || 0,
2: data[2001] || 0,
};
},
},
created() {
this.$root.$on('import-level-items', this.handleImportItemsEvent);
this.$root.importLevelItemsListening = true;
(obj => obj && (this.inputs = pickClone(this.inputs, obj)))(nls.getItem('inputs'));
},
beforeDestroy() {
this.$root.importLevelItemsListening = false;
this.$root.$off('import-level-items', this.handleImportItemsEvent);
},
});
</script>

Expand Down Expand Up @@ -567,5 +571,11 @@ export default defineComponent({
white-space: nowrap;
}
}
.exp-input {
width: 64px;
}
.lmd-input {
width: 84px;
}
}
</style>
30 changes: 29 additions & 1 deletion src/views/Material/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ export default defineComponent({
sklandReady: 'ready',
sklandCultivateCharacters: 'cultivateCharacters',
}),
importUsedMaterialIdList() {
return [...this.materialIdList, '2001', '2002', '2003', '2004', '4001'];
},
syncCode: {
get() {
return this.setting[`syncCodeV${SYNC_CODE_VER}`];
Expand Down Expand Up @@ -1638,10 +1641,35 @@ export default defineComponent({
}
},
importItems(items) {
const levelInputs = {
2001: 0,
2002: 0,
2003: 0,
2004: 0,
4001: 0,
};
_.each(items, (num, name) => {
const input = this.inputs[name];
if (input && typeof num === 'number') input.have = String(num);
else if (name in levelInputs) levelInputs[name] = num;
});
// 导入龙门币和狗粮到升级计算
if (_.sum(Object.values(levelInputs))) {
if (this.$root.importLevelItemsListening) {
this.$root.$emit('import-level-items', levelInputs);
} else {
const levelNls = new NamespacedLocalStorage('level');
const inputs = levelNls.getItem('inputs') || {};
inputs.money = levelInputs[4001];
inputs.have = {
5: levelInputs[2004],
4: levelInputs[2003],
3: levelInputs[2002],
2: levelInputs[2001],
};
levelNls.setItem('inputs', inputs);
}
}
},
isSkillReleased({ isPatch, unlockStages }) {
return !isPatch || unlockStages.every(stage => !this.unopenedStages.includes(stage));
Expand Down Expand Up @@ -1716,7 +1744,7 @@ export default defineComponent({
);
},
showImportConfirm(items) {
items = _.pick(items, this.materialIdList);
items = _.pick(items, this.importUsedMaterialIdList);
if (!_.size(items)) {
this.$snackbar(this.$t('cultivate.panel.importFromJSON.nothingImported'));
return;
Expand Down

0 comments on commit e917fad

Please sign in to comment.