Fix committed merge errors; fetch placeable ships from service

master
Garrett Mills 4 years ago
parent c0a4bb93cd
commit 531d11fee8
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

@ -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
}

@ -3,7 +3,6 @@ import {GameState, ShipType} from '../module/util.js'
import game_service from '../services/GameState.service.js'
const template = `
<<<<<<< Updated upstream
<div class="top-level-container">
<div class="top-level-component">
<div v-if="current_state === GameState.ChoosingNumberOfShips">
@ -13,24 +12,6 @@ const template = `
<button @click="ship(3)" class="shipBtn">3 ships</button>
<button @click="ship(4)" class="shipBtn">4 ships</button>
<button @click="ship(5)" class="shipBtn">5 ships</button>
=======
<div class="top-level-component">
<div v-if="current_state === GameState.ChoosingNumberOfShips">
Choose number of ships:
<button @click="ship1" class="shipBtn">1 ship</button>
<button @click="ship2" class="shipBtn">2 ships</button>
<button @click="ship3" class="shipBtn">3 ships</button>
<button @click="ship4" class="shipBtn">4 ships</button>
<button @click="ship5" class="shipBtn">5 ships</button>
</div>
<<<<<<< HEAD
=======
>>>>>>> 19aa3733d0604f37e6875b825eb51ccd4092d4c4
<div v-if="current_state !== GameState.ChoosingNumberOfShips" class="game-boards-container">
<!-- Opponent's board -->
<div class="game-board">
<app-game-board v-bind:rows="opponent_rows"></app-game-board>
>>>>>>> Stashed changes
</div>
<div v-if="current_state !== GameState.ChoosingNumberOfShips" class="game-boards-container">
<!-- Opponent's board -->
@ -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

@ -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]
}
}
/**

Loading…
Cancel
Save