Completed
Pull Request — master (#210)
by
unknown
08:31
created

SmTest::onPlayerThrowsObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 6
nc 1
nop 4
1
<?php
2
3
namespace eXpansion\Bundle\Acme\Plugins;
4
5
use eXpansion\Framework\Core\Helpers\ChatNotification;
6
use eXpansion\Framework\Core\Services\Console;
7
use eXpansion\Framework\Core\Storage\PlayerStorage;
8
use eXpansion\Framework\GameShootmania\DataProviders\Listener\ListenerInterfaceSmPlayer;
9
use eXpansion\Framework\GameShootmania\DataProviders\Listener\ListenerInterfaceSmPlayerExtra;
10
use eXpansion\Framework\GameShootmania\DataProviders\Listener\ListenerInterfaceSmPlayerShoot;
11
use eXpansion\Framework\GameShootmania\Structures\Landmark;
12
use eXpansion\Framework\GameShootmania\Structures\Position;
13
14
class SmTest implements ListenerInterfaceSmPlayer, ListenerInterfaceSmPlayerShoot, ListenerInterfaceSmPlayerExtra
15
{
16
    /**
17
     * @var ChatNotification
18
     */
19
    private $chatNotification;
20
    /**
21
     * @var Console
22
     */
23
    private $console;
24
    /**
25
     * @var PlayerStorage
26
     */
27
    private $playerStorage;
28
29
    /**
30
     * Test constructor.
31
     * @param ChatNotification $chatNotification
32
     * @param Console          $console
33
     * @param PlayerStorage    $playerStorage
34
     */
35
    public function __construct(
36
        ChatNotification $chatNotification,
37
        Console $console,
38
        PlayerStorage $playerStorage
39
    ) {
40
41
        $this->chatNotification = $chatNotification;
42
        $this->console = $console;
43
        $this->playerStorage = $playerStorage;
44
    }
45
46
    /**
47
     * Callback sent when a player is hit.
48
     *
49
     * @param string   $shooterLogin    login
50
     * @param string   $victimLogin     login
51
     * @param int      $weapon          id of weapon: [1-laser, 2-rocket, 3-nucleus, 5-arrow]
52
     * @param int      $damage          amount damage done by hit
53
     * @param int      $points          amount of points scored by shooter
54
     * @param float    $distance        distance between 2 players
55
     * @param Position $shooterPosition position at level
56
     * @param Position $victimPosition  position at level
57
     * @return void
58
     */
59
    public function onPlayerHit(
60
        $shooterLogin,
61
        $victimLogin,
62
        $weapon,
63
        $damage,
64
        $points,
65
        $distance,
66
        Position $shooterPosition,
67
        Position $victimPosition
68
    ) {
69
        // do nothing
70
        $this->console->writeln($shooterLogin." -> ".$victimLogin." with: ".$damage);
71
    }
72
73
    /**
74
     * Callback sent when a player is eliminated.
75
     * @param string $shooterLogin    login
76
     * @param string $victimLogin     login
77
     * @param int    $weapon          id of weapon: [1-laser, 2-rocket, 3-nucleus, 5-arrow]
78
     * @param int    $damage          amount damage done by hit
79
     * @param array  $shooterPosition position at level
80
     * @param array  $victimPosition  position at level
81
     * @return void
82
     */
83
    public function onArmorEmpty(
84
        $shooterLogin,
85
        $victimLogin,
86
        $weapon,
87
        $damage,
88
        Position $shooterPosition,
89
        Position $victimPosition
90
    ) {
91
        $this->console->writeln("armor empty: ".$victimLogin." with: ".$damage);
92
    }
93
94
    /**
95
     * Callback when pole is being captured
96
     *
97
     * @param array    $players
98
     * @param Landmark $landmark
99
     */
100
    public function onCapture(
101
        $players,
102
        Landmark $landmark
103
    ) {
104
        $this->console->writeln('onCapture');
105
    }
106
107
    /**
108
     * Callback when player triggers sector
109
     *
110
     * @param string $login
111
     * @param string $sectorId
112
     */
113
    public function onPlayerTriggersSector(
114
        $login,
115
        $sectorId
116
    ) {
117
        $this->console->writeln('Player Triggers Sector: '.$login." Sector:".$sectorId);
118
    }
119
120
    /**
121
     *  Callback when player touches an object at level
122
     *
123
     * @param string $login
124
     * @param string $objectId
125
     * @param string $modelId
126
     * @param string $modelName
127
     */
128
    public function onPlayerTouchesObject(
129
        $login,
130
        $objectId,
131
        $modelId,
132
        $modelName
133
    ) {
134
        $this->console->writeln('Object: '.$login.' ModelName:'.$modelName);
135
    }
136
137
    /**
138
     *  Callback when player touches an object at level
139
     *
140
     * @param string $login
141
     * @param string $objectId
142
     * @param string $modelId
143
     * @param string $modelName
144
     */
145
    public function onPlayerThrowsObject(
146
        $login,
147
        $objectId,
148
        $modelId,
149
        $modelName
150
    ) {
151
        $this->console->writeln('Throw: '.$login.' ModelName:'.$modelName);
152
    }
153
154
    /**
155
     * @param string $login  login
156
     * @param int    $weapon indexes are: 1-Laser, 2-Rocket, 3-Nucleus, 5-Arrow
157
     * @return void
158
     */
159
    public function onShoot($login, $weapon)
160
    {
161
        $this->console->writeln('Shoot: '.$login.' Weapon: '.$weapon);
162
    }
163
164
    /**
165
     * @param string   $shooterLogin    Login of the player who shot
166
     * @param string   $victimLogin     Login of the player who dodged
167
     * @param int      $weapon          Id of the weapon [1-Laser, 2-Rocket, 3-Nucleus, 5-Arrow]
168
     * @param float    $distance        Distance of the near miss
169
     * @param Position $shooterPosition position in level
170
     * @param Position $victimPosition  position in level
171
     * @return void
172
     */
173
    public function onNearMiss(
174
        $shooterLogin,
175
        $victimLogin,
176
        $weapon,
177
        $distance,
178
        Position $shooterPosition,
179
        Position $victimPosition
180
    ) {
181
        $this->console->writeln('NearMiss: '.$victimLogin.' Weapon: '.$weapon." Distance:".$distance);
182
    }
183
184
    /**
185
     * @param string $shooterLogin
186
     * @param string $victimLogin
187
     * @param int    $shooterWeapon
188
     * @param int    $victimWeapon
189
     * @return void
190
     */
191
    public function onShotDeny($shooterLogin, $victimLogin, $shooterWeapon, $victimWeapon)
192
    {
193
        $this->console->writeln('Deny: '.$shooterLogin." -> ".$victimLogin);
194
    }
195
196
    /**
197
     * @param string $login
198
     * @return void
199
     */
200
    public function onFallDamage($login)
201
    {
202
        $this->console->writeln('FallDamage: '.$login);
203
    }
204
205
    /**
206
     * @param string $login
207
     * @return void
208
     */
209
    public function onRequestRespawn($login)
210
    {
211
        $this->console->writeln('Respawn: '.$login);
212
    }
213
}
214