Skip to content

Commit

Permalink
multiple evolve
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin-Morette committed Jun 8, 2024
1 parent d714844 commit c86b2aa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/src/controllers/PokemonController.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class PokemonController {
const { namePokemon } = req.body;
const { idTrainer } = req.body;
const { isShiny } = req.body;
const { quantity } = req.body;
models.pokemon.findByName(namePokemon).then(([pokemon]) => {
if (pokemon.length === 0) {
res.status(201).send({ status: "noExistPokemon" });
Expand All @@ -183,7 +184,7 @@ class PokemonController {
.updateDownQuantity(
pokemon[0].id,
idTrainer,
pokemon[0].numberEvolution,
pokemon[0].numberEvolution * quantity,
isShiny
)
.then(([result]) => {
Expand All @@ -204,7 +205,7 @@ class PokemonController {
idTrainer,
isShiny,
};
models.pokemon_trainer.insert(pokemonTrainer).then(() => {
models.pokemon_trainer.insert(pokemonTrainer, quantity).then(() => {
models.pokemon.find(idEvolution).then(([resultPokemon]) => {
res.status(201).send({
status: "evolve",
Expand Down

0 comments on commit c86b2aa

Please sign in to comment.