Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bataille Navale Front
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Taha BELKHIRI
Bataille Navale Front
Commits
fa2bccf9
Commit
fa2bccf9
authored
Mar 9, 2023
by
Taha
Browse files
Options
Downloads
Patches
Plain Diff
faciiiiiiiiiiiiiiiiile
parent
6c9c1316
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Game.js
+10
-9
10 additions, 9 deletions
src/Game.js
src/Player.js
+2
-4
2 additions, 4 deletions
src/Player.js
src/index.css
+1
-1
1 addition, 1 deletion
src/index.css
with
13 additions
and
14 deletions
src/Game.js
+
10
−
9
View file @
fa2bccf9
...
@@ -29,7 +29,7 @@ class Game extends Component {
...
@@ -29,7 +29,7 @@ class Game extends Component {
playerId
:
this
.
props
.
playerId
,
playerId
:
this
.
props
.
playerId
,
gameId
:
this
.
props
.
gameId
,
gameId
:
this
.
props
.
gameId
,
errorMessage
:
'
No error
'
,
errorMessage
:
'
No error
'
,
gameState
:
'
Building Phase
'
,
gameState
:
'
Waiting for players
'
,
turn
:
'
Players take turns once all ships are placed
'
,
turn
:
'
Players take turns once all ships are placed
'
,
endGame
:
false
,
endGame
:
false
,
API_URL
:
this
.
props
.
backendUrl
+
"
/api/game/
"
,
API_URL
:
this
.
props
.
backendUrl
+
"
/api/game/
"
,
...
@@ -226,6 +226,12 @@ class Game extends Component {
...
@@ -226,6 +226,12 @@ class Game extends Component {
console
.
log
(
"
Game Over
"
);
console
.
log
(
"
Game Over
"
);
}
}
if
(
data
.
isBuildPhase
){
if
(
data
.
player1Id
!=
0
&&
data
.
player2Id
!=
0
){
this
.
setState
({
gameState
:
"
Building Phase
"
});
}
}
if
(
!
data
.
isBuildPhase
){
if
(
!
data
.
isBuildPhase
){
this
.
setState
({
gameState
:
"
Attacking Phase
"
});
this
.
setState
({
gameState
:
"
Attacking Phase
"
});
this
.
player
.
mode
=
0
;
this
.
player
.
mode
=
0
;
...
@@ -341,12 +347,6 @@ class Game extends Component {
...
@@ -341,12 +347,6 @@ class Game extends Component {
shipSelection
=
4
;
shipSelection
=
4
;
}
}
}
}
if
(
event
.
code
==
'
Digit5
'
)
{
if
(
!
this
.
player
.
ships
[
4
].
isSetup
)
{
this
.
player
.
tpUnsetShips
(
4
);
shipSelection
=
5
;
}
}
if
(
event
.
code
==
'
KeyR
'
)
{
if
(
event
.
code
==
'
KeyR
'
)
{
this
.
player
.
hoverRotation
+=
1
;
this
.
player
.
hoverRotation
+=
1
;
if
(
this
.
player
.
hoverRotation
>
1
)
this
.
player
.
hoverRotation
=
0
;
if
(
this
.
player
.
hoverRotation
>
1
)
this
.
player
.
hoverRotation
=
0
;
...
@@ -381,6 +381,7 @@ class Game extends Component {
...
@@ -381,6 +381,7 @@ class Game extends Component {
console
.
log
(
ship
);
console
.
log
(
ship
);
let
shipOriginIndexs
=
this
.
board
.
getPointedTile
(
this
.
camera
);
let
shipOriginIndexs
=
this
.
board
.
getPointedTile
(
this
.
camera
);
if
(
shipOriginIndexs
.
x
!=
-
1
&&
shipOriginIndexs
.
z
!=
-
1
)
{
if
(
shipOriginIndexs
.
x
!=
-
1
&&
shipOriginIndexs
.
z
!=
-
1
)
{
// lock ship to grid
ship
.
position
.
x
=
shipOriginIndexs
.
x
;
ship
.
position
.
x
=
shipOriginIndexs
.
x
;
ship
.
position
.
z
=
shipOriginIndexs
.
z
;
ship
.
position
.
z
=
shipOriginIndexs
.
z
;
ship
.
rotation
=
this
.
player
.
hoverRotation
;
ship
.
rotation
=
this
.
player
.
hoverRotation
;
...
@@ -389,6 +390,7 @@ class Game extends Component {
...
@@ -389,6 +390,7 @@ class Game extends Component {
const
y
=
shipOriginIndexs
.
z
;
const
y
=
shipOriginIndexs
.
z
;
const
horizontalOrientation
=
this
.
player
.
hoverRotation
?
"
false
"
:
"
true
"
;
const
horizontalOrientation
=
this
.
player
.
hoverRotation
?
"
false
"
:
"
true
"
;
const
shipType
=
ship
.
index
-
1
;
const
shipType
=
ship
.
index
-
1
;
// send request to server
fetch
(
this
.
state
.
API_URL
+
this
.
props
.
gameId
+
'
/ship/
'
+
this
.
props
.
playerId
+
'
?x=
'
+
x
+
'
&y=
'
+
y
+
'
&horizontalOrientation=
'
+
horizontalOrientation
+
'
&shipType=
'
+
shipType
,
{
fetch
(
this
.
state
.
API_URL
+
this
.
props
.
gameId
+
'
/ship/
'
+
this
.
props
.
playerId
+
'
?x=
'
+
x
+
'
&y=
'
+
y
+
'
&horizontalOrientation=
'
+
horizontalOrientation
+
'
&shipType=
'
+
shipType
,
{
method
:
'
POST
'
method
:
'
POST
'
})
})
...
@@ -424,7 +426,6 @@ class Game extends Component {
...
@@ -424,7 +426,6 @@ class Game extends Component {
else
{
else
{
// get the tile that the player is pointing at
// get the tile that the player is pointing at
const
indexes
=
this
.
ennemyBoard
.
getPointedTile
(
this
.
camera
);
const
indexes
=
this
.
ennemyBoard
.
getPointedTile
(
this
.
camera
);
console
.
log
(
indexes
);
if
(
indexes
.
x
!=
-
1
&&
indexes
.
z
!=
-
1
)
{
if
(
indexes
.
x
!=
-
1
&&
indexes
.
z
!=
-
1
)
{
const
tile
=
this
.
ennemyBoard
.
getTileByIndex
(
indexes
);
const
tile
=
this
.
ennemyBoard
.
getTileByIndex
(
indexes
);
fetch
(
this
.
state
.
API_URL
+
this
.
props
.
gameId
+
'
/shoot/
'
+
this
.
props
.
playerId
+
'
?x=
'
+
indexes
.
x
+
'
&y=
'
+
indexes
.
z
,
fetch
(
this
.
state
.
API_URL
+
this
.
props
.
gameId
+
'
/shoot/
'
+
this
.
props
.
playerId
+
'
?x=
'
+
indexes
.
x
+
'
&y=
'
+
indexes
.
z
,
...
@@ -471,7 +472,7 @@ class Game extends Component {
...
@@ -471,7 +472,7 @@ class Game extends Component {
if
(
this
.
state
.
winner
)
{
if
(
this
.
state
.
winner
)
{
return
(
return
(
<>
<>
<
h1
style
=
{{
position
:
'
absolute
'
,
top
:
'
5
0%
'
,
left
:
'
50%
'
,
transform
:
'
translate(-50%, -50%)
'
}}
>
Game
Over
<
/h1
>
<
h1
style
=
{{
position
:
'
absolute
'
,
top
:
'
3
0%
'
,
left
:
'
50%
'
,
transform
:
'
translate(-50%, -50%)
'
}}
>
Game
Over
<
/h1
>
<
h2
style
=
{{
position
:
'
absolute
'
,
top
:
'
70%
'
,
left
:
'
50%
'
,
transform
:
'
translate(-50%, -50%)
'
}}
>
{(
this
.
state
.
winner
===
this
.
props
.
playerId
)
?
"
You won!
"
:
"
You lost!
"
}
<
/h2
>
<
h2
style
=
{{
position
:
'
absolute
'
,
top
:
'
70%
'
,
left
:
'
50%
'
,
transform
:
'
translate(-50%, -50%)
'
}}
>
{(
this
.
state
.
winner
===
this
.
props
.
playerId
)
?
"
You won!
"
:
"
You lost!
"
}
<
/h2
>
<
h2
style
=
{{
position
:
'
absolute
'
,
top
:
'
60%
'
,
left
:
'
50%
'
,
transform
:
'
translate(-50%, -50%)
'
}}
>
Reload
the
page
to
play
again
<
/h2
>
<
h2
style
=
{{
position
:
'
absolute
'
,
top
:
'
60%
'
,
left
:
'
50%
'
,
transform
:
'
translate(-50%, -50%)
'
}}
>
Reload
the
page
to
play
again
<
/h2
>
...
...
This diff is collapsed.
Click to expand it.
src/Player.js
+
2
−
4
View file @
fa2bccf9
...
@@ -6,8 +6,7 @@ const hoverModes = {
...
@@ -6,8 +6,7 @@ const hoverModes = {
MicroRecon
:
1
,
MicroRecon
:
1
,
Warship
:
2
,
Warship
:
2
,
GalactixRacer
:
3
,
GalactixRacer
:
3
,
RedFighter
:
4
,
RedFighter
:
4
DualStriker
:
5
}
}
const
hoverAreas
=
[
const
hoverAreas
=
[
...
@@ -15,8 +14,7 @@ const hoverAreas = [
...
@@ -15,8 +14,7 @@ const hoverAreas = [
{
x
:
2
,
y
:
1
},
{
x
:
2
,
y
:
1
},
{
x
:
3
,
y
:
2
},
{
x
:
3
,
y
:
2
},
{
x
:
3
,
y
:
1
},
{
x
:
3
,
y
:
1
},
{
x
:
4
,
y
:
2
},
{
x
:
4
,
y
:
2
}
{
x
:
5
,
y
:
1
}
];
];
const
hoverRotationDirections
=
[
const
hoverRotationDirections
=
[
...
...
This diff is collapsed.
Click to expand it.
src/index.css
+
1
−
1
View file @
fa2bccf9
...
@@ -123,7 +123,7 @@ code {
...
@@ -123,7 +123,7 @@ code {
}
}
.Buttons
{
.Buttons
{
margin-top
:
14
%
;
margin-top
:
7
%
;
display
:
flex
;
display
:
flex
;
flex-direction
:
row
;
flex-direction
:
row
;
...
...
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