Add option to auto-reality if no glyphs pass filter

This commit is contained in:
SpectralFlame 2023-05-15 16:06:59 -05:00 committed by cyip92
parent a38139f901
commit 12d66ba3fd
6 changed files with 92 additions and 34 deletions

View File

@ -109,22 +109,6 @@
margin-bottom: 0.4rem;
}
.l-glyph-sacrifice-options__help {
position: absolute;
top: 0;
left: calc(100% - 1.8rem);
z-index: 2;
}
.c-glyph-sacrifice-options__help {
font-size: 1.2rem;
color: var(--color-reality-dark);
}
.s-base--dark .c-glyph-sacrifice-options__help {
color: var(--color-reality-light);
}
.l-glyph-sacrifice-options__option {
box-sizing: border-box;
}

View File

@ -21,6 +21,7 @@ export default {
alchemyUnlocked: false,
// Note: there are two units at play: strength is from 1..3.5+; rarity is 0..100
rarityThresholds: GLYPH_TYPES.mapToObject(e => e, () => 0),
autoRealityForFilter: player.options.autoRealityForFilter,
};
},
computed: {
@ -116,6 +117,7 @@ export default {
},
setMode(m) {
AutoGlyphProcessor.scoreMode = m;
player.reality.hasCheckedFilter = false;
},
setRarityThreshold(id, value) {
AutoGlyphProcessor.types[id].rarity = value;
@ -166,6 +168,11 @@ export default {
getSymbol(type) {
return CosmeticGlyphTypes[type].currentSymbol.symbol;
},
toggleAutoReality() {
player.options.autoRealityForFilter = !player.options.autoRealityForFilter;
this.autoRealityForFilter = player.options.autoRealityForFilter;
player.reality.hasCheckedFilter = false;
},
exportFilterSettings() {
const filter = player.reality.glyphs.filter;
const serializeType = settings => [settings.rarity, settings.score, settings.effectCount,
@ -177,7 +184,7 @@ export default {
},
importFilterSettings() {
Modal.importFilter.show();
}
},
}
};
</script>
@ -185,27 +192,31 @@ export default {
<template>
<div class="l-glyph-sacrifice-options c-glyph-sacrifice-options l-glyph-sidebar-panel-size">
<div class="c-glyph-sacrifice-options c-glyph-sacrifice-options-container">
<div class="l-glyph-sacrifice-options__help c-glyph-sacrifice-options__help">
<div
v-tooltip="questionmarkTooltip"
class="o-questionmark o-clickable"
@click="showFilterHowTo"
>
?
</div>
</div>
<div class="c-glyph-filter-export">
<div class="c-filter-extra-btns c-top-left">
<i
v-tooltip="'Export filter settings'"
class="fas fa-file-export o-clickable l-glyph-filter-export-btn"
class="fas fa-file-export l-top-left-btn"
@click="exportFilterSettings"
/>
<i
v-tooltip="'Import filter settings'"
class="fas fa-file-import o-clickable l-glyph-filter-export-btn"
class="fas fa-file-import l-top-left-btn"
@click="importFilterSettings"
/>
</div>
<div class="c-filter-extra-btns c-top-right">
<i
v-tooltip="'Immediately Reality if no choices pass filter, ignoring all other Auto-Reality settings'"
class="fas fa-recycle l-top-right-btn"
:class="{ 'o-quick-reality' : autoRealityForFilter }"
@click="toggleAutoReality"
/>
<i
v-tooltip="questionmarkTooltip"
class="fas fa-question-circle l-top-right-btn o-borderless"
@click="showFilterHowTo"
/>
</div>
Current Filter Mode:
<br>
{{ filterMode(mode) }}
@ -376,21 +387,49 @@ export default {
cursor: pointer;
}
.c-glyph-filter-export {
.c-filter-extra-btns {
position: absolute;
display: flex;
flex-direction: row;
top: 0;
right: calc(100% - 8rem);
z-index: 2;
font-size: 1.3rem;
}
.c-top-left {
right: calc(100% - 6rem);
color: var(--color-reality-dark);
}
.l-glyph-filter-export-btn {
.c-top-right {
left: calc(100% - 5rem);
}
.l-top-left-btn {
cursor: pointer;
border: var(--var-border-width, 0.2rem) solid;
width: 3rem;
margin: 0.5rem;
width: 2.5rem;
margin: 0.5rem 0 0 0.5rem;
padding: 0.5rem;
}
.l-top-right-btn {
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
border: var(--var-border-width, 0.2rem) solid;
width: 2rem;
height: 2rem;
margin: 0.5rem 0.5rem 0 0;
padding: 0.2rem;
}
.o-borderless {
border: none;
}
.o-quick-reality {
background: var(--color-accent);
}
</style>

View File

@ -254,4 +254,20 @@ export default {
.c-glyph-set-preview-area {
width: 18rem;
}
.l-glyph-sacrifice-options__help {
position: absolute;
top: 0;
left: calc(100% - 1.8rem);
z-index: 2;
}
.c-glyph-sacrifice-options__help {
font-size: 1.2rem;
color: var(--color-reality-dark);
}
.s-base--dark .c-glyph-sacrifice-options__help {
color: var(--color-reality-light);
}
</style>

View File

@ -76,6 +76,22 @@ Autobuyer.reality = new class RealityAutobuyerState extends AutobuyerState {
}
tick() {
// Checking if auto-reality should trigger immediately due to bad glyph options happens at a higher priority
// than everything else, preempting other settings and only checking them if it fails
// In order to reduce excessive computational load, this only ever gets checked once per reality unless filter
// settings are changed (in which case it checks once more); otherwise, glyph choices would be generated every tick
const shouldCheckFilter = EffarigUnlock.glyphFilter.isUnlocked && !player.reality.hasCheckedFilter;
if (isRealityAvailable() && player.options.autoRealityForFilter && shouldCheckFilter) {
const choices = GlyphSelection.glyphList(GlyphSelection.choiceCount, gainedGlyphLevel(),
{ isChoosingGlyph: false });
const bestGlyph = AutoGlyphProcessor.pick(choices);
player.reality.hasCheckedFilter = true;
if (!AutoGlyphProcessor.wouldKeep(bestGlyph)) {
autoReality();
return;
}
}
let proc = false;
// The game generally displays amplified values, so we want to adjust the thresholds to
// account for that and make the automation trigger based on the actual displayed values

View File

@ -528,6 +528,7 @@ window.player = {
currentInfoPane: AutomatorPanels.INTRO_PAGE,
},
achTimer: 0,
hasCheckedFilter: false,
},
blackHole: Array.range(0, 2).map(id => ({
id,
@ -886,6 +887,7 @@ window.player = {
clearOnRestart: true,
},
invertTTgenDisplay: false,
autoRealityForFilter: false,
},
IAP: {
enabled: false,

View File

@ -720,6 +720,7 @@ export function finishProcessReality(realityProps) {
if (!isReset) Ra.applyAlchemyReactions(realityRealTime);
player.reality.gainedAutoAchievements = false;
player.reality.hasCheckedFilter = false;
if (realityProps.restoreCelestialState || player.options.retryCelestial) restoreCelestialRuns(celestialRunState);