-
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
21 changed files
with
50,869 additions
and
50,667 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
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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stu\Component\Map\Effects; | ||
|
||
use Override; | ||
use RuntimeException; | ||
use Stu\Component\Map\Effects\Type\EffectHandlerInterface; | ||
use Stu\Lib\Information\InformationInterface; | ||
use Stu\Lib\Map\FieldTypeEffectEnum; | ||
use Stu\Module\Spacecraft\Lib\Message\MessageCollectionInterface; | ||
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; | ||
|
||
final class EffectHandling implements EffectHandlingInterface | ||
{ | ||
/** | ||
* @param array<string, EffectHandlerInterface> $handlerList | ||
*/ | ||
public function __construct( | ||
private array $handlerList | ||
) {} | ||
|
||
#[Override] | ||
public function handleSpacecraftTick(SpacecraftWrapperInterface $wrapper, InformationInterface $information): void | ||
{ | ||
foreach ($wrapper->get()->getLocation()->getFieldType()->getEffects() as $effect) { | ||
$this->getHandler($effect)->handleSpacecraftTick($wrapper, $information); | ||
} | ||
} | ||
|
||
#[Override] | ||
public function handleIncomingSpacecraft(SpacecraftWrapperInterface $wrapper, MessageCollectionInterface $messages): void | ||
{ | ||
foreach ($wrapper->get()->getLocation()->getFieldType()->getEffects() as $effect) { | ||
$this->getHandler($effect)->handleIncomingSpacecraft($wrapper, $messages); | ||
} | ||
} | ||
|
||
private function getHandler(FieldTypeEffectEnum $effect): EffectHandlerInterface | ||
{ | ||
if (!array_key_exists($effect->value, $this->handlerList)) { | ||
throw new RuntimeException(sprintf('no handler defined for type: %d', $effect->value)); | ||
} | ||
|
||
$handler = $this->handlerList[$effect->value]; | ||
|
||
return $handler; | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stu\Component\Map\Effects; | ||
|
||
use Stu\Lib\Information\InformationInterface; | ||
use Stu\Module\Spacecraft\Lib\Message\MessageCollectionInterface; | ||
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; | ||
|
||
interface EffectHandlingInterface | ||
{ | ||
public function handleSpacecraftTick(SpacecraftWrapperInterface $wrapper, InformationInterface $information): void; | ||
|
||
public function handleIncomingSpacecraft(SpacecraftWrapperInterface $wrapper, MessageCollectionInterface $messages): void; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/Component/Map/Effects/Type/CloakUnuseableEffectHandler.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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stu\Component\Map\Effects\Type; | ||
|
||
use Stu\Component\Spacecraft\System\SpacecraftSystemManagerInterface; | ||
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; | ||
use Stu\Lib\Information\InformationInterface; | ||
use Stu\Module\Spacecraft\Lib\Message\MessageCollectionInterface; | ||
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; | ||
|
||
class CloakUnuseableEffectHandler implements EffectHandlerInterface | ||
{ | ||
public function __construct( | ||
private SpacecraftSystemManagerInterface $spacecraftSystemManager | ||
) {} | ||
|
||
public function handleSpacecraftTick(SpacecraftWrapperInterface $wrapper, InformationInterface $information): void | ||
{ | ||
// not needed | ||
} | ||
|
||
public function handleIncomingSpacecraft(SpacecraftWrapperInterface $wrapper, MessageCollectionInterface $messages): void | ||
{ | ||
$spacecraft = $wrapper->get(); | ||
if ($spacecraft->isCloaked()) { | ||
|
||
$this->spacecraftSystemManager->deactivate($wrapper, SpacecraftSystemTypeEnum::CLOAK, true); | ||
|
||
$messages->addInformation( | ||
sprintf("[color=yellow]Tarnung durch %s ausgefallen.[/color]", $spacecraft->getLocation()->getFieldType()->getName()), | ||
$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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?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; | ||
|
||
interface EffectHandlerInterface | ||
{ | ||
public function handleSpacecraftTick(SpacecraftWrapperInterface $wrapper, InformationInterface $information): void; | ||
|
||
public function handleIncomingSpacecraft(SpacecraftWrapperInterface $wrapper, MessageCollectionInterface $messages): void; | ||
} |
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
33 changes: 33 additions & 0 deletions
33
...e/Spacecraft/Lib/Movement/Component/Consequence/PostFlight/FieldTypeEffectConsequence.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Stu\Module\Spacecraft\Lib\Movement\Component\Consequence\PostFlight; | ||
|
||
use Override; | ||
use Stu\Component\Map\Effects\EffectHandlingInterface; | ||
use Stu\Module\Spacecraft\Lib\Message\MessageCollectionInterface; | ||
use Stu\Module\Spacecraft\Lib\Movement\Component\Consequence\AbstractFlightConsequence; | ||
use Stu\Module\Spacecraft\Lib\Movement\Route\FlightRouteInterface; | ||
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; | ||
|
||
class FieldTypeEffectConsequence extends AbstractFlightConsequence implements PostFlightConsequenceInterface | ||
{ | ||
public function __construct(private EffectHandlingInterface $effectHandling) {} | ||
|
||
#[Override] | ||
protected function skipWhenTractored(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
#[Override] | ||
protected function triggerSpecific( | ||
SpacecraftWrapperInterface $wrapper, | ||
FlightRouteInterface $flightRoute, | ||
MessageCollectionInterface $messages | ||
): void { | ||
|
||
$this->effectHandling->handleIncomingSpacecraft($wrapper, $messages); | ||
} | ||
} |
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
Oops, something went wrong.