Skip to content

Commit

Permalink
variables for streakbooster
Browse files Browse the repository at this point in the history
  • Loading branch information
saertna committed Oct 18, 2023
1 parent f33451b commit 1b28467
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
13 changes: 8 additions & 5 deletions main.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ export const pointsNoteMajurity = 100;
export const pointsMajurity = 10;
export const pointsForDailyChallenge = 500;
export const pointsForWeeklyChallenge = 2000;
export const streakboosterDecrease = 0.2;
export const streakboosterIncreaseDaily = 0.1;
export const streakboosterIncreaseWeekly = 1;
export const avatarInitContent = `# Avatar
| | |
Expand Down
14 changes: 9 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
pointsMajurity,
pointsNoteMajurity,
pointsForDailyChallenge,
pointsForWeeklyChallenge
pointsForWeeklyChallenge,
streakboosterDecrease,
streakboosterIncreaseDaily,
streakboosterIncreaseWeekly
} from './constants'
import {
count_inlinks,
Expand Down Expand Up @@ -42,6 +45,7 @@ export default class gamification extends Plugin {
private statusBarItem = this.addStatusBarItem();
private statusbarGamification = this.statusBarItem.createEl("span", { text: "" });


async onload() {
console.log('obsidian-pkm-gamification loaded!');

Expand Down Expand Up @@ -520,7 +524,7 @@ export default class gamification extends Plugin {
await this.updateAvatarPage(this.settings.avatarPageName);
console.log(`${newDailyNoteCreationTask}/2 Notes created today.`)
} else if (newDailyNoteCreationTask == 2) {
this.increaseStreakbooster(0.1)
this.increaseStreakbooster(streakboosterIncreaseDaily)
//this.settings.streakboosterDate = window.moment().format('DD.MM.YYYY');
await this.saveSettings();
await this.updateStatusBar(this.statusbarGamification)
Expand Down Expand Up @@ -567,7 +571,7 @@ export default class gamification extends Plugin {
await this.updateAvatarPage(this.settings.avatarPageName);
console.log(`${newWeeklyNoteCreationTask}/7 Notes created in a chain.`)
} else if (newWeeklyNoteCreationTask == 7) {
this.increaseStreakbooster(1);
this.increaseStreakbooster(streakboosterIncreaseWeekly);
//this.settings.streakboosterDate = window.moment().format('DD.MM.YYYY');
await this.saveSettings();
await this.giveStatusPoints(pointsForWeeklyChallenge)
Expand Down Expand Up @@ -642,7 +646,7 @@ export default class gamification extends Plugin {
}

async increaseStreakbooster(increaseValue:number){
let newBoosterFakfor = parseFloat((this.settings.streakbooster + increaseValue).toFixed(1));
let newBoosterFakfor = parseFloat((this.settings.streakbooster + increaseValue).toFixed(streakboosterIncreaseWeekly));
if(newBoosterFakfor > 80){
newBoosterFakfor = 80;
}
Expand All @@ -654,7 +658,7 @@ export default class gamification extends Plugin {


async decreaseStreakbooster(decreaseValue:number){
let newBoosterFakfor = parseFloat((this.settings.streakbooster - decreaseValue).toFixed(1))
let newBoosterFakfor = parseFloat((this.settings.streakbooster - decreaseValue).toFixed(streakboosterDecrease))
this.settings.streakbooster = newBoosterFakfor
if (newBoosterFakfor < 0){
newBoosterFakfor = 0
Expand Down

0 comments on commit 1b28467

Please sign in to comment.