Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for Burger Master reward in inventory upgrade cost #395

Open
jeremyckahn opened this issue Feb 8, 2023 · 2 comments
Open

Account for Burger Master reward in inventory upgrade cost #395

jeremyckahn opened this issue Feb 8, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jeremyckahn
Copy link
Owner

From @M8theone on Discord:

Suggestion: Make burger master inventory spaces not contribute to the cost of purchasing more space

Further clarification from @lstebner:

those free spaces shouldn't affect the cost of extra inventory.

@jeremyckahn jeremyckahn added enhancement New feature or request good first issue Good for newcomers labels Feb 8, 2023
@jeremyckahn
Copy link
Owner Author

This is the root of the logic that would need to be revisited to achieve this:

farmhand/src/utils.js

Lines 1141 to 1153 in 0763ad8

/**
* @param {number} currentInventoryLimit
* @returns {number}
*/
export const getCostOfNextStorageExpansion = currentInventoryLimit => {
const upgradesPurchased =
(currentInventoryLimit - INITIAL_STORAGE_LIMIT) / STORAGE_EXPANSION_AMOUNT
return (
STORAGE_EXPANSION_BASE_PRICE +
upgradesPurchased * STORAGE_EXPANSION_SCALE_PREMIUM
)
}

This would need to account for the whether the "Burger Master" achievement has been completed:

((goal = 10000, goalItem = itemsMap['burger'], reward = 5000) => ({
id: 'sale-goal-3',
name: `Burger Master`,
description: `Sell ${integerString(goal)} ${goalItem.name} units.`,
rewardDescription: `${integerString(reward)} additional inventory spaces`,
condition: state => state.itemsSold[goalItem.id] >= goal,
reward: state => ({
...state,
inventoryLimit: state.inventoryLimit + reward,
}),
}))(),

Here's where getCostOfNextStorageExpansion gets called:

storageUpgradeCost = getCostOfNextStorageExpansion(inventoryLimit),

The Shop component will need to be updated to pull in completedAchievements (which is already being passed to all connected components like Shop and Item) to be passed to getCostOfNextStorageExpansion. Here's some prior art for that:

export const Item = ({
completedAchievements,

@lstebner
Copy link
Collaborator

lstebner commented Feb 8, 2023

an alternate solution to checking for the achievement in this method could be to switch from calculating the cost based on storage size to actually tracking the number of storage upgrades that have been purchased and using that number to calculate the cost of the next one. this would keep us from having to update this method for any future inventory space rewards we add.

one complication to this approach is that something would need added to initialize this value in existing game saves based on inventory size and if they had completed the burger achievement already or not. i think it would be worth the effort though to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants