|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace eXpansion\Bundle\VoteManager\Structures; |
|
4
|
|
|
|
|
5
|
|
|
use eXpansion\Bundle\Maps\Services\JukeboxService; |
|
6
|
|
|
use eXpansion\Framework\Core\Helpers\ChatNotification; |
|
7
|
|
|
use eXpansion\Framework\Core\Storage\Data\Player; |
|
8
|
|
|
use eXpansion\Framework\Core\Storage\MapStorage; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class NexMapVote |
|
12
|
|
|
* |
|
13
|
|
|
* @author de Cramer Oliver<[email protected]> |
|
14
|
|
|
* @copyright 2017 Smile |
|
15
|
|
|
* @package eXpansion\Bundle\VoteManager\Structures |
|
16
|
|
|
*/ |
|
17
|
|
|
class RestartMapVote extends AbstractVote |
|
18
|
|
|
{ |
|
19
|
|
|
/** @var JukeboxService */ |
|
20
|
|
|
protected $jukebox; |
|
21
|
|
|
|
|
22
|
|
|
/** @var MapStorage */ |
|
23
|
|
|
protected $mapStorage; |
|
24
|
|
|
|
|
25
|
|
|
/** @var ChatNotification */ |
|
26
|
|
|
protected $chatNotification; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* NexMapVote constructor. |
|
30
|
|
|
* |
|
31
|
|
|
* @param Player $player |
|
32
|
|
|
* @param string $type |
|
33
|
|
|
* @param int $duration |
|
34
|
|
|
* @param float $ration |
|
35
|
|
|
* @param JukeboxService $jukebox |
|
36
|
|
|
* @param MapStorage $mapStorage |
|
37
|
|
|
* @param ChatNotification $chatNotification |
|
38
|
|
|
*/ |
|
39
|
3 |
View Code Duplication |
public function __construct( |
|
|
|
|
|
|
40
|
|
|
Player $player, |
|
41
|
|
|
string $type, |
|
42
|
|
|
int $duration = 30, |
|
43
|
|
|
float $ration = 0.57, |
|
44
|
|
|
JukeboxService $jukebox, |
|
45
|
|
|
MapStorage $mapStorage, |
|
46
|
|
|
ChatNotification $chatNotification |
|
47
|
|
|
) { |
|
48
|
3 |
|
parent::__construct($player, $type, $duration, $ration); |
|
49
|
|
|
|
|
50
|
3 |
|
$this->jukebox = $jukebox; |
|
51
|
3 |
|
$this->mapStorage = $mapStorage; |
|
52
|
3 |
|
$this->chatNotification = $chatNotification; |
|
53
|
3 |
|
} |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @inheritdoc |
|
58
|
|
|
*/ |
|
59
|
1 |
|
public function getQuestion(): string |
|
60
|
|
|
{ |
|
61
|
1 |
|
return 'expansion_votemanager.restartmap.question'; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @inheritdoc |
|
66
|
|
|
*/ |
|
67
|
1 |
|
public function executeVotePassed() |
|
68
|
|
|
{ |
|
69
|
1 |
|
$this->jukebox->addMap($this->mapStorage->getCurrentMap(), $this->getPlayer()->getLogin(), true); |
|
70
|
1 |
|
$this->chatNotification->sendMessage("|info| Vote passed. Will replay map!"); |
|
71
|
1 |
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @inheritdoc |
|
75
|
|
|
*/ |
|
76
|
1 |
|
public function executeVoteFailed() |
|
77
|
|
|
{ |
|
78
|
|
|
// Do Nothing |
|
79
|
1 |
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.