Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
Web Games
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
atm2g19
Web Games
Commits
1820e2bc
Commit
1820e2bc
authored
5 years ago
by
atm2g19
Browse files
Options
Downloads
Patches
Plain Diff
removed excess debuggong logs
parent
c685deb0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
public/games/battleships_v2/game.js
+1
-1
1 addition, 1 deletion
public/games/battleships_v2/game.js
public/games/battleships_v2/game.ts
+1
-1
1 addition, 1 deletion
public/games/battleships_v2/game.ts
src/games/battleships_v2.ts
+9
-9
9 additions, 9 deletions
src/games/battleships_v2.ts
with
11 additions
and
11 deletions
public/games/battleships_v2/game.js
+
1
−
1
View file @
1820e2bc
...
@@ -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
);
});
});
}
}
...
...
This diff is collapsed.
Click to expand it.
public/games/battleships_v2/game.ts
+
1
−
1
View file @
1820e2bc
...
@@ -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
);
})
})
}
}
...
...
This diff is collapsed.
Click to expand it.
src/games/battleships_v2.ts
+
9
−
9
View file @
1820e2bc
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment