Completed
Pull Request — master (#307)
by
unknown
03:53
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\Services\Application\Dispatcher;
7
use eXpansion\Framework\Core\Services\DedicatedConnection\Factory;
8
use eXpansion\Framework\Core\Storage\PlayerStorage;
9
use eXpansion\Framework\GameManiaplanet\DataProviders\Listener\ListenerInterfaceMpScriptPodium;
10
use Maniaplanet\DedicatedServer\Connection;
11
12
/**
13
 * Class NextMapVote
14
 *
15
 * @author    de Cramer Oliver<[email protected]>
16
 * @copyright 2017 eXpansion
17
 * @package eXpansion\Bundle\VoteManager\Plugins\Votes
18
 */
19
class NextMapVote extends AbstractVotePlugin implements ListenerInterfaceMpScriptPodium
20
{
21
    /** @var Factory */
22
    protected $factory;
23
24
    /** @var ChatNotification */
25
    protected $chatNotification;
26
27
    /**
28
     * NextMapVote constructor.
29
     *
30
     * @param Dispatcher       $dispatcher
31
     * @param PlayerStorage    $playerStorage
32
     * @param Factory          $factory
33
     * @param ChatNotification $chatNotification
34
     * @param int              $duration
35
     * @param float            $ratio
36
     */
37
    public function __construct(
38
        Dispatcher $dispatcher,
39
        PlayerStorage $playerStorage,
40
        Factory $factory,
41
        ChatNotification $chatNotification,
42
        int $duration,
43
        float $ratio
44
    ) {
45
        parent::__construct($dispatcher, $playerStorage, $duration, $ratio);
46
47
        $this->factory = $factory;
48
        $this->chatNotification = $chatNotification;
49
    }
50
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function getQuestion(): string
56
    {
57
        return 'expansion_votemanager.nextmap.question';
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63
    protected function executeVotePassed()
64
    {
65
        $this->factory->getConnection()->nextMap(false);
66
        $this->chatNotification->sendMessage("|info| Vote passed. Skipping map!");
67
    }
68
69
    /**
70
     * @inheritdoc
71
     */
72
    protected function executeVoteFailed()
73
    {
74
        // Do Nothing
75
    }
76
77
    /**
78
     * Get type code of this vote.
79
     *
80
     * @return string
81
     */
82
    public function getCode(): string
83
    {
84
        return 'Exp_NextMap';
85
    }
86
87
    /**
88
     * Get native votes this votes replaces.
89
     *
90
     * @return string[]
91
     */
92
    public function getReplacementTypes(): array
93
    {
94
        return ['NextMap'];
95
    }
96
97
    /**
98
     * Callback sent when the "onPodiumStart" section start.
99
     *
100
     * @param int $time Server time when the callback was sent
101
     * @return void
102
     */
103
    public function onPodiumStart($time)
104
    {
105
        //nothing
106
    }
107
108
    /**
109
     * Callback sent when the "onPodiumEnd" section end.
110
     *
111
     * @param int $time Server time when the callback was sent
112
     *
113
     * @return void
114
     */
115
    public function onPodiumEnd($time)
116
    {
117
        $this->cancel();
118
    }
119
}
120