Skip to content

Commit

Permalink
pseudo VC reset
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-vorobiov committed Oct 18, 2024
1 parent c89f240 commit 3f79a76
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 8 deletions.
33 changes: 32 additions & 1 deletion demo/history.5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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]]
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion evolve_analytics.meta.js
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
11 changes: 10 additions & 1 deletion src/exports/historyFiltering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down
18 changes: 17 additions & 1 deletion src/ui/viewSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 10 additions & 4 deletions src/ui/viewTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions test/historyFiltering.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 3f79a76

Please sign in to comment.