From e4bdc9037611e74472204a2e8b8a7f0682f6e3c0 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Sun, 23 Jul 2017 22:36:27 +0200 Subject: [PATCH 01/22] Add Kern as an admin --- system/Classes/Library/Utils.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/Classes/Library/Utils.php b/system/Classes/Library/Utils.php index 7cd3937a2..17a81a91a 100644 --- a/system/Classes/Library/Utils.php +++ b/system/Classes/Library/Utils.php @@ -12,6 +12,7 @@ class Utils { public static function isAdmin($bindkey) { $bindkeys = array( 'player1', 'player2', 'gil', 'noe', 'jacky', + 'YNbrdEaJpDw8mLZ2u6jYqgt6a', 'jq2Bjf0uKzzE0aMErO6rpBxcg', 'E6GatZvhO1W9seBHU7mgQe49c', 'FaDcTV3lWokXHZO8tXH4divWZ', From bb4a7507d532096b4e841f5e1ba66203d1c20e3a Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Sun, 23 Jul 2017 22:41:57 +0200 Subject: [PATCH 02/22] Release v2.1.1 --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffb9b9527..85c2d456d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +## [2.1.1] - 2017-17-23 +### Added +- Spy and combat active report highlighting in the list +- Daily scheduling for notifications cleaning and inactive accounts management +- Daily scheduling for rankings +- Set an INI parameter for max execution time +- Redis session handling + +### Fixed +- External invitations for registration +- School experience for commanders +- Access to admin interface +- Empty investments +- Conversation with no recipients error message +- Storage building informations +- Flashbags for queue's ending notification +- Ship recycling +- Parrainage reward +- Commercial shipping travel time +- Capital leaving +- Defenders losses after a successful defense +- Workers access to the session data + ## [2.1.0] - 2017-06-01 ### Added - Container class for services and parameters From 3af9ad21c38f05d13d29b3de8a79bfde8c441f04 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Sun, 23 Jul 2017 23:00:05 +0200 Subject: [PATCH 03/22] Implement Redis password --- config/services.yml | 1 + system/Classes/Redis/RedisManager.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/config/services.yml b/config/services.yml index 156d54cab..6319043c8 100644 --- a/config/services.yml +++ b/config/services.yml @@ -144,6 +144,7 @@ services: arguments: - "%redis_host" - "%redis_port" + - "%redis_password" - "%redis_timeout" exception_listener: diff --git a/system/Classes/Redis/RedisManager.php b/system/Classes/Redis/RedisManager.php index 997bea794..719ec5897 100644 --- a/system/Classes/Redis/RedisManager.php +++ b/system/Classes/Redis/RedisManager.php @@ -10,12 +10,14 @@ class RedisManager /** * @param string $host * @param int $port + * @param string $password * @param float $timeout */ - public function __construct($host, $port, $timeout) + public function __construct($host, $port, $password, $timeout) { $this->connection = new \Redis(); $this->connection->connect($host, $port, $timeout); + $this->connection->auth($password); } public function __destruct() From 90e54255c0ebe8a863fb037bca6ef1f659f07451 Mon Sep 17 00:00:00 2001 From: Tinydetoon Date: Thu, 27 Jul 2017 23:19:45 +0200 Subject: [PATCH 04/22] Fix incoming attacks detection --- .../Modules/Ares/Manager/CommanderManager.php | 23 +++++++++++++ system/views/components/fleet/listFleet.php | 32 ++++++------------- system/views/pages/desktop/fleet.php | 9 ++++-- .../desktop/mapElement/layer/attacks.php | 2 +- system/views/templates/desktop/toolbar.php | 19 +---------- 5 files changed, 40 insertions(+), 45 deletions(-) diff --git a/system/Modules/Ares/Manager/CommanderManager.php b/system/Modules/Ares/Manager/CommanderManager.php index ebd2dd944..9bf15b8e1 100644 --- a/system/Modules/Ares/Manager/CommanderManager.php +++ b/system/Modules/Ares/Manager/CommanderManager.php @@ -180,6 +180,29 @@ public function getIncomingAttacks($playerId) return $this->entityManager->getRepository(Commander::class)->getIncomingAttacks($playerId); } + /** + * @param int $playerId + * @return array + */ + public function getVisibleIncomingAttacks($playerId) + { + $attackingCommanders = $this->getIncomingAttacks($playerId) ; + $incomingCommanders = [] ; + + foreach ($attackingCommanders as $commander) { + # va chercher les heures auxquelles il rentre dans les cercles d'espionnage + $startPlace = $this->placeManager->get($commander->getRBase()); + $destinationPlace = $this->placeManager->get($commander->getRPlaceDestination()); + $times = Game::getAntiSpyEntryTime($startPlace, $destinationPlace, $commander->getArrivalDate()); + + if (strtotime(Utils::now()) >= strtotime($times[0])) { + # ajout de l'événement + $incomingCommanders[] = $commander; + } + } + return $incomingCommanders; + } + /** * @param int $playerId * @return array diff --git a/system/views/components/fleet/listFleet.php b/system/views/components/fleet/listFleet.php index 747e8a8d4..1ba97f37a 100755 --- a/system/views/components/fleet/listFleet.php +++ b/system/views/components/fleet/listFleet.php @@ -38,22 +38,12 @@ echo $base['info']['name']; echo ' (affecter un officier)'; echo ''; - + foreach ($base['fleets'] as $commander) { - $step = 0; - $reversed = $commander->rPlayer != $session->get('playerId') || $commander->travelType == Commander::BACK; - if ($commander->rPlayer != $session->get('playerId')) { - for ($i = 0; $i < $session->get('playerEvent')->size(); $i++) { - $event = $session->get('playerEvent')->get($i); - if ($event->get('eventId') == $commander->getId() && $event->exist('eventInfo')) { - foreach ($event->get('eventInfo')->get('inCircle') as $date) { - if (strtotime(Utils::now()) >= strtotime($date)) { $step++; } else { break; } - } - } - } - } + $reversed = $commander->rPlayer != $session->get('playerId') || $commander->travelType == Commander::BACK; + echo '
'; echo '
'; if ($commander->rPlayer != $session->get('playerId')) { @@ -70,20 +60,16 @@ } } echo ''; - echo (($commander->rPlayer == $session->get('playerId')) || ($commander->rPlayer != $session->get('playerId') && $step >= 2)) - ? CommanderResources::getInfo($commander->level, 'grade') . ' ' . $commander->name . ', ' - : 'Officier inconnu, '; + echo CommanderResources::getInfo($commander->level, 'grade') . ' ' . $commander->name . ', ' ; if ($commander->rPlayer != $session->get('playerId')) { - if ($step >= 2) { - switch ($commander->getTravelType()) { + + switch ($commander->travelType) { case Commander::LOOT: $type = 'tente de vous piller'; break; case Commander::COLO: $type = 'tente de vous conquérir'; break; default: $type = 'erreur'; break; } - } else { - echo 's\'approche de vous'; - } + echo $type; } elseif ($commander->statement == Commander::AFFECTED) { echo 'à quai'; } elseif ($commander->statement == Commander::MOVING) { @@ -96,9 +82,9 @@ } } - echo (($commander->rPlayer == $session->get('playerId')) || ($commander->rPlayer != $session->get('playerId') && $step >= 3)) + echo (($commander->rPlayer == $session->get('playerId')) ) ? ' | ' . Format::number($commander->getPev()) . ' pev' - : ' | ??? pev'; + : ' '; if ($commander->rPlayer == $session->get('playerId') && $commander->statement == Commander::MOVING && $commander->travelType != Commander::BACK) { echo ' annuler la mission'; diff --git a/system/views/pages/desktop/fleet.php b/system/views/pages/desktop/fleet.php index fd826f6cc..2bae5fa61 100755 --- a/system/views/pages/desktop/fleet.php +++ b/system/views/pages/desktop/fleet.php @@ -4,6 +4,10 @@ use Asylamba\Modules\Ares\Model\Commander; use Asylamba\Modules\Ares\Model\Report; use Asylamba\Classes\Exception\ErrorException; +use Asylamba\Classes\Library\Utils; +use Asylamba\Classes\Library\Chronos; +use Asylamba\Classes\Library\Format; +use Asylamba\Classes\Library\Game; $request = $this->getContainer()->get('app.request'); $response = $this->getContainer()->get('app.response'); @@ -55,9 +59,8 @@ } } } - - $attackingCommanders = $commanderManager->getCommandersByIds($commandersId); - + + $attackingCommanders = $commanderManager->getVisibleIncomingAttacks($session->get('playerId')); for ($i = 0; $i < count($obsets); $i++) { foreach ($attackingCommanders as $commander) { if ($commander->rDestinationPlace == $obsets[$i]['info']['id']) { diff --git a/system/views/pages/desktop/mapElement/layer/attacks.php b/system/views/pages/desktop/mapElement/layer/attacks.php index 0d75f7921..b73178bfe 100755 --- a/system/views/pages/desktop/mapElement/layer/attacks.php +++ b/system/views/pages/desktop/mapElement/layer/attacks.php @@ -12,7 +12,7 @@ # chargement des commandants attaquants $attackingCommanders = array_merge( - $commanderManager->getIncomingAttacks($session->get('playerId')), + $commanderManager->getVisibleIncomingAttacks($session->get('playerId')), $commanderManager->getOutcomingAttacks($session->get('playerId')) ); diff --git a/system/views/templates/desktop/toolbar.php b/system/views/templates/desktop/toolbar.php index a3fe9b31b..b5eedfdcd 100755 --- a/system/views/templates/desktop/toolbar.php +++ b/system/views/templates/desktop/toolbar.php @@ -21,24 +21,7 @@ $currentBase = $orbitalBaseManager->get($session->get('playerParams')->get('base')); - -$commanders = $commanderManager->getIncomingAttacks($session->get('playerId')); -$incomingCommanders = []; - -foreach ($commanders as $commander) { - # va chercher les heures auxquelles il rentre dans les cercles d'espionnage - $startPlace = $placeManager->get($commander->getRBase()); - $destinationPlace = $placeManager->get($commander->getRPlaceDestination()); - $times = Game::getAntiSpyEntryTime($startPlace, $destinationPlace, $commander->getArrivalDate()); - - if (strtotime(Utils::now()) >= strtotime($times[0])) { - //$info = $commanderManager->getEventInfo($commander); - //$info->add('inCircle', $times); - - # ajout de l'événement - $incomingCommanders[] = $commander; - } -} +$incomingCommanders = $commanderManager->getVisibleIncomingAttacks($session->get('playerId'));; $nbIncomingCommanders = count($incomingCommanders); $outcomingCommanders = $commanderManager->getPlayerCommanders($session->get('playerId'), [Commander::MOVING]); From 4fab54b598cf09d5043878d6bfa740fd52fbcb63 Mon Sep 17 00:00:00 2001 From: Tinydetoon Date: Thu, 27 Jul 2017 23:58:10 +0200 Subject: [PATCH 05/22] Fix incoming attacks detection --- system/views/pages/desktop/fleet.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/system/views/pages/desktop/fleet.php b/system/views/pages/desktop/fleet.php index 2bae5fa61..9f2286a60 100755 --- a/system/views/pages/desktop/fleet.php +++ b/system/views/pages/desktop/fleet.php @@ -4,10 +4,6 @@ use Asylamba\Modules\Ares\Model\Commander; use Asylamba\Modules\Ares\Model\Report; use Asylamba\Classes\Exception\ErrorException; -use Asylamba\Classes\Library\Utils; -use Asylamba\Classes\Library\Chronos; -use Asylamba\Classes\Library\Format; -use Asylamba\Classes\Library\Game; $request = $this->getContainer()->get('app.request'); $response = $this->getContainer()->get('app.response'); From 0269ab67d32e837f08a8843a57412e6096a06200 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Wed, 9 Aug 2017 12:22:42 +0200 Subject: [PATCH 06/22] Fix recycling places conversion to empty places --- .../Modules/Athena/Manager/OrbitalBaseManager.php | 9 +++++---- system/Modules/Gaia/Manager/PlaceManager.php | 9 +++++++++ .../Modules/Gaia/Repository/PlaceRepository.php | 15 +++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/system/Modules/Athena/Manager/OrbitalBaseManager.php b/system/Modules/Athena/Manager/OrbitalBaseManager.php index 2f85354fe..a195a7df4 100644 --- a/system/Modules/Athena/Manager/OrbitalBaseManager.php +++ b/system/Modules/Athena/Manager/OrbitalBaseManager.php @@ -716,8 +716,7 @@ public function uRecycling($missionId) { # if there is no more resource if ($targetPlace->resources <= 0) { # the place become an empty place - $targetPlace->resources = 0; - $targetPlace->typeOfPlace = Place::EMPTYZONE; + $this->placeManager->turnAsEmptyPlace($targetPlace); # stop the mission $mission->statement = RecyclingMission::ST_DELETED; @@ -860,8 +859,10 @@ public function uRecycling($missionId) { # update u $mission->uRecycling = Utils::addSecondsToDate($mission->uRecycling, $mission->cycleTime); - // Schedule the next mission - $this->realtimeActionScheduler->schedule('athena.orbital_base_manager', 'uRecycling', $mission, $mission->uRecycling); + // Schedule the next mission if there is still resources + if ($mission->getStatement() !== RecyclingMission::ST_DELETED) { + $this->realtimeActionScheduler->schedule('athena.orbital_base_manager', 'uRecycling', $mission, $mission->uRecycling); + } } else { # the place become an empty place $targetPlace->resources = 0; diff --git a/system/Modules/Gaia/Manager/PlaceManager.php b/system/Modules/Gaia/Manager/PlaceManager.php index f648d2c50..26906b27b 100644 --- a/system/Modules/Gaia/Manager/PlaceManager.php +++ b/system/Modules/Gaia/Manager/PlaceManager.php @@ -162,6 +162,15 @@ public function updatePlayerPlaces() { $this->entityManager->commit(); $this->entityManager->clear(Place::class); } + + /** + * @param Place $place + * @return bool + */ + public function turnAsEmptyPlace(Place $place) + { + return $this->entityManager->getRepository(Place::class)->turnAsEmptyPlace($place->getId()); + } public function turnAsSpawnPlace($placeId, $playerId) { diff --git a/system/Modules/Gaia/Repository/PlaceRepository.php b/system/Modules/Gaia/Repository/PlaceRepository.php index 5ec863414..071a8272e 100644 --- a/system/Modules/Gaia/Repository/PlaceRepository.php +++ b/system/Modules/Gaia/Repository/PlaceRepository.php @@ -232,6 +232,21 @@ public function updatePlace($place, $updateDanger = false) ]); } + /** + * @param int $placeId + * @return bool + */ + public function turnAsEmptyPlace($placeId) + { + $statement = $this->connection->prepare( + 'UPDATE place SET typeOfPlace = :place_type WHERE id = :id' + ); + return $statement->execute([ + 'place_type' => Place::EMPTYZONE, + 'id' => $placeId + ]); + } + /** * @param int $placeId * @param int $playerId From 25b07adbcfb4f34e94e2bd08e4f5b25425050b7e Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Wed, 9 Aug 2017 14:40:43 +0200 Subject: [PATCH 07/22] Fix player reborn method --- system/Modules/Zeus/Manager/PlayerManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Modules/Zeus/Manager/PlayerManager.php b/system/Modules/Zeus/Manager/PlayerManager.php index 5137bc782..7a0706b0f 100644 --- a/system/Modules/Zeus/Manager/PlayerManager.php +++ b/system/Modules/Zeus/Manager/PlayerManager.php @@ -396,7 +396,7 @@ public function reborn($playerId) { $placeId = NULL; foreach ($sectors as $sector) { # place choice - $qr = $this->entityManager->getConnection()->prepare('SELECT * FROM place AS p + $qr = $this->entityManager->getConnection()->prepare('SELECT p.id FROM place AS p INNER JOIN system AS sy ON p.rSystem = sy.id INNER JOIN sector AS se ON sy.rSector = se.id WHERE p.typeOfPlace = 1 @@ -409,7 +409,7 @@ public function reborn($playerId) { $aw = $qr->fetchAll(); if ($aw !== NULL) { $placeFound = TRUE; - $placeId = $aw[rand(0, (count($aw) - 1))][0]; + $placeId = $aw[rand(0, (count($aw) - 1))]['id']; break; } } From c512672d2bef04e0fe35955fb245e4055e4918e2 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Wed, 9 Aug 2017 14:41:44 +0200 Subject: [PATCH 08/22] Remove the dumping methods for the process gateway --- system/Classes/Process/ProcessGateway.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/system/Classes/Process/ProcessGateway.php b/system/Classes/Process/ProcessGateway.php index e16c5dba0..2167ffbaa 100644 --- a/system/Classes/Process/ProcessGateway.php +++ b/system/Classes/Process/ProcessGateway.php @@ -14,7 +14,6 @@ class ProcessGateway */ public function writeTo(Process $process, $data) { - \Asylamba\Classes\Daemon\Server::debug('Writing to Process : ' . json_encode($data)); fwrite($process->getOutput(), json_encode($data) . "\n"); } @@ -23,7 +22,6 @@ public function writeTo(Process $process, $data) */ public function writeToMaster($data) { - \Asylamba\Classes\Daemon\Server::debug('Writing to master: ' . json_encode($data)); fwrite(STDOUT, json_encode($data) . "\n"); } From bf8fa167075569d94253f31536652289cf213603 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Wed, 9 Aug 2017 15:17:39 +0200 Subject: [PATCH 09/22] Enable scheduled actions cancellation from process tasks --- system/Classes/Daemon/Server.php | 7 ++++++ .../Scheduler/RealTimeActionScheduler.php | 24 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/system/Classes/Daemon/Server.php b/system/Classes/Daemon/Server.php index 0e82944b6..9b56a977d 100644 --- a/system/Classes/Daemon/Server.php +++ b/system/Classes/Daemon/Server.php @@ -195,6 +195,13 @@ public function treatCommand($data) $data['data']['date'] ); break; + case 'cancel': + $this->realTimeActionScheduler->cancelFromProcess( + $data['data']['object_class'], + $data['data']['object_id'], + $data['data']['date'] + ); + break; } } diff --git a/system/Classes/Scheduler/RealTimeActionScheduler.php b/system/Classes/Scheduler/RealTimeActionScheduler.php index 2253feda8..7d29cf4b8 100644 --- a/system/Classes/Scheduler/RealTimeActionScheduler.php +++ b/system/Classes/Scheduler/RealTimeActionScheduler.php @@ -138,12 +138,36 @@ public function reschedule($object, $date, $oldDate) { */ public function cancel($object, $date) { + if (P_TYPE === 'worker') { + return $this->processGateway->writeToMaster([ + 'command' => 'cancel', + 'data' => [ + 'object_class' => get_class($object), + 'object_id' => $object->id, + 'date' => $date + ] + ]); + } unset($this->queue[$date][get_class($object) . '-' . $object->id]); if (empty($this->queue[$date])) { unset($this->queue[$date]); } } + + /** + * @param string $class + * @param int $id + * @param string $date + */ + public function cancelFromProcess($class, $id, $date) + { + unset($this->queue[$date][$class . '-' . $id]); + + if (empty($this->queue[$date])) { + unset($this->queue[$date]); + } + } /** * @return array From a4887c5a591ca9653f013afbf52a44d78d7dfd35 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Wed, 9 Aug 2017 15:17:52 +0200 Subject: [PATCH 10/22] Fix moving commanders when their base is taken --- system/Modules/Athena/Manager/OrbitalBaseManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Modules/Athena/Manager/OrbitalBaseManager.php b/system/Modules/Athena/Manager/OrbitalBaseManager.php index a195a7df4..3347b42b4 100644 --- a/system/Modules/Athena/Manager/OrbitalBaseManager.php +++ b/system/Modules/Athena/Manager/OrbitalBaseManager.php @@ -420,7 +420,7 @@ public function changeOwnerById($id, $base, $newOwner, $baseCommanders) { if (in_array($commander->statement, [Commander::INSCHOOL, Commander::ONSALE, Commander::RESERVE])) { $commander->rPlayer = $newOwner; } else if ($commander->statement == Commander::MOVING) { - $commander->statement = Commander::RETIRED; + $this->commanderManager->endTravel($commander, Commander::RETIRED); $this->realtimeActionScheduler->cancel($commander, $commander->getArrivalDate()); } else { $commander->statement = Commander::DEAD; From ceae636165fdc802c8dd65cb7ffbac5b4d3bc181 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Wed, 9 Aug 2017 22:29:08 +0200 Subject: [PATCH 11/22] Refactor sector ownership calcul in sector manager and store results in Redis --- .../Gaia/EventListener/SectorListener.php | 41 +------- system/Modules/Gaia/Manager/SectorManager.php | 97 ++++++++++++++++++- .../Modules/Gaia/Resource/config/config.yml | 10 +- 3 files changed, 106 insertions(+), 42 deletions(-) diff --git a/system/Modules/Gaia/EventListener/SectorListener.php b/system/Modules/Gaia/EventListener/SectorListener.php index b0a103479..24d5957af 100644 --- a/system/Modules/Gaia/EventListener/SectorListener.php +++ b/system/Modules/Gaia/EventListener/SectorListener.php @@ -16,42 +16,29 @@ class SectorListener protected $sectorManager; /** @var SystemManager **/ protected $systemManager; - /** @var OrbitalBaseManager **/ - protected $orbitalBaseManager; - /** @var PlayerManager **/ - protected $playerManager; /** @var EntityManager **/ protected $entityManager; - /** @var array **/ - protected $scores; /** @var int **/ protected $minimalScore; /** * @param SectorManager $sectorManager * @param SystemManager $systemManager - * @param OrbitalBaseManager $orbitalBaseManager - * @param PlayerManager $playerManager * @param EntityManager $entityManager + * @param RedisManager $redisManager * @param array $scores * @param int $minimalScore */ public function __construct( SectorManager $sectorManager, SystemManager $systemManager, - OrbitalBaseManager $orbitalBaseManager, - PlayerManager $playerManager, EntityManager $entityManager, - $scores, $minimalScore ) { $this->sectorManager = $sectorManager; $this->systemManager = $systemManager; - $this->orbitalBaseManager = $orbitalBaseManager; - $this->playerManager = $playerManager; $this->entityManager = $entityManager; - $this->scores = $scores; $this->minimalScore = $minimalScore; } @@ -61,31 +48,9 @@ public function __construct( public function onPlaceOwnerChange(PlaceOwnerChangeEvent $event) { $system = $this->systemManager->get($event->getPlace()->rSystem); - $systems = $this->systemManager->getSectorSystems($system->rSector); $sector = $this->sectorManager->get($system->rSector); - $bases = $this->orbitalBaseManager->getSectorBases($system->rSector); - $scores = []; - - foreach ($bases as $base) - { - $player = $this->playerManager->get($base->rPlayer); - - $scores[$player->rColor] = - (!empty($scores[$player->rColor])) - ? $scores[$player->rColor] + $this->scores[$base->typeOfBase] - : $this->scores[$base->typeOfBase] - ; - } - // For each system, the owning faction gains two points - foreach ($systems as $system) { - if ($system->rColor === 0) { - continue; - } - $scores[$system->rColor] = (!empty($scores[$system->rColor])) ? $scores[$system->rColor] + 2 : 2; - } - $scores[0] = 0; - arsort($scores); - reset($scores); + $scores = $this->sectorManager->calculateOwnership($sector); + $newColor = key($scores); $hasEnoughPoints = false; foreach ($scores as $factionId => $score) { diff --git a/system/Modules/Gaia/Manager/SectorManager.php b/system/Modules/Gaia/Manager/SectorManager.php index d04dc211c..2d700fbcd 100644 --- a/system/Modules/Gaia/Manager/SectorManager.php +++ b/system/Modules/Gaia/Manager/SectorManager.php @@ -12,20 +12,71 @@ namespace Asylamba\Modules\Gaia\Manager; use Asylamba\Classes\Entity\EntityManager; +use Asylamba\Classes\Redis\RedisManager; +use Asylamba\Classes\Process\LoadBalancer; +use Asylamba\Classes\Task\TaskManager; + +use Asylamba\Modules\Athena\Manager\OrbitalBaseManager; +use Asylamba\Modules\Zeus\Manager\PlayerManager; +use Asylamba\Modules\Gaia\Manager\SystemManager; use Asylamba\Modules\Gaia\Model\Sector; class SectorManager { /** @var EntityManager **/ protected $entityManager; + /** @var RedisManager **/ + protected $redisManager; + /** @var LoadBalancer **/ + protected $loadBalancer; + /** @var TaskManager **/ + protected $taskManager; + /** @var OrbitalBaseManager **/ + protected $orbitalBaseManager; + /** @var PlayerManager **/ + protected $playerManager; + /** @var SystemManager **/ + protected $systemManager; + /** @var array **/ + protected $scores = []; /** * @param EntityManager $entityManager + * @param RedisManager $redisManager + * @param LoadBalancer $loadBalancer + * @param TaskManager $taskManager + * @param OrbitalBaseManager $orbitalBaseManager + * @param PlayerManager $playerManager + * @param SystemManager $systemManager + * @param array $scores */ - public function __construct(EntityManager $entityManager) + public function __construct( + EntityManager $entityManager, + RedisManager $redisManager, + LoadBalancer $loadBalancer, + TaskManager $taskManager, + OrbitalBaseManager $orbitalBaseManager, + PlayerManager $playerManager, + SystemManager $systemManager, + $scores + ) { $this->entityManager = $entityManager; + $this->redisManager = $redisManager; + $this->loadBalancer = $loadBalancer; + $this->taskManager = $taskManager; + $this->orbitalBaseManager = $orbitalBaseManager; + $this->playerManager = $playerManager; + $this->systemManager = $systemManager; + $this->scores = $scores; } + + public function initOwnershipData() + { + $this->loadBalancer->affectTask( + $this->taskManager->createTechnicalTask('gaia.sector_manager', 'calculateAllOwnerships') + ); + } /** * @param int $id @@ -59,4 +110,48 @@ public function changeOwnership(Sector $sector) { $this->entityManager->getRepository(Sector::class)->changeOwnership($sector); } + + public function calculateAllOwnerships() + { + \Asylamba\Classes\Daemon\Server::debug('sectors'); + foreach ($this->getAll() as $sector) { + $this->calculateOwnership($sector); + } + } + + /** + * @param Sector $sector + * @return array + */ + public function calculateOwnership(Sector $sector) + { + $systems = $this->systemManager->getSectorSystems($sector->getId()); + $bases = $this->orbitalBaseManager->getSectorBases($sector->getId()); + $scores = []; + + foreach ($bases as $base) + { + $player = $this->playerManager->get($base->rPlayer); + + $scores[$player->rColor] = + (!empty($scores[$player->rColor])) + ? $scores[$player->rColor] + $this->scores[$base->typeOfBase] + : $this->scores[$base->typeOfBase] + ; + } + // For each system, the owning faction gains two points + foreach ($systems as $system) { + if ($system->rColor === 0) { + continue; + } + $scores[$system->rColor] = (!empty($scores[$system->rColor])) ? $scores[$system->rColor] + 2 : 2; + } + $scores[0] = 0; + arsort($scores); + reset($scores); + + $this->redisManager->getConnection()->set('sector:' . $sector->getId(), serialize($scores)); + + return $scores; + } } \ No newline at end of file diff --git a/system/Modules/Gaia/Resource/config/config.yml b/system/Modules/Gaia/Resource/config/config.yml index 9fc04b0e2..3f777fc7f 100644 --- a/system/Modules/Gaia/Resource/config/config.yml +++ b/system/Modules/Gaia/Resource/config/config.yml @@ -39,6 +39,13 @@ services: class: Asylamba\Modules\Gaia\Manager\SectorManager arguments: - "@entity_manager" + - "@redis_manager" + - "@load_balancer" + - "@task_manager" + - "@athena.orbital_base_manager" + - "@zeus.player_manager" + - "@gaia.system_manager" + - "%gaia.scores" gaia.system_manager: class: Asylamba\Modules\Gaia\Manager\SystemManager @@ -53,10 +60,7 @@ services: arguments: - "@gaia.sector_manager" - "@gaia.system_manager" - - "@athena.orbital_base_manager" - - "@zeus.player_manager" - "@entity_manager" - - "%gaia.scores" - "%gaia.sector_minimal_score" tags: - {type: "event_listener", event: "gaia.place_owner_change", method: "onPlaceOwnerChange", order: 2} From 7469ca94e7053026a31b81be1f14125f500370bb Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Wed, 9 Aug 2017 22:29:37 +0200 Subject: [PATCH 12/22] Configure technical task to initialize sectors ownership data at server boot --- system/Classes/Task/TechnicalTask.php | 2 ++ system/Classes/Worker/Application.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/system/Classes/Task/TechnicalTask.php b/system/Classes/Task/TechnicalTask.php index 7daa7a368..bfe97c0ba 100644 --- a/system/Classes/Task/TechnicalTask.php +++ b/system/Classes/Task/TechnicalTask.php @@ -4,6 +4,8 @@ class TechnicalTask extends Task { + const DEFAULT_ESTIMATED_TIME = 10.00; + /** * {@inheritdoc} */ diff --git a/system/Classes/Worker/Application.php b/system/Classes/Worker/Application.php index 3a870a78b..199539125 100644 --- a/system/Classes/Worker/Application.php +++ b/system/Classes/Worker/Application.php @@ -90,6 +90,8 @@ public function init() $this->container->get('process_manager')->launchProcesses(); $this->container->get('realtime_action_scheduler')->init(); $this->container->get('cyclic_action_scheduler')->init(); + $this->container->get('gaia.sector_manager')->initOwnershipData(); + $server = $this->container->get('server'); $server->createHttpServer(); $server->listen(); From 4a1e97a9f7757e217400b309b1e3e84421076cb4 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Wed, 9 Aug 2017 22:29:53 +0200 Subject: [PATCH 13/22] Update tactical view in faction registry --- .../faction/data/tactical/sectors.php | 79 +++++++++---------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/system/views/components/faction/data/tactical/sectors.php b/system/views/components/faction/data/tactical/sectors.php index c99bd9848..ff0a04bf4 100755 --- a/system/views/components/faction/data/tactical/sectors.php +++ b/system/views/components/faction/data/tactical/sectors.php @@ -1,41 +1,14 @@ getContainer()->get('demeter.color_manager'); -$database = $this->getContainer()->get('database'); - -$qr = 'SELECT - se.id AS id, - se.rColor AS color, - se.name AS name, - se.points AS points, - (SELECT COUNT(sy.id) FROM system AS sy WHERE sy.rSector = se.id) AS nbc0,'; +$sectorManager = $this->getContainer()->get('gaia.sector_manager'); +$redisManager = $this->getContainer()->get('redis_manager'); +$sectors = $sectorManager->getAll(); $factions = $colorManager->getAll(); -foreach ($factions as $f) { - $qr .= '(SELECT COUNT(sy.id) FROM system AS sy WHERE sy.rColor = ' . $f->id . ' AND sy.rSector = se.id) AS nbc' . $f->id .','; -} - -$qr = substr($qr, 0, -1) . ' FROM sector AS se ORDER BY (nbc' . $faction->id . ' / nbc0) DESC'; - -$qr = $database->prepare($qr); -$qr->execute(); -$aw = $qr->fetchAll(); $qr->closeCursor(); - - -$sectort = array( - 'Secteurs conquis' => array(), - 'Secteurs en balance' => array() -); - -for ($i = 0; $i < count($aw); $i++) { - if ($aw[$i]['color'] == $faction->id) { - $sectort['Secteurs conquis'][] = $aw[$i]; - } else { - $sectort['Secteurs en balance'][] = $aw[$i]; - } -} echo '
'; echo '
'; @@ -43,29 +16,50 @@ echo '
'; echo '
'; echo '
'; - foreach ($sectort as $type => $sectors) { + foreach (['Secteurs conquis', 'Secteurs en balance'] as $type) { $displayed = 0; echo '

' . $type . '

'; echo '
    '; - foreach ($sectors as $sector) { - $percents = array(); + foreach ($sectors as $key => $sector) { + $treated = false; + $percents = ['color' . $faction->getId() => 0]; + $scores = unserialize($redisManager->getConnection()->get('sector:' . $sector->getId())); + + if (!isset($scores[$faction->getId()]) && $sector->getRColor() !== $faction->getId()) { + unset($sectors[$key]); + continue; + } + if ($type === 'Secteurs conquis' && $sector->getRColor() !== $faction->getId()) { + continue; + } foreach ($factions as $f) { - if ($f->id === 0) { + if ($f->id === 0 || !isset($scores[$f->id])) { continue; } - $percents['color' . $f->id] = Format::percent($sector['nbc' . $f->id], $sector['nbc0']); + $percents['color' . $f->id] = round(Format::percent($scores[$f->id], array_sum($scores), false)); } arsort($percents); - if ($sector['color'] == $faction->id || ($sector['nbc' . $faction->id] > 0)) { + if ($sector->getRColor() == $faction->getId() || ($scores[$faction->getId()] > 0)) { echo '
  • '; - echo '' . $sector['id'] . ''; - echo '' . $sector['name'] . ' (' . $sector['points'] . ' point' . Format::plural($sector['points']). ')'; - echo '' . Format::percent($sector['nbc' . $faction->id], $sector['nbc0']) . ' %'; + echo '' . $sector->getId() . ''; + echo '' . + $sector->getName() . + ' (' . $sector->getPoints() . ' point' . Format::plural($sector->getPoints()). ')' . + ''; + foreach ($scores as $factionId => $points) { + if ($points === 0) { + continue; + } + echo '' . + ColorResource::getInfo($factionId, 'popularName') . ' : ' . $points . ' point' . Format::plural($points) . ' de contrôle' . + ''; + } + echo '' . $percents['color' . $faction->getId()] . ' %'; echo ''; foreach ($percents as $color => $percent) { echo ''; @@ -74,7 +68,12 @@ echo '
  • '; $displayed++; + $treated = true; } + // If the sector has been displayed, we remove it for the second loop round + if ($treated === true) { + unset($sectors[$key]); + } } echo '
'; From 276633e076ba9c4b282be2460dd3f42553ca7013 Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Wed, 9 Aug 2017 22:37:45 +0200 Subject: [PATCH 14/22] Release v2.1.2 --- CHANGELOG.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c2d456d..21e95e644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,15 @@ -## [2.1.1] - 2017-17-23 +## [2.1.2] - 2017-08-09 +### Added +- Storage of the sectors ownership data in Redis + +### Fixed +- Commanders defection when their base is taken +- Display of the incoming attacks in the admiralty +- Sectors ownership data in faction tactical registry +- Ending of recycling missions +- Conversion of the recycling places when there is no resources left + +## [2.1.1] - 2017-07-23 ### Added - Spy and combat active report highlighting in the list - Daily scheduling for notifications cleaning and inactive accounts management From c4c72f69c432c08fef37b988f5bdcde1674fcbcc Mon Sep 17 00:00:00 2001 From: Axel Venet Date: Fri, 11 Aug 2017 12:39:05 +0200 Subject: [PATCH 15/22] 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 16/22] 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 17/22] 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 18/22] 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 19/22] 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 20/22] 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 21/22] 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 22/22] 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