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
22 changes: 20 additions & 2 deletions api/analyzer-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,24 @@ code = "incompatible-parameter-name"
message = 'Parameter #1 of `App\Game\Card\Monster\SirenCard::onturnaction()` is named `$context` but parent `App\Game\Card\Trait\BaseOnTurnTrait::onturnaction()` names it `$gameContext`'
count = 1

[[issues]]
file = "src/Game/Card/Passive/DeadCatCard.php"
code = "mixed-property-type-coercion"
message = "A value with a less specific type `nonnull` is being assigned to property `$$counter` (int)."
count = 1

[[issues]]
file = "src/Game/Card/Passive/DeadCatCard.php"
code = "possibly-null-argument"
message = 'Argument #1 of method `App\Game\GameContext::discardcard` is possibly `null`, but parameter type `string` does not accept it.'
count = 1

[[issues]]
file = "src/Game/Card/Passive/DeadCatCard.php"
code = "possibly-null-argument"
message = 'Argument #1 of method `App\Game\GameContext::getplayerstatebyid` is possibly `null`, but parameter type `string` does not accept it.'
count = 1

[[issues]]
file = "src/Game/Card/Passive/ImStillStandingCard.php"
code = "possibly-null-argument"
Expand Down Expand Up @@ -321,13 +339,13 @@ count = 1
[[issues]]
file = "src/Game/Card/Trait/BaseOnTurnTrait.php"
code = "non-existent-method"
message = 'Method `guardedaction` does not exist on type `App\Game\Card\Trait\BaseOnTurnTrait`.'
message = 'Method `getinstanceid` does not exist on type `App\Game\Card\Trait\BaseOnTurnTrait`.'
count = 1

[[issues]]
file = "src/Game/Card/Trait/BaseOnTurnTrait.php"
code = "non-existent-method"
message = 'Method `getinstanceid` does not exist on type `App\Game\Card\Trait\BaseOnTurnTrait`.'
message = 'Method `guardedaction` does not exist on type `App\Game\Card\Trait\BaseOnTurnTrait`.'
count = 1

[[issues]]
Expand Down
1 change: 1 addition & 0 deletions api/resources/cards_list.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/src/Command/ImportGameReplayCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function __invoke(#[Argument('filePath')] string $filePath, OutputInterfa
}

$output->writeln(sprintf('<info>File "%s" imported successfully.</info>', $filePath));
$output->writeln($id);

return 0;
}
Expand Down
71 changes: 71 additions & 0 deletions api/src/Game/Card/Passive/DeadCatCard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

namespace App\Game\Card\Passive;

use App\Enum\CardRarityEnum;
use App\Enum\CardSetEnum;
use App\Enum\GameEventTypeEnum;
use App\Game\Card\CardState;
use App\Game\Card\Interface\DeathAwareInterface;
use App\Game\Card\Trait\DeathAwareTrait;
use App\Game\GameContext;
use App\Game\GameUtils;

final class DeadCatCard extends AbstractPassiveCard implements DeathAwareInterface
{
use DeathAwareTrait;

private const int REVIVE_HP = 1;

private int $counter = 9;

public function getId(): string
{
return 'DeadCat';
}

public function getDescription(): string
{
return GameUtils::formatDescription(parent::getDescription(), ['value' => $this->getValue(self::REVIVE_HP), 'value2' => $this->counter]);
}

public function onPlayerDeath(GameContext $gameContext, string $deadPlayerId): void
{
if ($deadPlayerId !== $this->getOwnerId()) {
return;
}

$player = $gameContext->getPlayerStateById($this->getOwnerId());

$gameContext->heal(abs(min(0, $player->healthPoints)) + self::REVIVE_HP, $this->getOwnerId());

$gameContext->pushGameEvent(GameEventTypeEnum::CARD_STATE_UPDATED, [
'cardId' => $this->getInstanceId(),
'playerId' => $this->getOwnerId(),
'stateToUpdate' => [
'counter' => --$this->counter,
],
]);

if ($this->counter <= 0) {
$gameContext->discardCard($this->getInstanceId());
}
}

public function setState(CardState $state): void
{
parent::setState($state);

$this->counter = $state->values['counter'] ?? 9;
}

public function getSerie(): CardSetEnum
{
return CardSetEnum::TBOI;
}

public function getRarity(): CardRarityEnum
{
return CardRarityEnum::RARE;
}
}
15 changes: 15 additions & 0 deletions api/templates/dev/passive.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?= "<?php\n" ?>

namespace <?= $class_data->getNamespace(); ?>;

<?= $class_data->getUseStatements(); ?>

<?= $class_data->getClassDeclaration(); ?> <?= $interfaces ?>
{
<?= $traits ?>

public function getId(): string
{
return '<?= $id; ?>';
}
}
48 changes: 36 additions & 12 deletions api/tests/GameReplay/resources/replay2.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 41 additions & 13 deletions api/tests/GameReplay/resources/replay3.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading