EncounterEvent::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
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