Browse Source

新增装备强化继承功能

master
许孟阳 1 week ago
parent
commit
e519513f9d
  1. 39
      src/components/confirm.vue
  2. 17
      src/components/dialog.vue
  3. 2
      src/config/equips/constant.ts
  4. 9
      src/config/i18n/zh.ts
  5. 16
      src/tool/caller.ts
  6. 6
      src/tool/mixins/popoverMenu.ts
  7. 50
      src/views/backpack/equip-menu.vue
  8. 228
      src/views/backpack/inherited.vue
  9. 31
      src/views/backpack/strengthen.vue
  10. 5
      src/views/version/update-log.vue
  11. 1
      vue.config.js

39
src/components/confirm.vue

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<template>
<Dialog :show-header="false" v-model="show" :left="left" :top="top" padding="0">
<Dialog :show-header="false" v-model="show" :left="left" :top="top" :right="right" padding="0" :z="999">
<div class="confirm">
<div class='tip'>
<img :src="warning_icon">
@ -17,8 +17,8 @@ @@ -17,8 +17,8 @@
import { useStore } from "vuex";
import { reactive, onMounted, ref } from "vue";
import { useI18n } from "vue3-i18n";
import { Tooltip, EquipTip, EquipIcon, Dialog, PopoverMenu } from "@/components"
import { usePopoverMenu, conisOfBuy } from "@/tool";
import { Dialog } from "@/components"
import { usePopoverMenu } from "@/tool";
import { warning_icon } from "@/config";
@ -27,6 +27,7 @@ const { state, commit, dispatch } = useStore(); @@ -27,6 +27,7 @@ const { state, commit, dispatch } = useStore();
const menu = usePopoverMenu();
const { show, top, left, open } = menu;
const right = ref('');
const emit = defineEmits(['confirm', 'cancel'])
@ -49,14 +50,23 @@ defineProps({ @@ -49,14 +50,23 @@ defineProps({
}
})
defineExpose({ open })
defineExpose({
open: (idx, e) => {
if (state.mobile) {
right.value = '10px';
top.value = e.pageY + 10 + 'px';
show.value = true;
} else {
open(idx, e);
}
}
})
onMounted(() => { });
</script>
<style lang="scss" scoped>
.confirm {
padding: 1rem;
width: v-bind('width');
}
.tip {
@ -72,8 +82,6 @@ onMounted(() => { }); @@ -72,8 +82,6 @@ onMounted(() => { });
span {
margin-left: 0.8rem;
// height: 2.5rem;
width: v-bind('width');
line-height: 2.5rem;
}
}
@ -81,4 +89,21 @@ onMounted(() => { }); @@ -81,4 +89,21 @@ onMounted(() => { });
.btns {
justify-self: center;
}
@media only screen and (max-width: 768px) {
.tip {
margin-bottom: 1rem;
font-size: 1rem;
img {
width: 2rem;
height: 2rem;
}
span {
margin-left: 0.5rem;
line-height: 2rem;
}
}
}
</style>

17
src/components/dialog.vue

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<template>
<teleport to="#app">
<div class="dialog" v-show="show" @contextmenu.prevent="console.log('禁用浏览器默认右键功能')"
@click=" commit('close_equip_tip');">
@click=" commit('close_equip_tip');" :style="style">
<div class="content" @click.native.stop>
<div class="title" v-if="title">
<span>{{ title }}</span>
@ -22,6 +22,7 @@ import { close_icon } from "@/config"; @@ -22,6 +22,7 @@ import { close_icon } from "@/config";
const { t } = useI18n();
const { state, commit, dispatch } = useStore();
const show = ref(false);
const style = ref<any>({})
const emit = defineEmits(['update:modelValue', 'close'])
const prop = defineProps({
@ -33,6 +34,10 @@ const prop = defineProps({ @@ -33,6 +34,10 @@ const prop = defineProps({
type: Boolean,
default: true
},
obscured: {
type: Boolean,
default: false
},
title: {
type: String,
defalut: ""
@ -78,13 +83,19 @@ onMounted(() => { @@ -78,13 +83,19 @@ onMounted(() => {
show.value = false;
}
})
if (prop.obscured) {
style.value = {
height: '100%'
}
} else {
style.value = {};
}
});
</script>
<style lang="scss" scoped>
.dialog {
width: 100%;
height: 100%;
position: absolute;
width: 100%;
z-index: v-bind('z');
background: rgba(0, 0, 0, 0.5);

2
src/config/equips/constant.ts

@ -71,6 +71,8 @@ export const attr_unitys = { @@ -71,6 +71,8 @@ export const attr_unitys = {
battleSpeed: '%',
};
export const strengthen_rates = [1, 1, 1, 1, 1, 1, 0.8, 0.65, 0.45, 0.3, 0.2];
export const entry_initor = {
atk: (lv: number, qualityCoefficient: number, valCoefficient?: number) => {
valCoefficient = valCoefficient || 1;

9
src/config/i18n/zh.ts

@ -124,6 +124,15 @@ export default class Zh { @@ -124,6 +124,15 @@ export default class Zh {
unlock = '解锁';
sell = '出售';
sellAll = '一键出售';
inherited = [
'继承',
'继承需要花费金币:',
'将身上对应部位装备强化等级继承到该装备上',
'费用为两件强化到目标等级花费金币期望值的差值',
'高等级装备继承到低等级不会返还差值金币',
];
cannotInherited = ['身上对应部分并未穿戴装备,无法继承', '身上装备强化等级小于或等于当前装备,无需继承'];
inheritedConfirm = ['确认继承', '继承后被继承装备强化等级将清零,确认要继承吗?', '哥有钱,点了', '算了', '装备继承成功'];
shop = '商店(S)';
watiTime = '下次刷新次数获取:';

16
src/tool/caller.ts

@ -1,3 +1,5 @@ @@ -1,3 +1,5 @@
import { strengthen_rates } from '@/config';
export const strengthenValue = (value, strengthenLv) => {
if (strengthenLv <= 0) {
return value;
@ -192,3 +194,17 @@ export const callEuqipTipsLocation = (e, mobile) => { @@ -192,3 +194,17 @@ export const callEuqipTipsLocation = (e, mobile) => {
}
return [tipsStyle, tipsStyle2];
};
export const strengthenCoins = (lv, strengthenLv) => {
return Math.round((lv + 1) * 1.1 ** (strengthenLv ** 1.1) * (10 + lv / 5) + 100);
};
export const strengthenAvgCoins = (lv, strengthenLv) => {
let sum = 0;
const len = strengthen_rates.length;
for (let i = 0; i < strengthenLv; i++) {
const rate = i < len ? strengthen_rates[i] : strengthen_rates[len - 1];
sum += strengthenCoins(lv, i) / rate + (sum * (1 - rate)) / rate;
}
return Math.round(sum);
};

6
src/tool/mixins/popoverMenu.ts

@ -2,9 +2,9 @@ import { ref, onMounted, onBeforeUnmount } from 'vue'; @@ -2,9 +2,9 @@ import { ref, onMounted, onBeforeUnmount } from 'vue';
export default class PopoverMenu {
show = ref(false);
top = ref('0px');
left = ref('0px');
bottom = ref('0px');
top = ref('');
left = ref('');
bottom = ref('');
index = ref(0);
open = (idx, e) => {

50
src/views/backpack/equip-menu.vue

@ -4,41 +4,81 @@ @@ -4,41 +4,81 @@
{ label: t('use'), onClick: useEquip },
{ label: t('strengthen'), onClick: strengthenEquip },
{ label: t('reforge'), onClick: strengthenEquip },
{ label: state.grid[index]?.locked ? t('unlock') : t('lock'), onClick: () => state.grid[index].locked = !state.grid[index].locked },
{ label: t('sell'), onClick: () => dispatch('sell_equip', index) },
{ label: t('inherited.0'), onClick: inheritedEquip },
{ label: state.grid[index]?.locked ? t('unlock') : t('lock'), onClick: lockEquip },
{ label: t('sell'), onClick: sellEquip },
]" />
</Dialog>
<Dialog :title="t('strengthen') + t('equip')" v-model="showStrengthen" :top="state.mobile ? '5rem' : '10rem'"
left="2rem" padding="0" :z="11">
left="2rem" padding="0" :z="11" :obscured="true">
<Strengthen :equip="state.grid[index]" />
</Dialog>
<Dialog :title="t('equip') + t('inherited.0')" v-model="showInherited" :top="state.mobile ? '5rem' : '10rem'"
left="2rem" padding="0" :z="11" :obscured="true">
<Inherited :target="equip" :source="curEquip" @close="showInherited = false" />
</Dialog>
</template>
<script lang="ts" setup>
import { useStore } from "vuex";
import { onBeforeUnmount, onMounted, ref } from "vue";
import { onBeforeUnmount, onMounted, ref, computed } from "vue";
import { useI18n } from "vue3-i18n";
import { Dialog, PopoverMenu } from "@/components"
import Strengthen from "./strengthen.vue";
import { usePopoverMenu } from "@/tool";
import Inherited from "./inherited.vue";
const { t } = useI18n();
const { state, commit, dispatch } = useStore();
const showStrengthen = ref(false);
const showInherited = ref(false);
const { show, top, left, index, open, close } = usePopoverMenu();
const emit = defineEmits(['closePack'])
const equip = computed(() => {
return state.grid[index.value];
})
const curEquip = computed(() => {
if (!equip.value) {
return null;
}
return state.playerAttribute[equip.value.type];
})
defineExpose({ open })
const useEquip = () => {
dispatch("useEquip", index.value);
close();
}
const strengthenEquip = () => {
emit('closePack');
close();
showStrengthen.value = true;
close();
}
const lockEquip = () => {
state.grid[index.value].locked = !state.grid[index.value].locked;
close();
}
const sellEquip = () => {
dispatch('sell_equip', index.value);
close();
}
const inheritedEquip = () => {
if (!curEquip.value) {
commit("set_sys_info", { msg: t('cannotInherited.0'), type: "warning", });
return;
}
if (curEquip.value.strengthenLv <= equip.value.strengthenLv) {
commit("set_sys_info", { msg: t('cannotInherited.1'), type: "warning", });
return;
}
emit('closePack');
showInherited.value = true;
close();
}
onMounted(() => {

228
src/views/backpack/inherited.vue

@ -0,0 +1,228 @@ @@ -0,0 +1,228 @@
<template>
<div class="inherited" v-if="target && source">
<div class="coins">
{{ t('coins.0') }}:{{ useCoins }}
</div>
<div class="message">
<p>{{ t('inherited.1') + needCoins }}</p>
<div class="tips">
<p>- {{ t('inherited.2') }}</p>
<p>- {{ t('inherited.3') }}</p>
<p>- {{ t('inherited.4') }}</p>
</div>
<div class='btn-div'>
<button class="button" @click="inherited">{{ t('inheritedConfirm.0') }}</button>
</div>
</div>
<div class="equip">
<EquipIcon :equip="target" />
<div class='name' :style="{ color: target.quality.color }">
{{ t(target.type + '.' + target.base.name + '.0') }}
{{ '(+' + target.strengthenLv + ')' }}
<span></span>
{{ '(+' + source.strengthenLv + ')' }}
</div>
</div>
<div class="entry">
<div>
<div v-for="v in target.base.entry" :key="v.id">
{{ t(v.type + '.0') }} : + {{ strengthenValue(v.value, target.strengthenLv) }}
</div>
</div>
<div class="arror"></div>
<div>
<div v-for="v in target.base.entry" :key="v.id">
<span>{{ strengthenValue(v.value, source.strengthenLv) }}</span>
<span class="set">
({{ strengthenValue(v.value, source.strengthenLv) -
strengthenValue(v.value, target.strengthenLv) }})
</span>
</div>
</div>
</div>
<div class="equip">
<EquipIcon :equip="source" />
<div class='name' :style="{ color: source.quality.color }">
{{ t(source.type + '.' + source.base.name + '.0') }}
{{ '(+' + source.strengthenLv + ')' }}
<span></span>
{{ '(+0)' }}
</div>
</div>
<div class="entry">
<div>
<div v-for="v in source.base.entry" :key="v.id">
{{ t(v.type + '.0') }} : + {{ strengthenValue(v.value, source.strengthenLv) }}
</div>
</div>
<div class="arror"></div>
<div>
<div v-for="v in source.base.entry" :key="v.id">
<span>{{ strengthenValue(v.value, 0) }}</span>
<span class="down">
({{ strengthenValue(v.value, source.strengthenLv) - strengthenValue(v.value, 0) }})
</span>
</div>
</div>
</div>
</div>
<Confirm ref="confirm" width="8rem" :tip="t('inheritedConfirm.1')" :confirm="t('inheritedConfirm.2')"
:cancel="t('inheritedConfirm.3')" @confirm="confirmInherited" />
</template>
<script lang="ts" setup>
import { useStore } from "vuex";
import { computed, onMounted, ref } from "vue";
import { useI18n } from "vue3-i18n";
import { strengthenAvgCoins, strengthenValue } from "@/tool";
import { EquipIcon, Confirm } from "@/components";
const { t } = useI18n();
const { state, commit, dispatch } = useStore();
const useCoins = computed(() => {
return state.playerAttribute.coins;
})
const needCoins = computed(() => {
const need = strengthenAvgCoins(prop.target.lv, prop.source.strengthenLv)
const used = strengthenAvgCoins(prop.source.lv, prop.source.strengthenLv)
return need > used ? need - used : 0;
})
const confirm = ref();
const emit = defineEmits(['close'])
const prop = defineProps({
target: {
type: Object,
default: null
},
source: {
type: Object,
default: null
}
});
const inherited = (e) => {
confirm.value.open(0, e)
}
const confirmInherited = () => {
if (useCoins.value < needCoins.value) {
commit("set_sys_info", { msg: t('stNoCoins'), type: "warning", });
return
}
prop.target.strengthenLv = prop.source.strengthenLv;
prop.source.strengthenLv = 0;
commit("set_sys_info", { msg: t('inheritedConfirm.4'), type: "win", });
emit('close');
}
onMounted(() => { });
</script>
<style lang="scss" scoped>
.inherited {
color: #f1f1f1;
width: 25rem;
height: auto;
background: rgba(0, 0, 0, 0.2);
border: #393839;
border-radius: 0.4rem;
padding: 0 1rem;
box-sizing: border-box;
}
.coins {
display: flex;
align-items: center !important;
justify-content: center;
font-size: 1.1rem;
color: #2fe20f;
}
.message {
display: flex;
flex-direction: column;
border-bottom: 1px solid #ccc;
padding-bottom: 0.8rem;
p {
margin: 0.7rem;
}
.tips {
padding-left: 1.3rem;
p {
color: #999;
font-size: 0.8rem;
margin: 0rem;
}
}
.btn-div {
padding: 0.1rem;
display: flex;
justify-content: flex-end;
padding-right: 2rem;
}
}
.equip {
display: flex;
width: 100%;
justify-content: center;
margin-top: 1rem;
.name {
height: 3.5rem;
line-height: 3.5rem;
margin-left: 1.6rem;
font-size: 1.2rem;
}
}
.entry {
width: 100%;
padding: 1rem;
display: flex;
justify-content: space-around;
font-size: 1.2rem;
align-items: center;
div {
text-align: left;
&>div {
height: 2rem;
}
.set {
color: #2fe20f;
margin-left: 0.7rem;
}
.down {
color: #f70d05;
margin-left: 0.7rem;
}
}
}
@media only screen and (max-width: 768px) {
.inherited {
width: 23rem;
}
.equip .name {
height: 2.5rem;
line-height: 2.5rem;
margin-left: 1rem;
font-size: 1rem;
}
.entry {
font-size: 1rem;
}
}
</style>

31
src/views/backpack/strengthen.vue

@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
<div class="btn-group" v-if='!auto'>
<p>{{ t('stren.0') }}<span :class="{ 'red': useCoins < needCoins }">{{ needCoins }}</span></p>
<button class="button" @click="strengthen(false)">{{ t('stren.1') }}+{{ parseInt(equip.strengthenLv) + 1
}}</button>
}}</button>
</div>
<div class="btn-group" v-if='!auto'>
<p>{{ t('stren.0') }}<span :class="{ 'red': useCoins < needCoins }">{{ needCoins }}</span></p>
@ -75,15 +75,13 @@ import { useStore } from "vuex"; @@ -75,15 +75,13 @@ import { useStore } from "vuex";
import { reactive, onMounted, ref, computed, watch } from "vue";
import { useI18n } from "vue3-i18n";
import { Tooltip, EquipIcon } from "@/components"
import { strengthenValue } from "@/tool"
import { extra_entry_num, weaponExtraEntry, armorExtraEntry, neckExtraEntry, ringExtraEntry } from "@/config";
import { strengthenValue, strengthenCoins } from "@/tool"
import { extra_entry_num, weaponExtraEntry, armorExtraEntry, neckExtraEntry, ringExtraEntry, strengthen_rates } from "@/config";
const { t } = useI18n();
const { state, commit, dispatch } = useStore();
const auto = ref(false);
const autoLv = ref(12);
const successLv = 5;
const rates = [0.8, 0.65, 0.45, 0.3, 0.2];
const reforgeFlag = ref(false);
const reforgeing = ref(false);
const testFlag = ref(false);
@ -113,7 +111,7 @@ const useCoins = computed(() => { @@ -113,7 +111,7 @@ const useCoins = computed(() => {
return state.playerAttribute.coins;
})
const needCoins = computed(() => {
return Math.round((prop.equip.lv + 1) * (1.1 ** (prop.equip.strengthenLv) ** 1.1) * (10 + prop.equip.lv / 5) + 100);
return strengthenCoins(prop.equip.lv, prop.equip.strengthenLv);
})
const strengthen = (test?) => {
@ -128,13 +126,8 @@ const strengthen = (test?) => { @@ -128,13 +126,8 @@ const strengthen = (test?) => {
return
}
const lv = prop.equip.strengthenLv;
let rate = 1;
if (lv > successLv) {
let idx = lv - successLv - 1;
const len = rates.length;
idx = idx > len ? len : idx;
rate = rates[idx] || 0.2;
}
const len = strengthen_rates.length;
const rate = lv < len ? strengthen_rates[lv] : strengthen_rates[len - 1];
const result = Math.random() < rate ? 1 : -1;
if (test) {
@ -220,7 +213,6 @@ onMounted(() => { }); @@ -220,7 +213,6 @@ onMounted(() => { });
justify-content: center;
.name {
font-size: 1.6rem;
height: 3.5rem;
line-height: 3.5rem;
margin-left: 1.6rem;
@ -303,5 +295,16 @@ onMounted(() => { }); @@ -303,5 +295,16 @@ onMounted(() => { });
.strengthen {
width: 23rem;
}
.equip .name {
height: 2.5rem;
line-height: 2.5rem;
margin-left: 1rem;
font-size: 1rem;
}
.entry{
font-size: 1rem;
}
}
</style>

5
src/views/version/update-log.vue

@ -31,6 +31,11 @@ const { state, commit, dispatch } = useStore(); @@ -31,6 +31,11 @@ const { state, commit, dispatch } = useStore();
const curVersion = '测试版';
const updateLogs: any = [{
date: '2025-04-26', version: '测试版',
adjust: [
'新增装备强化继承功能',
]
}, {
date: '2025-04-25', version: '测试版',
adjust: [
'适配移动端',

1
vue.config.js

@ -3,3 +3,4 @@ module.exports = defineConfig({ @@ -3,3 +3,4 @@ module.exports = defineConfig({
productionSourceMap: false,
transpileDependencies: true,
});

Loading…
Cancel
Save