コード例 #1
0
 public function getNeedExpForNextLevel(Player $player)
 {
     $cl = $player->getCharParameters()->getLevel();
     if ($cl < 11) {
         $needExp = 40 * pow($cl, 2) + 360 * $cl;
     } elseif ($cl >= 11 and $cl < 30) {
         $needExp = -0.4 * pow($cl, 3) + 40.4 * pow($cl, 2) + 396 * $cl;
     } elseif ($cl >= 30 and $cl < 60) {
         //(65x 2 - 165x - 6750) × 0,82
         $needExp = (65 * pow($cl, 2) - 165 * $cl - 6750) * 0.82;
     } elseif ($cl >= 61 and $cl < 69) {
         //580 + (5 × CL)
         //155 + MXP (CL) х (1344 - ((69-CL) * (3 + (69-CL) * 4)))
         $needExp = 155 + 580 + 5 * $cl * (1344 - (69 - $cl) * (3 + (69 - $cl) * 4));
     } elseif ($cl >= 70 and $cl < 80) {
         //580 + (5 × CL)
         //155 + MXP (CL) х (1344 - ((69-CL) * (3 + (69-CL) * 4)))
         $needExp = 155 + 1878 + 5 * $cl * (1990 - (89 - $cl) * (3 + (89 - $cl) * 5));
     } elseif ($cl >= 80 and $cl < 100) {
         //155 + 3517 + (5*83)*(3820-((99-83)*(3+(99-83)*5)))
         $needExp = 155 + 3517 + 5 * $cl * (3829 - (100 - $cl) * (3 + (100 - $cl) * 5));
     } else {
         $needExp = 155 + 3517 + 5 * $cl * (3829 - (100 - $cl) * (3 + (100 - $cl) * 5));
     }
     return $needExp;
 }
コード例 #2
0
 /**
  * @param Player $object
  * @return mixed
  */
 public function calculate($object)
 {
     $stats = $object->getStats();
     $charParameters = $object->getCharParameters();
     $warParameters = $object->getWar();
     $maxLife = ($stats->getEndurance() + $stats->getStrenge()) * 10 + 10 * $charParameters->getLevel();
     $maxMana = $stats->getIntelligence() * 10 + 10 * $charParameters->getLevel();
     $charParameters->setMaxLife($maxLife);
     $charParameters->setMaxMana($maxMana);
     if ($charParameters->getLife() === null) {
         $charParameters->setLife($charParameters->getMaxLife());
     }
     if ($charParameters->getMana() === null) {
         $charParameters->setMana($charParameters->getMaxMana());
     }
     $object->setCharParameters($charParameters);
 }
コード例 #3
0
 /**
  * @param string $name
  * @param int $sex
  * @param int $class
  * @return Player
  */
 public function createPlayer($name, $sex, $class)
 {
     $account = $this->authService->getAccount(Game::getInstance()->getAuthToken()->getValue());
     $player = new Player();
     $statistic = new PlayerStatistic();
     $player->setAccount($account);
     $player->setName($name);
     $player->setStatistic($statistic);
     $player->setSex($sex);
     $player->setClass($class);
     $this->getRepository()->save($player);
 }
コード例 #4
0
 /**
  * @param \Likedimion\Tools\Helper\PlayerDataHelper $playerData
  * @throws \Likedimion\Exception\RegistrationException
  * @return Player
  */
 public function createPlayer(PlayerDataHelper $playerData)
 {
     try {
         $findPlayer = $this->playerService->getRepository()->findPlayerByName($playerData->name);
         throw new RegistrationException("player_name_exists");
     } catch (EntityNotFoundException $e) {
         $player = new Player();
         $player->setName($playerData->name);
         $player->setSex($playerData->sex);
         $player->setClass($playerData->class);
         $player->setRace($playerData->race);
         $stats = $player->getStats();
         $cfg = Game::getInstance()->getConfig();
         $stats->setStrenge($cfg["new_player"][$player->getClass()]["str"]);
         $stats->setDexterity($cfg["new_player"][$player->getClass()]["dex"]);
         $stats->setIntelligence($cfg["new_player"][$player->getClass()]["int"]);
         $stats->setSpirituality($cfg["new_player"][$player->getClass()]["spr"]);
         $stats->setEndurance($cfg["new_player"][$player->getClass()]["end"]);
         $player->setStats($stats);
         $this->playerCalculatingService->calculate($player);
         $this->playerService->getRepository()->save($player);
         $account = $this->authService->getAccount(Game::getInstance()->getAuthToken()->getValue());
         $player->setAccount($account);
         $this->accountService->getRepository()->save($account);
         $this->playerService->getRepository()->save($player);
         return $player;
     }
 }