Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Manish Kumar
webpoke
Commits
1404b97d
Commit
1404b97d
authored
Jun 19, 2020
by
Sofia Aicha Delijaj
Browse files
rectifications
parent
f46b24bf
Changes
5
Hide whitespace changes
Inline
Side-by-side
backend/.gitignore
View file @
1404b97d
...
...
@@ -25,7 +25,6 @@ speed-measure-plugin*.json
# IDE - VSCode
.vscode/*
.vscode/
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
...
...
frontend/src/app/battle-menu/battle-menu.component.ts
View file @
1404b97d
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
ChatService
}
from
'
../chat.service
'
;
import
{
HttpClient
,
HttpHeaders
}
from
'
@angular/common/http
'
;
import
{
__assign
}
from
'
tslib
'
;
...
...
@@ -18,7 +17,7 @@ export class BattleMenuComponent implements OnInit {
demandesExt
:
any
=
[];
demandesInt
:
any
=
[];
constructor
(
private
chatService
:
ChatService
,
private
http
:
HttpClient
){}
constructor
(
private
http
:
HttpClient
){}
ngOnInit
()
{
this
.
http
.
get
(
'
http://localhost:3000/checkLogin
'
,
{
responseType
:
'
json
'
,
withCredentials
:
true
}).
subscribe
(
(
res
:
any
)
=>
{
...
...
frontend/src/app/battle/battle.component.html
View file @
1404b97d
...
...
@@ -60,7 +60,7 @@
What should {{curPoke.pokeName}} do?
</div>
<div
class=
"actions"
>
<button
(click)=
"typeAdv(move.m_id_type)"
*ngFor=
"let move of curPoke.moves"
>
{{move.identifier}}
</button>
<button
(click)=
"typeAdv(move.m_id_type
, move.power
)"
*ngFor=
"let move of curPoke.moves"
>
{{move.identifier}}
</button>
</div>
<div
class=
"continue"
>
</div>
...
...
frontend/src/app/battle/battle.component.ts
View file @
1404b97d
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
ActivatedRoute
}
from
'
@angular/router
'
;
import
{
ChatService
}
from
'
../chat.service
'
;
@
Component
({
...
...
@@ -17,9 +18,8 @@ export class BattleComponent implements OnInit {
uid
:
any
;
log
:
boolean
;
level
=
50
;
Power
=
60
;
atk
:
number
;
def
:
number
;
def
:
number
=
0
;
typeMoi
:
number
;
typeMove
:
number
;
typeToi
=
10
;
...
...
@@ -29,9 +29,10 @@ export class BattleComponent implements OnInit {
selfTeam
:
any
=
[];
curPoke
:
any
=
{};
affichageHp
:
number
=
0
;
user
:
any
;
constructor
(
private
route
:
ActivatedRoute
,
private
httpClient
:
HttpClient
)
{
}
constructor
(
private
route
:
ActivatedRoute
,
private
httpClient
:
HttpClient
,
private
chatService
:
ChatService
)
{
}
getPokemon
(){
...
...
@@ -39,7 +40,6 @@ export class BattleComponent implements OnInit {
if
(
el
.
stats
[
0
].
stat_value
>
0
)
this
.
curPoke
=
el
;
this
.
curHealthSelf
=
this
.
curPoke
.
stats
[
0
].
stat_value
;
this
.
atk
=
this
.
curPoke
.
stats
[
1
].
stat_value
;
this
.
def
=
this
.
curPoke
.
stats
[
2
].
stat_value
;
this
.
typeMoi
=
this
.
curPoke
.
types
[
0
].
id_type
;
this
.
maxHealth
=
this
.
curPoke
.
base_stats
[
0
].
base_stat
this
.
healthUpdate
();
...
...
@@ -66,12 +66,12 @@ export class BattleComponent implements OnInit {
(
res
)
=>
{
this
.
selfTeam
=
res
;
this
.
getPokemon
(),
console
.
log
(
res
)});
}
typeAdv
(
type
){
this
.
httpClient
.
post
(
"
http://localhost:3000/geteff
"
,
{
typeNous
:
type
,
typeEux
:
this
.
typeToi
},
{
responseType
:
'
json
'
,
withCredentials
:
true
}).
subscribe
((
res
:
any
)
=>
(
this
.
calculeDmg
(
res
.
body
[
0
].
damage_factor
)))
typeAdv
(
type
,
power
){
this
.
httpClient
.
post
(
"
http://localhost:3000/geteff
"
,
{
typeNous
:
type
,
typeEux
:
this
.
typeToi
},
{
responseType
:
'
json
'
,
withCredentials
:
true
}).
subscribe
((
res
:
any
)
=>
(
this
.
calculeDmg
(
res
.
body
[
0
].
damage_factor
,
power
)))
}
calculeDmg
(
eff
){
let
dmg
=
((((
0.4
*
this
.
level
+
2
)
*
this
.
atk
*
this
.
P
ower
)
/
(
50
*
this
.
def
))
+
2
)
*
(
eff
/
100
)
*
(
Math
.
random
()
*
(
1
-
0.85
)
+
0.85
)
calculeDmg
(
eff
,
power
){
let
dmg
=
((((
0.4
*
this
.
level
+
2
)
*
this
.
atk
*
p
ower
)
/
(
50
*
this
.
def
))
+
2
)
*
(
eff
/
100
)
*
(
Math
.
random
()
*
(
1
-
0.85
)
+
0.85
)
this
.
applyDamageOpponent
(
dmg
);
console
.
log
(
dmg
+
"
"
+
this
.
curHealthOpp
)
}
...
...
@@ -87,6 +87,7 @@ export class BattleComponent implements OnInit {
this
.
id_partie
=
+
params
[
'
id
'
];
// (+) converts string 'id' to a number
console
.
log
(
this
.
id_partie
);
});
this
.
chatService
.
currentUsers
.
subscribe
(
users
=>
this
.
user
=
users
);
}
}
frontend/src/app/friends-menu/friends-menu.component.ts
View file @
1404b97d
...
...
@@ -58,7 +58,7 @@ export class FriendsMenuComponent implements OnInit {
for
(
let
i
=
0
;
i
<
this
.
resultat
.
res
.
length
;
i
++
){
if
(
this
.
resultat
.
res
[
i
].
accept
===
1
){
this
.
amis
.
push
(
this
.
resultat
.
res
[
i
])
}
else
{
}
else
if
(
this
.
resultat
.
res
[
i
].
id_joueur1
!=
this
.
uid
)
{
this
.
requests
.
push
(
this
.
resultat
.
res
[
i
])
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment