> For the complete documentation index, see [llms.txt](/llms.txt)

# Equipment Enchantment

Rolls random bonuses onto equipment, with configurable slot counts, options and weights.




**About this demo**

The demo signs in automatically with an anonymous account. The account is shared across every demo in the showroom, so items and currency you get in one demo carry over to the others. Loading takes a moment. If the frame is too small, open the demo in a new tab.

## Overview

Each piece of equipment you take rolls 1 to 3 random bonuses (enchantments) of its own. Bonuses are drawn by weight from six options (`attack`, `defense`, `hp`, `speed`, `critical`, `luck`) and shown on the piece's row as text such as `attack +12 / hp +50`. You can spend coins to reroll the bonuses or to add one more.

## How to try it

1. Press **Deposit** under **Get coins** to put 100 free coins into **Free balance** under **Your coins**.
1. Press **Take** next to an equipment name under **Take equipment**. The piece appears under **Your equipment and its bonuses**, and the first time it is read it rolls 1 to 3 bonuses (one is most likely, three is rare).
1. Press **Reroll** on a piece to pay 10 coins and draw the same number of bonuses again.
1. Press **Add bonus** to pay 30 coins and draw one more bonus. If the piece already holds the maximum of 3, the press fails and no coins are taken.
1. If the bag runs out of room, press **Expand** under **Equipment bag** to add 2 slots (up to 10).

**How enchanting works** states the rules for how many bonuses a piece gets and what each press costs. Two pieces with the same name are separate items, and each rolls its own bonuses.

## GS2 services used

- [GS2-Enchant](/microservices/enchant/): GS2-Enchant's rarity parameter model `standard` defines the maximum of 3 bonuses, the weights for how many are rolled, and the six options with their values. Bonuses are kept per piece (the item set's `propertyId`); rerolling uses `Gs2Enchant:ReDrawRarityParameterStatusByUserId` and adding uses `Gs2Enchant:AddRarityParameterStatusByUserId`.
- [GS2-Exchange](/microservices/exchange/): GS2-Exchange rate models define **Reroll** and **Add bonus** as single transactions that take the coins and change the enchantment, run atomically on the server. Taking equipment, expanding the bag and depositing free coins also go through exchange rates.
- [GS2-Inventory](/microservices/inventory/): GS2-Inventory holds the equipment the player has taken and the bag it goes in (4 slots to start, 10 at most).
- [GS2-Money2](/microservices/money2/): A GS2-Money2 wallet holds the coins; **Reroll** withdraws 10 and **Add bonus** withdraws 30.

## Use it in GS2 Studio

In GS2 Studio's Simple mode, open **Add features** and press **Add** on **Equipment Enchantment** to bring this feature into your own project. To point at the package directly, choose **Add from GitHub** and enter the package below.

```text
https://github.com/gs2io/gs2-studio-package/tree/main/micro-economy-equipment-enchant/packages/micro-economy-equipment-enchant
```

- Owner: `gs2io`
- Repository: `gs2-studio-package`
- Subdirectory: `micro-economy-equipment-enchant/packages/micro-economy-equipment-enchant`

## Source code

- Demo project: <https://github.com/gs2io/gs2-studio-package/tree/main/micro-economy-equipment-enchant/live-demo>
- Feature package: <https://github.com/gs2io/gs2-studio-package/tree/main/micro-economy-equipment-enchant>



