Skip to content

Commit

Permalink
Change Currency, Upgrade docs, add Item docs
Browse files Browse the repository at this point in the history
Change Upgrade docs to mdx, update type info.
  • Loading branch information
xShadowBlade committed Jun 25, 2024
1 parent abfb3b8 commit 547546d
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 275 deletions.
1 change: 1 addition & 0 deletions documentation/docs/main/currency.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ To create a currency, do either of the following:

// 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");

// All the methods are in `<GameCurrency>.static`, which contains the same methods as <CurrencyStatic>
Expand Down
38 changes: 38 additions & 0 deletions documentation/docs/main/item.md
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");
```
1 change: 1 addition & 0 deletions documentation/docs/main/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ This category lists the primary exports of the package `emath.js`.
- [Boost](./boost)
- [Currency](./currency)
- [Grid](./grid)
- [Item](./item)
- [Numerical Analysis](./numerical-analysis)
- [Upgrade](./upgrade)
275 changes: 0 additions & 275 deletions documentation/docs/main/upgrade.md

This file was deleted.

Loading

0 comments on commit 547546d

Please sign in to comment.