Currency
The Currency
and CurrencyStatic
classes are one of the main classes. It is used to represent currencies, their boosts/multipliers, and their upgrades.
It is not recommended to use this class on its own without a Game
class, as you will need to manually set up saving and loading, among other things.
Uses
To create a currency, do either of the following:
-
Using
Game
class (recommended)currency.jsimport { myGame } from "./game.js";
// 1 parameter - `name` is required. It must be unique,
// as it is used for saving/loading to identify the currnecy.
// Another parameter - `upgrades` is optional. See the `Upgrade` class for more information.
const myCurrency = myGame.addCurrency("myCurrency");
// <GameCurrency> extends <CurrencyStatic> so it contains the same methods and properties.
myCurrency.gain();
console.log(myCurrency.value); // new Decimal(1) -
Using without
Game
classcurrency.jsimport { CurrencyStatic } from "emath.js";
const myCurrency = new CurrencyStatic();
myCurrency.gain();
console.log(myCurrency.value); // new Decimal(1)