From c4c72f69c432c08fef37b988f5bdcde1674fcbcc Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Fri, 11 Aug 2017 12:39:05 +0200 Subject: [PATCH 1/8] Fix out of range error for empty recycling places --- system/Modules/Athena/Manager/OrbitalBaseManager.php | 2 ++ 1 file changed, 2 insertions(+) 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); From b40c2d244bf7ad2ab7773dfd4974b783965627d9 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Fri, 11 Aug 2017 12:43:57 +0200 Subject: [PATCH 2/8] Reduce user error logging --- system/action/std/athena/building/build.php | 2 +- system/action/std/athena/transaction/propose.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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.'); } From cef294913dbba3792da2ecbed23fb163693b4932 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Fri, 11 Aug 2017 13:33:45 +0200 Subject: [PATCH 3/8] Fix elections ending when no candidates or votes exist. Handle the case where the old chief is dead --- .../Modules/Demeter/Manager/ColorManager.php | 120 +++++++++++++----- 1 file changed, 91 insertions(+), 29 deletions(-) diff --git a/system/Modules/Demeter/Manager/ColorManager.php b/system/Modules/Demeter/Manager/ColorManager.php index d7c63b6d8..5e0c4523e 100644 --- a/system/Modules/Demeter/Manager/ColorManager.php +++ b/system/Modules/Demeter/Manager/ColorManager.php @@ -379,6 +379,7 @@ public function ballot($factionId) { ? -1 : 1; }); } + \Asylamba\Classes\Daemon\Server::debug('logique'); reset($listCandidate); $convPlayerID = $this->playerManager->getFactionAccount($faction->id)->id; @@ -402,6 +403,7 @@ public function ballot($factionId) { $this->uMandate($faction, $governmentMembers, $newChief, $chiefId, TRUE, $conv, $convPlayerID, $listCandidate); } else { + \Asylamba\Classes\Daemon\Server::debug("t'es trop fort"); $this->uMandate($faction, 0, 0, $chiefId, FALSE, $conv, $convPlayerID, $listCandidate); } } elseif ($faction->regime == Color::ROYALISTIC) { @@ -596,41 +598,101 @@ 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: + 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(); From e4f3144ab913f48ddb538f14e24e1c0f2fd22b1f Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Fri, 11 Aug 2017 17:45:38 +0200 Subject: [PATCH 4/8] Fix ranking diff --- system/Modules/Atlas/Manager/RankingManager.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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); From fc950bf704cdbcaa69ddcbd70faba28a33e45797 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Fri, 11 Aug 2017 17:46:16 +0200 Subject: [PATCH 5/8] Remove debugging dumps --- system/Modules/Demeter/Manager/ColorManager.php | 2 -- system/Modules/Gaia/Manager/SectorManager.php | 1 - 2 files changed, 3 deletions(-) diff --git a/system/Modules/Demeter/Manager/ColorManager.php b/system/Modules/Demeter/Manager/ColorManager.php index 5e0c4523e..74ca9f766 100644 --- a/system/Modules/Demeter/Manager/ColorManager.php +++ b/system/Modules/Demeter/Manager/ColorManager.php @@ -379,7 +379,6 @@ public function ballot($factionId) { ? -1 : 1; }); } - \Asylamba\Classes\Daemon\Server::debug('logique'); reset($listCandidate); $convPlayerID = $this->playerManager->getFactionAccount($faction->id)->id; @@ -403,7 +402,6 @@ public function ballot($factionId) { $this->uMandate($faction, $governmentMembers, $newChief, $chiefId, TRUE, $conv, $convPlayerID, $listCandidate); } else { - \Asylamba\Classes\Daemon\Server::debug("t'es trop fort"); $this->uMandate($faction, 0, 0, $chiefId, FALSE, $conv, $convPlayerID, $listCandidate); } } elseif ($faction->regime == Color::ROYALISTIC) { 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); } From 2c5957fb857180dd47f086c025d12e94e9140b50 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Fri, 11 Aug 2017 17:56:29 +0200 Subject: [PATCH 6/8] Show inactive accounts in dev mode buffer list --- system/buffer/main.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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]); ?> From abf7efbaa28d2e08ea1f4ce73e8a3ba90180e64a Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Fri, 11 Aug 2017 18:03:00 +0200 Subject: [PATCH 7/8] Schedule theocratic campaigns after elections result --- system/Modules/Demeter/Manager/ColorManager.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/system/Modules/Demeter/Manager/ColorManager.php b/system/Modules/Demeter/Manager/ColorManager.php index 74ca9f766..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); @@ -668,6 +672,10 @@ public function uMandate(Color $color, $governmentMembers, $newChief, $idOldChie $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(); From d0a4709092e5769a4f3ea3f38c2495892dd6d689 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Fri, 11 Aug 2017 18:03:34 +0200 Subject: [PATCH 8/8] Release v2.1.3 --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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