Currency Plugin
The currency plugin is responsible for storing various amount of currencies. It provides helpful methods for gaining and spending these currencies.
Demo
You have 0 money!
Usage
import { CurrencyPlugin } from '@123ishatest/ludiek';
const currency = new CurrencyPlugin();
currency.loadContent([
{ id: '/currency/money' },
{ id: '/currency/gems' },
]);
currency.gainCurrency('/currency/money', 3);
currency.loseCurrency('/currency/money', 2);
const isPaid = currency.payCurrency('/currency/money', 5);
console.log(isPaid); // false, we didn't have enough
currency.onCurrencyGain.sub(({ id, amount }) => {
console.log(`You gained ${amount} ${id}`);
});