feat: add player methods

This commit is contained in:
Mike 2024-03-15 20:49:39 -04:00
parent 904c4901da
commit 718fdf63b1
4 changed files with 34 additions and 1 deletions

View file

@ -1,5 +1,4 @@
import { Ship } from './ship'; import { Ship } from './ship';
let _ = require('lodash');
class Gameboard { class Gameboard {
constructor() { constructor() {

View file

@ -0,0 +1,9 @@
import { Gameboard } from './gameboard';
class Player {
constructor(name) {
this.gameboard = new Gameboard();
this.playerName = name;
}
}
export { Player };

View file

@ -0,0 +1,7 @@
import { Player } from './components/player';
const player1 = new Player('Player 1');
const player2 = new Player('CPU');
console.log(player1.gameboard);
console.log(player2.gameboard);

View file

@ -0,0 +1,18 @@
import { Gameboard } from '../src/components/gameboard';
class Player {
constructor(name) {
this.gameboard = new Gameboard();
this.playerName = name;
}
}
let p = new Player('Player1');
it('should contain a gameboard', () => {
expect(p.gameboard).toHaveProperty(
'ships',
'scoreboard',
'shipCount',
'sunkShipCount',
);
});