Skip to content

Commit

Permalink
Merge pull request #165 from Kern046/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
acknowledge authored Aug 11, 2017
2 parents 5a3a779 + d0a4709 commit 5c5e755
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 43 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions system/Modules/Athena/Manager/OrbitalBaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 8 additions & 8 deletions system/Modules/Atlas/Manager/RankingManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);

Expand All @@ -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) {
Expand All @@ -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);
Expand Down
126 changes: 97 additions & 29 deletions system/Modules/Demeter/Manager/ColorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
? '<br>Par conséquent, ' . $oldChief->getName() . ' est toujours au pouvoir.'
: '<br>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();
Expand Down
1 change: 0 additions & 1 deletion system/Modules/Gaia/Manager/SectorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion system/action/std/athena/building/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions system/action/std/athena/transaction/propose.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
Expand Down
4 changes: 3 additions & 1 deletion system/buffer/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
?>
<!DOCTYPE html>
<html lang="fr">
Expand Down

0 comments on commit 5c5e755

Please sign in to comment.