Commit 1404b97d authored by Sofia Aicha Delijaj's avatar Sofia Aicha Delijaj
Browse files

rectifications

parent f46b24bf
......@@ -25,7 +25,6 @@ speed-measure-plugin*.json
# IDE - VSCode
.vscode/*
.vscode/
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
......
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) => {
......
......@@ -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>
......
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.Power)/(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*power)/(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);
}
}
......@@ -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])
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment