Skip to content

Commit

Permalink
Guaranteed System Toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
AguzzTN54 committed Oct 25, 2023
1 parent a950e6d commit 966774e
Show file tree
Hide file tree
Showing 16 changed files with 173 additions and 95 deletions.
10 changes: 10 additions & 0 deletions src/lib/helpers/gacha/itemdrop-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 };
};

11 changes: 7 additions & 4 deletions src/lib/helpers/gacha/probabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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);
Expand Down
23 changes: 14 additions & 9 deletions src/lib/helpers/gacha/wishCharacter.js
Original file line number Diff line number Diff line change
@@ -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 }) {
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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 };
Expand Down
20 changes: 14 additions & 6 deletions src/lib/helpers/gacha/wishWeapon.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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',
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions src/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>\"{banner}\"</b> probabilities back to default?"
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"wishTitle": "Gebet",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@
"charRate": "Chance to get Character instead of Weapon",
"nonRateup": "(Non RateUp Item)",
"selectedRate": "Selected Weapon Rate:",
"disGuaranteed": "Disable Guaranteed System <small>(after getting a non-RateUP item)</small>",
"guaranteedSystem": "Guaranteed System",
"backToDefault": "Back to Default",
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?"
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"wishTitle": "Wish",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@
"charRate": "Chance to get Character instead of Weapon",
"nonRateup": "(Non RateUp Item)",
"selectedRate": "Selected Weapon Rate:",
"disGuaranteed": "Disable Guaranteed System <small>(after getting a non-RateUP item)</small>",
"guaranteedSystem": "Guaranteed System",
"backToDefault": "Back to Default",
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?"
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"wishTitle": "Vœux",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/id-ID.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <b>\"{banner}\"</b>?"
"resetPrompt": "Apakah kamu yakin akan mereset pengaturan probabilitas untuk <b>\"{banner}\"</b>?",
"default": "Aktif",
"never": "NonAktif",
"always": "Selalu"
},
"wish": {
"wishTitle": "Permohonan",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@
"charRate": "Chance to get Character instead of Weapon",
"nonRateup": "(Non RateUp Item)",
"selectedRate": "Selected Weapon Rate:",
"disGuaranteed": "Disable Guaranteed System <small>(after getting a non-RateUP item)</small>",
"guaranteedSystem": "Guaranteed System",
"backToDefault": "Back to Default",
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?"
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"wishTitle": "Wish",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@
"charRate": "武器ではなくキャラクターを入手する確率",
"nonRateup": "(すり抜け時)",
"selectedRate": "軌定武器獲得確率:",
"disGuaranteed": "確定天井の無効化 <small>(すり抜け後)</small>",
"guaranteedSystem": "Guaranteed System",
"backToDefault": "初期設定に戻す",
"resetPrompt": "<b>\"{banner}\"</b> の確率設定を初期設定に戻しますか?"
"resetPrompt": "<b>\"{banner}\"</b> の確率設定を初期設定に戻しますか?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"wishTitle": "祈願",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@
"charRate": "Chance to get Character instead of Weapon",
"nonRateup": "(Non RateUp Item)",
"selectedRate": "Selected Weapon Rate:",
"disGuaranteed": "Disable Guaranteed System <small>(after getting a non-RateUP item)</small>",
"guaranteedSystem": "Guaranteed System",
"backToDefault": "Back to Default",
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?"
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"wishTitle": "Orar",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@
"charRate": "Chance to get Character instead of Weapon",
"nonRateup": "(Non RateUp Item)",
"selectedRate": "Selected Weapon Rate:",
"disGuaranteed": "Disable Guaranteed System <small>(after getting a non-RateUP item)</small>",
"guaranteedSystem": "Guaranteed System",
"backToDefault": "Back to Default",
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?"
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"wishTitle": "Молитва",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/th-TH.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@
"charRate": "Chance to get Character instead of Weapon",
"nonRateup": "(Non RateUp Item)",
"selectedRate": "Selected Weapon Rate:",
"disGuaranteed": "Disable Guaranteed System <small>(after getting a non-RateUP item)</small>",
"guaranteedSystem": "Guaranteed System",
"backToDefault": "Back to Default",
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?"
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"wishTitle": "การอธิษฐาน",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/vi-VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@
"charRate": "Chance to get Character instead of Weapon",
"nonRateup": "(Non RateUp Item)",
"selectedRate": "Selected Weapon Rate:",
"disGuaranteed": "Disable Guaranteed System <small>(after getting a non-RateUP item)</small>",
"guaranteedSystem": "Guaranteed System",
"backToDefault": "Back to Default",
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?"
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"wishTitle": "Cầu Nguyện",
Expand Down
7 changes: 5 additions & 2 deletions src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@
"charRate": "Chance to get Character instead of Weapon",
"nonRateup": "(Non RateUp Item)",
"selectedRate": "Selected Weapon Rate:",
"disGuaranteed": "Disable Guaranteed System <small>(after getting a non-RateUP item)</small>",
"guaranteedSystem": "Guaranteed System",
"backToDefault": "Back to Default",
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?"
"resetPrompt": "Are you sure to Reset <b>\"{banner}\"</b> probabilities back to default?",
"default": "Default",
"never": "Never",
"always": "Always"
},
"wish": {
"rollButton": "祈愿{count}次",
Expand Down
Loading

0 comments on commit 966774e

Please sign in to comment.