From 84a83c4c788c2b08cab38e074c22d26492a19263 Mon Sep 17 00:00:00 2001 From: saertna <83655354+saertna@users.noreply.github.com> Date: Wed, 20 Mar 2024 21:14:11 +0100 Subject: [PATCH 1/6] secure streakboster milestones --- src/Messages.ts | 3 ++- src/main.ts | 28 ++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Messages.ts b/src/Messages.ts index 2d7d3d7..01f1e5d 100644 --- a/src/Messages.ts +++ b/src/Messages.ts @@ -16,7 +16,8 @@ I develop this plugin as a hobby, spending my free time doing this. If you find "0.0.89": ` ## New - Introduction to Release Note showcase -- Added automatic triggering of rate, can be enabled in settings`, +- Added automatic triggering of rate, can be enabled in settings +- booster factor is not going below a multiple of 5. Means, whenever you reach a multiple of 5, it's a secured milestone.`, "0.0.88":` ## Changed - Support more levels, up to 200, and fix incorrect calculations diff --git a/src/main.ts b/src/main.ts index 2011975..4cd5bd9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -31,7 +31,7 @@ import { rateOutlinks, rateProgressiveSummarization } from './maturitycalculation' -import {Badge, checkIfReceiveABadge, getBadge, getBadgeDetails, getBadgeForInitLevel, getBadgeForLevel} from './badges' +import {Badge, checkIfReceiveABadge, getBadge, getBadgeForInitLevel, getBadgeForLevel} from './badges' import {getLevelForPoints, statusPointsForLevel} from './levels' import { getRandomMessagePoints, @@ -220,13 +220,15 @@ export default class gamification extends Plugin implements GamificationMediator //await this.checkForContinuouslyNoteCreation(180) //const obsidianJustInstalled = this.settings.previousRelease === "0.0.0" - new ReleaseNotes( - this.app, - this, - //obsidianJustInstalled ? null : - PLUGIN_VERSION - ).open(); + // new ReleaseNotes( + // this.app, + // this, + // //obsidianJustInstalled ? null : + // PLUGIN_VERSION + // ).open(); + + await this.decreaseStreakbooster(50); //this.setBadgeSave(getBadgeDetails('Brainiac Trailblazer'),'23-09-07', 'level 20'); //this.setBadgeSave(getBadgeDetails('Savvy Scholar'), '23-08-15', 'level 15'); }); @@ -1027,7 +1029,17 @@ export default class gamification extends Plugin implements GamificationMediator async decreaseStreakbooster(decreaseValue:number){ - let newBoosterFakfor = parseFloat((this.getSettingNumber('streakbooster') - decreaseValue * streakboosterDecrease).toFixed(1)) + //let newBoosterFakfor = parseFloat((this.getSettingNumber('streakbooster') - decreaseValue * streakboosterDecrease).toFixed(1)) + const currentValue = this.getSettingNumber('streakbooster'); + let newBoosterFakfor; + if (streakboosterDecrease >= currentValue % 5) { + // If streakboosterDecrease is greater than or equal to the difference to the next multiple of 5 + newBoosterFakfor = Math.floor(currentValue / 5) * 5; // Round down to the nearest multiple of 5 + } else { + // If streakboosterDecrease is smaller than the difference to the next multiple of 5 + newBoosterFakfor = currentValue - (currentValue % 5 - streakboosterDecrease); // Subtract the difference + } + this.setSettingNumber('streakbooster', newBoosterFakfor) if (newBoosterFakfor < 0){ newBoosterFakfor = 0 From 62b666ab028db5358880ac3bac8c484c78458131 Mon Sep 17 00:00:00 2001 From: saertna <83655354+saertna@users.noreply.github.com> Date: Wed, 20 Mar 2024 21:16:48 +0100 Subject: [PATCH 2/6] refactor --- src/main.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 4cd5bd9..15e204a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1014,13 +1014,13 @@ export default class gamification extends Plugin implements GamificationMediator } async increaseStreakbooster(increaseValue:number){ - let newBoosterFakfor = parseFloat((this.getSettingNumber('streakbooster') + increaseValue).toFixed(1)); - if(newBoosterFakfor > 80){ - newBoosterFakfor = 80; + let newBoosterFactor = parseFloat((this.getSettingNumber('streakbooster') + increaseValue).toFixed(1)); + if(newBoosterFactor > 80){ + newBoosterFactor = 80; } - if(debugLogs) console.debug(`newBoosterFakfor: ${newBoosterFakfor}`) + if(debugLogs) console.debug(`newBoosterFakfor: ${newBoosterFactor}`) //if(debugLogs) console.debug(`old value streakbooster: ${this.getSettingNumber('streakbooster')}`) - this.setSettingNumber('streakbooster', newBoosterFakfor); + this.setSettingNumber('streakbooster', newBoosterFactor); this.setSettingBoolean('streakboosterDate', true); //if(debugLogs) console.debug(`new value streakbooster: ${this.getSettingNumber('streakbooster')}`) //await this.saveData(this.settings) From fb6c7da76671ceb7d54347a4b0da41a442a51b38 Mon Sep 17 00:00:00 2001 From: saertna <83655354+saertna@users.noreply.github.com> Date: Wed, 20 Mar 2024 21:23:29 +0100 Subject: [PATCH 3/6] check if new booster factor crosses multiple of 5 --- src/main.ts | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main.ts b/src/main.ts index 15e204a..de49f57 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1013,19 +1013,28 @@ export default class gamification extends Plugin implements GamificationMediator } - async increaseStreakbooster(increaseValue:number){ - let newBoosterFactor = parseFloat((this.getSettingNumber('streakbooster') + increaseValue).toFixed(1)); - if(newBoosterFactor > 80){ + async increaseStreakbooster(increaseValue: number) { + const oldBoosterFactor = this.getSettingNumber('streakbooster'); + let newBoosterFactor = parseFloat((oldBoosterFactor + increaseValue).toFixed(1)); + + if (newBoosterFactor > 80) { newBoosterFactor = 80; } - if(debugLogs) console.debug(`newBoosterFakfor: ${newBoosterFactor}`) - //if(debugLogs) console.debug(`old value streakbooster: ${this.getSettingNumber('streakbooster')}`) + + // Send message if newBoosterFactor crosses a multiple of 5 + const oldIntegerPart = Math.floor(oldBoosterFactor); + const newIntegerPart = Math.floor(newBoosterFactor); + if (newBoosterFactor > oldBoosterFactor && newIntegerPart !== oldIntegerPart) { + // send high five + + } + + if (debugLogs) console.debug(`newBoosterFakfor: ${newBoosterFactor}`); + this.setSettingNumber('streakbooster', newBoosterFactor); this.setSettingBoolean('streakboosterDate', true); - //if(debugLogs) console.debug(`new value streakbooster: ${this.getSettingNumber('streakbooster')}`) - //await this.saveData(this.settings) - //if(debugLogs) console.debug(`streakbooster: ${this.getSettingNumber('streakbooster')}`) - } + } + async decreaseStreakbooster(decreaseValue:number){ From 4d02dc15dd0d7fac324cba139c53f0da86283a4d Mon Sep 17 00:00:00 2001 From: saertna <83655354+saertna@users.noreply.github.com> Date: Wed, 20 Mar 2024 21:31:44 +0100 Subject: [PATCH 4/6] send high five when milestone crossed --- src/main.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index de49f57..6bdc691 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1025,8 +1025,7 @@ export default class gamification extends Plugin implements GamificationMediator const oldIntegerPart = Math.floor(oldBoosterFactor); const newIntegerPart = Math.floor(newBoosterFactor); if (newBoosterFactor > oldBoosterFactor && newIntegerPart !== oldIntegerPart) { - // send high five - + new Notice(`Boom! You just hit another milestone! High five, champ!`,this.getSettingNumber('timeShowNotice') * 1000 * 1.2) } if (debugLogs) console.debug(`newBoosterFakfor: ${newBoosterFactor}`); From 92083843a9badb935820a5ce4dd33d90251bff0d Mon Sep 17 00:00:00 2001 From: saertna <83655354+saertna@users.noreply.github.com> Date: Wed, 20 Mar 2024 22:27:46 +0100 Subject: [PATCH 5/6] random boosterfactor milestone message --- src/main.ts | 13 +++++--- src/randomNotificationText.ts | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index 6bdc691..b174053 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,7 +36,8 @@ import {getLevelForPoints, statusPointsForLevel} from './levels' import { getRandomMessagePoints, getRandomMessageTwoNoteChallenge, - getRandomMessageWeeklyChallenge + getRandomMessageWeeklyChallenge, + getRandomMessageBoosterFactor } from './randomNotificationText' import {ModalInformationbox} from 'ModalInformationbox'; import {ModalBooster} from 'ModalBooster'; @@ -228,7 +229,9 @@ export default class gamification extends Plugin implements GamificationMediator // PLUGIN_VERSION // ).open(); - await this.decreaseStreakbooster(50); + //await this.decreaseStreakbooster(50); + await this.increaseStreakbooster(0.8); + //this.setBadgeSave(getBadgeDetails('Brainiac Trailblazer'),'23-09-07', 'level 20'); //this.setBadgeSave(getBadgeDetails('Savvy Scholar'), '23-08-15', 'level 15'); }); @@ -1024,8 +1027,10 @@ export default class gamification extends Plugin implements GamificationMediator // Send message if newBoosterFactor crosses a multiple of 5 const oldIntegerPart = Math.floor(oldBoosterFactor); const newIntegerPart = Math.floor(newBoosterFactor); - if (newBoosterFactor > oldBoosterFactor && newIntegerPart !== oldIntegerPart) { - new Notice(`Boom! You just hit another milestone! High five, champ!`,this.getSettingNumber('timeShowNotice') * 1000 * 1.2) + if (oldBoosterFactor <= 80 && newBoosterFactor <= 80 && newBoosterFactor > oldBoosterFactor && + newIntegerPart !== oldIntegerPart && newIntegerPart % 5 === 0) { + new Notice(getRandomMessageBoosterFactor(),this.getSettingNumber('timeShowNotice') * 1000 * 1.2) + console.log(`${getRandomMessageBoosterFactor()} : ${newBoosterFactor}`) } if (debugLogs) console.debug(`newBoosterFakfor: ${newBoosterFactor}`); diff --git a/src/randomNotificationText.ts b/src/randomNotificationText.ts index eeff6aa..b14a445 100644 --- a/src/randomNotificationText.ts +++ b/src/randomNotificationText.ts @@ -162,6 +162,58 @@ const randomPointNotices: string[] = [ "Well deserved! [X] points earned!" ]; +const boosterFactorMessage : string[] = [ + "Boom! You just hit a new Boosterfactor milestone! High five, booster pro!", + "Boosting it up! High five for reaching that Boosterfactor benchmark!", + "Way to amplify your game! High five for hitting that Boosterfactor goal!", + "You're turbocharging your progress! High five for achieving that Boosterfactor milestone!", + "Bam! Another Boosterfactor milestone smashed! High five, booster champion!", + "You're on turbo mode! High five for maximizing your Boosterfactor!", + "High five alert! You just boosted your way to a new milestone!", + "You're officially a booster master! High five for your unstoppable Boosterfactor streak!", + "Nailed it! High five for reaching another Boosterfactor milestone!", + "Woo hoo! High five for leveling up your Boosterfactor game!", + "On a boost spree! High five for maximizing your Boosterfactor!", + "High fives all around for reaching that Boosterfactor milestone!", + "Look at you go! High five for turbocharging your Boosterfactor!", + "You're making waves with your Boosterfactor! High five for the milestone!", + "High five incoming! You're a Boosterfactor maestro!", + "Keep 'em coming! High five for reaching another Boosterfactor milestone!", + "Bravo! High five for your stellar Boosterfactor progress!", + "High fives galore for hitting that Boosterfactor milestone!", + "You're unstoppable! High five for your Boosterfactor mayhem!", + "Kaboom! High five for blowing past that Boosterfactor milestone!", + "Way to hustle with your Boosterfactor! High five, booster hustler!", + "High five vibes for boosting your way to that milestone!", + "Bringing the heat with your Boosterfactor! High five for the milestone heatwave!", + "You're a Boosterfactor machine! High five, keep it up!", + "High fives incoming! You're a Boosterfactor mastermind!", + "Boosting like a boss! High five, booster superstar!", + "Look out, world! High five for your Boosterfactor domination!", + "High fives on repeat! You're a Boosterfactor magician!", + "Impressive stuff! High five for your Boosterfactor magic!", + "You're unstoppable! High five for your Boosterfactor momentum!", + "Keep the boost alive! High five for your Boosterfactor mojo!", + "High fives are in order! You're a Boosterfactor ninja!", + "Mission accomplished! High five for reaching that Boosterfactor milestone!", + "You're on a boost roll! High five for your Boosterfactor rampage!", + "High five alert! You're a Boosterfactor rockstar!", + "Two thumbs up! High five for your Boosterfactor success!", + "You're boosting it! High five for your Boosterfactor spree!", + "High fives incoming! You're a Boosterfactor sensation!", + "You're a Boosterfactor superhero! High five, booster caped crusader!", + "High five vibes! You're a Boosterfactor sensation!", + "You're a Boosterfactor legend! High five, oh mighty booster!", + "High fives all around! You're a Boosterfactor superstar!", + "You're a Boosterfactor champion! High five, boost conqueror!", + "High five incoming! You're a Boosterfactor warrior!", + "You're on fire with your Boosterfactor! High five for the victory!", + "You're a Boosterfactor guru! High five, wise booster!", + "High five vibes! You're a Boosterfactor wizard!", + "You're a Boosterfactor icon! High five, illustrious booster!", + "High five alert! You're a Boosterfactor prodigy!", + "You're unstoppable! High five for your Boosterfactor triumph!" +] export function getRandomMessageWeeklyChallenge(points: number): string { const randomIndex = Math.floor(Math.random() * messagesWeeklyChallenge.length); @@ -183,6 +235,11 @@ export function getRandomMessagePoints(points: number): string { return message.replace("[X]", points.toString()); } +export function getRandomMessageBoosterFactor(): string { + const randomIndex = Math.floor(Math.random() * boosterFactorMessage.length); + return boosterFactorMessage[randomIndex]; +} + // Example usage // const randomPoints = 100; // Replace with your actual points value // const randomMessage = getRandomMessageWeeklyChallenge(randomPoints); From 2977bf843d9457bcdbeac6a1589ffc78d8412188 Mon Sep 17 00:00:00 2001 From: saertna <83655354+saertna@users.noreply.github.com> Date: Wed, 20 Mar 2024 22:31:50 +0100 Subject: [PATCH 6/6] Release 0.0.89 --- manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/Messages.ts | 3 ++- src/constants.ts | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index d867baa..a46c983 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "gamified-pkm", "name": "Gamificate your PKM", - "version": "0.0.88", + "version": "0.0.89", "minAppVersion": "0.15.0", "description": "Enhance your Personal Knowledge Management with gamification elements. Boost motivation and achieve growth as you engage with your PKM.", "author": "Andreas Trebing", diff --git a/package-lock.json b/package-lock.json index 4ed91ef..2c0354d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-gamified-pkm", - "version": "0.0.88", + "version": "0.0.89", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-gamified-pkm", - "version": "0.0.88", + "version": "0.0.89", "license": "MIT", "dependencies": { "crypto-js": "^4.1.1", diff --git a/package.json b/package.json index fa7db0a..670b59e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-gamified-pkm", - "version": "0.0.88", + "version": "0.0.89", "description": "Enhance your Personal Knowledge Management with gamification elements. Boost motivation and achieve growth as you engage with your PKM.", "main": "main.js", "scripts": { diff --git a/src/Messages.ts b/src/Messages.ts index 01f1e5d..c8a467e 100644 --- a/src/Messages.ts +++ b/src/Messages.ts @@ -17,7 +17,8 @@ I develop this plugin as a hobby, spending my free time doing this. If you find ## New - Introduction to Release Note showcase - Added automatic triggering of rate, can be enabled in settings -- booster factor is not going below a multiple of 5. Means, whenever you reach a multiple of 5, it's a secured milestone.`, +- booster factor is not going below a multiple of 5. Means, whenever you reach a multiple of 5, it's a secured milestone. +- inform about booster factor milestone achievement`, "0.0.88":` ## Changed - Support more levels, up to 200, and fix incorrect calculations diff --git a/src/constants.ts b/src/constants.ts index 57ef999..86292ea 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,5 @@ import { Badge } from './badges' -export const PLUGIN_VERSION = '0.0.88'; +export const PLUGIN_VERSION = '0.0.89'; export const pointsNoteMajurity = 100; export const pointsMajurity = 10; export const pointsForDailyChallenge = 500;