Files
introduction-to-testing/examples/characters/src/character.js
2024-09-16 13:13:38 -06:00

27 lines
617 B
JavaScript

import { Person } from './person.js';
import { rollDice } from './roll-dice.js';
export class Character extends Person {
constructor(firstName, lastName, role) {
super(firstName, lastName);
this.role = role;
this.level = 1;
this.createdAt = new Date();
this.lastModified = this.createdAt;
this.strength = rollDice(4, 6);
this.dexterity = rollDice(4, 6);
this.intelligence = rollDice(4, 6);
this.wisdom = rollDice(4, 6);
this.charisma = rollDice(4, 6);
this.constitution = rollDice(4, 6);
}
levelUp() {
this.level++;
this.lastModified = new Date();
}
}