mirror of
https://github.com/maierfelix/POGOserver.git
synced 2026-08-20 01:14:01 -05:00
Update
- Better cp, level and move calc - Splitted actions into seperate file
This commit is contained in:
@@ -17,17 +17,6 @@ export default class Party {
|
||||
|
||||
this.addPkmn({
|
||||
dexNumber: 4,
|
||||
cp: 100,
|
||||
stamina: 10,
|
||||
staminaMax: 20,
|
||||
move1: "TACKLE",
|
||||
move2: "SIGNAL BEAM",
|
||||
height: 0.3,
|
||||
weight: 0.55,
|
||||
ivAttack: 10,
|
||||
ivDefense: 12,
|
||||
ivStamina: 15,
|
||||
cpMultiplier: 0.333,
|
||||
pokeball: "ITEM_POKE_BALL",
|
||||
favorite: 0
|
||||
});
|
||||
|
||||
66
src/models/Pokemon/action.js
Normal file
66
src/models/Pokemon/action.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import print from "../../print";
|
||||
|
||||
import {
|
||||
_toCC,
|
||||
} from "../../utils";
|
||||
|
||||
const pokename = require("pokename")();
|
||||
|
||||
/**
|
||||
* @return {Boolean}
|
||||
*/
|
||||
export function powerUp() {
|
||||
if (this.hasReachedMaxLevel()) {
|
||||
print(`${this.owner.username}'s ${this.getPkmnName()} already reached maximum level!`);
|
||||
return void 0;
|
||||
}
|
||||
let pkmnTmpl = this.getPkmnTemplate(this.dexNumber);
|
||||
let ownerStardust = this.owner.info.stardust;
|
||||
let ownerPkmnCandies = this.owner.candyBag.getCandy(this.dexNumber);
|
||||
let requiredCandies = this.candiesToPowerUp();
|
||||
print(`${this.getPkmnName()} requires ${requiredCandies} to power up!`);
|
||||
if (ownerPkmnCandies >= requiredCandies) {
|
||||
this.level += 1;
|
||||
this.owner.candyBag.removeCandy(this.dexNumber, pkmnTmpl.candy_to_evolve);
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Boolean}
|
||||
*/
|
||||
export function evolve() {
|
||||
let pkmnTmpl = this.getPkmnTemplate(this.dexNumber);
|
||||
let ownerPkmnCandies = this.owner.candyBag.getCandy(this.dexNumber);
|
||||
let candiesToEvolve = this.candiesToEvolve();
|
||||
if (ownerPkmnCandies < candiesToEvolve()) {
|
||||
return print(`You have ${ownerPkmnCandies}/${candiesToEvolve} candies to evolve ${this.getPkmnName()}!`, 31);
|
||||
}
|
||||
let evolutions = pkmnTmpl.evolution_ids;
|
||||
if (this.hasEvolution() && evolutions.length <= 1) {
|
||||
let result = this.evolveInto(evolutions[0]);
|
||||
this.owner.candyBag.removeCandy(this.dexNumber, pkmnTmpl.candy_to_evolve);
|
||||
return (result);
|
||||
}
|
||||
else {
|
||||
print(`Evolving this pokemon isnt supported yet!`, 31);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} ev
|
||||
* @return {Boolean}
|
||||
*/
|
||||
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);
|
||||
return (false);
|
||||
}
|
||||
let evTmpl = this.getPkmnTemplate(evId);
|
||||
print(`${this.owner.username} successfully evolved ${this.getPkmnName()} into ${evName}`);
|
||||
return (true);
|
||||
}
|
||||
@@ -12,13 +12,15 @@ export function calcStats() {
|
||||
this.defense = stats.base_defense;
|
||||
this.stamina = stats.base_stamina;
|
||||
|
||||
this.ivAttack = (Math.random() * maxIV) << 0 + minIV;
|
||||
this.ivDefense = (Math.random() * maxIV) << 0 + minIV;
|
||||
this.ivStamina = (Math.random() * maxIV) << 0 + minIV;
|
||||
this.ivAttack = ~~(Math.random() * maxIV) + minIV;
|
||||
this.ivDefense = ~~(Math.random() * maxIV) + minIV;
|
||||
this.ivStamina = ~~(Math.random() * maxIV) + minIV;
|
||||
|
||||
this.height = pkmnTmpl.pokedex_height_m + ((Math.random() * pkmnTmpl.height_std_dev) + .1);
|
||||
this.weight = pkmnTmpl.pokedex_weight_kg + ((Math.random() * pkmnTmpl.weight_std_dev) + .1);
|
||||
|
||||
this.cp = this.calcCP();
|
||||
|
||||
}
|
||||
|
||||
export function calcMoves() {
|
||||
@@ -28,8 +30,8 @@ export function calcMoves() {
|
||||
let weakMoves = pkmnTmpl.quick_moves;
|
||||
let strongMoves = pkmnTmpl.cinematic_moves;
|
||||
|
||||
this.move1 = weakMoves[(Math.random() * weakMoves.length) << 0 + 1];
|
||||
this.move2 = strongMoves[(Math.random() * strongMoves.length) << 0 + 1];
|
||||
this.move1 = (Math.random() * weakMoves.length) << 0;
|
||||
this.move2 = (Math.random() * strongMoves.length) << 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -38,24 +40,14 @@ export function calcMoves() {
|
||||
*/
|
||||
export function calcCP() {
|
||||
|
||||
let ecpm = this.getEffectiveCpMultiplier();
|
||||
let ecpm = this.getCPMultipliers()[this.owner.info.lvl - 1];
|
||||
|
||||
let baseAtk = this.attack;
|
||||
let baseDef = this.defense;
|
||||
let baseSta = this.stamina;
|
||||
|
||||
let ivAtk = this.ivAttack;
|
||||
let ivDef = this.ivDefense;
|
||||
let ivSta = this.ivStamina;
|
||||
let atk = (this.attack + this.ivAttack) * ecpm;
|
||||
let def = (this.defense + this.ivDefense) * ecpm;
|
||||
let sta = (this.stamina + this.ivStamina) * ecpm;
|
||||
|
||||
return (
|
||||
Math.floor(
|
||||
(baseAtk + ivAtk) *
|
||||
Math.pow(baseDef + ivDef, 0.5) *
|
||||
Math.pow(baseSta + ivSta, 0.5) *
|
||||
Math.pow(ecpm, 2) /
|
||||
10
|
||||
)
|
||||
Math.max(10, Math.floor(Math.sqrt(atk * atk * def * sta) / 10))
|
||||
);
|
||||
|
||||
}
|
||||
@@ -63,28 +55,18 @@ export function calcCP() {
|
||||
/**
|
||||
* @return {Array}
|
||||
*/
|
||||
export function getCpMultipliers() {
|
||||
export function getCPMultipliers() {
|
||||
return (
|
||||
this.owner.info.getLevelSettings().cp_multiplier
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Number}
|
||||
*/
|
||||
export function getEffectiveCpMultiplier() {
|
||||
if (!Number.isInteger(this.level / 2)) {
|
||||
return (this.getHalfLevelCpMultiplier());
|
||||
}
|
||||
return (this.getCpMultipliers()[this.level / 2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Number} lvl
|
||||
* @return {Number}
|
||||
*/
|
||||
export function getHalfLevelCpMultiplier(lvl) {
|
||||
let next = this.getCpMultipliers()[lvl + 1];
|
||||
export function getHalfLevelCPMultiplier(lvl) {
|
||||
let next = this.getCPMultipliers()[lvl + 1];
|
||||
return (
|
||||
Math.sqrt(Math.pow(lvl, 2) + ((Math.pow(next, 2) - Math.pow(lvl, 2)) / 2))
|
||||
);
|
||||
|
||||
@@ -2,6 +2,8 @@ import MapObject from "../World/MapObject";
|
||||
|
||||
import { GAME_MASTER } from "../../shared";
|
||||
|
||||
import Settings from "../../modes";
|
||||
|
||||
import {
|
||||
_toCC,
|
||||
inherit,
|
||||
@@ -11,6 +13,7 @@ import {
|
||||
import print from "../../print";
|
||||
|
||||
import * as _calc from "./calc";
|
||||
import * as _actions from "./action";
|
||||
|
||||
const pokename = require("pokename")();
|
||||
|
||||
@@ -30,9 +33,7 @@ export default class Pokemon extends MapObject {
|
||||
this.id = 0;
|
||||
this.dexNumber = 0;
|
||||
|
||||
this.owner = null;
|
||||
|
||||
this.level = 0;
|
||||
this._level = 1;
|
||||
this.capturedLevel = 0;
|
||||
|
||||
this.cp = 0;
|
||||
@@ -55,20 +56,22 @@ export default class Pokemon extends MapObject {
|
||||
|
||||
this.staminaMax = 0;
|
||||
|
||||
this.nickname = null;
|
||||
|
||||
this.pokeball = null;
|
||||
|
||||
this.favorite = 0;
|
||||
|
||||
this.owner = null;
|
||||
this.nickname = null;
|
||||
this.pokeball = null;
|
||||
|
||||
this.init(obj);
|
||||
|
||||
}
|
||||
|
||||
get level() {
|
||||
return (this._level + 1);
|
||||
}
|
||||
set level(value) {
|
||||
this._level = parseFloat(value);
|
||||
this.calcStats();
|
||||
this.calcMoves();
|
||||
|
||||
this.powerUp();
|
||||
this.evolve();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,6 +84,8 @@ export default class Pokemon extends MapObject {
|
||||
this[key] = obj[key];
|
||||
}
|
||||
};
|
||||
this.calcStats();
|
||||
this.calcMoves();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,42 +134,25 @@ export default class Pokemon extends MapObject {
|
||||
/**
|
||||
* @return {Number}
|
||||
*/
|
||||
getCandiesToEvolve() {
|
||||
candiesToEvolve() {
|
||||
let pkmnTmpl = this.getPkmnTemplate(this.dexNumber);
|
||||
return (pkmnTmpl.candy_to_evolve << 0);
|
||||
}
|
||||
|
||||
powerUp() {
|
||||
let pkmnTmpl = this.getPkmnTemplate(this.dexNumber);
|
||||
let ownerStardust = this.owner.info.stardust;
|
||||
let ownerPkmnCandies = this.owner.candyBag.getCandy(this.dexNumber);
|
||||
let requiredCandies = this.getCandiesToEvolve();
|
||||
let requiredStardust = this.xxx();
|
||||
}
|
||||
|
||||
evolve() {
|
||||
let pkmnTmpl = this.getPkmnTemplate(this.dexNumber);
|
||||
let ownerPkmnCandies = this.owner.candyBag.getCandy(this.dexNumber);
|
||||
if (ownerPkmnCandies < this.getCandiesToEvolve()) return void 0;
|
||||
let evolutions = pkmnTmpl.evolution_ids;
|
||||
if (this.hasEvolution() && evolutions.length <= 1) {
|
||||
this.evolveInto(evolutions[0]);
|
||||
this.owner.candyBag.removeCandy(this.dexNumber, pkmnTmpl.candy_to_evolve);
|
||||
}
|
||||
else {
|
||||
print(`Evolving this pokemon isnt supported yet!`, 31);
|
||||
}
|
||||
/**
|
||||
* @return {Number}
|
||||
*/
|
||||
candiesToPowerUp() {
|
||||
return (1337);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} ev
|
||||
* @return {Boolean}
|
||||
*/
|
||||
evolveInto(ev) {
|
||||
let evName = _toCC(ev);
|
||||
let evId = pokename.getPokemonIdByName(evName);
|
||||
if (evId <= 0) return print(`Failed at retrieving id for pokemon ${ev}`, 31);
|
||||
let evTmpl = this.getPkmnTemplate(evId);
|
||||
print(`${this.owner.username} successfully evolved ${this.getPkmnName()} into ${evName}`);
|
||||
hasReachedMaxLevel() {
|
||||
return (
|
||||
this.level > this.owner.info.getMaximumLevel() * 2
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,4 +191,5 @@ export default class Pokemon extends MapObject {
|
||||
|
||||
}
|
||||
|
||||
inherit(Pokemon, _calc);
|
||||
inherit(Pokemon, _calc);
|
||||
inherit(Pokemon, _actions);
|
||||
@@ -30,89 +30,6 @@ export default {
|
||||
},
|
||||
PKMN_SETTINGS: {
|
||||
MIN_IV: 1,
|
||||
MAX_IV: 15,
|
||||
POWER_UP_PRICE: [
|
||||
{
|
||||
dust: 200,
|
||||
candy: 1,
|
||||
pkmnLevel: [1, 1.5, 2, 2.5]
|
||||
}, {
|
||||
dust: 400,
|
||||
candy: 1,
|
||||
pkmnLevel: [3, 3.5, 4, 4.5]
|
||||
}, {
|
||||
dust: 600,
|
||||
candy: 1,
|
||||
pkmnLevel: [5, 5.5, 6, 6.5]
|
||||
}, {
|
||||
dust: 800,
|
||||
candy: 1,
|
||||
pkmnLevel: [7, 7.5, 8, 8.5]
|
||||
}, {
|
||||
dust: 1000,
|
||||
candy: 1,
|
||||
pkmnLevel: [9, 9.5, 10, 10.5]
|
||||
}, {
|
||||
dust: 1300,
|
||||
candy: 2,
|
||||
pkmnLevel: [11, 11.5, 12, 12.5]
|
||||
}, {
|
||||
dust: 1600,
|
||||
candy: 2,
|
||||
pkmnLevel: [13, 13.5, 14, 14.5]
|
||||
}, {
|
||||
dust: 1900,
|
||||
candy: 2,
|
||||
pkmnLevel: [15, 15.5, 16, 16.5]
|
||||
}, {
|
||||
dust: 2200,
|
||||
candy: 2,
|
||||
pkmnLevel: [17, 17.5, 18, 18.5]
|
||||
}, {
|
||||
dust: 2500,
|
||||
candy: 2,
|
||||
pkmnLevel: [19, 19.5, 20, 20.5]
|
||||
}, {
|
||||
dust: 3000,
|
||||
candy: 3,
|
||||
pkmnLevel: [21, 21.5, 22, 22.5]
|
||||
}, {
|
||||
dust: 3500,
|
||||
candy: 3,
|
||||
pkmnLevel: [23, 23.5, 24, 24.5]
|
||||
}, {
|
||||
dust: 4000,
|
||||
candy: 3,
|
||||
pkmnLevel: [25, 25.5, 26, 26.5]
|
||||
}, {
|
||||
dust: 4500,
|
||||
candy: 3,
|
||||
pkmnLevel: [27, 27.5, 28, 28.5]
|
||||
}, {
|
||||
dust: 5000,
|
||||
candy: 3,
|
||||
pkmnLevel: [29, 29.5, 30, 30.5]
|
||||
}, {
|
||||
dust: 6000,
|
||||
candy: 4,
|
||||
pkmnLevel: [31, 31.5, 32, 32.5]
|
||||
}, {
|
||||
dust: 7000,
|
||||
candy: 4,
|
||||
pkmnLevel: [33, 33.5, 34, 34.5]
|
||||
}, {
|
||||
dust: 8000,
|
||||
candy: 4,
|
||||
pkmnLevel: [35, 35.5, 36, 36.5]
|
||||
}, {
|
||||
dust: 9000,
|
||||
candy: 4,
|
||||
pkmnLevel: [37, 37.5, 38, 38.5]
|
||||
}, {
|
||||
dust: 10000,
|
||||
candy: 4,
|
||||
pkmnLevel: [39, 39.5, 40, 40.5]
|
||||
}
|
||||
]
|
||||
MAX_IV: 15
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user