Bug fixes

- Fixed avatar
- Fixed avatar wrong range validation
- Fixed player currencies
This commit is contained in:
Felix
2016-09-05 20:24:03 +02:00
parent 8be4111e94
commit 2de38e5568
6 changed files with 73 additions and 50 deletions

View File

@@ -19,7 +19,7 @@ export default class Avatar {
this._shoes = 0;
this._eyes = 0;
this._backpack = 0;
this._gender = "MALE";
this._gender = 0;
}
@@ -60,7 +60,7 @@ export default class Avatar {
return (this._shirt);
}
set shirt(value) {
if (this.between(value, 0, 3)) {
if (this.between(value, 0, 9)) {
this._shirt = value;
}
}
@@ -117,10 +117,10 @@ export default class Avatar {
// gender
get gender() {
return (this._gender);
return (this._gender === 0 ? "MALE" : "FEMALE");
}
set gender(value) {
if (value === "MALE" || value === "FEMALE") {
if (this.between(value, 0, 1)) {
this._gender = value;
}
}

View File

@@ -11,11 +11,6 @@ export default class Currency {
this.player = player;
this.currencies = {
"POKECOIN": 0,
"STARDUST": 0
};
}
/**
@@ -23,12 +18,14 @@ export default class Currency {
*/
serialize() {
let out = [];
for (let key in this.currencies) {
out.push({
name: key,
amount: this.currencies[key]
});
};
out.push({
name: "POKECOIN",
amount: this.player.info.pokecoin
});
out.push({
name: "STARDUST",
amount: this.player.info.stardust
});
return (out);
}

View File

@@ -2,6 +2,8 @@ import { GAME_MASTER } from "../../../shared";
import print from "../../../print";
import ENUM from "../../../enum";
/**
* @class Info
*/
@@ -15,16 +17,15 @@ export default class Info {
this.player = player;
this.lvl = 1;
this.stardust = 0;
this.pokecoins = 0;
this.team = "NEUTRAL";
this._exp = 0;
this._team = 0;
this._level = 0;
this.exp = this.getLevelExp(this.lvl);
this.prevLvlExp = this.getLevelExp(this.lvl);
this.nextLvlExp = this.getLevelExp(this.lvl + 1);
this.prevLvlExp = 0;
this.nextLvlExp = 0;
this.levelReward = false;
@@ -43,6 +44,34 @@ export default class Info {
}
get exp() {
return (this._exp);
}
set exp(value) {
this._exp = value;
this.updatePrevNextExp();
}
get level() {
return (this._level);
}
set level(value) {
this._level = value;
this.updatePrevNextExp();
}
get team() {
return (ENUM.getNameById(ENUM.TEAM, this._team));
}
set team(value) {
this._team = value << 0;
}
updatePrevNextExp() {
this.prevLvlExp = this.getLevelExp(this.level);
this.nextLvlExp = this.getLevelExp(this.level + 1);
}
upgradeLevel() {
}
@@ -80,14 +109,14 @@ export default class Info {
*/
upgradeExp(exp) {
if (!this.maxLevelReached()) {
let currentLevelExp = this.getLevelExp(this.lvl);
let nextLevelExp = this.getLevelExp(this.lvl + 1);
let currentLevelExp = this.getLevelExp(this.level);
let nextLevelExp = this.getLevelExp(this.level + 1);
let leftExp = nextLevelExp - this.exp;
this.levelReward = false;
if (this.exp + exp >= nextLevelExp) {
this.lvl += 1;
this.level += 1;
this.prevLvlExp = nextLevelExp;
this.nextLvlExp = this.getLevelExp(this.lvl + 1);
this.nextLvlExp = this.getLevelExp(this.level + 1);
this.exp += leftExp + 1;
this.levelReward = true;
this.upgradeExp(exp - leftExp);
@@ -103,7 +132,7 @@ export default class Info {
*/
maxLevelReached() {
return (
this.lvl + 1 >= this.getMaximumLevel()
this.level + 1 >= this.getMaximumLevel()
);
}
@@ -115,8 +144,9 @@ export default class Info {
modified_timestamp_ms: +new Date(),
inventory_item_data: {
player_stats: {
level: this.lvl,
level: this.level,
experience: this.exp,
prev_level_xp: this.prevLvlExp,
next_level_xp: this.nextLvlExp,
km_walked: this.kmWalked,
pokemons_encountered: this.pkmnEncountered,
@@ -126,28 +156,7 @@ export default class Info {
pokeballs_thrown: this.pokeballsThrown,
eggs_hatched: this.eggsHatched,
big_magikarp_caught: this.bigMagikarpCaught,
pokemon_deployed: this.pkmnDeployed,
pokemon_caught_by_type: {
0: 0,
1: 1,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
8: 0,
9: 0,
10: 0,
11: 0,
12: 0,
13: 0,
14: 0,
15: 0,
16: 0,
17: 0,
18: 0
}
pokemon_deployed: this.pkmnDeployed
}
}
});

View File

@@ -193,6 +193,21 @@ export default class Player extends MapObject {
else if (key === "tutorial") {
this.tutorial.parseJSON(obj[key]);
}
else if (key === "pokecoins") {
this.info.pokecoins = obj[key] << 0;
}
else if (key === "stardust") {
this.info.stardust = obj[key] << 0;
}
else if (key === "level") {
this.info.level = obj[key] << 0;
}
else if (key === "exp") {
this.info.exp = obj[key] << 0;
}
else if (key === "team") {
this.info.team = obj[key] << 0;
}
else {
if (this.hasOwnProperty(key)) {
this[key] = obj[key];

View File

@@ -9,9 +9,11 @@ export default function GetInventory(msg) {
let items = this.bag.serialize();
let stats = this.info.serialize();
let party = this.party.serialize();
let currencies = this.currency.serialize();
//let pokedex = this.pokedex.serialize();
items.push(stats);
items.push(currencies);
party.map((pkmn) => {
items.push(pkmn);

View File

@@ -40,7 +40,7 @@ export function calcMoves() {
*/
export function calcCP() {
let ecpm = this.getCPMultipliers()[this.owner.info.lvl - 1];
let ecpm = this.getCPMultipliers()[this.owner.info.level - 1];
let atk = (this.attack + this.ivAttack) * ecpm;
let def = (this.defense + this.ivDefense) * ecpm;