fix saving performance to file bug + add use of weighted pp

This commit is contained in:
Louie Sebastian Kurenai 2026-03-09 20:34:00 +08:00
parent b29765c2ee
commit a3a329b50e
3 changed files with 8 additions and 3 deletions

View file

@ -3,9 +3,11 @@
// import { PerformanceEntry } from "../interfaces/performanceEntry";
// import { getTopPerformanceEntries } from "./getTopPerformanceEntries";
import PerformiumPlugin from "../main";
import { getWeightedPP } from "./weightPP";
import { App } from "obsidian";
// it may not be used or i don't know.
export function generateFact(plugin: PerformiumPlugin): string {
export async function generateFact(plugin: PerformiumPlugin, app: App): Promise<string> {
const array = [
`As of January 22, 2026, the old fun facts were removed in favor of the new ones!`,
`As of this update, Performium is being developed in Arch Linux!`,
@ -52,6 +54,9 @@ export function generateFact(plugin: PerformiumPlugin): string {
// count the total number of text lines
array.push(`There are a total of ${array.length + 1} fun facts to encounter! Try to find them all!`);
// make use of the newly-made weighted pp
array.push(`From all the performance calculations you have executed, weighting them all would give you a total amount of ${new Intl.NumberFormat().format(Math.trunc(await getWeightedPP(app)))}`);
let fact: string = array[Math.floor(Math.random() * array.length)];
return fact;
}

View file

@ -1,7 +1,7 @@
import { App } from "obsidian";
export async function savePerformanceToFile(app: App, value: number) {
const filePath = `.${app.vault.configDir}/pp-entries.json`;
const filePath = `${app.vault.configDir}/pp-entries.json`;
const adapter = app.vault.adapter;
const now = new Date();

View file

@ -123,7 +123,7 @@ export class PerformiumSettingsTab extends PluginSettingTab {
// const installTimestamp = this.plugin.settings.installTimestamp ?? Date.now();
let factText: string = generateFact(this.plugin);
let factText: string = await generateFact(this.plugin, this.app);
// const totalTime = installTimestamp - Date.now();