-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Currency, Upgrade docs, add Item docs
Change Upgrade docs to mdx, update type info.
- Loading branch information
1 parent
abfb3b8
commit 547546d
Showing
5 changed files
with
119 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
id: item | ||
title: Item | ||
sidebar_label: Item | ||
--- | ||
|
||
[Link to auto generated docs](https://xshadowblade.github.io/emath.js/typedoc/classes/classes_Item.Item.html) | ||
|
||
The `Item` class represents an item that can be bought with a currency. An item is similar to an upgrade, except that it doesn't have a level nor a scalable cost. | ||
|
||
It can be used internally in the `CurrencyStatic` class. | ||
|
||
## Usage | ||
|
||
There is currently only one way to create items: | ||
|
||
1. Create items using the `addItem` method of the `CurrencyStatic` class. See [Currency Docs](./currency) for more information on the ways to create currencies. | ||
|
||
```js | ||
// If using `CurrencyStatic` class on its own (not recommended) | ||
// import { myCurrency } from "./currency.js"; | ||
|
||
// If using `Game` class | ||
import { myGame } from "./game.js"; | ||
// Create the currency with the game (See Currency docs for more information) | ||
const myCurrency = myGame.addCurrency("myCurrency"); | ||
|
||
myCurrency.addItem({ | ||
id: "item1", | ||
name: "Gold Coin", | ||
description: "A coin made of gold.", | ||
effect: (amount) => console.log(`You have ${amount} gold coins.`), | ||
cost: () => new Decimal(1000), | ||
}); | ||
|
||
// Buy the max amount of the item | ||
myCurrency.buyItem("item1"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.