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[]} * @type {string[]}
*/ */
column_labels = ["A", "B", "C", "D", "E", "F", "G", "H", "I"] 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 * 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) window.removeEventListener('keydown', keydown_fn)
} }
<<<<<<< Updated upstream
on_cell_click(row_i, cell_i) { on_cell_click(row_i, cell_i) {
if ( this.is_placement_mode && this.ships_to_place[0] ) { if ( this.is_placement_mode && this.ships_to_place[0] ) {
// We should try to place a ship here // 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' import game_service from '../services/GameState.service.js'
const template = ` const template = `
<<<<<<< Updated upstream
<div class="top-level-container"> <div class="top-level-container">
<div class="top-level-component"> <div class="top-level-component">
<div v-if="current_state === GameState.ChoosingNumberOfShips"> <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(3)" class="shipBtn">3 ships</button>
<button @click="ship(4)" class="shipBtn">4 ships</button> <button @click="ship(4)" class="shipBtn">4 ships</button>
<button @click="ship(5)" class="shipBtn">5 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>
<div v-if="current_state !== GameState.ChoosingNumberOfShips" class="game-boards-container"> <div v-if="current_state !== GameState.ChoosingNumberOfShips" class="game-boards-container">
<!-- Opponent's board --> <!-- Opponent's board -->
@ -113,8 +94,7 @@ export default class TopLevelComponent extends Component {
this.player_is_placing_ships = next_state === GameState.PlayerSetup this.player_is_placing_ships = next_state === GameState.PlayerSetup
if ( !was_refresh && this.player_is_placing_ships ) { if ( !was_refresh && this.player_is_placing_ships ) {
// TODO replace with call to game state service this.ships_to_place = game_service.get_possible_boats()
this.ships_to_place = [ShipType.x1, ShipType.x2, ShipType.x3]
} }
// TODO add code for instructions // TODO add code for instructions

@ -68,21 +68,21 @@ export class GameStateService {
} }
} }
get_possible_boats(number){ get_possible_boats(){
if (get_n_boats == 1) { if (this.get_n_boats() === 1) {
return (ships:x1) return [ShipType.x1]
} }
if (get_n_boats == 2) { else if (this.get_n_boats() === 2) {
return (ships:x1, x2) return [ShipType.x1, ShipType.x2]
} }
if (get_n_boats == 3) { else if (this.get_n_boats() === 3) {
return (ships:x1, x2, x3) return [ShipType.x1, ShipType.x2, ShipType.x3]
} }
if (get_n_boats == 4) { else if (this.get_n_boats() === 4) {
return (ships:x1, x2, x3,x4) return [ShipType.x1, ShipType.x2, ShipType.x3, ShipType.x4]
} }
if (get_n_boats == 5) { else if (this.get_n_boats() === 5) {
return (ships:x1, x2, x3, x4, x5) return [ShipType.x1, ShipType.x2, ShipType.x3, ShipType.x4, ShipType.x5]
} }
} }
/** /**

Loading…
Cancel
Save