Commit 0bfd91e5 authored by Sofia Aicha Delijaj's avatar Sofia Aicha Delijaj
Browse files

depens on the physical or speciale types

parent 578e1498
......@@ -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 {
......
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