From 966774ea9d2f35fcd94fe890b17712fe96a0a548 Mon Sep 17 00:00:00 2001 From: AguzzTN54 Date: Wed, 25 Oct 2023 23:36:05 +0700 Subject: [PATCH] Guaranteed System Toggle --- src/lib/helpers/gacha/itemdrop-base.js | 10 ++ src/lib/helpers/gacha/probabilities.js | 11 +- src/lib/helpers/gacha/wishCharacter.js | 23 ++-- src/lib/helpers/gacha/wishWeapon.js | 20 ++- src/locales/de-DE.json | 7 +- src/locales/en-US.json | 7 +- src/locales/fr-FR.json | 7 +- src/locales/id-ID.json | 7 +- src/locales/it-IT.json | 7 +- src/locales/ja-JP.json | 7 +- src/locales/pt-BR.json | 7 +- src/locales/ru-RU.json | 7 +- src/locales/th-TH.json | 7 +- src/locales/vi-VN.json | 7 +- src/locales/zh-CN.json | 7 +- .../banner-card/_probability-editor.svelte | 127 ++++++++++-------- 16 files changed, 173 insertions(+), 95 deletions(-) diff --git a/src/lib/helpers/gacha/itemdrop-base.js b/src/lib/helpers/gacha/itemdrop-base.js index 6a20bc29..b424c39d 100644 --- a/src/lib/helpers/gacha/itemdrop-base.js +++ b/src/lib/helpers/gacha/itemdrop-base.js @@ -2,6 +2,7 @@ import { standard } from '$lib/data/banners/standard.json'; import { data as weaponsDB } from '$lib/data/weapons.json'; import { data as charsDB, onlyStandard } from '$lib/data/characters.json'; import { getRate, prob } from './probabilities'; +import { guaranteedStatus } from '$lib/store/localstore-manager'; const standardWeapons = (star) => { return getAllWeapons(star).filter(({ limited }) => !limited); @@ -176,3 +177,12 @@ export const isRateup = (banner) => { return item === 'rateup'; }; +// CheckGuaranteed +export const checkGuaranteed = (banner, rarity) => { + const status = guaranteedStatus.get(`${banner}-${rarity}star`); + const guaranteedSystem = getRate(banner, 'guaranteed'); + const never = guaranteedSystem === 'never'; + const always = guaranteedSystem === 'always'; + return { status, never, always }; +}; + diff --git a/src/lib/helpers/gacha/probabilities.js b/src/lib/helpers/gacha/probabilities.js index f188bf97..bd2164a4 100644 --- a/src/lib/helpers/gacha/probabilities.js +++ b/src/lib/helpers/gacha/probabilities.js @@ -38,8 +38,11 @@ export const getRate = (banner, key) => { const initial = probabilityRates[banner]; const local = localrate.get(banner); - if (local[key] || local[key] >= 0) return local[key]; - return initial[key]; + if (!(local[key] || local[key] >= 0)) return initial[key]; + + const val = parseFloat(local[key]); + if (isNaN(val)) return local[key]; + return val; }; export const setRate = (banner, key, val) => { @@ -48,8 +51,8 @@ export const setRate = (banner, key, val) => { local[key] = val; } else { const value = parseFloat(val); - if (isNaN(value)) return value; - local[key] = value; + if (isNaN(value)) local[key] = val; + else local[key] = value; } localrate.set(banner, local); diff --git a/src/lib/helpers/gacha/wishCharacter.js b/src/lib/helpers/gacha/wishCharacter.js index fc2e243b..cbdcc5cb 100644 --- a/src/lib/helpers/gacha/wishCharacter.js +++ b/src/lib/helpers/gacha/wishCharacter.js @@ -1,6 +1,12 @@ import { guaranteedStatus } from '$lib/store/localstore-manager'; -import { get3StarItem, get4StarItem, rand, get5StarItem, isRateup } from './itemdrop-base'; -import { getRate } from './probabilities'; +import { + get3StarItem, + get4StarItem, + rand, + get5StarItem, + isRateup, + checkGuaranteed +} from './itemdrop-base'; const characterWish = { init({ indexOfBanner, featured, rateup, version, phase, stdver }) { @@ -21,9 +27,8 @@ const characterWish = { if (rarity === 4) { const { _version: version, _phase: phase, _rateup: rateup } = this; - const isGuaranteed = guaranteedStatus.get('character-event-4star'); - const turnOffGuaranteed = getRate('character-event', 'disGuaranteed'); - const useRateup = (isGuaranteed && !turnOffGuaranteed) || isRateup('character-event'); + const { status: isGuaranteed, never, always } = checkGuaranteed('character-event', 4); + const useRateup = (isGuaranteed && !never) || always || isRateup('character-event'); const droplist = get4StarItem({ banner: 'character-event', @@ -39,9 +44,8 @@ const characterWish = { if (rarity === 5) { const { _featured, _indexOfBanner, _stdver } = this; - const isGuaranteed = guaranteedStatus.get('character-event-5star'); - const turnOffGuaranteed = getRate('character-event', 'disGuaranteed'); - const useRateup = (isGuaranteed && !turnOffGuaranteed) || isRateup('character-event'); + const { status: isGuaranteed, never, always } = checkGuaranteed('character-event', 5); + const useRateup = (isGuaranteed && !never) || always || isRateup('character-event'); const droplist = get5StarItem({ banner: 'character-event', @@ -51,7 +55,8 @@ const characterWish = { }); const result = rand(droplist); - const rateUpStatus = isGuaranteed ? 'guaranteed' : 'win'; + const statusGuarateed = (isGuaranteed && !never) || always; + const rateUpStatus = statusGuarateed ? 'guaranteed' : 'win'; const status = useRateup ? rateUpStatus : 'lose'; guaranteedStatus.set('character-event-5star', !useRateup); return { ...result, status }; diff --git a/src/lib/helpers/gacha/wishWeapon.js b/src/lib/helpers/gacha/wishWeapon.js index 57c9d914..2d6c87b5 100644 --- a/src/lib/helpers/gacha/wishWeapon.js +++ b/src/lib/helpers/gacha/wishWeapon.js @@ -1,7 +1,14 @@ // import { fatePoint, selectedCourse } from '$lib/store/stores'; import { course } from '$lib/store/app-stores'; import { fatepointManager, guaranteedStatus } from '$lib/store/localstore-manager'; -import { rand, get3StarItem, get4StarItem, get5StarItem, isRateup } from './itemdrop-base'; +import { + rand, + get3StarItem, + get4StarItem, + get5StarItem, + isRateup, + checkGuaranteed +} from './itemdrop-base'; import { getRate, prob } from './probabilities'; const fatepoint = { @@ -62,8 +69,8 @@ const weaponWish = { // 4 star items (Character or Weapon) if (rarity === 4) { const { _version: version, _phase: phase, _rateup: rateup } = this; - const isGuaranteed = guaranteedStatus.get('weapon-event-4star'); - const useRateup = isGuaranteed || isRateup('weapon-event'); + const { status: isGuaranteed, never, always } = checkGuaranteed('weapon-event', 4); + const useRateup = (isGuaranteed && !never) || always || isRateup('weapon-event'); const droplist = get4StarItem({ banner: 'weapon-event', @@ -80,8 +87,8 @@ const weaponWish = { // 5 Star Weapon if (rarity === 5) { const { _featured, _fatesystem } = this; - const isGuaranteed = guaranteedStatus.get('weapon-event-5star'); - let useRateup = isGuaranteed || isRateup('weapon-event'); + const { status: isGuaranteed, never, always } = checkGuaranteed('weapon-event', 5); + let useRateup = (isGuaranteed && !never) || always || isRateup('weapon-event'); let calculateFatepoint = false; let rateupItem = _featured.map(({ name }) => name); @@ -118,7 +125,8 @@ const weaponWish = { const result = rand(droplist); const isFatepointFull = _fatesystem?.verify(result); - const rateUpStatus = isGuaranteed ? 'guaranteed' : 'win'; + const statusGuarateed = (isGuaranteed && !never) || always; + const rateUpStatus = statusGuarateed ? 'guaranteed' : 'win'; const fatepointstatus = calculateFatepoint && isFatepointFull ? 'selected' : rateUpStatus; const status = useRateup ? fatepointstatus : 'lose'; guaranteedStatus.set('weapon-event-5star', !useRateup); diff --git a/src/locales/de-DE.json b/src/locales/de-DE.json index 3d3dcd40..40dd05fd 100644 --- a/src/locales/de-DE.json +++ b/src/locales/de-DE.json @@ -77,9 +77,12 @@ "charRate": "Chance to get Character instead of Weapon", "nonRateup": "(Non RateUp Item)", "selectedRate": "Selected Weapon Rate:", - "disGuaranteed": "Disable Guaranteed System (after getting a non-RateUP item)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "Back to Default", - "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?" + "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "wishTitle": "Gebet", diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 210425c4..dc7033ed 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -77,9 +77,12 @@ "charRate": "Chance to get Character instead of Weapon", "nonRateup": "(Non RateUp Item)", "selectedRate": "Selected Weapon Rate:", - "disGuaranteed": "Disable Guaranteed System (after getting a non-RateUP item)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "Back to Default", - "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?" + "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "wishTitle": "Wish", diff --git a/src/locales/fr-FR.json b/src/locales/fr-FR.json index 4cc3fb7f..856408b4 100644 --- a/src/locales/fr-FR.json +++ b/src/locales/fr-FR.json @@ -77,9 +77,12 @@ "charRate": "Chance to get Character instead of Weapon", "nonRateup": "(Non RateUp Item)", "selectedRate": "Selected Weapon Rate:", - "disGuaranteed": "Disable Guaranteed System (after getting a non-RateUP item)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "Back to Default", - "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?" + "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "wishTitle": "Vœux", diff --git a/src/locales/id-ID.json b/src/locales/id-ID.json index 1ba84539..1a4cbe30 100644 --- a/src/locales/id-ID.json +++ b/src/locales/id-ID.json @@ -77,9 +77,12 @@ "charRate": "Probabilitas mendapat Karakter dibanding Senjata", "nonRateup": "(Item non-RateUP)", "selectedRate": "Probabilitas mendapat senjata terpilih:", - "disGuaranteed": "Nonaktifkan sistem jaminan setelah mendapat item non-RateUP", + "guaranteedSystem": "Sistem Jaminan", "backToDefault": "Pengaturan Default", - "resetPrompt": "Apakah kamu yakin akan mereset pengaturan probabilitas untuk \"{banner}\"?" + "resetPrompt": "Apakah kamu yakin akan mereset pengaturan probabilitas untuk \"{banner}\"?", + "default": "Aktif", + "never": "NonAktif", + "always": "Selalu" }, "wish": { "wishTitle": "Permohonan", diff --git a/src/locales/it-IT.json b/src/locales/it-IT.json index db5a6743..23b82f74 100644 --- a/src/locales/it-IT.json +++ b/src/locales/it-IT.json @@ -77,9 +77,12 @@ "charRate": "Chance to get Character instead of Weapon", "nonRateup": "(Non RateUp Item)", "selectedRate": "Selected Weapon Rate:", - "disGuaranteed": "Disable Guaranteed System (after getting a non-RateUP item)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "Back to Default", - "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?" + "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "wishTitle": "Wish", diff --git a/src/locales/ja-JP.json b/src/locales/ja-JP.json index 1a1ff88b..a05ba24d 100644 --- a/src/locales/ja-JP.json +++ b/src/locales/ja-JP.json @@ -77,9 +77,12 @@ "charRate": "武器ではなくキャラクターを入手する確率", "nonRateup": "(すり抜け時)", "selectedRate": "軌定武器獲得確率:", - "disGuaranteed": "確定天井の無効化 (すり抜け後)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "初期設定に戻す", - "resetPrompt": "\"{banner}\" の確率設定を初期設定に戻しますか?" + "resetPrompt": "\"{banner}\" の確率設定を初期設定に戻しますか?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "wishTitle": "祈願", diff --git a/src/locales/pt-BR.json b/src/locales/pt-BR.json index 31103f7c..ab84456e 100644 --- a/src/locales/pt-BR.json +++ b/src/locales/pt-BR.json @@ -77,9 +77,12 @@ "charRate": "Chance to get Character instead of Weapon", "nonRateup": "(Non RateUp Item)", "selectedRate": "Selected Weapon Rate:", - "disGuaranteed": "Disable Guaranteed System (after getting a non-RateUP item)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "Back to Default", - "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?" + "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "wishTitle": "Orar", diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json index 98a4c282..4281cd88 100644 --- a/src/locales/ru-RU.json +++ b/src/locales/ru-RU.json @@ -78,9 +78,12 @@ "charRate": "Chance to get Character instead of Weapon", "nonRateup": "(Non RateUp Item)", "selectedRate": "Selected Weapon Rate:", - "disGuaranteed": "Disable Guaranteed System (after getting a non-RateUP item)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "Back to Default", - "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?" + "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "wishTitle": "Молитва", diff --git a/src/locales/th-TH.json b/src/locales/th-TH.json index 5a7d86d1..a7a158f4 100644 --- a/src/locales/th-TH.json +++ b/src/locales/th-TH.json @@ -77,9 +77,12 @@ "charRate": "Chance to get Character instead of Weapon", "nonRateup": "(Non RateUp Item)", "selectedRate": "Selected Weapon Rate:", - "disGuaranteed": "Disable Guaranteed System (after getting a non-RateUP item)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "Back to Default", - "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?" + "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "wishTitle": "การอธิษฐาน", diff --git a/src/locales/vi-VN.json b/src/locales/vi-VN.json index 666daa2d..c76bd333 100644 --- a/src/locales/vi-VN.json +++ b/src/locales/vi-VN.json @@ -77,9 +77,12 @@ "charRate": "Chance to get Character instead of Weapon", "nonRateup": "(Non RateUp Item)", "selectedRate": "Selected Weapon Rate:", - "disGuaranteed": "Disable Guaranteed System (after getting a non-RateUP item)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "Back to Default", - "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?" + "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "wishTitle": "Cầu Nguyện", diff --git a/src/locales/zh-CN.json b/src/locales/zh-CN.json index 21337eec..c6f2349a 100644 --- a/src/locales/zh-CN.json +++ b/src/locales/zh-CN.json @@ -77,9 +77,12 @@ "charRate": "Chance to get Character instead of Weapon", "nonRateup": "(Non RateUp Item)", "selectedRate": "Selected Weapon Rate:", - "disGuaranteed": "Disable Guaranteed System (after getting a non-RateUP item)", + "guaranteedSystem": "Guaranteed System", "backToDefault": "Back to Default", - "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?" + "resetPrompt": "Are you sure to Reset \"{banner}\" probabilities back to default?", + "default": "Default", + "never": "Never", + "always": "Always" }, "wish": { "rollButton": "祈愿{count}次", diff --git a/src/routes/_wish/banner-card/_probability-editor.svelte b/src/routes/_wish/banner-card/_probability-editor.svelte index eb1c140d..6e2d9d79 100644 --- a/src/routes/_wish/banner-card/_probability-editor.svelte +++ b/src/routes/_wish/banner-card/_probability-editor.svelte @@ -1,6 +1,6 @@ @@ -144,7 +146,7 @@ -
= 100 || !max5 || max5 <= 1}> +
{$t('editor.currentPity', { values: { rarity: 5 } })}
@@ -198,7 +200,7 @@
-
= 100 || !max5 || max5 <= 1}> +
{$t('editor.currentPity', { values: { rarity: 4 } })}
@@ -212,10 +214,15 @@
{#if type !== 'standard'} -
+
{$t('editor.winRate')}
- changeRate(e, 'winRate')} /> + changeRate(e, 'winRate')} + />
{/if} @@ -253,14 +260,30 @@ {#if type !== 'standard'}
-
{@html $t('editor.disGuaranteed')}
-
- +
{@html $t('editor.guaranteedSystem')}
+
+ + {#if showGuarateedOption} +
+ + + +
+ {/if}
{/if} @@ -386,7 +409,9 @@ border-bottom-right-radius: 3rem; } + .select button.selected, input { + background-color: #fff; width: 100%; padding: 0 15%; margin-bottom: 2%; @@ -403,45 +428,39 @@ padding-right: 35%; } - input:focus { + input:focus, + .selection { box-shadow: 0 0 0.4rem rgba(227, 149, 48, 0.7); } - /* Checkbox */ - .checkbox { - font-size: 150%; - display: flex; - align-items: center; - justify-content: center; - } - .checkbox label { - text-align: left; - display: flex; - align-items: center; - height: 80%; + .selection { + position: absolute; + bottom: 100%; + left: 0; + width: 100%; + z-index: +10; + background-color: #fff; + border-radius: 0.25rem; + border: #c3b8a5 1px solid; } - .checkbox input + label i { - color: white; - border: 1px solid #aaa; - display: inline-flex; - justify-content: center; - align-items: center; - height: 100%; - aspect-ratio: 1/1; - background-color: #fff; - transition: all 0.2s; + .select button.selected { + font-size: 90%; } - .checkbox input:checked + label i { - background-color: #06bbff; + .selection button { + font-size: 100%; + display: block; + padding: 10% 15%; + width: 100%; + text-align: left; + border-bottom: #c5bcac 1px solid; } - - .checkbox:hover input + label i { - border: 1px solid #06bbff; - box-shadow: rgba(106, 168, 230, 0.6) 0px 0px 7px 5px; + button.selected, + .selection button { + transition: background 0.25s; } - - .checkbox input { - display: none; + button.selected:hover, + .selection button:hover { + background-color: #e8e5e0; }