| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| 1 | <?php |
||
| 26 | 13 | public function decide(GameState $state): Decision |
|
| 27 | { |
||
| 28 | 13 | if (!$state->getNextPlayer()->equals($this->objectivePlayer)) { |
|
| 29 | 1 | throw new BadMethodCallException('It is not this players turn'); |
|
| 30 | } |
||
| 31 | 12 | $topLevelNode = new DecisionPoint( |
|
| 32 | 12 | $this->objectivePlayer, |
|
| 33 | $state, |
||
| 34 | 12 | $this->maxDepth, |
|
| 35 | 12 | DecisionWithScore::getBestComparator() |
|
| 36 | ); |
||
| 37 | 12 | $decisionWithScore = $topLevelNode->decide(); |
|
| 38 | 12 | if ($decisionWithScore->decision === null) { |
|
| 39 | 1 | throw new RuntimeException('There are no possible moves'); |
|
| 40 | } |
||
| 41 | 11 | return $decisionWithScore->decision; |
|
| 42 | } |
||
| 43 | } |
||
| 44 |