Commit 1fe4e726 authored by Manish Kumar's avatar Manish Kumar
Browse files

Merge branch 'master' of gitlab.unige.ch:Manish.Kumar/webpoke

parents 198a32b3 0bfd91e5
......@@ -11,7 +11,7 @@ const Pokemon = function(pokemon) {
Pokemon.getAll = result => {
sql.query("SELECT * FROM pokemon", (err, res) => {
sql.query("SELECT * FROM pokemon WHERE id_pokemon < 175", (err, res) => {
if (err) {
console.log("error: ", err);
result(null, err);
......
......@@ -11,7 +11,7 @@
</div>
</div>
<div class="col-md-4">
<a class="btn btn-primary" id="remove" [routerLink]="['/battle', partie.id_partie, partie.joueurTour, partie.pseudo]">Continue</a>
<a class="btn btn-primary" id="remove" [routerLink]="['/battle', partie.id_partie, partie.joueurTour, partie.pseudo]" skipLocationChange>Continue</a>
</div>
</div>
</div>
......@@ -55,7 +55,7 @@
</div>
</section>
<div class="alert alert-warning alert-dismissible fade show" role="alert" *ngIf="!loggedIn">
You need to <strong>create an account</strong> to use this feature.
You need to <strong>create an account</strong> to use this feature.
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
......
......@@ -23,6 +23,8 @@ export class BattleComponent implements OnInit {
curPoke: any = {};
def: number;
affichageHp: number = 0;
dmgClasse: number;
atkspec: number;
enemyPokemon: any = {};
enemyTeam: any = [];
......@@ -30,6 +32,7 @@ export class BattleComponent implements OnInit {
enemyCurHealth = 100;
enemyMaxHealth: number;
enemyDef: number;
enemySpecDEf: number;
enemyAtk: number;
enemyAffichageHp: number = 0;
......@@ -62,6 +65,7 @@ export class BattleComponent implements OnInit {
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.atkspec = this.curPoke.stats[4].stat_value;
this.typeMoi = this.curPoke.types[0].id_type;
this.maxHealth = this.curPoke.base_stats[0].base_stat;
this.affichageHp = this.healthUpdate(this.curHealthSelf, this.maxHealth);
......@@ -75,6 +79,7 @@ export class BattleComponent implements OnInit {
this.enemyCurHealth = this.enemyPokemon.stats[0].stat_value;
this.enemyAtk = this.enemyPokemon.stats[1].stat_value;
this.enemyDef = this.enemyPokemon.stats[2].stat_value;
this.enemySpecDEf = this.enemyPokemon.stats[5].stat_value;
this.enemyType = this.enemyPokemon.types[0].id_type;
this.enemyMaxHealth = this.enemyPokemon.base_stats[0].base_stat;
this.enemyAffichageHp = this.healthUpdate(this.enemyCurHealth, this.enemyMaxHealth);
......@@ -148,6 +153,7 @@ export class BattleComponent implements OnInit {
typeAdv(move){
console.log(move);
this.dmgClasse = move.id_dmg_classe;
this.httpClient.post("http://localhost:3000/geteff", { typeNous: move.m_id_type, typeEux: this.enemyType}, {responseType: 'json', withCredentials: true}).subscribe((res:any) => {
console.log(res);
this.moveToSend = move;
......@@ -195,10 +201,20 @@ export class BattleComponent implements OnInit {
calculeDmg(eff, power){
console.log(eff, power);
console.log(this.enemyDef + " " + this.atk);
let dmg = Math.round(((((0.4*this.level+2)*this.atk*power)/(50*this.enemyDef))+2)*(eff/100)*(Math.random()*(1 - 0.85)+ 0.85));
this.applyDamageOpponent(dmg);
console.log(dmg + " " + this.enemyCurHealth);
return dmg;
if(this.dmgClasse == 2){
let dmg = Math.round(((((0.4*this.level+2)*this.atk*power)/(50*this.enemyDef))+2)*(eff/100)*(Math.random()*(1 - 0.85)+ 0.85));
this.applyDamageOpponent(dmg);
console.log(dmg + " " + this.enemyCurHealth);
return dmg;
} else if (this.dmgClasse == 3){
let dmg = Math.round(((((0.4*this.level+2)*this.atkspec*power)/(50*this.enemySpecDEf))+2)*(eff/100)*(Math.random()*(1 - 0.85)+ 0.85));
this.applyDamageOpponent(dmg);
console.log(dmg + " " + this.enemyCurHealth);
return dmg;
} else {
this.applyDamageOpponent(0);
return 0;
}
}
ngOnInit(): void {
......
......@@ -25,7 +25,7 @@
<div class="btn btn-primary" (click)="refuser(ami, i)">
<h6>Effacer</h6>
</div>
<div class="btn btn-primary" (click)="challenge(ami)">
<div class="btn btn-primary" (click)="challenge(ami.pseudo)">
<h6>Défier</h6>
</div>
</div>
......
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