Fixed cloth and up not treating mastery correctly

This commit is contained in:
thepaperpilot 2022-12-18 18:27:18 -06:00
parent a84eceea65
commit 7eb3e2fa0b
5 changed files with 64 additions and 61 deletions

View file

@ -27,7 +27,7 @@ import Decimal, { DecimalSource, format } from "util/bignum";
import { formatWhole } from "util/break_eternity";
import { Direction } from "util/common";
import { render, renderCol, renderRow } from "util/vue";
import { computed, ref } from "vue";
import { computed, ref, unref } from "vue";
import boxes from "./boxes";
import dyes from "./dyes";
import { ElfBuyable } from "./elves";
@ -73,9 +73,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
style: {
minHeight: "80px"
},
canClick: () => Decimal.gte(breedingProgress.value, computedBreedingCooldown.value),
canClick: () =>
Decimal.gte(breedingProgress.value, computedBreedingCooldown.value) &&
(!main.isMastery.value || masteryEffectActive.value),
onClick() {
if (Decimal.lt(breedingProgress.value, computedBreedingCooldown.value)) {
if (!unref(breeding.canClick)) {
return;
}
const amount = Decimal.floor(computedSheepGain.value);
@ -109,9 +111,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
style: {
minHeight: "80px"
},
canClick: () => Decimal.gte(shearingProgress.value, computedShearingCooldown.value),
canClick: () =>
Decimal.gte(shearingProgress.value, computedShearingCooldown.value) &&
(!main.isMastery.value || masteryEffectActive.value),
onClick() {
if (Decimal.lt(shearingProgress.value, computedShearingCooldown.value)) {
if (!unref(shearing.canClick)) {
return;
}
const amount = Decimal.min(sheep.value, computedShearingAmount.value).floor();
@ -145,9 +149,11 @@ const layer = createLayer(id, function (this: BaseLayer) {
style: {
minHeight: "80px"
},
canClick: () => Decimal.gte(spinningProgress.value, computedSpinningCooldown.value),
canClick: () =>
Decimal.gte(spinningProgress.value, computedSpinningCooldown.value) &&
(!main.isMastery.value || masteryEffectActive.value),
onClick() {
if (Decimal.lt(spinningProgress.value, computedSpinningCooldown.value)) {
if (!unref(spinning.canClick)) {
return;
}
const amount = Decimal.min(wool.value, computedSpinningAmount.value).floor();
@ -375,16 +381,12 @@ const layer = createLayer(id, function (this: BaseLayer) {
createMultiplicativeModifier(() => ({
multiplier: gingersnapEffect,
description: "Gingersnap Level 2",
enabled: () =>
management.elfTraining.clothElfTraining.milestones[1].earned.value &&
!main.isMastery.value
enabled: management.elfTraining.clothElfTraining.milestones[1].earned
})),
createMultiplicativeModifier(() => ({
multiplier: hollyEffect,
description: "Holly Level 3",
enabled: () =>
management.elfTraining.cutterElfTraining.milestones[2].earned.value &&
!main.isMastery.value
enabled: management.elfTraining.cutterElfTraining.milestones[2].earned
})),
createMultiplicativeModifier(() => ({
multiplier: 2,
@ -419,16 +421,12 @@ const layer = createLayer(id, function (this: BaseLayer) {
createMultiplicativeModifier(() => ({
multiplier: gingersnapEffect,
description: "Gingersnap Level 2",
enabled: () =>
management.elfTraining.clothElfTraining.milestones[1].earned.value &&
!main.isMastery.value
enabled: management.elfTraining.clothElfTraining.milestones[1].earned
})),
createMultiplicativeModifier(() => ({
multiplier: hollyEffect,
description: "Holly Level 3",
enabled: () =>
management.elfTraining.cutterElfTraining.milestones[2].earned.value &&
!main.isMastery.value
enabled: management.elfTraining.cutterElfTraining.milestones[2].earned
})),
createMultiplicativeModifier(() => ({
multiplier: 2,
@ -463,16 +461,12 @@ const layer = createLayer(id, function (this: BaseLayer) {
createMultiplicativeModifier(() => ({
multiplier: gingersnapEffect,
description: "Gingersnap Level 2",
enabled: () =>
management.elfTraining.clothElfTraining.milestones[1].earned.value &&
!main.isMastery.value
enabled: management.elfTraining.clothElfTraining.milestones[1].earned
})),
createMultiplicativeModifier(() => ({
multiplier: hollyEffect,
description: "Holly Level 3",
enabled: () =>
management.elfTraining.cutterElfTraining.milestones[2].earned.value &&
!main.isMastery.value
enabled: management.elfTraining.cutterElfTraining.milestones[2].earned
})),
createMultiplicativeModifier(() => ({
multiplier: 2,
@ -659,8 +653,10 @@ const layer = createLayer(id, function (this: BaseLayer) {
minimizedDisplay: jsx(() => (
<div>
{name}{" "}
<span class="desc">{format(cloth.value)} {cloth.displayName}</span>
</div>
<span class="desc">
{format(cloth.value)} {cloth.displayName}
</span>
</div>
)),
mastery,
mastered

View file

@ -148,9 +148,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
createMultiplicativeModifier(() => ({
multiplier: () => Decimal.add(cloth.cloth.value, Math.E).ln(),
description: "Gingersnap Level 1",
enabled: () =>
management.elfTraining.clothElfTraining.milestones[0].earned.value &&
!main.isMastery.value
enabled: management.elfTraining.clothElfTraining.milestones[0].earned
}))
);
modifiers.push(
@ -178,9 +176,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
createMultiplicativeModifier(() => ({
multiplier: 2,
description: "Gingersnap Level 3",
enabled: () =>
management.elfTraining.clothElfTraining.milestones[2].earned.value &&
!main.isMastery.value
enabled: management.elfTraining.clothElfTraining.milestones[2].earned
}))
);
modifiers.push(
@ -274,7 +270,12 @@ const layer = createLayer(id, function (this: BaseLayer) {
);
},
canPurchase: computed((cost?: DecimalSource) => {
if (unref(buyable.visibility) != Visibility.Visible) return false;
if (unref(buyable.visibility) != Visibility.Visible) {
return false;
}
if (main.isMastery.value && !masteryEffectActive.value) {
return false;
}
const trueCost = cost ?? unref(buyable.cost) ?? Decimal.dInf;
return unref(costs).every(c =>
Decimal.div(c.res.value, unref(c.base))
@ -283,6 +284,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
);
}),
onPurchase(cost?: DecimalSource) {
if (!unref(buyable.canPurchase)) {
return;
}
const trueCost = cost ?? unref(buyable.cost) ?? Decimal.dInf;
amount.value = Decimal.add(amount.value, computedToGenerate.value);

View file

@ -61,7 +61,9 @@ const layer = createLayer(id, function (this: BaseLayer) {
style: {
minHeight: "80px"
},
canClick: () => Decimal.gte(processingProgress.value, computedProcessingCooldown.value),
canClick: () =>
Decimal.gte(processingProgress.value, computedProcessingCooldown.value) &&
(!main.isMastery.value || masteryEffectActive.value),
onClick() {
if (Decimal.lt(processingProgress.value, computedProcessingCooldown.value)) {
return;
@ -87,7 +89,8 @@ const layer = createLayer(id, function (this: BaseLayer) {
resource: metal.metal,
cost() {
return Decimal.pow(10, metalBuyable.amount.value).times(1e21);
}
},
visibility: () => showIf(!main.isMastery.value || masteryEffectActive.value)
})) as GenericBuyable;
const plasticBuyable = createBuyable(() => ({
display: {
@ -101,7 +104,8 @@ const layer = createLayer(id, function (this: BaseLayer) {
resource: plastic.plastic,
cost() {
return Decimal.pow(1.5, plasticBuyable.amount.value).times(1e9);
}
},
visibility: () => showIf(!main.isMastery.value || masteryEffectActive.value)
})) as GenericBuyable;
const paperBuyable = createBuyable(() => ({
display: {
@ -114,7 +118,8 @@ const layer = createLayer(id, function (this: BaseLayer) {
resource: paper.paper,
cost() {
return Decimal.pow(3, paperBuyable.amount.value).times(1e38);
}
},
visibility: () => showIf(!main.isMastery.value || masteryEffectActive.value)
})) as GenericBuyable;
const buyables = { metalBuyable, plasticBuyable, paperBuyable };
@ -304,8 +309,10 @@ const layer = createLayer(id, function (this: BaseLayer) {
minimizedDisplay: jsx(() => (
<div>
{name}{" "}
<span class="desc">{format(letters.value)} {letters.displayName}</span>
</div>
<span class="desc">
{format(letters.value)} {letters.displayName}
</span>
</div>
)),
mastery,
mastered

View file

@ -141,7 +141,8 @@ const layer = createLayer(id, function (this: BaseLayer) {
color: colorText,
width: "160px",
flexGrow: 1
}
},
visibility: () => showIf(!main.isMastery.value || masteryEffectActive.value)
})) as ElfBuyable & { resource: Resource };
const {
min: minHeavy,
@ -854,16 +855,12 @@ 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
})),
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
})),
createMultiplicativeModifier(() => ({
multiplier: () => coalEffectiveness.value,
@ -917,23 +914,17 @@ 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
})),
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
})),
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
}))
]) as WithRequired<Modifier, "description" | "revert">;
const computedOilSpeed = computed(() => oilSpeed.apply(0));
@ -1353,8 +1344,10 @@ const layer = createLayer(id, function (this: BaseLayer) {
minimizedDisplay: jsx(() => (
<div>
{name}{" "}
<span class="desc">{format(oil.value)} {oil.displayName}</span>
</div>
<span class="desc">
{format(oil.value)} {oil.displayName}
</span>
</div>
)),
mastery,
mastered

View file

@ -101,7 +101,8 @@ const layer = createLayer(id, function (this: BaseLayer) {
},
style: {
width: "300px"
}
},
visibility: () => showIf(!main.isMastery.value || masteryEffectActive.value)
})) as GenericBuyable & { resource: Resource };
const {
min: minRefinery,
@ -384,8 +385,10 @@ const layer = createLayer(id, function (this: BaseLayer) {
minimizedDisplay: jsx(() => (
<div>
{name}{" "}
<span class="desc">{format(plastic.value)} {plastic.displayName}</span>
</div>
<span class="desc">
{format(plastic.value)} {plastic.displayName}
</span>
</div>
)),
mastery,
mastered