Completed
Pull Request — master (#175)
by
unknown
05:30
created

NextMapVote::onPodiumEnd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace eXpansion\Bundle\VoteManager\Plugins\Votes;
4
5
use eXpansion\Framework\Core\Helpers\ChatNotification;
6
use eXpansion\Framework\Core\Storage\PlayerStorage;
7
use eXpansion\Framework\GameManiaplanet\DataProviders\Listener\ListenerInterfaceMpScriptPodium;
8
use Maniaplanet\DedicatedServer\Connection;
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 NextMapVote extends AbstractVotePlugin implements ListenerInterfaceMpScriptPodium
18
{
19
    /** @var Connection */
20
    protected $connection;
21
22
    /** @var ChatNotification */
23
    protected $chatNotification;
24
25
    /**
26
     * NextMapVote constructor.
27
     *
28
     * @param PlayerStorage $playerStorage
29
     * @param Connection $connection
30
     * @param ChatNotification $chatNotification
31
     * @param int $duration
32
     * @param float $ratio
33
     */
34 7
    public function __construct(
35
        PlayerStorage $playerStorage,
36
        Connection $connection,
37
        ChatNotification $chatNotification,
38
        int $duration,
39
        float $ratio
40
    ) {
41 7
        parent::__construct($playerStorage, $duration, $ratio);
42
43 7
        $this->connection = $connection;
44 7
        $this->chatNotification = $chatNotification;
45 7
    }
46
47
48
    /**
49
     * @inheritdoc
50
     */
51 1
    public function getQuestion(): string
52
    {
53 1
        return 'expansion_votemanager.nextmap.question';
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59 2
    protected function executeVotePassed()
60
    {
61 2
        $this->connection->nextMap(false);
62 2
        $this->chatNotification->sendMessage("|info| Vote passed. Skipping map!");
63 2
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68 1
    protected function executeVoteFailed()
69
    {
70
        // Do Nothing
71 1
    }
72
73
    /**
74
     * Get type code of this vote.
75
     *
76
     * @return string
77
     */
78 6
    public function getCode(): string
79
    {
80 6
       return 'Exp_NextMap';
81
    }
82
83
    /**
84
     * Get native votes this votes replaces.
85
     *
86
     * @return string[]
87
     */
88 1
    public function getReplacementTypes(): array
89
    {
90 1
        return ['NextMap'];
91
    }
92
93
    /**
94
     * Callback sent when the "onPodiumStart" section start.
95
     *
96
     * @param int $time Server time when the callback was sent
97
     * @return void
98
     */
99
    public function onPodiumStart($time)
100
    {
101
        //nothing
102
    }
103
104
    /**
105
     * Callback sent when the "onPodiumEnd" section end.
106
     *
107
     * @param int $time Server time when the callback was sent
108
     *
109
     * @return void
110
     */
111
    public function onPodiumEnd($time)
112
    {
113
        $this->cancel();
114
    }
115
}
116