Skip to content

Commit

Permalink
Merge pull request #29 from saertna/ingrediment-booster
Browse files Browse the repository at this point in the history
Ingrediment booster
  • Loading branch information
saertna authored Nov 1, 2023
2 parents eef66d6 + c6c97b6 commit e713523
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 12 deletions.
31 changes: 24 additions & 7 deletions main.js

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion src/MultiSelectModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
listOfUseableIngredientsToBeShown
} from './constants';
import { ModalInformationbox } from 'ModalInformationbox';
import gamification, { isMinutesPassed, hoursUntilMinutesPassed } from 'main';
import gamification, { isMinutesPassed, hoursUntilMinutesPassed} from 'main';



Expand Down Expand Up @@ -42,6 +42,11 @@ export class MultiSelectModal extends Modal {
contentEl.appendChild(listItem);
}
});
const fortuneInfusionBooster = boosterRecipes.find(entry => entry.varname === 'fortuneInfusion');
if (fortuneInfusionBooster){
const listItem = this.createItemContainer(fortuneInfusionBooster.name);
contentEl.appendChild(listItem);
}
} else {
const listItem = this.createItemContainer("");
contentEl.appendChild(listItem);
Expand Down Expand Up @@ -147,6 +152,7 @@ export class MultiSelectModal extends Modal {
'Precision Prism': this.gamificationInstance.getSettingNumber('precisionPrism') as number,
'Hyperlink Harmony': this.gamificationInstance.getSettingNumber('hyperlinkHarmony') as number,
'Ephemeral Euphoria': this.gamificationInstance.getSettingNumber('ephemeralEuphoria') as number,
'Fortune Infusion': 1,
};
}
}
Expand All @@ -169,6 +175,7 @@ export class MultiSelectModal extends Modal {


private createCraftingLayout() {
this.readIngrementStock();
const container = document.createElement('div');
container.className = 'modal-crafting-container';

Expand Down Expand Up @@ -302,6 +309,10 @@ export class MultiSelectModal extends Modal {

private useBoosterItem(labelText: string) {
console.log(`use Booster ${labelText}`);
if(labelText=='Fortune Infusion'){
//console.log(`acquireIngredients();`)
this.gamificationInstance.acquireIngredients(1,1,10)
}
/*const stock = this.boosters[labelText];
if (stock > 0) {
//this.selectedItems.push(labelText);
Expand Down Expand Up @@ -424,6 +435,8 @@ export class MultiSelectModal extends Modal {
console.log(`not enough ingredients for booster ${selectedItems.name} in stock`);
new ModalInformationbox(this.app, `Not enough ingrediments available for '${selectedItems.name}'. Craft more Notes to collect new ingrediments.`).open();
}
} else if(selectedItems.name == 'Fortune Infusion'){

} else {
if (this.checkIngredientsAvailability(selectedItems)) {
console.log(`craft booster ${selectedItems.name}`);
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,6 @@ export const boosterRecipes = [
{ 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.' },
{ boosterUseCountName: 'boosterUseCountFortuneInfusion', boosterRunTime: 0, boosterCooldown: 22*60, boosterDate: 'boosterDateFortuneInfusion', boosterSwitch: 'boosterFactorFortuneInfusion', varname: 'fortuneInfusion' ,name: 'Fortune Infusion', incredients: ['free all 22h'], description: "Infuse your knowledge journey with a dash of randomness using the Fortune Infusion booster. Upon activation, you'll receive a randomized amount of valuable ingredients to aid your knowledge crafting endeavors. Sometimes, you'll strike it lucky with a bountiful yield of 10 ingredients, while most of the time, you'll secure a more modest 2. The rarer, the more ingredients you might acquire. Add a twist of unpredictability to your knowledge management strategy and see how your points soar!" },
];

9 changes: 5 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export default class gamification extends Plugin {
//this.setSettingString('weeklyNoteCreationDate', window.moment().format('DD.MM.YYYY'))
//this.setSettingString('weeklyNoteCreationDate', window.moment().format('DD.MM.YYYY'))
//await this.saveSettings();
new ModalBooster(this.app, ` `, this).open();
});
}

Expand Down Expand Up @@ -498,7 +499,7 @@ export default class gamification extends Plugin {
this.decisionIfBadge(newLevel);
detectIfNoteIsFirstTimeRated = true;
this.setSettingNumber('counterMajurityCalcInitial',this.getSettingNumber('counterMajurityCalcInitial') + 1)
this.acquireIngredients();
this.acquireIngredients(chanceToEarnIngredient,1,3);
if(this.getSettingNumber('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();
}
Expand Down Expand Up @@ -1218,10 +1219,10 @@ export default class gamification extends Plugin {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

async acquireIngredients() {
async acquireIngredients(chance:number, min:number, max:number) {
let earnedIngredientToShow = [];
if (Math.random() < chanceToEarnIngredient) {
const randomAmount = this.getRandomInt(1,3);
if (Math.random() < chance) {
const randomAmount = this.getRandomInt(min,max);
for (let i=1;i<=randomAmount;i++){
const randomIngredientIndex = this.getRandomInt(0, listOfUseableIngredientsToBeShown.length-1);
const earnedIngredient = elements[randomIngredientIndex];
Expand Down
4 changes: 4 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const defaultSettings: Partial<ISettings> = {
precisionPrism: "U2FsdGVkX1+72YwT/XdQzbpOLwA9ltJY8a+3GWB+IkQ=",
hyperlinkHarmony: "U2FsdGVkX191lYd3kaeLOKdWTo9GllDL25tN36zPYxE=",
ephemeralEuphoria: "U2FsdGVkX1+ijNputHqHW5gK0frfmswGx7EUdaHxjnk=",
fortuneInfusion: "U2FsdGVkX1+ijNputHqHW5gK0frfmswGx7EUdaHxjnk=",
boosterFactorPerpetualProgress: "U2FsdGVkX19/Fss2X+hd+w6ZmI5yNJcuUWA+ImrOGmg=",
boosterDatePerpetualProgress: "U2FsdGVkX1+RQltOMLx9axaYLmqyGEU9q2EJ6aFkRyvnCWTShMLGhyFmYzT35BaY",
boosterFactorStrategicSynapses: "U2FsdGVkX18575mGIVSjGk/qJposIrfRUy+v/Cs8dK0=",
Expand All @@ -65,6 +66,8 @@ export const defaultSettings: Partial<ISettings> = {
boosterDateHyperlinkHarmony: "U2FsdGVkX1+qUnz6LN+9w8gDvpVPPOmgy3BNAOa/mm1OwjUaVX05LqorO2wrXLho",
boosterFactorEphemeralEuphoria: "U2FsdGVkX1+pxM+VURwTAj8eAAGOsb2ERuh1Lh7ZLnE=",
boosterDateEphemeralEuphoria: "U2FsdGVkX19pJpw2a3f0SvfpjfUS7z9MlPAuqASwQFJBLjWjyHUj5qYGfN6rb/SY",
boosterFactorFortuneInfusion: "U2FsdGVkX1+pxM+VURwTAj8eAAGOsb2ERuh1Lh7ZLnE=",
boosterDateFortuneInfusion: "U2FsdGVkX19pJpw2a3f0SvfpjfUS7z9MlPAuqASwQFJBLjWjyHUj5qYGfN6rb/SY",
streakbooster: "U2FsdGVkX1/lU8z1269GCh/eAbXcmvMeI8MyfL7nzEI=",
streakboosterDate: "U2FsdGVkX1+DBUBmrzXuSiZlRp1jO9/UJv8sTTfeSNI=",
boosterUseCount: "U2FsdGVkX1/VWmniuhXR6FAx6PTBe9NS+tCv9XbK32Q=",
Expand All @@ -81,6 +84,7 @@ export const defaultSettings: Partial<ISettings> = {
boosterUseCountPrecisionPrism: "U2FsdGVkX18/kncuSG4klFZ6LpDHkp80wmp2U0knrr4=",
boosterUseCountHyperlinkHarmony: "U2FsdGVkX1+R4fU/oDIdb34kCIedxc4165PX3oOnCLc=",
boosterUseCountEphemeralEuphoria: "U2FsdGVkX191hJANYr8JHI1bn1YRrJfBh0cQ0vgkKRM=",
boosterUseCountFortuneInfusion: "U2FsdGVkX191hJANYr8JHI1bn1YRrJfBh0cQ0vgkKRM=",
counterMajurityCalc: "U2FsdGVkX19TLndonGY4Y8vHuZFfLJ5gZ2t/CLprh0o=",
counterMajurityCalcInitial: "U2FsdGVkX1+2Qii8qhFSqrNqmKR1Wh6saEjYbwPdi8Q="
};
Expand Down

0 comments on commit e713523

Please sign in to comment.