Completed
Push — master ( 47c10a...c931cd )
by De Cramer
13s
created

RestartMapVote::getCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace eXpansion\Bundle\VoteManager\Plugins\Votes;
4
5
use eXpansion\Bundle\Maps\Services\JukeboxService;
6
use eXpansion\Framework\Core\Helpers\ChatNotification;
7
use eXpansion\Framework\Core\Storage\MapStorage;
8
use eXpansion\Framework\Core\Storage\PlayerStorage;
9
10
/**
11
 * Class NextMapVote
12
 *
13
 * @author    de Cramer Oliver<[email protected]>
14
 * @copyright 2017 eXpansion
15
 * @package eXpansion\Bundle\VoteManager\Plugins\Votes
16
 */
17
class RestartMapVote extends AbstractVotePlugin
18
{
19
    /** @var JukeboxService */
20
    protected $jukebox;
21
22
    /** @var MapStorage */
23
    protected $mapStorage;
24
25
    /** @var ChatNotification */
26
    protected $chatNotification;
27
28
    /**
29
     * RestartMapVote constructor.
30
     *
31
     * @param PlayerStorage $playerStorage
32
     * @param JukeboxService $jukebox
33
     * @param MapStorage $mapStorage
34
     * @param ChatNotification $chatNotification
35
     * @param int $duration
36
     * @param float $ratio
37
     */
38 3
    public function __construct(
39
        PlayerStorage $playerStorage,
40
        JukeboxService $jukebox,
41
        MapStorage $mapStorage,
42
        ChatNotification $chatNotification,
43
        int $duration,
44
        float $ratio
45
    ) {
46 3
        parent::__construct($playerStorage, $duration, $ratio);
47
48 3
        $this->jukebox = $jukebox;
49 3
        $this->mapStorage = $mapStorage;
50 3
        $this->chatNotification = $chatNotification;
51 3
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56 1
    public function getQuestion(): string
57
    {
58 1
        return 'expansion_votemanager.restartmap.question';
59
    }
60
61
    /**
62
     * @inheritdoc
63
     */
64 1
    public function executeVotePassed()
65
    {
66 1
        $this->jukebox->addMap($this->mapStorage->getCurrentMap(), $this->getCurrentVote()->getPlayer()->getLogin(), true);
67 1
        $this->chatNotification->sendMessage("|info| Vote passed. Will replay map!");
68 1
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73 1
    protected function executeVoteFailed()
74
    {
75
        // Do Nothing
76 1
    }
77
78
    /**
79
     * Get type code of this vote.
80
     *
81
     * @return string
82
     */
83 3
    public function getCode(): string
84
    {
85 3
        return 'Exp_RestartMap';
86
    }
87
88
    /**
89
     * Get native votes this votes replaces.
90
     *
91
     * @return string[]
92
     */
93 1
    public function getReplacementTypes(): array
94
    {
95 1
        return ['RestartMap'];
96
    }
97
}
98