Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat✨: 添加up抽数计算 #59

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/i18n/简体中文.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"ui.data.star3": "3星",
"ui.data.history": "5星历史记录",
"ui.data.average": "5星平均出货次数为",
"ui.data.averageUP": "UP平均出货次数为",
"ui.data.regular": "姬子,瓦尔特,布洛妮娅,杰帕德,克拉拉,彦卿,白露,银河铁道之夜,无可取代的东西,但战斗还未结束,以世界之名,制胜的瞬间,如泥酣眠,时节不居",
"ui.data.chara5": "5星角色",
"ui.data.chara4": "4星角色",
"ui.data.weapon5": "5星光锥",
Expand Down
19 changes: 18 additions & 1 deletion src/renderer/components/GachaDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
</span>
</p>
<p v-if="detail.ssrPos.length" class="text-gray-600 text-xs">{{text.average}}{{colon}}<span class="text-green-600">{{avg5(detail.ssrPos)}}</span></p>
<p v-if="detail.ssrPos.length && (type === '11' || type === '12')" class="text-gray-600 text-xs">
{{ text.averageUP }}{{ colon }}
<span class="text-green-600">{{ avg6(detail.ssrPos) }}</span>
</p>
</template>

<script setup>
Expand All @@ -58,6 +62,19 @@ const avg5 = (list) => {
return parseInt((n / list.length) * 100) / 100
}

const avg6 = (list) => {
let n = 0,
length = list.length;
const regularList = text.value?.regular?.split(',') ?? [];
list.forEach((item) => {
n += item[1];
if (regularList.includes(item[0]) && length > 1) {
length -= 1;
}
});
return parseInt((n / length) * 100) / 100;
};

const percent = (num, total) => {
return `${Math.round(num / total * 10000) / 100}%`
}
Expand Down Expand Up @@ -88,4 +105,4 @@ function hashCode(str) {
return Array.from(str)
.reduce((s, c) => Math.imul(31, s) + c.charCodeAt(0) | 0, 0)
}
</script>
</script>