feat: update random chances to take random weight into account

This commit is contained in:
Youwen Wu 2024-02-24 21:26:40 -08:00
parent e7dd4ddc7b
commit b8d4aa3d0b
3 changed files with 29 additions and 16 deletions

View file

@ -2,6 +2,7 @@
import { Notifications } from '../../Notifications/notifications'
import { settingsStore } from '../../stores/settingsStore'
import AppContainer from '../AppContainer.svelte'
import SettingsInput from './SettingsInput.svelte'
import SettingsToggle from './SettingsToggle.svelte'
settingsStore.subscribe(async value => {
@ -31,6 +32,13 @@
tooltip="Disables content that could be perceived as offensive for PR and DEI purposes."
>Go Woke</SettingsToggle
>
<SettingsInput
setting="randomWeight"
tooltip="Changes the likelihood of random events occurring (default: 1). Set to a decimal to lower probability and a number >= 1 to increase it."
width="3rem"
>
RNG Weight
</SettingsInput>
<button
class="mt-10 px-4 py-2 bg-blue-500 hover:brightness-75 text-medium rounded-lg w-min"
on:click={resetSettings}>Reset</button

View file

@ -77,7 +77,7 @@ const periodicSequence = async () => {
throw new Error('Probability must be between 0 and 1')
}
return Math.random() < probability
return Math.random() < probability * get(settingsStore).randomWeight
}
/**
@ -94,7 +94,9 @@ const periodicSequence = async () => {
every(15, () => {
if (chance(0.2)) breaching1323Sequence()
else if (chance(0.2)) breaching254Sequence()
else if (chance(0.05)) bullyingRohanSequence()
})
every(25, () => {
if (chance(0.05)) bullyingRohanSequence()
else if (chance(0.1)) bypassCoprocessorRestrictionsSequence()
})

View file

@ -1,35 +1,38 @@
/* stores global app wide settings */
import { writable } from "svelte/store";
import { writable } from 'svelte/store'
export interface SettingsStoreData {
disableAnnoyances: boolean;
goWoke: boolean;
fastStartup: boolean;
disableAnnoyances: boolean
goWoke: boolean
fastStartup: boolean
randomWeight: number
}
export const defaults: SettingsStoreData = {
disableAnnoyances: false, // disable non-critical notifications
goWoke: false, // go woke (for showing parents or other officials where DEI has taken over), disables "offensive" sequences
fastStartup: false, // skip the loading splash screen (for development purposes. Setting this from within the app has no effect.)
};
fastStartup: true, // skip the loading splash screen (for development purposes. Setting this from within the app has no effect.)
randomWeight: 1, // the weight of random events (multiplied by the original probability)
}
const createSequenceStore = () => {
const { subscribe, set, update } = writable<SettingsStoreData>(defaults);
const { subscribe, set, update } = writable<SettingsStoreData>(defaults)
return {
subscribe,
update: (
data: keyof SettingsStoreData,
newValue: SettingsStoreData[typeof data]
) => {
update((store) => {
store[data] = newValue;
return store;
});
update(store => {
// @ts-expect-error
store[data] = newValue
return store
})
},
reset: () => set(defaults),
set: (data: SettingsStoreData) => set(data),
};
};
}
}
export const settingsStore = createSequenceStore();
export const settingsStore = createSequenceStore()