Skip to content
Snippets Groups Projects
Commit 1820e2bc authored by atm2g19's avatar atm2g19
Browse files

removed excess debuggong logs

parent c685deb0
Branches
No related tags found
No related merge requests found
...@@ -314,7 +314,7 @@ class attack extends base { ...@@ -314,7 +314,7 @@ class attack extends base {
this.shots.push(...shot); this.shots.push(...shot);
}), }),
this.socket.on("sunk", (ships) => { this.socket.on("sunk", (ships) => {
console.log("sunk"); // console.log("sunk");
this.placed_ships.push(...ships); this.placed_ships.push(...ships);
}); });
} }
......
...@@ -388,7 +388,7 @@ class attack extends base { ...@@ -388,7 +388,7 @@ class attack extends base {
this.shots.push(...shot); this.shots.push(...shot);
}), }),
this.socket.on("sunk", (ships: ship[]) => { this.socket.on("sunk", (ships: ship[]) => {
console.log("sunk"); // console.log("sunk");
this.placed_ships.push(...ships); this.placed_ships.push(...ships);
}) })
} }
......
...@@ -241,14 +241,14 @@ const battleships_v2: GameConstructor = class battleships_v2 implements Game { ...@@ -241,14 +241,14 @@ const battleships_v2: GameConstructor = class battleships_v2 implements Game {
if (game_data.data.turn != player.player_no) return false; if (game_data.data.turn != player.player_no) return false;
let opponent_ships: ship[] = game_data.json[(player.player_no + 1) % 2 + 1]; let opponent_ships: ship[] = game_data.json[(player.player_no + 1) % 2 + 1];
if (!opponent_ships) return false; if (!opponent_ships) return false;
console.log("MARK 1") // console.log("MARK 1")
//check not duplicate //check not duplicate
let shots: shot[] = game_data.json[player.player_no + 3]; let shots: shot[] = game_data.json[player.player_no + 3];
if (shots.reduce((dup: boolean, s) => dup || (s.x == shot.x && s.y == shot.y), false)) { if (shots.reduce((dup: boolean, s) => dup || (s.x == shot.x && s.y == shot.y), false)) {
player.socket.emit("fire"); player.socket.emit("fire");
return false; return false;
} }
console.log("MARK 2"); // console.log("MARK 2");
game_data.data.turn++; game_data.data.turn++;
game_data.data.turn %= 2; game_data.data.turn %= 2;
this.db.query("UPDATE game_data SET data_value=? WHERE game_id=? AND data_key=0;", [JSON.stringify(game_data.data), game_data.id]); this.db.query("UPDATE game_data SET data_value=? WHERE game_id=? AND data_key=0;", [JSON.stringify(game_data.data), game_data.id]);
...@@ -287,12 +287,12 @@ const battleships_v2: GameConstructor = class battleships_v2 implements Game { ...@@ -287,12 +287,12 @@ const battleships_v2: GameConstructor = class battleships_v2 implements Game {
if (shot.hit && shot.x == X && shot.y == Y) hits--; if (shot.hit && shot.x == X && shot.y == Y) hits--;
} }
} }
console.log({ // console.log({
hits, // hits,
shot, // shot,
hit, // hit,
ship // ship
}); // });
if (hits == 0 && hit == ship) { if (hits == 0 && hit == ship) {
console.log("SUNK"); console.log("SUNK");
player.socket.emit("sunk", [ship]); player.socket.emit("sunk", [ship]);
...@@ -306,7 +306,7 @@ const battleships_v2: GameConstructor = class battleships_v2 implements Game { ...@@ -306,7 +306,7 @@ const battleships_v2: GameConstructor = class battleships_v2 implements Game {
opp.socket.emit("shot", [shot]); opp.socket.emit("shot", [shot]);
opp.socket.emit("fire"); opp.socket.emit("fire");
} }
console.log("MARK 3") // console.log("MARK 3")
if (shot.hit) { if (shot.hit) {
let hits = shots.reduce((count: number, shot) => count + (shot.hit ? 1 : 0), 0); let hits = shots.reduce((count: number, shot) => count + (shot.hit ? 1 : 0), 0);
if (hits >= 19) { if (hits >= 19) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment