Commit 11d735d8 authored by Manish Kumar's avatar Manish Kumar
Browse files

merge fix

parents a9567179 97dbff02
......@@ -12,8 +12,7 @@ exports.create = (req, res) => {
Partie.create(req.session.uid, req.body.pseudo, (err, data) => {
if (err)
res.status(500).send({
message:
err.message || "Some error occurred while creating the Pokemon."
message: err.message || "Some error occurred while creating the Pokemon."
});
else res.send(data);
});
......@@ -21,22 +20,22 @@ exports.create = (req, res) => {
exports.getDemandes = (req, res) => {
console.log("Is logged in: " + req.session.loggedIn);
if(req.session.loggedIn){
if (req.session.loggedIn) {
Partie.getDemandes(req.session.uid, (err, data) => {
if (err) {
if (err.kind === "not_found") {
res.send({res: true, body: data});
res.send({ res: true, body: data });
} else {
res.status(500).send({
message: "Error retrieving games with id " + req.session.uid
});
}
} else{
res.send({res: true, body: data});
} else {
res.send({ res: true, body: data });
}
});
} else{
res.send({res: false, body:'You must be logged in to see your games !'});
} else {
res.send({ res: false, body: 'You must be logged in to see your games !' });
res.end();
}
};
......@@ -76,3 +75,15 @@ exports.refuse = (req, res) => {
});
}
};
exports.eff = (req, res) => {
if (req.session.loggedIn) {
Partie.efficacite(req.body.typeNous, req.body.typeEux, (err, data) => {
if (err)
res.status(500).send({
message: err.message || "Some error occurred while deleting the challenge."
});
else res.send(data);
});
}
};
\ No newline at end of file
const sql = require("./db.js");
\ No newline at end of file
const Combat = function(combat, joueur) {
this.pseudo = joueur.id_pokemon;
this.email = joueur.courant;
this.password = joueur.password;
};
\ No newline at end of file
......@@ -145,9 +145,20 @@ Partie.refuse = (id_partie, result) => {
}
console.log("deleted game with id: ", id_partie);
result(null, {res: true, body: res});
result(null, { res: true, body: res });
});
};
Partie.efficacite = (typeNous, typeEux, result) => {
sql.query("SELECT damage_factor from efficacite WHERE damage_type_id = ? AND target_type_id = ?", [typeNous, typeEux], (err, res) => {
if (err) {
console.log("error: ", err);
result(err, null);
return;
}
result(null, { body: res })
});
};
module.exports = Partie;
\ No newline at end of file
module.exports = app => {
const partie = require("../controllers/combat.controller.js");
//get type efficacité
app.get();
};
\ No newline at end of file
......@@ -11,5 +11,6 @@ module.exports = app => {
app.post("/refusepartie", partie.refuse);
app.post("/getCombatTeam", partie.getCombatTeam);
app.post("/geteff", partie.eff);
};
\ No newline at end of file
......@@ -65,7 +65,7 @@
</div>
<div class="actions">
<button (click)="toggle()">Water Cannon</button>
<button onclick="calculeDmg()">Water Pulse</button>
<button (click)="typeAdv()">Water Pulse</button>
<button onclick="surf()">Surf</button>
<button onclick="tackle()">Tackle</button>
</div>
......
......@@ -13,13 +13,9 @@ export class BattleComponent implements OnInit {
maxHealth = 100;
curHealthSelf = 100;
curHealthOpp = 100;
damage = 0;
maTeam: any = [];
saTeam: any = [];
pseudo: string;
uid: any;
log: boolean;
dmg: Number;
level = 50;
Power = 60;
atk = 100;
......@@ -39,33 +35,22 @@ export class BattleComponent implements OnInit {
constructor(private route: ActivatedRoute, private httpClient: HttpClient) { }
teams(arg, id){
if(id == this.uid){
this.maTeam.push(arg)
} else {
this.saTeam.push(arg)
}
}
getCombatTeam(){
this.httpClient.post("http://localhost:3000/getCombatTeam", {id_partie: this.id_partie}, { responseType: 'json', withCredentials: true }).subscribe(
(res) => {console.log(res)}); ///////////
}
typeAdv(chiffMoi, chiffToi){
if(chiffMoi == chiffToi){
return 1
}
typeAdv(){
this.httpClient.post("http://localhost:3000/geteff", { typeNous: this.typeMoi, typeEux: this.typeToi}, {responseType: 'json', withCredentials: true}).subscribe((res:any) => (this.calculeDmg(res.body[0].damage_factor)))
}
calculeDmg(){
var reduc = this.typeAdv(this.typeMoi, this.typeToi);
this.dmg = ((((((2*this.level)/5)+2)*this.Power*(this.atk/this.def))/50)+2)*Math.random()*reduc
calculeDmg(eff){
let dmg = ((((0.4*this.level+2)*this.atk*this.Power)/(50*this.def))+2)*Math.random()*(eff/100)
console.log(dmg)
}
ngOnInit(): void {
this.httpClient.get("http://localHost:3000/checkLogin", { responseType: 'json', withCredentials: true}).subscribe( (res: any) => {
this.httpClient.get("http://localhost:3000/checkLogin", { responseType: 'json', withCredentials: true}).subscribe( (res: any) => {
this.log = res.res;
this.pseudo = res.body;
this.uid = res.uid;
......
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