From d3520ed9a253e43faee7ff29079ef0cd535d2587 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 30 Apr 2023 15:52:28 -0500 Subject: [PATCH] Prevent duplicate influences --- src/data/planes.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/data/planes.tsx b/src/data/planes.tsx index d9be0e6..875cdee 100644 --- a/src/data/planes.tsx +++ b/src/data/planes.tsx @@ -38,6 +38,9 @@ import { } from "./projEntry"; import type { ResourceState, Resources, PortalState } from "./projEntry"; import { getColor, getName, sfc32 } from "./utils"; +import { useToast } from "vue-toastification"; + +const toast = useToast(); export type Treasure = GenericAchievement & { update?: (diff: number) => void; @@ -68,7 +71,7 @@ export function createPlane( if (influences.some(i => i.type === "decreaseDiff")) { difficultyRand = difficultyRand / 2; } - const difficulty = random() + tierIndex + 1; + const difficulty = difficultyRand + tierIndex + 1; const rewardsLevel = influences.some(i => i.type === "increaseRewards") ? difficulty + 1 : difficulty; @@ -408,6 +411,14 @@ export function createPlane( influenceTreasures.push(randomInfluence); description = `Gain a new portal influence`; onComplete = () => { + if (randomInfluence in main.influenceNodes.value) { + toast.warning( + "Error: ignoring duplicate portal influence (" + + influenceTypes[randomInfluence].display + + ")" + ); + return; + } const node = { id: getUniqueNodeID(main.board), position: {