Skip to content

Commit

Permalink
Connected booster conditions with givePoints
Browse files Browse the repository at this point in the history
  • Loading branch information
saertna committed Oct 21, 2023
1 parent f29f413 commit 8c33a2b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 69 deletions.
70 changes: 35 additions & 35 deletions main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export const boosterRecipes = [
{ 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 you note for the next 3 hours.' },
{ 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.' },
Expand Down
67 changes: 34 additions & 33 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export default class gamification extends Plugin {
this.settings.badgeBoosterState = false
this.settings.badgeBoosterFactor = 1
await this.saveData(this.settings);
await this.giveStatusPoints(0)
await this.giveStatusPoints(0,'')
await this.updateStatusBar(this.statusbarGamification)
new ModalInformationbox(this.app, `Game is now reseted. Please delete the Profile Page: "${this.settings.avatarPageName}.md" manually.`).open();
}
Expand Down Expand Up @@ -311,50 +311,50 @@ export default class gamification extends Plugin {
await this.app.fileManager.processFrontMatter(file, (frontmatter) => {
if (rateDirectionForStatusPoints(frontmatter['note-maturity'], noteMajurity) >= 1) {
pointsReceived += pointsNoteMajurity * rateDirectionForStatusPoints(frontmatter['note-maturity'], noteMajurity)
this.giveStatusPoints(pointsNoteMajurity * rateDirectionForStatusPoints("frontmatter['note-maturity']", noteMajurity))
this.giveStatusPoints(pointsNoteMajurity * rateDirectionForStatusPoints("frontmatter['note-maturity']", noteMajurity),'fromNoteMajurity')
} else if (!('note-maturity' in frontmatter)) {
pointsReceived += pointsNoteMajurity * rateDirectionForStatusPoints("0", noteMajurity)
this.giveStatusPoints(pointsNoteMajurity * rateDirectionForStatusPoints("0", noteMajurity))
this.giveStatusPoints(pointsNoteMajurity * rateDirectionForStatusPoints("0", noteMajurity),'fromNoteMajurityFirstTime')
}

if (rateDirectionForStatusPoints(frontmatter['title-class'], fileNameRate) >= 1 && 'title-class' in frontmatter) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints(frontmatter['title-class'], fileNameRate)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['title-class'], fileNameRate))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['title-class'], fileNameRate),'fromTitleClass')
} else if (!('title-class' in frontmatter)) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints("0", fileNameRate)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", fileNameRate))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", fileNameRate),'fromTitleClassFirstTime')
}

if (rateDirectionForStatusPoints(frontmatter['note-length-class'], rateFileLength) >= 1) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints(frontmatter['note-length-class'], rateFileLength)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['note-length-class'], rateFileLength))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['note-length-class'], rateFileLength),'fromNoteLengthClass')
} else if (!('note-length-class' in frontmatter)) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints("0", rateFileLength)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateFileLength))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateFileLength),'fromNoteLengthClassFirstTime')
}

if (rateDirectionForStatusPoints(frontmatter['inlink-class'], inlinkClass) >= 1) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints(frontmatter['inlink-class'], inlinkClass)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['inlink-class'], inlinkClass))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['inlink-class'], inlinkClass),'fromInlinkClass')
} else if (!('inlink-class' in frontmatter)) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints("0", inlinkClass)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", inlinkClass))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", inlinkClass),'fromInlinkClassFirstTime')
}

if (rateDirectionForStatusPoints(frontmatter['outlink-class'], rateOut) >= 1) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints(frontmatter['outlink-class'], rateOut)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['outlink-class'], rateOut))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['outlink-class'], rateOut),'fromOutlinkClass')
} else if (!('outlink-class' in frontmatter)) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints("0", rateOut)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateOut))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateOut),'fromOutlinkClassFirstTime')
}

if (rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum) >= 1) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum),'fromProgressiveTummarizationMaturity')
} else if (!('progressive-summarization-maturity' in frontmatter)) {
pointsReceived += pointsMajurity * rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum)
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateProgressiveSum))
this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateProgressiveSum),'fromProgressiveTummarizationMaturityFirstTime')

}

Expand Down Expand Up @@ -462,62 +462,62 @@ export default class gamification extends Plugin {
if (rateDirectionForStatusPoints(frontmatter['note-maturity'], noteMajurity) >= 1){
console.log(`note-maturity >=1`)
pointsReceived += pointsNoteMajurity*rateDirectionForStatusPoints(frontmatter['note-maturity'], noteMajurity)
const newLevel = this.giveStatusPoints(pointsNoteMajurity * rateDirectionForStatusPoints("frontmatter['note-maturity']", noteMajurity))
const newLevel = this.giveStatusPoints(pointsNoteMajurity * rateDirectionForStatusPoints("frontmatter['note-maturity']", noteMajurity),'fromNoteMajurity')
this.decisionIfBadge(newLevel)
} else if (!('note-maturity' in frontmatter)){
pointsReceived += pointsNoteMajurity*rateDirectionForStatusPoints("0", noteMajurity)
const newLevel = this.giveStatusPoints(pointsNoteMajurity * rateDirectionForStatusPoints("0", noteMajurity))
const newLevel = this.giveStatusPoints(pointsNoteMajurity * rateDirectionForStatusPoints("0", noteMajurity),'fromNoteMajurityFirstTime')
this.decisionIfBadge(newLevel);
detectIfNoteIsFirstTimeRated = true;
}

if (rateDirectionForStatusPoints(frontmatter['title-class'], fileNameRate) >= 1 && 'title-class' in frontmatter){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints(frontmatter['title-class'], fileNameRate)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['title-class'], fileNameRate))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['title-class'], fileNameRate),'fromTitleClass')
this.decisionIfBadge(newLevel)
} else if (!('title-class' in frontmatter)){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints("0", fileNameRate)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", fileNameRate))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", fileNameRate),'fromTitleClassFirstTime')
this.decisionIfBadge(newLevel)
}

if (rateDirectionForStatusPoints(frontmatter['note-length-class'], rateFileLength) >= 1){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints(frontmatter['note-length-class'], rateFileLength)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['note-length-class'], rateFileLength))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['note-length-class'], rateFileLength),'fromNoteLengthClass')
this.decisionIfBadge(newLevel)
}else if (!('note-length-class' in frontmatter)){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints("0", rateFileLength)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateFileLength))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateFileLength),'fromNoteLengthClassFirstTime')
this.decisionIfBadge(newLevel)
}

if (rateDirectionForStatusPoints(frontmatter['inlink-class'], inlinkClass) >= 1){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints(frontmatter['inlink-class'], inlinkClass)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['inlink-class'], inlinkClass))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['inlink-class'], inlinkClass),'fromInlinkClass')
this.decisionIfBadge(newLevel)
}else if (!('inlink-class' in frontmatter)){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints("0", inlinkClass)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", inlinkClass))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", inlinkClass),'fromInlinkClassFirstTime')
this.decisionIfBadge(newLevel)
}

if (rateDirectionForStatusPoints(frontmatter['outlink-class'], rateOut) >= 1){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints(frontmatter['outlink-class'], rateOut)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['outlink-class'], rateOut))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['outlink-class'], rateOut),'fromOutlinkClass')
this.decisionIfBadge(newLevel)
}else if (!('outlink-class' in frontmatter)){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints("0", rateOut)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateOut))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateOut),'fromOutlinkClassFirstTime')
this.decisionIfBadge(newLevel)
}

if (rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum) >= 1){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum),'fromProgressiveTummarizationMaturity')
this.decisionIfBadge(newLevel)
}else if (!('progressive-summarization-maturity' in frontmatter)){
pointsReceived += pointsMajurity*rateDirectionForStatusPoints(frontmatter['progressive-summarization-maturity'], rateProgressiveSum)
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateProgressiveSum))
const newLevel = this.giveStatusPoints(pointsMajurity * rateDirectionForStatusPoints("0", rateProgressiveSum),'fromProgressiveTummarizationMaturityFirstTime')
this.decisionIfBadge(newLevel)
}
console.log(`pointsReceived: ${pointsReceived}`)
Expand Down Expand Up @@ -640,7 +640,7 @@ export default class gamification extends Plugin {
//this.settings.streakboosterDate = window.moment().format('DD.MM.YYYY');
await this.saveSettings();
await this.updateStatusBar(this.statusbarGamification)
await this.giveStatusPoints(pointsForDailyChallenge)
await this.giveStatusPoints(pointsForDailyChallenge,'formIncreaseDailyCreatedNoteCount')
const message = getRandomMessageTwoNoteChallenge(pointsForDailyChallenge * (this.settings.badgeBoosterFactor + this.settings.streakbooster));
console.log(`daily Challenge reached! ${newDailyNoteCreationTask}/2 created.`)
new Notice(message,4000)
Expand Down Expand Up @@ -689,7 +689,7 @@ export default class gamification extends Plugin {
this.increaseStreakbooster(streakboosterIncreaseWeekly);
//this.settings.streakboosterDate = window.moment().format('DD.MM.YYYY');
await this.saveSettings();
await this.giveStatusPoints(pointsForWeeklyChallenge)
await this.giveStatusPoints(pointsForWeeklyChallenge, 'fromCheckForWeeklyNoteChallengeEvaluation')
console.log(`Weekly Challenge reached! ${newWeeklyNoteCreationTask}/7 created in a chain.`)
const message = getRandomMessageWeeklyChallenge(pointsForWeeklyChallenge * (this.settings.badgeBoosterFactor + this.settings.streakbooster));
new Notice(message,4000)
Expand Down Expand Up @@ -751,7 +751,7 @@ export default class gamification extends Plugin {
}


async giveStatusPoints(pointsToAdd: number): Promise<boolean>{
async giveStatusPoints(pointsToAdd: number, caller: string): Promise<boolean>{
let boosterFactor = 1;
let streakbooster = this.settings.streakbooster;
let boosterFactorPerpetualProgress = 0;
Expand All @@ -763,6 +763,7 @@ export default class gamification extends Plugin {
let boosterFactorPrecisionPrism = 0;
let boosterFactorHyperlinkHarmony = 0;
let boosterFactorEphemeralEuphoria = 0;

if (this.settings.badgeBoosterState){
boosterFactor = this.settings.badgeBoosterFactor;
}
Expand All @@ -775,19 +776,19 @@ export default class gamification extends Plugin {
if (this.settings.boosterFactorLinkersLode){
boosterFactorLinkersLode = 10;
}
if (this.settings.boosterFactorRecursiveReflection){
if (this.settings.boosterFactorRecursiveReflection && ( caller == 'fromNoteMajurity' || caller == 'fromTitleClass' || caller == 'fromNoteLengthClass' || caller == 'fromInlinkClass' || caller == 'fromOutlinkClass' || caller == 'fromProgressiveTummarizationMaturity')){
boosterFactorRecursiveReflection = 5;
}
if (this.settings.boosterFactorSynapticSurge){
if (this.settings.boosterFactorSynapticSurge && (caller == 'fromInlinkClass' || caller == 'fromOutlinkClass')){
boosterFactorSynapticSurge = 20;
}
if (this.settings.boosterFactorTitleTitan){
if (this.settings.boosterFactorTitleTitan && caller == 'fromTitleClass'){
boosterFactorTitleTitan = 4;
}
if (this.settings.boosterFactorPrecisionPrism){
if (this.settings.boosterFactorPrecisionPrism && caller == 'fromNoteLengthClass'){
boosterFactorPrecisionPrism = 4;
}
if (this.settings.boosterFactorHyperlinkHarmony){
if (this.settings.boosterFactorHyperlinkHarmony && (caller == 'fromInlinkClass' || caller == 'fromOutlinkClass')){
boosterFactorHyperlinkHarmony = 5;
}
if (this.settings.boosterFactorEphemeralEuphoria){
Expand Down

0 comments on commit 8c33a2b

Please sign in to comment.