feat: add poc
This commit is contained in:
parent
43d27b04d9
commit
4a4fa05ce4
53 changed files with 6191 additions and 0 deletions
53
src/items/ItemRegistry.js
Normal file
53
src/items/ItemRegistry.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { Item } from './Item.js';
|
||||
|
||||
/**
|
||||
* Registry for all items in the game
|
||||
*/
|
||||
export class ItemRegistry {
|
||||
static items = new Map();
|
||||
|
||||
static {
|
||||
// Register items
|
||||
// Weapons
|
||||
this.register(this.createWeapon('iron_sword', 'Iron Sword', 15, 5));
|
||||
this.register(this.createWeapon('steel_claw', 'Steel Claw', 20, 3));
|
||||
|
||||
// Armor
|
||||
this.register(this.createArmor('leather_armor', 'Leather Armor', 10, 5));
|
||||
|
||||
// Consumables
|
||||
this.register(this.createConsumable('health_potion', 'Health Potion', 50));
|
||||
}
|
||||
|
||||
static register(item) {
|
||||
this.items.set(item.id, item);
|
||||
}
|
||||
|
||||
static get(id) {
|
||||
return this.items.get(id);
|
||||
}
|
||||
|
||||
static createWeapon(id, name, damage, speed) {
|
||||
const item = new Item(id, name, 'weapon');
|
||||
item.damage = damage;
|
||||
item.attackSpeed = speed;
|
||||
item.description = `Weapon: +${damage} damage, ${speed} speed`;
|
||||
return item;
|
||||
}
|
||||
|
||||
static createArmor(id, name, defense, hp) {
|
||||
const item = new Item(id, name, 'armor');
|
||||
item.defense = defense;
|
||||
item.maxHp = hp;
|
||||
item.description = `Armor: +${defense} defense, +${hp} HP`;
|
||||
return item;
|
||||
}
|
||||
|
||||
static createConsumable(id, name, healAmount) {
|
||||
const item = new Item(id, name, 'consumable');
|
||||
item.healAmount = healAmount;
|
||||
item.description = `Restores ${healAmount} HP`;
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue