for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Stu\Component\Spacecraft\Trait;
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum;
use Stu\Module\Control\GameControllerInterface;
trait SpacecraftCrewTrait
{
use SpacecraftTrait;
use HasSpacecraftSystemTrait;
public function getNeededCrewCount(): int
$buildplan = $this->getThis()->getBuildplan();
if ($buildplan === null) {
return 0;
}
return $buildplan->getCrew();
public function getCrewCount(): int
return $this->getThis()->getCrewAssignments()->count();
public function getExcessCrewCount(): int
return $this->getCrewCount() - $this->getNeededCrewCount();
public function hasEnoughCrew(?GameControllerInterface $game = null): bool
if ($game !== null) {
$game->addInformation(_("Keine Crew vorhanden"));
return false;
$result = $buildplan->getCrew() <= 0
|| $this->getCrewCount() >= $buildplan->getCrew();
if (!$result && $game !== null) {
$game->addInformationf(
_("Es werden %d Crewmitglieder benötigt"),
$buildplan->getCrew()
);
return $result;
public function canMan(): bool
return $buildplan !== null
&& $buildplan->getCrew() > 0
&& $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::LIFE_SUPPORT);