EncounterEvent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 7
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A __invoke() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Event;
6
7
use AardsGerds\Game\Entity\Entity;
8
use AardsGerds\Game\Event\Decision\Decision;
9
use AardsGerds\Game\Event\Decision\DecisionCollection;
10
use AardsGerds\Game\Player\Player;
11
use AardsGerds\Game\Player\PlayerAction;
12
13
abstract class EncounterEvent extends Event
14
{
15
    public function __construct(
16
        Context $context,
17
        DecisionCollection $decisionCollection,
18
        protected Entity $subject,
19
    ) {
20
        parent::__construct(
21
            $context,
22
            $decisionCollection,
23
        );
24
    }
25
26
    public function __invoke(Player $player, PlayerAction $playerAction): Decision
27
    {
28
        $playerAction->introduce((string) $this->context->getLocation());
29
        // dialog, travel, fight or retreat?
30
        return $playerAction->askForDecision((string) $this->context, $this->decisionCollection);
31
    }
32
}
33