mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-26 22:30:44 -05:00
feat: add player methods
This commit is contained in:
parent
904c4901da
commit
718fdf63b1
4 changed files with 34 additions and 1 deletions
|
@ -1,5 +1,4 @@
|
|||
import { Ship } from './ship';
|
||||
let _ = require('lodash');
|
||||
|
||||
class Gameboard {
|
||||
constructor() {
|
||||
|
|
9
battleship/src/components/player.js
Normal file
9
battleship/src/components/player.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { Gameboard } from './gameboard';
|
||||
class Player {
|
||||
constructor(name) {
|
||||
this.gameboard = new Gameboard();
|
||||
this.playerName = name;
|
||||
}
|
||||
}
|
||||
|
||||
export { Player };
|
|
@ -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);
|
18
battleship/tests/player.test.js
Normal file
18
battleship/tests/player.test.js
Normal 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',
|
||||
);
|
||||
});
|
Loading…
Reference in a new issue