@@ -4,10 +4,23 @@ const cliColor = require('cli-color');
4
4
const beep = require ( 'beepbeep' ) ;
5
5
const position = require ( "./GameController/position.js" ) ;
6
6
const letters = require ( "./GameController/letters.js" ) ;
7
+ const telemetryClient = require ( "./TelemetryClient/telemetryClient.js" ) ;
8
+ const appInsights = require ( 'applicationinsights' ) ;
9
+
10
+ let telemetry = new telemetryClient ( ) ;
7
11
8
12
class Battleship {
13
+ constructor ( ) {
14
+ this . start = this . start . bind ( this ) ;
15
+ this . printWelcomeScreen = this . printWelcomeScreen . bind ( this ) ;
16
+ }
9
17
10
18
start ( ) {
19
+ console . log ( "Starting..." ) ;
20
+ telemetry . trackevent ( "ApplicationStarted" , { Technolog : "Node.js" } , this . printWelcomeScreen ) ;
21
+ } ;
22
+
23
+ printWelcomeScreen ( ) {
11
24
console . log ( cliColor . magenta ( " |__" ) ) ;
12
25
console . log ( cliColor . magenta ( " |\\/" ) ) ;
13
26
console . log ( cliColor . magenta ( " ---" ) ) ;
@@ -46,6 +59,7 @@ class Battleship {
46
59
console . log ( "Enter coordinates for your shot :" ) ;
47
60
var position = Battleship . ParsePosition ( readline . question ( ) ) ;
48
61
var isHit = gameController . CheckIsHit ( this . enemyFleet , position ) ;
62
+
49
63
if ( isHit ) {
50
64
beep ( ) ;
51
65
@@ -111,9 +125,9 @@ class Battleship {
111
125
console . log ( ) ;
112
126
console . log ( `Please enter the positions for the ${ ship . name } (size: ${ ship . size } )` ) ;
113
127
for ( var i = 1 ; i < ship . size + 1 ; i ++ ) {
114
- console . log ( `Enter position ${ i } of ${ ship . size } (i.e A3):` ) ;
115
- const position = readline . question ( ) ;
116
- ship . addPosition ( Battleship . ParsePosition ( position ) ) ;
128
+ console . log ( `Enter position ${ i } of ${ ship . size } (i.e A3):` ) ;
129
+ const position = readline . question ( ) ;
130
+ ship . addPosition ( Battleship . ParsePosition ( position ) ) ;
117
131
}
118
132
} )
119
133
}
0 commit comments