diff --git a/demo/history.5.js b/demo/history.5.js index dfd1b5e..e976f0f 100644 --- a/demo/history.5.js +++ b/demo/history.5.js @@ -11,7 +11,8 @@ const history = { "event:womlings": 8, "tech:elerium_tech": 9, "built:space-iridium_ship:1": 10, - "tech:world_collider": 11 + "tech:world_collider": 11, + "reset:blackhole": 12 }, "runs": [ { @@ -974,6 +975,36 @@ const history = { "run": 570, "universe": "heavy", "milestones": [[8, 78], [0, 97], [1, 200], [2, 268], [3, 381], [4, 520], [5, 564], [6, 576], [7, 599]] + }, + { + "run": 571, + "universe": "heavy", + "milestones": [[12, 123]] + }, + { + "run": 572, + "universe": "magic", + "milestones": [[12, 234]] + }, + { + "run": 573, + "universe": "evil", + "milestones": [[12, 345]] + }, + { + "run": 574, + "universe": "heavy", + "milestones": [[12, 456]] + }, + { + "run": 575, + "universe": "magic", + "milestones": [[12, 567]] + }, + { + "run": 576, + "universe": "evil", + "milestones": [[12, 678]] } ] }; diff --git a/evolve_analytics.meta.js b/evolve_analytics.meta.js index f5e5004..30bb2bf 100644 --- a/evolve_analytics.meta.js +++ b/evolve_analytics.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Evolve Analytics // @namespace http://tampermonkey.net/ -// @version 0.6.6 +// @version 0.7.0 // @description Track and see detailed information about your runs // @author Sneed // @match https://pmotschmann.github.io/Evolve/ diff --git a/src/exports/historyFiltering.ts b/src/exports/historyFiltering.ts index 65d0127..e9ca08c 100644 --- a/src/exports/historyFiltering.ts +++ b/src/exports/historyFiltering.ts @@ -4,7 +4,11 @@ import type { ViewConfig } from "../config"; function getResetType(entry: HistoryEntry, history: HistoryManager) { const [milestoneID] = entry.milestones[entry.milestones.length - 1]; const milestone = history.getMilestone(milestoneID); - return milestone.slice(6); // strip away the leading "reset:" + + const prefix = "reset:"; + if (milestone.startsWith(prefix)) { + return milestone.slice(prefix.length); + } } export function shouldIncludeRun(entry: HistoryEntry, view: ViewConfig, history: HistoryManager) { @@ -16,6 +20,11 @@ export function shouldIncludeRun(entry: HistoryEntry, view: ViewConfig, history: return false; } + // Don't show VC runs in generic Black Hole views + if (view.resetType === "blackhole" && view.universe === undefined) { + return entry.universe !== "magic"; + } + return true; } diff --git a/src/ui/viewSettings.ts b/src/ui/viewSettings.ts index 0c8f349..02deebb 100644 --- a/src/ui/viewSettings.ts +++ b/src/ui/viewSettings.ts @@ -11,9 +11,25 @@ export function makeViewSettings(view: View) { .css("width", "150px") .on("change", function(this: HTMLInputElement) { view.resetType = this.value as keyof typeof resets; }); + function updateResetTypes(universe: string) { + resetTypeInput.find(`> option[value="blackhole"]`).text(universe === "magic" ? "Vacuum Collapse" : "Black Hole"); + } + + // In case an existing view is blackhole + magic + updateResetTypes(view.universe ?? "any"); + const universeInput = makeSelect([["any", "Any"], ...Object.entries(universes)], view.universe ?? "any") .css("width", "150px") - .on("change", function(this: HTMLSelectElement) { view.universe = this.value === "any" ? undefined : this.value as keyof typeof universes; }); + .on("change", function(this: HTMLSelectElement) { + updateResetTypes(this.value); + + if (this.value === "any") { + view.universe = undefined; + } + else { + view.universe = this.value as keyof typeof universes; + } + }); const modeInput = makeSelect(Object.entries(viewModes), view.mode) .css("width", "150px") diff --git a/src/ui/viewTab.ts b/src/ui/viewTab.ts index dd74602..5aae47b 100644 --- a/src/ui/viewTab.ts +++ b/src/ui/viewTab.ts @@ -62,12 +62,18 @@ async function copyToClipboard(node: JQuery) { } function viewTitle(view: View) { - let title = resets[view.resetType]; - if (view.universe !== undefined) { - title += ` (${universes[view.universe as keyof typeof universes]})`; + if (view.universe === "magic" && view.resetType === "blackhole") { + return "Vacuum Collapse"; } + else { + let title = resets[view.resetType]; - return title; + if (view.universe !== undefined) { + title += ` (${universes[view.universe as keyof typeof universes]})`; + } + + return title; + } } export function makeViewTab(id: string, view: View, config: ConfigManager, history: HistoryManager) { diff --git a/test/historyFiltering.test.ts b/test/historyFiltering.test.ts index feffc48..8671f64 100644 --- a/test/historyFiltering.test.ts +++ b/test/historyFiltering.test.ts @@ -72,6 +72,27 @@ describe("Export", () => { ]); }); + it("should not show vacuum collapse runs if universe is not specified", () => { + const game = new Game(makeGameState({})); + const history = makeHistory(game, { + milestones: { "reset:blackhole": 1 }, + runs: [ + { run: 1, universe: "standard", milestones: [[1, 10]] }, + { run: 2, universe: "heavy", milestones: [[1, 10]] }, + { run: 3, universe: "magic", milestones: [[1, 10]] } + ] + }); + + expect(applyFilters(history, makeView({ resetType: "blackhole" }))).toEqual([ + history.runs[0], + history.runs[1] + ]); + + expect(applyFilters(history, makeView({ resetType: "blackhole", universe: "magic" }))).toEqual([ + history.runs[2] + ]); + }); + it("should filter last N runs", () => { const game = new Game(makeGameState({})); const history = makeHistory(game, {