Key Item Plugin
KeyItems are one-off unlock that mark the progression of a player up to a certain point.
The keyItem plugin handles the earning of KeyItems. When unlocked, key items provide Bonuses.
Demo
You have 0.00 money!
Silver coin +10% coins gain Not earned
Gold coin +20% money gain Not earned
Usage
import { KeyItemPlugin } from '@123ishatest/ludiek';
const keyItem = new KeyItemPlugin();
// Define your keyItems
const keyItems: KeyItemDetail[] = [
{
id: '/key-item/silver-coin',
name: 'Silver coin',
description: '+10% coins gain',
rewards: [{ type: '/bonus/seed-global', amount: +0.1 }],
},
{
id: '/key-item/gold-coin',
name: 'Gold coin',
description: '+20% money gain',
rewards: [{ type: '/bonus/seed-global', amount: +0.2 }],
},
];
keyItem.loadContent(keyItems);
// Manually earn an keyItem
keyItem.gainKeyItem('/key-item/silver-coin')
// Check whether we have it
keyItem.hasKeyItem('/key-item/silver-coin') // true Hook into the “keyItem earned” event for UI/popups
currency.onKeyItemEarn.subscribe(({ id }) => {
console.log(`Congratulations, you have earned keyItem ${id}!`)
});