Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 89 additions & 2 deletions config/routes/demeter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,93 @@ embassy:
path: /embassy
controller: App\Modules\Demeter\Infrastructure\Controller\ViewEmbassy

faction:
faction_overview:
path: /faction
controller: App\Modules\Demeter\Infrastructure\Controller\FactionController
controller: App\Modules\Demeter\Infrastructure\Controller\ViewOverview

faction_members:
path: /faction/members
controller: App\Modules\Demeter\Infrastructure\Controller\ViewMembers

faction_government:
path: /faction/government
controller: App\Modules\Demeter\Infrastructure\Controller\ViewGovernment

faction_data:
path: /faction/data
controller: App\Modules\Demeter\Infrastructure\Controller\ViewData

faction_forum:
path: /faction/forum

faction_senate:
path: /faction/senate
controller: App\Modules\Demeter\Infrastructure\Controller\ViewSenate

view_faction_election:
path: /faction/election
controller: App\Modules\Demeter\Infrastructure\Controller\ViewElection

initiate_faction_coup:
path: /faction/coup
controller: App\Modules\Demeter\Infrastructure\Controller\MakeACoup

abdicate:
path: /abdicate
controller: App\Modules\Demeter\Infrastructure\Controller\Government\Ruler\Abdicate

resign:
path: /resign
controller: App\Modules\Demeter\Infrastructure\Controller\Government\Resign

write_faction_conversation:
path: /faction/write-conversation
controller: App\Modules\Demeter\Infrastructure\Controller\Government\WriteToFaction

create_law:
path: /faction/law/create
controller: App\Modules\Demeter\Infrastructure\Controller\Government\CreateLaw

send_credits_from_faction:
path: /faction/send-credits
controller: App\Modules\Demeter\Infrastructure\Controller\Government\SendCredits

update_faction_description:
path: /faction/update-description
controller: App\Modules\Demeter\Infrastructure\Controller\Government\UpdateDescription

pin_faction_news:
path: /faction/news/{id}/pin
controller: App\Modules\Demeter\Infrastructure\Controller\News\Pin

create_faction_news:
path: /faction/news/create
controller: App\Modules\Demeter\Infrastructure\Controller\News\Create

edit_faction_news:
path: /faction/news/{id}/edit
controller: App\Modules\Demeter\Infrastructure\Controller\News\Edit

delete_faction_news:
path: /faction/news/{id}/delete
controller: App\Modules\Demeter\Infrastructure\Controller\News\Delete

choose_minister:
path: /faction/government/{department}/choose-minister
controller: App\Modules\Demeter\Infrastructure\Controller\Government\Ruler\ChooseMinister

fire_minister:
path: /faction/government/ministers/{id}/fire
controller: App\Modules\Demeter\Infrastructure\Controller\Government\Ruler\FireMinister

postulate:
path: /faction/elections/{id}/postulate
controller: App\Modules\Demeter\Infrastructure\Controller\Postulate

vote_for_candidate:
path: /faction/elections/{electionId}/candidates/{candidateId}/vote
controller: App\Modules\Demeter\Infrastructure\Controller\VoteForCandidate

vote_for_law:
path: /faction/laws/{id}/vote
controller: App\Modules\Demeter\Infrastructure\Controller\VoteForLaw
3 changes: 3 additions & 0 deletions config/routes/hermes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ delete_notification:
list_conversations:
path: /messages
controller: App\Modules\Hermes\Infrastructure\Controller\Conversation\ListController

new_message:
path: /messages/new
10 changes: 10 additions & 0 deletions src/Modules/Ares/Manager/CommanderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ public function getIncomingCommanders(int $place): array
{
return $this->entityManager->getRepository(Commander::class)->getIncomingCommanders($place);
}

public function getFactionCommanderStats(int $factionId): array
{
return $this->entityManager->getRepository(Commander::class)->getFactionCommanderStats($factionId);
}

public function getFactionFleetStats(int $factionId): array
{
return $this->entityManager->getRepository(Commander::class)->getFactionFleetStats($factionId);
}

public function schedule(): void
{
Expand Down
46 changes: 46 additions & 0 deletions src/Modules/Ares/Repository/CommanderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,52 @@ public function countCommandersByLine($orbitalBaseId, $line)
$statement->execute(['orbital_base_id' => $orbitalBaseId, 'line' => $line]);
return (int) $statement->fetch()['nb_commanders'];
}

public function getFactionCommanderStats(int $factionId): array
{
$qr = $this->connection->prepare('SELECT
COUNT(c.id) AS nb,
AVG(c.level) AS avgLevel
FROM commander AS c
LEFT JOIN player AS p
ON c.rPlayer = p.id
WHERE p.rColor = ? AND (c.statement = ? OR c.statement = ?)
');
$qr->execute(array($factionId, Commander::AFFECTED, Commander::MOVING));
$aw1 = $qr->fetch();
$qr->closeCursor();

return $aw1;
}

public function getFactionFleetStats(int $factionId): array
{
$qr = $this->connection->prepare('SELECT
SUM(s.ship0) AS nbs0,
SUM(s.ship1) AS nbs1,
SUM(s.ship2) AS nbs2,
SUM(s.ship3) AS nbs3,
SUM(s.ship4) AS nbs4,
SUM(s.ship5) AS nbs5,
SUM(s.ship6) AS nbs6,
SUM(s.ship7) AS nbs7,
SUM(s.ship8) AS nbs8,
SUM(s.ship9) AS nbs9,
SUM(s.ship10) AS nbs10,
SUM(s.ship11) AS nbs11
FROM squadron AS s
LEFT JOIN commander AS c
ON s.rCommander = c.id
LEFT JOIN player AS p
ON c.rPlayer = p.id
WHERE p.rColor = ? AND (c.statement = ? OR c.statement = ?)
');
$qr->execute(array($factionId, Commander::AFFECTED, Commander::MOVING));
$aw2 = $qr->fetch();
$qr->closeCursor();

return $aw2;
}

public function insert($commander)
{
Expand Down
10 changes: 10 additions & 0 deletions src/Modules/Athena/Manager/CommercialRouteManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public function getBaseCommercialData(OrbitalBase $orbitalBase): array
];
}

public function getCommercialRouteFactionData(int $factionId): array
{
return $this->entityManager->getRepository(CommercialRoute::class)->getCommercialRouteFactionData($factionId);
}

public function countCommercialRoutesBetweenFactions(int $factionId, int $otherFactionId): int
{
return $this->entityManager->getRepository(CommercialRoute::class)->countCommercialRoutesBetweenFactions($factionId, $otherFactionId);
}

public function searchCandidates(int $playerId, OrbitalBase $orbitalBase, array $factions, int $minDistance, int $maxDistance): array
{
return $this->entityManager->getRepository(CommercialRoute::class)->searchCandidates($playerId, $orbitalBase, $factions, $minDistance, $maxDistance);
Expand Down
55 changes: 55 additions & 0 deletions src/Modules/Athena/Repository/CommercialRouteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Modules\Athena\Model\CommercialRoute;
use App\Modules\Athena\Model\OrbitalBase;
use App\Modules\Demeter\Model\Color;
use App\Modules\Demeter\Resource\ColorResource;
use App\Modules\Zeus\Model\Player;

class CommercialRouteRepository extends AbstractRepository {
Expand Down Expand Up @@ -137,6 +138,60 @@ public function getAllPlayerRoutes(Player $player): array

return $query->fetchAll();
}

public function countCommercialRoutesBetweenFactions(int $factionId, $otherFactionId): int
{
$join = 'FROM commercialRoute AS cr
LEFT JOIN orbitalBase AS ob1
ON cr.rOrbitalBase = ob1.rPlace
LEFT JOIN player AS pl1
ON ob1.rPlayer = pl1.id
LEFT JOIN orbitalBase AS ob2
ON cr.rOrbitalBaseLinked = ob2.rPlace
LEFT JOIN player AS pl2
ON ob2.rPlayer = pl2.id';

$qr = $this->connection->prepare('SELECT
COUNT(cr.id) AS nb ' . $join . '
WHERE ((pl1.rColor = ? AND pl2.rColor = ?) OR (pl1.rColor = ? AND pl2.rColor = ?)) AND cr.statement = ?'
);
$qr->execute([$factionId, $otherFactionId, $otherFactionId, $factionId, CommercialRoute::ACTIVE]);
$aw3 = $qr->fetch();
$qr->closeCursor();

return $aw3['nb'] ?? 0;
}

public function getCommercialRouteFactionData(int $factionId): array
{
$join = 'FROM commercialRoute AS cr
LEFT JOIN orbitalBase AS ob1
ON cr.rOrbitalBase = ob1.rPlace
LEFT JOIN player AS pl1
ON ob1.rPlayer = pl1.id
LEFT JOIN orbitalBase AS ob2
ON cr.rOrbitalBaseLinked = ob2.rPlace
LEFT JOIN player AS pl2
ON ob2.rPlayer = pl2.id';
$qr = $this->connection->prepare('SELECT
COUNT(cr.id) AS nb,
SUM(cr.income) AS income
' . $join . '
WHERE (pl1.rColor = ? OR pl2.rColor = ?)
AND cr.statement = ?
');
$qr->execute(array($factionId, $factionId, CommercialRoute::ACTIVE));
$aw1 = $qr->fetch(); $qr->closeCursor();

$qr = $this->connection->prepare('SELECT COUNT(cr.id) AS nb ' . $join . ' WHERE pl1.rColor = ? AND pl2.rColor = ? AND cr.statement = ?');
$qr->execute(array($factionId, $factionId, CommercialRoute::ACTIVE));
$aw2 = $qr->fetch(); $qr->closeCursor();

return [
'aw1' => $aw1,
'aw2' => $aw2,
];
}

/**
* @param int $id
Expand Down
29 changes: 29 additions & 0 deletions src/Modules/Demeter/Infrastructure/Controller/CancelLaw.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Modules\Demeter\Infrastructure\Controller;

use App\Modules\Demeter\Manager\Law\LawManager;
use App\Modules\Demeter\Resource\LawResources;
use App\Modules\Zeus\Model\Player;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class CancelLaw extends AbstractController
{
public function __invoke(
Request $request,
Player $currentPlayer,
LawManager $lawManager,
int $id,
): Response {
if (($law = $lawManager->get($id)) === null) {
throw $this->createNotFoundException('Cette loi n\'existe pas.');
}
if ($currentPlayer->getStatus() != LawResources::getInfo($law->getType(), 'department')) {
throw $this->createAccessDeniedException('Vous n\'avez pas le droit d\'annuler cette loi.');
}
// @TODO implement law cancellation
return $this->redirect($request->headers->get('referer'));
}
}

This file was deleted.

Loading