-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
356 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Component/Map/Effects/Type/WarpdriveLeakEffectHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stu\Component\Map\Effects\Type; | ||
|
||
use Stu\Lib\Information\InformationInterface; | ||
use Stu\Module\Spacecraft\Lib\Message\MessageCollectionInterface; | ||
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; | ||
|
||
class WarpdriveLeakEffectHandler implements EffectHandlerInterface | ||
{ | ||
public function handleSpacecraftTick(SpacecraftWrapperInterface $wrapper, InformationInterface $information): void | ||
{ | ||
// not needed | ||
} | ||
|
||
public function handleIncomingSpacecraft(SpacecraftWrapperInterface $wrapper, MessageCollectionInterface $messages): void | ||
{ | ||
$spacecraft = $wrapper->get(); | ||
|
||
$warpdrive = $wrapper->getWarpDriveSystemData(); | ||
if ( | ||
$warpdrive === null | ||
|| !$spacecraft->getWarpDriveState() | ||
) { | ||
return; | ||
} | ||
|
||
$loss = min($warpdrive->getWarpDrive(), (int)ceil($warpdrive->getTheoreticalMaxWarpdrive() / 10)); | ||
if ($loss === 0) { | ||
return; | ||
} | ||
|
||
$warpdrive->lowerWarpDrive($loss)->update(); | ||
|
||
$messages->addInformation( | ||
sprintf("[color=yellow]Leck im Warpantrieb durch %s. (Verlust: %d)[/color]", $spacecraft->getLocation()->getFieldType()->getName(), $loss), | ||
$wrapper->get()->getUser()->getId() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stu\Migrations\Pgsql; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20250203092918 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Renaming some indices.'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER INDEX ship_crew_spacecraft_idx RENAME TO IDX_4793ED241C6AF6FD'); | ||
$this->addSql('ALTER INDEX ship_crew_colony_idx RENAME TO IDX_4793ED2496ADBADE'); | ||
$this->addSql('ALTER INDEX ship_crew_tradepost_idx RENAME TO IDX_4793ED248B935ABD'); | ||
$this->addSql('ALTER INDEX ship_crew_user_idx RENAME TO IDX_4793ED24A76ED395'); | ||
$this->addSql('ALTER INDEX ship_crew_crew_idx RENAME TO crew_assign_crew_idx'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER INDEX idx_4793ed24a76ed395 RENAME TO ship_crew_user_idx'); | ||
$this->addSql('ALTER INDEX idx_4793ed248b935abd RENAME TO ship_crew_tradepost_idx'); | ||
$this->addSql('ALTER INDEX idx_4793ed241c6af6fd RENAME TO ship_crew_spacecraft_idx'); | ||
$this->addSql('ALTER INDEX crew_assign_crew_idx RENAME TO ship_crew_crew_idx'); | ||
$this->addSql('ALTER INDEX idx_4793ed2496adbade RENAME TO ship_crew_colony_idx'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stu\Module\Spacecraft\Lib\Ui; | ||
|
||
use RuntimeException; | ||
use Stu\Lib\Map\FieldTypeEffectEnum; | ||
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Spacecraftcount\SpacecraftCountLayerTypeEnum; | ||
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace\SubspaceLayerTypeEnum; | ||
use Stu\Lib\Map\VisualPanel\Layer\PanelLayerCreationInterface; | ||
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; | ||
use Stu\Orm\Entity\LayerInterface; | ||
use Stu\Orm\Entity\LocationInterface; | ||
use Stu\Orm\Entity\MapInterface; | ||
use Stu\Orm\Entity\UserInterface; | ||
use Stu\Orm\Repository\UserMapRepositoryInterface; | ||
|
||
class PanelLayerConfiguration | ||
{ | ||
public function __construct(private UserMapRepositoryInterface $userMapRepository) {} | ||
|
||
public function configureLayers( | ||
PanelLayerCreationInterface $panelLayerCreation, | ||
SpacecraftWrapperInterface $wrapper, | ||
LocationInterface $panelCenter, | ||
UserInterface $currentUser, | ||
bool $tachyonFresh, | ||
bool $isShipOnLevel | ||
): void { | ||
|
||
$spacecraft = $wrapper->get(); | ||
|
||
if ($wrapper->get()->getSubspaceState()) { | ||
$panelLayerCreation->addSubspaceLayer($currentUser->getId(), SubspaceLayerTypeEnum::IGNORE_USER); | ||
} | ||
|
||
$isLssMalfunctioning = $spacecraft->getLocation()->getFieldType()->hasEffect(FieldTypeEffectEnum::LSS_MALFUNCTION); | ||
if ($isLssMalfunctioning) { | ||
return; | ||
} | ||
|
||
$panelLayerCreation | ||
->addShipCountLayer($tachyonFresh, $spacecraft, SpacecraftCountLayerTypeEnum::ALL, 0) | ||
->addBorderLayer($wrapper->get(), $isShipOnLevel) | ||
->addAnomalyLayer(); | ||
|
||
if ($panelCenter instanceof MapInterface) { | ||
$layer = $panelCenter->getLayer(); | ||
if ($layer === null) { | ||
throw new RuntimeException('this should not happen'); | ||
} | ||
$panelLayerCreation->addMapLayer($layer); | ||
$this->createUserMapEntries($wrapper, $layer, $currentUser); | ||
} else { | ||
$panelLayerCreation | ||
->addSystemLayer() | ||
->addColonyShieldLayer(); | ||
} | ||
} | ||
|
||
private function createUserMapEntries(SpacecraftWrapperInterface $wrapper, LayerInterface $layer, UserInterface $currentUser): void | ||
{ | ||
$map = $wrapper->get()->getMap(); | ||
if ($map === null) { | ||
return; | ||
} | ||
|
||
$cx = $map->getX(); | ||
$cy = $map->getY(); | ||
$range = $wrapper->getSensorRange(); | ||
|
||
if ($this->isUserMapActive($layer->getId(), $currentUser)) { | ||
$this->userMapRepository->insertMapFieldsForUser( | ||
$currentUser->getId(), | ||
$layer->getId(), | ||
$cx, | ||
$cy, | ||
$range | ||
); | ||
} | ||
} | ||
|
||
private function isUserMapActive(int $layerId, UserInterface $currentUser): bool | ||
{ | ||
if (!$currentUser->hasColony()) { | ||
return false; | ||
} | ||
|
||
return !$currentUser->hasExplored($layerId); | ||
} | ||
} |
Oops, something went wrong.