mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-22 00:21:31 +00:00
Add milestones between rows
This commit is contained in:
parent
78ca0c632c
commit
5611a7c052
2 changed files with 60 additions and 4 deletions
|
@ -17,3 +17,7 @@
|
||||||
.affected-node {
|
.affected-node {
|
||||||
filter: drop-shadow(0px 0px 20px var(--accent1));
|
filter: drop-shadow(0px 0px 20px var(--accent1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.achievement.final {
|
||||||
|
border-color: var(--accent3);
|
||||||
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ import { Resources, resourceNames } from "./projEntry";
|
||||||
import { getColor, getName, sfc32 } from "./utils";
|
import { getColor, getName, sfc32 } from "./utils";
|
||||||
import ModalVue from "components/Modal.vue";
|
import ModalVue from "components/Modal.vue";
|
||||||
import { addTooltip } from "features/tooltips/tooltip";
|
import { addTooltip } from "features/tooltips/tooltip";
|
||||||
|
import { createAchievement } from "features/achievements/achievement";
|
||||||
|
import { Computable } from "util/computed";
|
||||||
|
|
||||||
export function createPlane(id: string, tier: Resources, seed: number) {
|
export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
return createLayer(id, function (this: BaseLayer) {
|
return createLayer(id, function (this: BaseLayer) {
|
||||||
|
@ -31,7 +33,7 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
const resource = createResource<DecimalSource>(0, getName(random));
|
const resource = createResource<DecimalSource>(0, getName(random));
|
||||||
const tierIndex = resourceNames.indexOf(tier);
|
const tierIndex = resourceNames.indexOf(tier);
|
||||||
const difficulty = random() + tierIndex + 1;
|
const difficulty = random() + tierIndex + 1;
|
||||||
const length = random() * (tierIndex + 1) + 1;
|
const length = Math.ceil(random() * (tierIndex + 2));
|
||||||
|
|
||||||
const resourceModifiers: WithRequired<Modifier, "description" | "invert">[] = [];
|
const resourceModifiers: WithRequired<Modifier, "description" | "invert">[] = [];
|
||||||
const resourceGainModifier = createSequentialModifier(() => resourceModifiers);
|
const resourceGainModifier = createSequentialModifier(() => resourceModifiers);
|
||||||
|
@ -40,6 +42,7 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
const features: VueFeature[][] = [];
|
const features: VueFeature[][] = [];
|
||||||
const t = ref<DecimalSource>(0);
|
const t = ref<DecimalSource>(0);
|
||||||
let costFormula = Formula.variable(t);
|
let costFormula = Formula.variable(t);
|
||||||
|
let visibility: Computable<boolean> = true;
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const featureWeights = {
|
const featureWeights = {
|
||||||
upgrades: 16
|
upgrades: 16
|
||||||
|
@ -48,7 +51,7 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
const featureWeightsKeys = Object.keys(
|
const featureWeightsKeys = Object.keys(
|
||||||
featureWeights
|
featureWeights
|
||||||
) as (keyof typeof featureWeights)[];
|
) as (keyof typeof featureWeights)[];
|
||||||
const r = Math.floor(random() * sumFeatureWeights);
|
let r = Math.floor(random() * sumFeatureWeights);
|
||||||
let weight = 0;
|
let weight = 0;
|
||||||
let type: keyof typeof featureWeights | null = null;
|
let type: keyof typeof featureWeights | null = null;
|
||||||
for (let i = 0; i < featureWeightsKeys.length; i++) {
|
for (let i = 0; i < featureWeightsKeys.length; i++) {
|
||||||
|
@ -77,7 +80,7 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
upgradeTypeWeights
|
upgradeTypeWeights
|
||||||
) as (keyof typeof upgradeTypeWeights)[];
|
) as (keyof typeof upgradeTypeWeights)[];
|
||||||
let upgradeType: keyof typeof upgradeTypeWeights | null = null;
|
let upgradeType: keyof typeof upgradeTypeWeights | null = null;
|
||||||
const r = Math.floor(random() * sumUpgradeTypeWeights);
|
r = Math.floor(random() * sumUpgradeTypeWeights);
|
||||||
for (let i = 0; i < upgradeTypeWeightsKeys.length; i++) {
|
for (let i = 0; i < upgradeTypeWeightsKeys.length; i++) {
|
||||||
const type = upgradeTypeWeightsKeys[i];
|
const type = upgradeTypeWeightsKeys[i];
|
||||||
weight += upgradeTypeWeights[type];
|
weight += upgradeTypeWeights[type];
|
||||||
|
@ -127,7 +130,8 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
display: {
|
display: {
|
||||||
title,
|
title,
|
||||||
description
|
description
|
||||||
}
|
},
|
||||||
|
visibility
|
||||||
}));
|
}));
|
||||||
const eta = estimateTime(resource, computedResourceGain, cost);
|
const eta = estimateTime(resource, computedResourceGain, cost);
|
||||||
addTooltip(upgrade, {
|
addTooltip(upgrade, {
|
||||||
|
@ -139,6 +143,54 @@ export function createPlane(id: string, tier: Resources, seed: number) {
|
||||||
features.push(upgrades);
|
features.push(upgrades);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
const treasureWeights = {
|
||||||
|
dirtGeneration: 16
|
||||||
|
};
|
||||||
|
const sumTreasureWeights = Object.values(treasureWeights).reduce((a, b) => a + b);
|
||||||
|
const treasureWeightsKeys = Object.keys(
|
||||||
|
treasureWeights
|
||||||
|
) as (keyof typeof treasureWeights)[];
|
||||||
|
r = Math.floor(random() * sumTreasureWeights);
|
||||||
|
weight = 0;
|
||||||
|
let treasureType: keyof typeof treasureWeights | null = null;
|
||||||
|
for (let i = 0; i < treasureWeightsKeys.length; i++) {
|
||||||
|
const type = treasureWeightsKeys[i];
|
||||||
|
weight += treasureWeights[type];
|
||||||
|
if (r < weight) {
|
||||||
|
treasureType = type;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (treasureType == null) {
|
||||||
|
continue; // Should not happen
|
||||||
|
}
|
||||||
|
let description = "";
|
||||||
|
switch (treasureType) {
|
||||||
|
case "dirtGeneration":
|
||||||
|
description = `Gain ${format(difficulty)} dirt/s while plane is active`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const cost = Decimal.times(difficulty, random() + 0.5)
|
||||||
|
.pow_base(2)
|
||||||
|
.times(10)
|
||||||
|
.times(costFormula.evaluate());
|
||||||
|
const milestone = createAchievement(() => ({
|
||||||
|
requirements: createCostRequirement(() => ({
|
||||||
|
resource: noPersist(resource),
|
||||||
|
cost
|
||||||
|
})),
|
||||||
|
visibility,
|
||||||
|
display: {
|
||||||
|
requirement: `${format(cost)} ${resource.displayName}`,
|
||||||
|
effectDisplay: description
|
||||||
|
},
|
||||||
|
style: "width: 100%",
|
||||||
|
classes: {
|
||||||
|
final: i === length - 1
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
features.push([milestone]);
|
||||||
|
visibility = milestone.earned;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [resourceTab, resourceTabCollapsed] = createCollapsibleModifierSections(() => [
|
const [resourceTab, resourceTabCollapsed] = createCollapsibleModifierSections(() => [
|
||||||
|
|
Loading…
Reference in a new issue