LyssaGame/src/Item.js

21 lines
784 B
JavaScript

export class Item {
constructor(name, type, level, stats) {
this.name = name;
this.type = type; // 'weapon', 'armor', 'potion'
this.level = level;
this.stats = stats || {}; // { damage: 5 } or { defense: 2 }
this.x = 0;
this.y = 0;
this.symbol = '?';
this.color = '#ffff00';
if (type === 'weapon') this.symbol = ')';
if (type === 'armor') this.symbol = '[';
if (type === 'shield') this.symbol = ']';
if (type === 'potion') this.symbol = '!';
if (type === 'map') { this.symbol = '?'; this.color = '#ffd700'; }
if (type === 'quest') { this.symbol = '*'; this.color = '#ff00ff'; }
if (type === 'spellbook') { this.symbol = 'B'; this.color = '#00ffff'; }
}
}