-Fixed candiesToEvolve in evolve() function

-Fixed getCandy() function now returns number instead object
This commit is contained in:
Nagy Péter 2016-11-30 17:37:00 +01:00
parent 7db29979e4
commit 33f753132b
2 changed files with 6 additions and 7 deletions

View File

@ -1,7 +1,6 @@
import { GAME_MASTER } from "../../../shared";
import ENUM from "../../../enum";
/**
* @class CandyBag
*/
@ -70,9 +69,8 @@ export default class CandyBag {
* @return {Number}
*/
getCandy(dex) {
return (
this.getCandyByDexNumber(dex)
);
let candy = this.getCandyByDexNumber(dex);
return (candy.amount);
}
/**

View File

@ -33,8 +33,8 @@ export function powerUp() {
export function evolve() {
let pkmnTmpl = this.getPkmnTemplate(this.dexNumber);
let ownerPkmnCandies = this.owner.candyBag.getCandy(this.dexNumber);
let candiesToEvolve = 1;//this.candiesToEvolve();
if (ownerPkmnCandies < 1/*candiesToEvolve()*/) {
let candiesToEvolve = this.candiesToEvolve();
if (ownerPkmnCandies < candiesToEvolve) {
return print(`You have ${ownerPkmnCandies}/${candiesToEvolve} candies to evolve ${this.getPkmnName()}!`, 31);
}
let evolutions = pkmnTmpl.evolution_ids;
@ -57,11 +57,12 @@ export function evolveInto(ev) {
let evName = _toCC(ev);
let evId = pokename.getPokemonIdByName(evName);
if (evId <= 0) {
print(`Failed at retrieving id for pokemon ${ev}`, 31);
print(`Failed at retrieving id for pokemon ${ev}`, 31);
return (false);
}
let evTmpl = this.getPkmnTemplate(evId);
print(`${this.owner.username} successfully evolved ${this.getPkmnName()} into ${evName}`);
this.dexNumber = evId;
return (true);
}