Add computed value for when a layer's mastery effect should be active

This commit is contained in:
thepaperpilot 2022-12-18 01:47:31 -06:00
parent 65fbeb73ff
commit 8dc7488d31
14 changed files with 92 additions and 18 deletions

View file

@ -58,7 +58,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
createExponentialModifier(() => ({
exponent: 1.1,
description: "Bell Level 2",
enabled: () => management.elfTraining.boxElfTraining.milestones[1].earned.value && !main.isMastery.value
enabled: () =>
management.elfTraining.boxElfTraining.milestones[1].earned.value &&
!main.isMastery.value
}))
]) as WithRequired<Modifier, "description" | "revert">;
@ -600,7 +602,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
row3Upgrades: {
clothUpgrade: { bought: persistent<boolean>(false) },
dyeUpgrade: { bought: persistent<boolean>(false) },
xpUpgrade: { bought: persistent<boolean>(false) },
xpUpgrade: { bought: persistent<boolean>(false) }
},
buyables: {
logBoxesBuyable: { amount: persistent<DecimalSource>(0) },
@ -614,6 +616,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,
@ -646,7 +651,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
{renderGrid(Object.values(buyables), Object.values(buyables2))}
</>
)),
minimizedDisplay: jsx(() => (<div>{name} - {format(boxes.value)} {boxes.displayName}</div>)),
minimizedDisplay: jsx(() => (
<div>
{name} - {format(boxes.value)} {boxes.displayName}
</div>
)),
mastery,
mastered
};

View file

@ -613,6 +613,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,

View file

@ -1040,6 +1040,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
moreFertilizer: { amount: persistent<DecimalSource>(0) }
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,

View file

@ -822,6 +822,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,

View file

@ -1076,6 +1076,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
Decimal.gte(coal.coal.value, coalGoal)
) {
main.completeDay();
} else if (
main.currentlyMastering.value?.name === name &&
Decimal.gte(coal.coal.value, options.masteryGoal ?? options.goal)
) {
main.completeMastery();
}
});
@ -1189,6 +1194,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
]
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,

View file

@ -269,6 +269,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,
@ -298,7 +301,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
{milestonesDisplay()}
</>
)),
minimizedDisplay: jsx(() => (<div>{name} - {format(letters.value)} {letters.displayName}</div>)),
minimizedDisplay: jsx(() => (
<div>
{name} - {format(letters.value)} {letters.displayName}
</div>
)),
mastery,
mastered
};

View file

@ -1837,6 +1837,9 @@ const layer = createLayer(id, () => {
focusTime: persistent<number>(0)
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
// ------------------------------------------------------------------------------- Return

View file

@ -669,6 +669,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
hotterForge: { amount: persistent<DecimalSource>(0) }
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,

View file

@ -854,12 +854,16 @@ const layer = createLayer(id, function (this: BaseLayer) {
createMultiplicativeModifier(() => ({
multiplier: () => Decimal.add(totalOil.value, 1).log10().add(1),
description: "Cocoa Level 2",
enabled: () => management.elfTraining.oilElfTraining.milestones[1].earned.value && !main.isMastery.value
enabled: () =>
management.elfTraining.oilElfTraining.milestones[1].earned.value &&
!main.isMastery.value
})),
createMultiplicativeModifier(() => ({
multiplier: 2,
description: "Cocoa Level 3",
enabled: () => management.elfTraining.oilElfTraining.milestones[2].earned.value && !main.isMastery.value
enabled: () =>
management.elfTraining.oilElfTraining.milestones[2].earned.value &&
!main.isMastery.value
})),
createMultiplicativeModifier(() => ({
multiplier: () => coalEffectiveness.value,
@ -913,17 +917,23 @@ const layer = createLayer(id, function (this: BaseLayer) {
createMultiplicativeModifier(() => ({
multiplier: () => Decimal.sqrt(management.totalElfLevels.value),
description: "Jack Level 4",
enabled: () => management.elfTraining.heatedCutterElfTraining.milestones[3].earned.value && !main.isMastery.value
enabled: () =>
management.elfTraining.heatedCutterElfTraining.milestones[3].earned.value &&
!main.isMastery.value
})),
createMultiplicativeModifier(() => ({
multiplier: () => Decimal.add(buildHeavy2.amount.value, 1).sqrt(),
description: "Faith Level 4",
enabled: () => management.elfTraining.bonfireElfTraining.milestones[3].earned.value && !main.isMastery.value
enabled: () =>
management.elfTraining.bonfireElfTraining.milestones[3].earned.value &&
!main.isMastery.value
})),
createMultiplicativeModifier(() => ({
multiplier: 2,
description: "Cocoa Level 3",
enabled: () => management.elfTraining.oilElfTraining.milestones[2].earned.value && !main.isMastery.value
enabled: () =>
management.elfTraining.oilElfTraining.milestones[2].earned.value &&
!main.isMastery.value
}))
]) as WithRequired<Modifier, "description" | "revert">;
const computedOilSpeed = computed(() => oilSpeed.apply(0));
@ -1141,6 +1151,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
]
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,
@ -1337,7 +1350,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
</>
);
}),
minimizedDisplay: jsx(() => (<div>{name} - {format(oil.value)} {oil.displayName}</div>)),
minimizedDisplay: jsx(() => (
<div>
{name} - {format(oil.value)} {oil.displayName}
</div>
)),
mastery,
mastered

View file

@ -412,7 +412,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
createMultiplicativeModifier(() => ({
multiplier: 0.1,
description: "Star Level 2",
enabled: () => management.elfTraining.paperElfTraining.milestones[1].earned.value && !main.isMastery.value
enabled: () =>
management.elfTraining.paperElfTraining.milestones[1].earned.value &&
!main.isMastery.value
}))
]) as WithRequired<Modifier, "description" | "revert">;
const computedAshCost = computed(() => ashCost.apply(1e6));
@ -500,6 +502,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,
@ -526,7 +531,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
{renderCol(...Object.values(books))}
</>
)),
minimizedDisplay: jsx(() => (<div>{name} - {format(paper.value)} {paper.displayName}</div>)),
minimizedDisplay: jsx(() => (
<div>
{name} - {format(paper.value)} {paper.displayName}
</div>
)),
mastery,
mastered
};

View file

@ -335,6 +335,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,

View file

@ -456,7 +456,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
createAdditiveModifier(() => ({
addend: () => totalTrees.apply(0),
description: "Tree Mastery",
enabled: () => main.isMastery.value || mastered.value
enabled: () => masteryEffectActive.value
})),
createMultiplicativeModifier(() => ({
multiplier: 1.25,
@ -594,7 +594,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
logs.value = Decimal.add(logs.value, Decimal.times(logGain.apply(1), amount));
saplings.value = Decimal.add(
saplings.value,
amount.times(main.isMastery.value || mastered.value ? 2 : 1)
amount.times(masteryEffectActive.value ? 2 : 1)
);
manualCutProgress.value = 0;
}
@ -763,7 +763,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
);
logs.value = Decimal.add(logs.value, logsGained);
saplings.value = Decimal.add(
Decimal.mul(saplings.value, main.isMastery.value || mastered.value ? 2 : 1),
Decimal.mul(saplings.value, masteryEffectActive.value ? 2 : 1),
amountCut
);
const amountPlanted = Decimal.min(
@ -832,6 +832,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
]
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,

View file

@ -78,7 +78,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
roundUpCost: true,
// buyMax: management.elfTraining.expandersElfTraining.milestones[2].earned,
spend(gain, spent) {
if (main.isMastery.value || mastered.value) return;
if (masteryEffectActive.value) return;
trees.logs.value = Decimal.sub(trees.logs.value, spent);
}
}));
@ -92,7 +92,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
<br />
<br />
<span style="font-size: large">
{main.isMastery.value || mastered.value ? "Requirement" : "Cost"}:{" "}
{masteryEffectActive.value ? "Requirement" : "Cost"}:{" "}
{displayResource(
trees.logs,
Decimal.gte(foundationConversion.actualGain.value, 1)
@ -349,6 +349,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
}
};
const mastered = persistent<boolean>(false);
const masteryEffectActive = computed(
() => mastered.value || main.currentlyMastering.value?.name === name
);
return {
name,

View file

@ -293,7 +293,7 @@ const layer = createLayer(id, () => {
const { total: totalWrappingPaper, trackerDisplay } = setUpDailyProgressTracker({
resource: wrappingPaperSum,
goal: 1e20,
goal: 1e8,
name,
day,
color,