Skip to content

Commit

Permalink
Merge pull request #70 from saertna/BootlegQuest
Browse files Browse the repository at this point in the history
Bootleg quest
  • Loading branch information
saertna authored Mar 20, 2024
2 parents 99ed95c + 2977bf8 commit 49a4673
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 26 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 3 additions & 1 deletion src/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ 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.
- inform about booster factor milestone achievement`,
"0.0.88":`
## Changed
- Support more levels, up to 200, and fix incorrect calculations
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
65 changes: 45 additions & 20 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ 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,
getRandomMessageTwoNoteChallenge,
getRandomMessageWeeklyChallenge
getRandomMessageWeeklyChallenge,
getRandomMessageBoosterFactor
} from './randomNotificationText'
import {ModalInformationbox} from 'ModalInformationbox';
import {ModalBooster} from 'ModalBooster';
Expand Down Expand Up @@ -220,12 +221,16 @@ 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);
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');
Expand Down Expand Up @@ -1011,23 +1016,43 @@ 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;
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: ${newBoosterFakfor}`)
//if(debugLogs) console.debug(`old value streakbooster: ${this.getSettingNumber('streakbooster')}`)
this.setSettingNumber('streakbooster', newBoosterFakfor);
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')}`)

// Send message if newBoosterFactor crosses a multiple of 5
const oldIntegerPart = Math.floor(oldBoosterFactor);
const newIntegerPart = Math.floor(newBoosterFactor);
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}`);

this.setSettingNumber('streakbooster', newBoosterFactor);
this.setSettingBoolean('streakboosterDate', true);
}



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
Expand Down
57 changes: 57 additions & 0 deletions src/randomNotificationText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 49a4673

Please sign in to comment.