19 lines
626 B
JavaScript
19 lines
626 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'; }
|
||
|
|
}
|
||
|
|
}
|