diff --git a/CHANGELOG.md b/CHANGELOG.md index 21e95e644..2955c00db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## [2.1.3] - 2017-08-11 +### Added +- Messages when a ruler keeps his role due to election without candidates +- Handling of elections without candidates when the previous chief is dead + +### Changed +- Inactive accounts in dev mode are now displayed + +### Fixed +- Elections without candidates (empty messages and cycle blocking) +- Empty places resources value out of range +- Ranking diff + +### Removed +- Some recurrent user error logging + ## [2.1.2] - 2017-08-09 ### Added - Storage of the sectors ownership data in Redis diff --git a/system/Modules/Athena/Manager/OrbitalBaseManager.php b/system/Modules/Athena/Manager/OrbitalBaseManager.php index 3347b42b4..e1782732e 100644 --- a/system/Modules/Athena/Manager/OrbitalBaseManager.php +++ b/system/Modules/Athena/Manager/OrbitalBaseManager.php @@ -715,6 +715,8 @@ public function uRecycling($missionId) { $targetPlace->resources -= $totalRecycled; # if there is no more resource if ($targetPlace->resources <= 0) { + // Avoid out of range errors + $targetPlace->resources = 0; # the place become an empty place $this->placeManager->turnAsEmptyPlace($targetPlace); diff --git a/system/Modules/Atlas/Manager/RankingManager.php b/system/Modules/Atlas/Manager/RankingManager.php index 2adbdfcb0..e764a2127 100644 --- a/system/Modules/Atlas/Manager/RankingManager.php +++ b/system/Modules/Atlas/Manager/RankingManager.php @@ -88,6 +88,10 @@ public function processPlayersRanking() $playerRankingRepository = $this->entityManager->getRepository(PlayerRanking::class); + $S_PRM1 = $this->playerRankingManager->getCurrentSession(); + $this->playerRankingManager->newSession(); + $this->playerRankingManager->loadLastContext(); + $ranking = $this->createRanking(true, false); $playerRoutine->execute( @@ -103,10 +107,6 @@ public function processPlayersRanking() $playerRankingRepository->getDefendersButcherRanking(), $this->orbitalBaseHelper ); - - $S_PRM1 = $this->playerRankingManager->getCurrentSession(); - $this->playerRankingManager->newSession(); - $this->playerRankingManager->loadLastContext(); $playerRoutine->processResults($ranking, $players, $this->playerRankingManager, $playerRankingRepository); @@ -127,6 +127,10 @@ public function processFactionsRanking() $factionRankingRepository = $this->entityManager->getRepository(FactionRanking::class); $sectors = $this->entityManager->getRepository(Sector::class)->getAll(); + $S_FRM1 = $this->factionRankingManager->getCurrentSession(); + $this->factionRankingManager->newSession(); + $this->factionRankingManager->loadLastContext(); + $ranking = $this->createRanking(false, true); foreach ($factions as $faction) { @@ -138,10 +142,6 @@ public function processFactionsRanking() $factionRoutine->execute($faction, $playerRankings, $routesIncome, $sectors); } - $S_FRM1 = $this->factionRankingManager->getCurrentSession(); - $this->factionRankingManager->newSession(); - $this->factionRankingManager->loadLastContext(); - $winningFactionId = $factionRoutine->processResults($ranking, $factions, $this->factionRankingManager); $this->factionRankingManager->changeSession($S_FRM1); diff --git a/system/Modules/Demeter/Manager/ColorManager.php b/system/Modules/Demeter/Manager/ColorManager.php index d7c63b6d8..b8a8905f6 100644 --- a/system/Modules/Demeter/Manager/ColorManager.php +++ b/system/Modules/Demeter/Manager/ColorManager.php @@ -578,6 +578,10 @@ public function uMandate(Color $color, $governmentMembers, $newChief, $idOldChie $this->conversationMessageManager->add($message); } else { + $date = new \DateTime($color->dLastElection); + $date->modify('+' . $color->mandateDuration . ' second'); + $this->realtimeActionScheduler->schedule('demeter.color_manager', 'uCampaign', $color, $date->format('Y-m-d H:i:s')); + $notif = new Notification(); $notif->dSending = Utils::now(); $notif->setRPlayer($newChief->id); @@ -596,41 +600,105 @@ public function uMandate(Color $color, $governmentMembers, $newChief, $idOldChie $this->conversationMessageManager->add($message); } } else { + $noChief = false; + if (($oldChief = $this->playerManager->get($idOldChief)) === null) { + $noChief = true; + $oldChief = $this->playerManager->getByName($color->officialName); + } /* $date = new DateTime($this->dLastElection); $date->modify('+' . $this->mandateDuration + self::ELECTIONTIME + self::CAMPAIGNTIME . ' second'); $date = $date->format('Y-m-d H:i:s'); $this->dLastElection = $date;*/ + $color->dLastElection = Utils::now(); + $color->electionStatement = Color::MANDATE; - if ($color->regime == Color::ROYALISTIC) { - $notif = new Notification(); - $notif->dSending = Utils::now(); - $notif->setRPlayer($newChief->id); - $notif->setTitle('Votre coup d\'état a échoué'); - $notif->addBeg() - ->addTxt(' Le peuple ne vous a pas soutenu, l\'ancien gouvernement reste en place.'); - $this->notificationManager->add($notif); + switch ($color->regime) { + case Color::DEMOCRATIC: + $date = new \DateTime($color->dLastElection); + $date->modify('+' . $color->mandateDuration . ' second'); + $this->realtimeActionScheduler->schedule('demeter.color_manager', 'uCampaign', $color, $date->format('Y-m-d H:i:s')); - if ($idOldChief) { - $notif = new Notification(); - $notif->dSending = Utils::now(); - $notif->setRPlayer($idOldChief); - $notif->setTitle('Un coup d\'état a échoué'); - $notif->addBeg() - ->addTxt(' Le joueur ') - ->addLnk('embassy/player-' . $newChief->id, $newChief->name) - ->addTxt(' a tenté un coup d\'état, celui-ci a échoué.'); - $this->notificationManager->add($notif); - } - } elseif ($color->regime == Color::THEOCRATIC) { - if ($idOldChief) { - $notif = new Notification(); - $notif->dSending = Utils::now(); - $notif->setRPlayer($idOldChief); - $notif->setTitle('Vous avez été nommé Guide'); - $notif->addBeg() - ->addTxt(' Les Oracles ont parlé, vous êtes toujours désigné par la Grande Lumière pour guider Cardan vers la Gloire.'); - $this->notificationManager->add($notif); - } + if ($idOldChief) { + $notif = new Notification(); + $notif->dSending = Utils::now(); + $notif->setRPlayer($idOldChief); + $notif->setTitle('Vous demeurez ' . ColorResource::getInfo($color->getId(), 'status')[Player::CHIEF - 1]); + $notif->addBeg() + ->addTxt(' Aucun candidat ne s\'est présenté oour vous remplacer lors des dernières élections. Par conséquent, vous êtes toujours à la tête de ' . $color->popularName); + $this->notificationManager->add($notif); + } + # création du message + $message = new ConversationMessage(); + $message->rConversation = $conv->id; + $message->rPlayer = $convPlayerID; + $message->type = ConversationMessage::TY_STD; + $message->dCreation = Utils::now(); + $message->dLastModification = NULL; + $message->content = ' La période électorale est terminée. Aucun candidat ne s\'est présenté pour prendre la tête de ' . $color->popularName . '.'; + $message->content .= + ($noChief === false) + ? '
Par conséquent, ' . $oldChief->getName() . ' est toujours au pouvoir.' + : '
Par conséquent, le siège du pouvoir demeure vacant.' + ; + $this->conversationMessageManager->add($message); + break; + case Color::ROYALISTIC: + $notif = new Notification(); + $notif->dSending = Utils::now(); + $notif->setRPlayer($newChief->id); + $notif->setTitle('Votre coup d\'état a échoué'); + $notif->addBeg() + ->addTxt(' Le peuple ne vous a pas soutenu, l\'ancien gouvernement reste en place.'); + $this->notificationManager->add($notif); + + if ($idOldChief) { + $notif = new Notification(); + $notif->dSending = Utils::now(); + $notif->setRPlayer($idOldChief); + $notif->setTitle('Un coup d\'état a échoué'); + $notif->addBeg() + ->addTxt(' Le joueur ') + ->addLnk('embassy/player-' . $newChief->id, $newChief->name) + ->addTxt(' a tenté un coup d\'état, celui-ci a échoué.'); + $this->notificationManager->add($notif); + } + $message = new ConversationMessage(); + $message->rConversation = $conv->id; + $message->rPlayer = $convPlayerID; + $message->type = ConversationMessage::TY_STD; + $message->dCreation = Utils::now(); + $message->dLastModification = NULL; + $message->content = 'Un coup d\'état a échoué. ' . $oldChief->getName(). ' demeure le dirigeant de ' . $color->popularName . '.'; + $this->conversationMessageManager->add($message); + break; + case Color::THEOCRATIC: + $date = new \DateTime($color->dLastElection); + $date->modify('+' . $color->mandateDuration . ' second'); + $this->realtimeActionScheduler->schedule('demeter.color_manager', 'uCampaign', $color, $date->format('Y-m-d H:i:s')); + + if ($idOldChief) { + $notif = new Notification(); + $notif->dSending = Utils::now(); + $notif->setRPlayer($idOldChief); + $notif->setTitle('Vous avez été nommé Guide'); + $notif->addBeg() + ->addTxt(' Les Oracles ont parlé, vous êtes toujours désigné par la Grande Lumière pour guider Cardan vers la Gloire.'); + $this->notificationManager->add($notif); + } + $message = new ConversationMessage(); + $message->rConversation = $conv->id; + $message->rPlayer = $convPlayerID; + $message->type = ConversationMessage::TY_STD; + $message->dCreation = Utils::now(); + $message->dLastModification = NULL; + $message->content = 'Nul ne s\'est soumis au regard des dieux pour conduire ' . $color->popularName . ' vers sa gloire.'; + $message->content .= + ($noChief === false) + ? $oldChief->getName(). ' demeure l\'élu des dieux pour accomplir leurs desseins dans la galaxie.' + : 'Par conséquent, le siège du pouvoir demeure vacant.' + ; + $this->conversationMessageManager->add($message); + break; } } $this->entityManager->flush(); diff --git a/system/Modules/Gaia/Manager/SectorManager.php b/system/Modules/Gaia/Manager/SectorManager.php index 2d700fbcd..7e1f8fec8 100644 --- a/system/Modules/Gaia/Manager/SectorManager.php +++ b/system/Modules/Gaia/Manager/SectorManager.php @@ -113,7 +113,6 @@ public function changeOwnership(Sector $sector) public function calculateAllOwnerships() { - \Asylamba\Classes\Daemon\Server::debug('sectors'); foreach ($this->getAll() as $sector) { $this->calculateOwnership($sector); } diff --git a/system/action/std/athena/building/build.php b/system/action/std/athena/building/build.php index c22063265..533d19d0e 100755 --- a/system/action/std/athena/building/build.php +++ b/system/action/std/athena/building/build.php @@ -146,7 +146,7 @@ $session->addFlashbag('Construction programmée', Flashbag::TYPE_SUCCESS); } else { - throw new ErrorException('les conditions ne sont pas remplies pour construire ce bâtiment'); + throw new FormException('les conditions ne sont pas remplies pour construire ce bâtiment'); } } else { throw new ErrorException('cette base ne vous appartient pas'); diff --git a/system/action/std/athena/transaction/propose.php b/system/action/std/athena/transaction/propose.php index 6f205b15c..5c88ba31d 100755 --- a/system/action/std/athena/transaction/propose.php +++ b/system/action/std/athena/transaction/propose.php @@ -171,14 +171,14 @@ throw new ErrorException('Il y a un problème avec votre commandant.'); } } else { - throw new ErrorException('Vous n\'avez pas assez de vaisseaux de transport disponibles.'); + throw new FormException('Vous n\'avez pas assez de vaisseaux de transport disponibles.'); } } else { switch ($type) { case Transaction::TYP_RESOURCE : - throw new ErrorException('Vous n\'avez pas assez de ressources en stock.'); + throw new FormException('Vous n\'avez pas assez de ressources en stock.'); case Transaction::TYP_SHIP : - throw new ErrorException('Vous n\'avez pas assez de vaisseaux.'); + throw new FormException('Vous n\'avez pas assez de vaisseaux.'); default: throw new ErrorException('Erreur pour une raison étrange, contactez un administrateur.'); } diff --git a/system/buffer/main.php b/system/buffer/main.php index f9e85ff4f..cd1bd4079 100755 --- a/system/buffer/main.php +++ b/system/buffer/main.php @@ -2,12 +2,14 @@ use Asylamba\Classes\Library\Utils; +use Asylamba\Modules\Zeus\Model\Player; + if ($this->getContainer()->getParameter('environment') === 'dev' || $this->getContainer()->get('app.request')->query->get('key') === $this->getContainer()->getParameter('security_buffer_key')) { $playerManager = $this->getContainer()->get('zeus.player_manager'); $security = $this->getContainer()->get('security'); - $activePlayers = $playerManager->getActivePlayers(); + $activePlayers = $playerManager->getByStatements([Player::ACTIVE, Player::INACTIVE, Player::HOLIDAY]); ?>