-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 3% chance of black bass entering the tank.
- Loading branch information
Yukihiro Arisawa
committed
May 1, 2024
1 parent
8329767
commit b9f5853
Showing
6 changed files
with
104 additions
and
4 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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Iamyukihiro\Aquarium\Domain\Logic; | ||
|
||
class Probability | ||
{ | ||
public function calc(int $percentage): bool | ||
{ | ||
$randomNumber = mt_rand(1, 100); | ||
|
||
return $randomNumber <= $percentage; | ||
} | ||
} |
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 Iamyukihiro\Aquarium\Domain\Logic; | ||
|
||
use Iamyukihiro\Aquarium\Domain\Enum\BreedNameType; | ||
use Iamyukihiro\Aquarium\Domain\Enum\ConditionLevelType; | ||
use Iamyukihiro\Aquarium\Domain\Enum\FishType; | ||
use Iamyukihiro\Aquarium\Domain\Enum\HungerLevelType; | ||
use Iamyukihiro\Aquarium\Domain\Model\Fish\LargeMouseBass; | ||
use Iamyukihiro\Aquarium\Domain\ValueObject\Breed; | ||
|
||
use function Symfony\Component\Clock\now; | ||
|
||
class RandomLargeMouseBassGenerator | ||
{ | ||
public function __construct( | ||
private NicknameGenerator $nicknameGenerator, | ||
) { | ||
} | ||
|
||
public function generate(): LargeMouseBass | ||
{ | ||
return new LargeMouseBass( | ||
nickName: $this->nicknameGenerator->generate(), | ||
breed: new Breed(FishType::LARGE_MOUSE_BASS, BreedNameType::BIWAKO), | ||
conditionLevel: ConditionLevelType::FINE, | ||
hungerLevel: HungerLevelType::STUFFED, | ||
birthday: now() | ||
); | ||
} | ||
} |
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