mirror of
https://github.com/thepaperpilot/Advent-Incremental.git
synced 2024-11-28 02:51:46 +00:00
Implement goal
This commit is contained in:
parent
fa556849c1
commit
69af1b6b63
3 changed files with 36 additions and 23 deletions
|
@ -10,7 +10,7 @@ const element = shallowRef<HTMLElement | null>(null);
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
application: Application;
|
application: Application;
|
||||||
}>();
|
}>();
|
||||||
console.log(props.application);
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (element.value !== null) {
|
if (element.value !== null) {
|
||||||
element.value?.append(props.application.view);
|
element.value?.append(props.application.view);
|
||||||
|
|
|
@ -65,6 +65,8 @@ const id = "factory";
|
||||||
// what is the actual day?
|
// what is the actual day?
|
||||||
const day = 18;
|
const day = 18;
|
||||||
|
|
||||||
|
const toyGoal = 1e3;
|
||||||
|
|
||||||
// 20x20 block size
|
// 20x20 block size
|
||||||
// TODO: unhardcode stuff
|
// TODO: unhardcode stuff
|
||||||
|
|
||||||
|
@ -1325,7 +1327,7 @@ const factory = createLayer(id, () => {
|
||||||
<>
|
<>
|
||||||
<div>
|
<div>
|
||||||
{main.day.value === day
|
{main.day.value === day
|
||||||
? `Do something to complete the day`
|
? `Reach ${format(toyGoal)} for each toy to complete the day`
|
||||||
: `${name} Complete!`}{" "}
|
: `${name} Complete!`}{" "}
|
||||||
-{" "}
|
-{" "}
|
||||||
<button
|
<button
|
||||||
|
@ -1418,12 +1420,38 @@ const factory = createLayer(id, () => {
|
||||||
direction: Direction.Right,
|
direction: Direction.Right,
|
||||||
width: 600,
|
width: 600,
|
||||||
height: 25,
|
height: 25,
|
||||||
progress: () => (main.day.value === day ? 0 : 1),
|
fillStyle: `backgroundColor: ${color}`,
|
||||||
display: jsx(() => (main.day.value === day ? <>Requirement progress here</> : ""))
|
progress: () =>
|
||||||
|
main.day.value === day
|
||||||
|
? Decimal.div(toys.clothes.value, toyGoal)
|
||||||
|
.clampMax(1)
|
||||||
|
.add(Decimal.div(toys.woodenBlocks.value, toyGoal).clampMax(1))
|
||||||
|
.add(Decimal.div(toys.trucks.value, toyGoal).clampMax(1))
|
||||||
|
.div(3)
|
||||||
|
: 1,
|
||||||
|
display: jsx(() =>
|
||||||
|
main.day.value === day ? (
|
||||||
|
<>
|
||||||
|
{
|
||||||
|
[toys.clothes.value, toys.woodenBlocks.value, toys.trucks.value].filter(t =>
|
||||||
|
Decimal.gte(t, toyGoal)
|
||||||
|
).length
|
||||||
|
}{" "}
|
||||||
|
/ 3
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)
|
||||||
|
)
|
||||||
})) as GenericBar;
|
})) as GenericBar;
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
if (main.day.value === day && false) {
|
if (
|
||||||
|
main.day.value === day &&
|
||||||
|
Decimal.gte(toys.clothes.value, toyGoal) &&
|
||||||
|
Decimal.gte(toys.woodenBlocks.value, toyGoal) &&
|
||||||
|
Decimal.gte(toys.trucks.value, toyGoal)
|
||||||
|
) {
|
||||||
main.completeDay();
|
main.completeDay();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -104,7 +104,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
|
||||||
onPurchase() {
|
onPurchase() {
|
||||||
cloth.cloth.value = Decimal.sub(cloth.cloth.value, clothesCost.value.cloth);
|
cloth.cloth.value = Decimal.sub(cloth.cloth.value, clothesCost.value.cloth);
|
||||||
this.amount.value = Decimal.add(this.amount.value, 1);
|
this.amount.value = Decimal.add(this.amount.value, 1);
|
||||||
clothes.value = this.amount.value;
|
clothes.value = Decimal.add(clothes.value, 1);
|
||||||
}
|
}
|
||||||
})) as GenericBuyable;
|
})) as GenericBuyable;
|
||||||
const woodenBlocksCost = computed(() => {
|
const woodenBlocksCost = computed(() => {
|
||||||
|
@ -136,7 +136,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
|
||||||
onPurchase() {
|
onPurchase() {
|
||||||
trees.logs.value = Decimal.sub(trees.logs.value, woodenBlocksCost.value.wood);
|
trees.logs.value = Decimal.sub(trees.logs.value, woodenBlocksCost.value.wood);
|
||||||
this.amount.value = Decimal.add(this.amount.value, 1);
|
this.amount.value = Decimal.add(this.amount.value, 1);
|
||||||
woodenBlocks.value = this.amount.value;
|
woodenBlocks.value = Decimal.add(woodenBlocks.value, 1);
|
||||||
}
|
}
|
||||||
})) as GenericBuyable;
|
})) as GenericBuyable;
|
||||||
const trucksCost = computed(() => {
|
const trucksCost = computed(() => {
|
||||||
|
@ -196,7 +196,7 @@ const layer = createLayer(id, function (this: BaseLayer) {
|
||||||
metal.metal.value = Decimal.sub(metal.metal.value, trucksCost.value.metal);
|
metal.metal.value = Decimal.sub(metal.metal.value, trucksCost.value.metal);
|
||||||
plastic.plastic.value = Decimal.sub(plastic.plastic.value, trucksCost.value.plastic);
|
plastic.plastic.value = Decimal.sub(plastic.plastic.value, trucksCost.value.plastic);
|
||||||
this.amount.value = Decimal.add(this.amount.value, 1);
|
this.amount.value = Decimal.add(this.amount.value, 1);
|
||||||
trucks.value = this.amount.value;
|
trucks.value = Decimal.add(trucks.value, 1);
|
||||||
}
|
}
|
||||||
})) as GenericBuyable;
|
})) as GenericBuyable;
|
||||||
const buyables = [clothesBuyable, woodenBlocksBuyable, trucksBuyable];
|
const buyables = [clothesBuyable, woodenBlocksBuyable, trucksBuyable];
|
||||||
|
@ -284,21 +284,6 @@ const layer = createLayer(id, function (this: BaseLayer) {
|
||||||
/>
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
globalBus.on("update", diff => {
|
|
||||||
if (Decimal.lt(main.day.value, day)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Decimal.lt(clothes.value, clothesBuyable.amount.value)) {
|
|
||||||
clothesBuyable.amount.value = clothes.value;
|
|
||||||
}
|
|
||||||
if (Decimal.lt(woodenBlocks.value, woodenBlocksBuyable.amount.value)) {
|
|
||||||
woodenBlocksBuyable.amount.value = woodenBlocks.value;
|
|
||||||
}
|
|
||||||
if (Decimal.lt(trucks.value, trucksBuyable.amount.value)) {
|
|
||||||
trucksBuyable.amount.value = trucks.value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const { total: totalToys, trackerDisplay } = setUpDailyProgressTracker({
|
const { total: totalToys, trackerDisplay } = setUpDailyProgressTracker({
|
||||||
resource: toySum,
|
resource: toySum,
|
||||||
goal: 500,
|
goal: 500,
|
||||||
|
|
Loading…
Reference in a new issue