feat: update random chances to take random weight into account
This commit is contained in:
parent
e7dd4ddc7b
commit
b8d4aa3d0b
3 changed files with 29 additions and 16 deletions
|
@ -2,6 +2,7 @@
|
||||||
import { Notifications } from '../../Notifications/notifications'
|
import { Notifications } from '../../Notifications/notifications'
|
||||||
import { settingsStore } from '../../stores/settingsStore'
|
import { settingsStore } from '../../stores/settingsStore'
|
||||||
import AppContainer from '../AppContainer.svelte'
|
import AppContainer from '../AppContainer.svelte'
|
||||||
|
import SettingsInput from './SettingsInput.svelte'
|
||||||
import SettingsToggle from './SettingsToggle.svelte'
|
import SettingsToggle from './SettingsToggle.svelte'
|
||||||
|
|
||||||
settingsStore.subscribe(async value => {
|
settingsStore.subscribe(async value => {
|
||||||
|
@ -31,6 +32,13 @@
|
||||||
tooltip="Disables content that could be perceived as offensive for PR and DEI purposes."
|
tooltip="Disables content that could be perceived as offensive for PR and DEI purposes."
|
||||||
>Go Woke</SettingsToggle
|
>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
|
<button
|
||||||
class="mt-10 px-4 py-2 bg-blue-500 hover:brightness-75 text-medium rounded-lg w-min"
|
class="mt-10 px-4 py-2 bg-blue-500 hover:brightness-75 text-medium rounded-lg w-min"
|
||||||
on:click={resetSettings}>Reset</button
|
on:click={resetSettings}>Reset</button
|
||||||
|
|
|
@ -77,7 +77,7 @@ const periodicSequence = async () => {
|
||||||
throw new Error('Probability must be between 0 and 1')
|
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, () => {
|
every(15, () => {
|
||||||
if (chance(0.2)) breaching1323Sequence()
|
if (chance(0.2)) breaching1323Sequence()
|
||||||
else if (chance(0.2)) breaching254Sequence()
|
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()
|
else if (chance(0.1)) bypassCoprocessorRestrictionsSequence()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,35 +1,38 @@
|
||||||
/* stores global app wide settings */
|
/* stores global app wide settings */
|
||||||
|
|
||||||
import { writable } from "svelte/store";
|
import { writable } from 'svelte/store'
|
||||||
|
|
||||||
export interface SettingsStoreData {
|
export interface SettingsStoreData {
|
||||||
disableAnnoyances: boolean;
|
disableAnnoyances: boolean
|
||||||
goWoke: boolean;
|
goWoke: boolean
|
||||||
fastStartup: boolean;
|
fastStartup: boolean
|
||||||
|
randomWeight: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaults: SettingsStoreData = {
|
export const defaults: SettingsStoreData = {
|
||||||
disableAnnoyances: false, // disable non-critical notifications
|
disableAnnoyances: false, // disable non-critical notifications
|
||||||
goWoke: false, // go woke (for showing parents or other officials where DEI has taken over), disables "offensive" sequences
|
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 createSequenceStore = () => {
|
||||||
const { subscribe, set, update } = writable<SettingsStoreData>(defaults);
|
const { subscribe, set, update } = writable<SettingsStoreData>(defaults)
|
||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
update: (
|
update: (
|
||||||
data: keyof SettingsStoreData,
|
data: keyof SettingsStoreData,
|
||||||
newValue: SettingsStoreData[typeof data]
|
newValue: SettingsStoreData[typeof data]
|
||||||
) => {
|
) => {
|
||||||
update((store) => {
|
update(store => {
|
||||||
store[data] = newValue;
|
// @ts-expect-error
|
||||||
return store;
|
store[data] = newValue
|
||||||
});
|
return store
|
||||||
|
})
|
||||||
},
|
},
|
||||||
reset: () => set(defaults),
|
reset: () => set(defaults),
|
||||||
set: (data: SettingsStoreData) => set(data),
|
set: (data: SettingsStoreData) => set(data),
|
||||||
};
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export const settingsStore = createSequenceStore();
|
export const settingsStore = createSequenceStore()
|
||||||
|
|
Loading…
Reference in a new issue