Samarium
Hello
I have custom decorators that extends your decorators.
Here is example:
export default function SteelPlate(): ItemClass {
@Plate({
id: v4(),
name: 'Steel Armor',
displayName: 'Steel Armor',
icon: 'steel-plate-icon',
graphic: {
torso: 'steel-plate',
legs: 'steel-plate-legs-male',
},
type: ItemType.Plate,
price: 100,
pdef: Math.round(Math.random() * 10) + 8,
sdef: Math.round(Math.random() * 6) + 3,
equippable: true,
})
class SteelPlate {
}
return SteelPlate;
}
import { ItemType } from "../enum/ItemType";
import { Armor, ArmorOptions } from "./Armor";
export function Plate(options: ArmorOptions): (target: any, propertyKey: any) => void {
return function(target: any, propertyKey: any) {
options.type = ItemType.Plate;
Armor(options)(target, propertyKey);
};
}
import { Armor as RPGArmor } from '@rpgjs/database';
import { ArmorOptions as RPGArmorOptions } from "@rpgjs/database/src/armor";
import { TypeOfItem } from '../enum/ItemType';
import { ItemCommon, RPGItemCommon } from './ItemCommon';
import { Equippable } from '../interfaces/Equippable';
export interface ArmorOptions extends RPGArmorOptions, Equippable, ItemCommon, TypeOfItem {
}
export function Armor(options: ArmorOptions): (target: any, propertyKey: any) => void {
return function (target: any) {
RPGArmor(options)(target);
RPGItemCommon(options)(target);
target.type = options.type;
target.equippable = options.equippable;
};
}
so you can assume that:
const item = SteelPlate();
called as function because it is callback to get item with random properties
And before addItem
I have this:
player.server.addInDatabase(item.id, item);