diff --git a/src/components/GameBoard.component.js b/src/components/GameBoard.component.js index 52f34ee..19511e1 100644 --- a/src/components/GameBoard.component.js +++ b/src/components/GameBoard.component.js @@ -56,10 +56,6 @@ export default class GameBoardComponent extends Component { * @type {string[]} */ column_labels = ["A", "B", "C", "D", "E", "F", "G", "H", "I"] -<<<<<<< Updated upstream -======= - ->>>>>>> Stashed changes /** * Array of coordinates as [row_index, column_index] of cells which should @@ -107,7 +103,6 @@ export default class GameBoardComponent extends Component { window.removeEventListener('keydown', keydown_fn) } -<<<<<<< Updated upstream on_cell_click(row_i, cell_i) { if ( this.is_placement_mode && this.ships_to_place[0] ) { // We should try to place a ship here @@ -215,7 +210,4 @@ export default class GameBoardComponent extends Component { } } } -======= - ->>>>>>> Stashed changes } diff --git a/src/components/TopLevel.component.js b/src/components/TopLevel.component.js index 3ecfbbd..82730e6 100644 --- a/src/components/TopLevel.component.js +++ b/src/components/TopLevel.component.js @@ -3,7 +3,6 @@ import {GameState, ShipType} from '../module/util.js' import game_service from '../services/GameState.service.js' const template = ` -<<<<<<< Updated upstream
@@ -13,24 +12,6 @@ const template = ` -======= -
-
- Choose number of ships: - - - - - -
-<<<<<<< HEAD -======= ->>>>>>> 19aa3733d0604f37e6875b825eb51ccd4092d4c4 -
- -
- ->>>>>>> Stashed changes
@@ -113,8 +94,7 @@ export default class TopLevelComponent extends Component { this.player_is_placing_ships = next_state === GameState.PlayerSetup if ( !was_refresh && this.player_is_placing_ships ) { - // TODO replace with call to game state service - this.ships_to_place = [ShipType.x1, ShipType.x2, ShipType.x3] + this.ships_to_place = game_service.get_possible_boats() } // TODO add code for instructions diff --git a/src/services/GameState.service.js b/src/services/GameState.service.js index 023ef59..c165ff1 100644 --- a/src/services/GameState.service.js +++ b/src/services/GameState.service.js @@ -68,21 +68,21 @@ export class GameStateService { } } - get_possible_boats(number){ - if (get_n_boats == 1) { - return (ships:x1) + get_possible_boats(){ + if (this.get_n_boats() === 1) { + return [ShipType.x1] } - if (get_n_boats == 2) { - return (ships:x1, x2) + else if (this.get_n_boats() === 2) { + return [ShipType.x1, ShipType.x2] } - if (get_n_boats == 3) { - return (ships:x1, x2, x3) + else if (this.get_n_boats() === 3) { + return [ShipType.x1, ShipType.x2, ShipType.x3] } - if (get_n_boats == 4) { - return (ships:x1, x2, x3,x4) + else if (this.get_n_boats() === 4) { + return [ShipType.x1, ShipType.x2, ShipType.x3, ShipType.x4] } - if (get_n_boats == 5) { - return (ships:x1, x2, x3, x4, x5) + else if (this.get_n_boats() === 5) { + return [ShipType.x1, ShipType.x2, ShipType.x3, ShipType.x4, ShipType.x5] } } /**