Skip to content

Commit

Permalink
Merge pull request #24 from saertna/evolved-ui
Browse files Browse the repository at this point in the history
Evolved UI
  • Loading branch information
saertna authored Oct 22, 2023
2 parents 956cbcd + 1d10552 commit 16130ce
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 55 deletions.
97 changes: 70 additions & 27 deletions main.js

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions src/MultiSelectModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@ export class MultiSelectModal extends Modal {
this.gamificationInstance.setSetting(this.getBoosterVarNameFromName(booster), this.boosters[booster]);
this.gamificationInstance.setSettingBoolean(this.getBoosterSwitchFromName(booster), true);
this.gamificationInstance.setSettingString(this.getBoosterDateFromName(booster), window.moment().format('YYYY-MM-DD HH:mm:ss'));
const boosterOverallUse = this.gamificationInstance.getSetting('boosterUseCount')
if (typeof boosterOverallUse === 'number' && boosterOverallUse !== null) {
// Now you can safely assign boosterLastUsedDate to boosterLastUsedDate.
this.gamificationInstance.setSetting('boosterUseCount',boosterOverallUse + 1)
} else {
// Handle the case where boosterLastUsedDate is not a valid string.
console.debug(`decrementBooster: "boosterUseCount" could not got read.`)
}
const boosterUse = this.gamificationInstance.getSetting(this.getBoosterUseFromName(booster))
if (typeof boosterUse === 'number' && boosterUse !== null) {
// Now you can safely assign boosterLastUsedDate to boosterLastUsedDate.
this.gamificationInstance.setSetting(this.getBoosterUseFromName(booster),boosterUse + 1)
} else {
// Handle the case where boosterLastUsedDate is not a valid string.
console.debug(`decrementBooster: "${this.getBoosterUseFromName(booster)}" could not got read.`)
}
this.updateQuantityDisplay(booster);
}
} else {
Expand Down Expand Up @@ -515,4 +531,13 @@ export class MultiSelectModal extends Modal {
return 0; // Return null if no matching element is found
}

private getBoosterUseFromName(boosterName: string) {
for (const element of boosterRecipes) {
if (element.name === boosterName) {
return element.boosterUseCountName as string;
}
}
return ''; // Return null if no matching element is found
}

}
28 changes: 14 additions & 14 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const craftingItems = [
{ name: 'Hyperlink Harmony', incredients: ['2xS2', '1xS6'] },
];

export const listOfUseableBoostersToBeShown = ['Perpetual Progress', 'Title Titan', 'Precision Prism', 'Ephemeral Euphoria']
export const listOfUseableBoostersToBeShown = ['Perpetual Progress', 'Title Titan', 'Precision Prism']
export const listOfUseableIngredientsToBeShown = ['Connection Crystal', 'Insight Prism', 'Creative Catalyst', 'Precision Lens']
export const chanceToEarnIngredient = 0.5;

Expand All @@ -222,18 +222,18 @@ export const elements = [
];

export const boosterRecipes = [
{ boosterRunTime: 0, boosterCooldown: 0, boosterDate: '', boosterSwitch: '', varname: 'temporalTweaker' ,name: 'Temporal Tweaker', incredients: ['2xS1', '1xS6'], description: 'Temporal Tweaker: reset the cooldown phase for a booster your choice' },
{ boosterRunTime: 4*60, boosterCooldown: 36*60, boosterDate: 'boosterDatePerpetualProgress', boosterSwitch: 'boosterFactorPerpetualProgress', varname: 'perpetualProgress' ,name: 'Perpetual Progress', incredients: ['2xS2', '1xS4'], description: 'Perpetual Progress: get 3 times points an all your actions for the next 4 hours. You can use Perpetual Progress every three days, if you have the ingredients to craft it.' },
{ boosterRunTime: 4*60, boosterCooldown: 120*60, boosterDate: 'boosterDateStrategicSynapses', boosterSwitch: 'boosterFactorStrategicSynapses', varname: 'strategicSynapses' ,name: 'Strategic Synapses', incredients: ['3xS1', '2xS2'], description: 'Strategic Synapses: gain 3 times EP for all actions on Map Of Content ratings for the next 4 hours. This booster has a cooldown time of 5 days.' },
{ boosterRunTime: 0, boosterCooldown: 36*60, boosterDate: '', boosterSwitch: '', varname: 'acceleratedAcquisition' ,name: 'Accelerated Acquisition', incredients: ['1xS3', '2xS4'], description: 'Accelerated Acquisition: Use Accelerated Acquisition and collect much faster for the next 12 hours all sorts of ingredients when creating and improving notes' },
{ boosterRunTime: 3*60, boosterCooldown: 48*60, boosterDate: 'boosterDateLinkersLode', boosterSwitch: 'boosterFactorLinkersLode', varname: 'linkersLode' ,name: 'Linkers Lode', incredients: ['3xS2', '1xS1'], description: 'Linkers Lode: collect extra points when creating chain of thoughts for the next 3 hours. (cooldown 2 days)' },
{ boosterRunTime: 0, boosterCooldown: 480*60, boosterDate: '', boosterSwitch: '', varname: 'effortlessExpansion' ,name: 'Effortless Expansion', incredients: ['2xS3', '1xS6'], description: 'Effortless Expansion: Cast "Effortless Expansion" and lower the cap to the next level about 20% in the next 5 days. (Cooldown 20 days)' },
{ boosterRunTime: 5*60, boosterCooldown: 36*60, boosterDate: 'boosterDateRecursiveReflection', boosterSwitch: 'boosterFactorRecursiveReflection', varname: 'recursiveReflection' ,name: 'Recursive Reflection', incredients: ['2xS4', '1xS5'], description: 'Recursive Reflection: Improve your notes and get 5 times the points you get on normal condition for the next 5 hours. Cooldown 3 days.' },
{ boosterRunTime: 2*60, boosterCooldown: 36*60, boosterDate: 'boosterDateSynapticSurge', boosterSwitch: 'boosterFactorSynapticSurge', varname: 'synapticSurge' ,name: 'Synaptic Surge', incredients: ['2xS2', '1xS1'], description: 'Synaptic Surge: Link your ideas together, every increase in "linking maturity" pays out 20 times for the next 2 hours.' },
{ boosterRunTime: 0, boosterCooldown: 48*60, boosterDate: '', boosterSwitch: '', varname: 'inspirationInfusion' ,name: 'Inspiration Infusion', incredients: ['2xS7', '1xS1'], description: 'Inspiration Infusion: Increase the frequency to get helpful prompts to power up you personal knowledge management for the next 2 days.' },
{ boosterRunTime: 3*60, boosterCooldown: 36*60, boosterDate: 'boosterDateTitleTitan', boosterSwitch: 'boosterFactorTitleTitan', varname: 'titleTitan' ,name: 'Title Titan', incredients: ['2xS8', '1xS7'], description: 'Title Titan: Quadro your points when making your note title more to the point expressing the idea of your note for the next 3 hours.' },
{ boosterRunTime: 3*60, boosterCooldown: 36*60, boosterDate: 'boosterDatePrecisionPrism', boosterSwitch: 'boosterFactorPrecisionPrism', varname: 'precisionPrism' ,name: 'Precision Prism', incredients: ['2xS8', '1xS2'], description: 'Precision Prism: 4 times the points when increasing the "note length majurity" for a note the next 3 hours.' },
{ boosterRunTime: 3*60, boosterCooldown: 36*60, boosterDate: 'boosterDateHyperlinkHarmony', boosterSwitch: 'boosterFactorHyperlinkHarmony', varname: 'hyperlinkHarmony' ,name: 'Hyperlink Harmony', incredients: ['2xS2', '1xS6'], description: 'Hyperlink Harmony: Get for "Inlink majurity" AND "outlink majurity" improvements 5 times the point the next 3 hours.' },
{ boosterRunTime: 2*60, boosterCooldown: 2160*60, boosterDate: 'boosterDateEphemeralEuphoria', boosterSwitch: 'boosterFactorEphemeralEuphoria', varname: 'ephemeralEuphoria' ,name: 'Ephemeral Euphoria', incredients: ['1000xSX'], description: 'Unearth the hidden potential within your knowledge repository with the Ephemeral Euphoria booster. For a fleeting two-hour window, your notes will resonate with an extraordinary vitality, allowing you to earn points at an astonishing rate. Seize this moment of boundless opportunity and watch your knowledge flourish like never before! Be aware, you need in sum 1000 ingrediments to craft, ingrediments will be taken from all pots.' },
{ boosterUseCountName: 'boosterUseCountTemporalTweaker', boosterRunTime: 0, boosterCooldown: 0, boosterDate: '', boosterSwitch: '', varname: 'temporalTweaker' ,name: 'Temporal Tweaker', incredients: ['2xS1', '1xS6'], description: 'Temporal Tweaker: reset the cooldown phase for a booster your choice' },
{ boosterUseCountName: 'boosterUseCountPerpetualProgress', boosterRunTime: 4*60, boosterCooldown: 36*60, boosterDate: 'boosterDatePerpetualProgress', boosterSwitch: 'boosterFactorPerpetualProgress', varname: 'perpetualProgress' ,name: 'Perpetual Progress', incredients: ['2xS2', '1xS4'], description: 'Perpetual Progress: get 3 times points an all your actions for the next 4 hours. You can use Perpetual Progress every three days, if you have the ingredients to craft it.' },
{ boosterUseCountName: 'boosterUseCountStrategicSynapses', boosterRunTime: 4*60, boosterCooldown: 120*60, boosterDate: 'boosterDateStrategicSynapses', boosterSwitch: 'boosterFactorStrategicSynapses', varname: 'strategicSynapses' ,name: 'Strategic Synapses', incredients: ['3xS1', '2xS2'], description: 'Strategic Synapses: gain 3 times EP for all actions on Map Of Content ratings for the next 4 hours. This booster has a cooldown time of 5 days.' },
{ boosterUseCountName: 'boosterUseCountAcceleratedAcquisition', boosterRunTime: 0, boosterCooldown: 36*60, boosterDate: '', boosterSwitch: '', varname: 'acceleratedAcquisition' ,name: 'Accelerated Acquisition', incredients: ['1xS3', '2xS4'], description: 'Accelerated Acquisition: Use Accelerated Acquisition and collect much faster for the next 12 hours all sorts of ingredients when creating and improving notes' },
{ boosterUseCountName: 'boosterUseCountLinkersLode', boosterRunTime: 3*60, boosterCooldown: 48*60, boosterDate: 'boosterDateLinkersLode', boosterSwitch: 'boosterFactorLinkersLode', varname: 'linkersLode' ,name: 'Linkers Lode', incredients: ['3xS2', '1xS1'], description: 'Linkers Lode: collect extra points when creating chain of thoughts for the next 3 hours. (cooldown 2 days)' },
{ boosterUseCountName: 'boosterUseCountEffortlessExpansion', boosterRunTime: 0, boosterCooldown: 480*60, boosterDate: '', boosterSwitch: '', varname: 'effortlessExpansion' ,name: 'Effortless Expansion', incredients: ['2xS3', '1xS6'], description: 'Effortless Expansion: Cast "Effortless Expansion" and lower the cap to the next level about 20% in the next 5 days. (Cooldown 20 days)' },
{ boosterUseCountName: 'boosterUseCountrEcursiveReflection', boosterRunTime: 5*60, boosterCooldown: 36*60, boosterDate: 'boosterDateRecursiveReflection', boosterSwitch: 'boosterFactorRecursiveReflection', varname: 'recursiveReflection' ,name: 'Recursive Reflection', incredients: ['2xS4', '1xS5'], description: 'Recursive Reflection: Improve your notes and get 5 times the points you get on normal condition for the next 5 hours. Cooldown 3 days.' },
{ boosterUseCountName: 'boosterUseCountSynapticSurge', boosterRunTime: 2*60, boosterCooldown: 36*60, boosterDate: 'boosterDateSynapticSurge', boosterSwitch: 'boosterFactorSynapticSurge', varname: 'synapticSurge' ,name: 'Synaptic Surge', incredients: ['2xS2', '1xS1'], description: 'Synaptic Surge: Link your ideas together, every increase in "linking maturity" pays out 20 times for the next 2 hours.' },
{ boosterUseCountName: 'boosterUseCountInspirationInfusion', boosterRunTime: 0, boosterCooldown: 48*60, boosterDate: '', boosterSwitch: '', varname: 'inspirationInfusion' ,name: 'Inspiration Infusion', incredients: ['2xS7', '1xS1'], description: 'Inspiration Infusion: Increase the frequency to get helpful prompts to power up you personal knowledge management for the next 2 days.' },
{ boosterUseCountName: 'boosterUseCountTitleTitan', boosterRunTime: 3*60, boosterCooldown: 36*60, boosterDate: 'boosterDateTitleTitan', boosterSwitch: 'boosterFactorTitleTitan', varname: 'titleTitan' ,name: 'Title Titan', incredients: ['2xS8', '1xS7'], description: 'Title Titan: Quadro your points when making your note title more to the point expressing the idea of your note for the next 3 hours.' },
{ boosterUseCountName: 'boosterUseCountPrecisionPrism', boosterRunTime: 3*60, boosterCooldown: 36*60, boosterDate: 'boosterDatePrecisionPrism', boosterSwitch: 'boosterFactorPrecisionPrism', varname: 'precisionPrism' ,name: 'Precision Prism', incredients: ['2xS8', '1xS2'], description: 'Precision Prism: 4 times the points when increasing the "note length majurity" for a note the next 3 hours.' },
{ boosterUseCountName: 'boosterUseCountHyperlinkHarmony', boosterRunTime: 3*60, boosterCooldown: 36*60, boosterDate: 'boosterDateHyperlinkHarmony', boosterSwitch: 'boosterFactorHyperlinkHarmony', varname: 'hyperlinkHarmony' ,name: 'Hyperlink Harmony', incredients: ['2xS2', '1xS6'], description: 'Hyperlink Harmony: Get for "Inlink majurity" AND "outlink majurity" improvements 5 times the point the next 3 hours.' },
{ boosterUseCountName: 'boosterUseCountEphemeralEuphoria', boosterRunTime: 2*60, boosterCooldown: 2160*60, boosterDate: 'boosterDateEphemeralEuphoria', boosterSwitch: 'boosterFactorEphemeralEuphoria', varname: 'ephemeralEuphoria' ,name: 'Ephemeral Euphoria', incredients: ['1000xSX'], description: 'Unearth the hidden potential within your knowledge repository with the Ephemeral Euphoria booster. For a fleeting two-hour window, your notes will resonate with an extraordinary vitality, allowing you to earn points at an astonishing rate. Seize this moment of boundless opportunity and watch your knowledge flourish like never before! Be aware, you need in sum 1000 ingrediments to craft, ingrediments will be taken from all pots.' },
];

39 changes: 27 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,32 @@ export default class gamification extends Plugin {
//new ModalBooster(this.app, ` `, this).open();

this.acquireIngredients();


});
}

this.addRibbonIcon("test-tube-2", "Boosters", async () => {
//const file: TFile | null = this.app.workspace.getActiveFile();
new ModalBooster(this.app, ` `, this).open();
});
if(this.settings.counterMajurityCalcInitial >= 50){
this.addRibbonIcon("test-tube-2", "Boosters", async () => {
//const file: TFile | null = this.app.workspace.getActiveFile();
new ModalBooster(this.app, ` `, this).open();
});

this.addCommand({
id: 'boosters',
name: 'open booter pallete',
callback: async () => {
new ModalBooster(this.app, ` `, this).open();
},
});
}

this.addRibbonIcon("sprout", "Calculate Note Maturity", async () => {
//const file: TFile | null = this.app.workspace.getActiveFile();
await this.calculateNoteMajurity();
});

this.addCommand({
id: 'boosters',
name: 'open booter pallete',
callback: async () => {
new ModalBooster(this.app, ` `, this).open();
},
});


if (this.settings.enableInitCommand){
// command Initialize gamification ratings
Expand Down Expand Up @@ -436,6 +441,7 @@ export default class gamification extends Plugin {
const activeView = this.app.workspace.getActiveViewOfType(MarkdownView);
const fileContents = activeView?.editor.getValue();
const fileName = activeView?.file.basename;


let rateFileLength = 0;
let fileLength = 0;
Expand Down Expand Up @@ -464,7 +470,12 @@ export default class gamification extends Plugin {
rateOut = rateOutlinks(getNumberOfOutlinks(file));

const noteMajurity = rateLevelOfMaturity(rateFileLength, fileNameRate, inlinkClass, rateOut, rateProgressiveSum);




this.setSetting('counterMajurityCalc',this.settings.counterMajurityCalc + 1)


try {
await this.app.fileManager.processFrontMatter(file, (frontmatter) => {
if (frontmatter) {
Expand All @@ -481,6 +492,10 @@ export default class gamification extends Plugin {
pointsReceived += pointsToReceived;
this.decisionIfBadge(newLevel);
detectIfNoteIsFirstTimeRated = true;
this.setSetting('counterMajurityCalcInitial',this.settings.counterMajurityCalcInitial + 1)
if(this.settings.counterMajurityCalcInitial == 50){
new ModalInformationbox(this.app, `🚀 Introducing Boosters! 🚀Level up faster, you enabled the next stage! Craft Boosters for an accelerated knowledge journey. Click the "test-tube" on the right or type 'Open Booster Palette' to get started! you got one booster as a gift, so try it out!🌟📚🔍`).open();
}
}

if (rateDirectionForStatusPoints(frontmatter['title-class'], fileNameRate) >= 1 && 'title-class' in frontmatter){
Expand Down
52 changes: 50 additions & 2 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const defaultSettings: Partial<ISettings> = {
creativeCatalyst: 0,
precisionLens: 0,
temporalTweaker: 0,
perpetualProgress: 0,
perpetualProgress: 1,
strategicSynapses: 0,
acceleratedAcquisition: 0,
linkersLode: 0,
Expand Down Expand Up @@ -65,7 +65,23 @@ export const defaultSettings: Partial<ISettings> = {
boosterFactorEphemeralEuphoria: false,
boosterDateEphemeralEuphoria: '2022-08-15 20:00:00',
streakbooster: 0,
streakboosterDate: false
streakboosterDate: false,
boosterUseCount: 0,
boosterUseCountTemporalTweaker: 0,
boosterUseCountPerpetualProgress: 0,
boosterUseCountStrategicSynapses: 0,
boosterUseCountAcceleratedAcquisition: 0,
boosterUseCountLinkersLode: 0,
boosterUseCountEffortlessExpansion: 0,
boosterUseCountrEcursiveReflection: 0,
boosterUseCountSynapticSurge: 0,
boosterUseCountInspirationInfusion: 0,
boosterUseCountTitleTitan: 0,
boosterUseCountPrecisionPrism: 0,
boosterUseCountHyperlinkHarmony: 0,
boosterUseCountEphemeralEuphoria: 0,
counterMajurityCalc: 0,
counterMajurityCalcInitial: 0
};

export interface DynamicSettings {
Expand Down Expand Up @@ -136,6 +152,22 @@ export interface ISettings extends DynamicSettings{
boosterDateHyperlinkHarmony: string;
boosterFactorEphemeralEuphoria: boolean;
boosterDateEphemeralEuphoria: string;
boosterUseCount: number;
boosterUseCountTemporalTweaker: number;
boosterUseCountPerpetualProgress: number;
boosterUseCountStrategicSynapses: number;
boosterUseCountAcceleratedAcquisition: number;
boosterUseCountLinkersLode: number;
boosterUseCountEffortlessExpansion: number;
boosterUseCountrEcursiveReflection: number;
boosterUseCountSynapticSurge: number;
boosterUseCountInspirationInfusion: number;
boosterUseCountTitleTitan: number;
boosterUseCountPrecisionPrism: number;
boosterUseCountHyperlinkHarmony: number;
boosterUseCountEphemeralEuphoria: number;
counterMajurityCalc: number;
counterMajurityCalcInitial: number;
//[key: string]: number | string | boolean | MomentInput;
}

Expand Down Expand Up @@ -207,6 +239,22 @@ export class GamificationPluginSettings extends PluginSettingTab {
public boosterDateHyperlinkHarmony: string;
public boosterFactorEphemeralEuphoria: boolean;
public boosterDateEphemeralEuphoria: string;
public boosterUseCount: number;
public boosterUseCountTemporalTweaker: number;
public boosterUseCountPerpetualProgress: number;
public boosterUseCountStrategicSynapses: number;
public boosterUseCountAcceleratedAcquisition: number;
public boosterUseCountLinkersLode: number;
public boosterUseCountEffortlessExpansion: number;
public boosterUseCountrEcursiveReflection: number;
public boosterUseCountSynapticSurge: number;
public boosterUseCountInspirationInfusion: number;
public boosterUseCountTitleTitan: number;
public boosterUseCountPrecisionPrism: number;
public boosterUseCountHyperlinkHarmony: number;
public boosterUseCountEphemeralEuphoria: number;
public counterMajurityCalc: number;
public counterMajurityCalcInitial: number;

constructor(app: App, plugin: gamification) {
super(app, plugin);
Expand Down

0 comments on commit 16130ce

Please sign in to comment.