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

Remake Version: Upgrade Formula is extremely flawed #9

Open
XDConfirm opened this issue Jan 8, 2023 · 0 comments
Open

Remake Version: Upgrade Formula is extremely flawed #9

XDConfirm opened this issue Jan 8, 2023 · 0 comments
Assignees
Labels
Bug Code is doing something it's not supposed to do.

Comments

@XDConfirm
Copy link
Owner

The current formula for making the cost more expensive is very flawed currently.
Factors of the Formula are the cost of the upgrade, the amount of the upgrade that the player has, and the amount that the player is buying.

Demo Version of Cost Formula:

( Note: This exact code is not planned to be inside the game. )

// All of this is supposed to be inside a buyUpgrade() function
... {
 const amount = upgrade.amount;
 const cost = upgrade.cost;
 const buy = buy_btn.buy;

/* First Demo Method */
 function changeCostViaFormula() {
    let totalCost = buy * (cost + Math.floor(cost * ((amount * 10) / 100)));
    return totalCost;
 }

/* Second Demo Method */
 function changeCostViaFormulaForLoop() {
 let totalCost = 0;
 for (let i = 0; i <= buy; i++) {
    const iterate = Math.floor(cost + (cost * ((amount * 10) / 100)));
    totalCost += iterate;
 }
  return totalCost;
 }

// Examples
 const amount = 1;
 const cost = 100;
 const buy = 2;
 return console.debug(changeCostViaFormula()); // Returns a cost of 220
 return console.debug(changeCostViaFormulaForLoop()); // Should return a cost of 220

 const amount = 3;
 const cost = 450;
 const buy = 5;
 return console.debug(changeCostViaFormula()); // Returns a cost of 2925
 return console.debug(changeCostViaFormulaForLoop()); // Should return a cost of 2925
}
@XDConfirm XDConfirm added the Bug Code is doing something it's not supposed to do. label Jan 8, 2023
@XDConfirm XDConfirm self-assigned this Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Code is doing something it's not supposed to do.
Projects
None yet
Development

No branches or pull requests

1 participant