GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ActionHelper::proposeRC()   F
last analyzed

Complexity

Conditions 20
Paths 414

Size

Total Lines 112
Code Lines 87

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 20
eloc 87
nc 414
nop 5
dl 0
loc 112
rs 3.5641
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Asylamba\Modules\Gaia\Helper;
4
5
use Asylamba\Classes\Library\Chronos;
6
use Asylamba\Classes\Library\Game;
7
use Asylamba\Classes\Library\Format;
8
9
use Asylamba\Modules\Promethee\Model\Technology;
10
11
use Asylamba\Modules\Promethee\Resource\TechnologyResource;
12
use Asylamba\Modules\Athena\Resource\OrbitalBaseResource;
13
use Asylamba\Modules\Athena\Helper\OrbitalBaseHelper;
14
15
use Asylamba\Modules\Ares\Manager\CommanderManager;
16
use Asylamba\Modules\Athena\Manager\CommercialRouteManager;
17
use Asylamba\Classes\Library\Session\SessionWrapper;
18
19
abstract class ActionHelper {
20
	/** @var CommanderManager **/
21
	protected $commanderManager;
22
	/** @var CommercialRouteManager **/
23
	protected $commercialRouteManager;
24
	/** @var OrbitalBaseHelper **/
25
	protected $orbitalBaseHelper;
26
	/** @var int **/
27
	protected $routeSectorBonus;
28
	/** @var int **/
29
	protected $routeColorBonus;
30
	/** @var SessionWrapper **/
31
	protected $sessionWrapper;
32
	/** @var string **/
33
	protected $sessionToken;
34
	
35
	/**
36
	 * @param CommanderManager $commanderManager
37
	 * @param CommercialRouteManager $commercialRouteManager
38
	 * @param OrbitalBaseHelper $orbitalBaseHelper
39
	 * @param int $routeSectorBonus
40
	 * @param int $routeColorBonus
41
	 * @param SessionWrapper $session
42
	 */
43
	public function __construct(
44
		CommanderManager $commanderManager,
45
		CommercialRouteManager $commercialRouteManager,
46
		OrbitalBaseHelper $orbitalBaseHelper,
47
		$routeSectorBonus,
48
		$routeColorBonus,
49
		SessionWrapper $session
50
	) {
51
		$this->commanderManager = $commanderManager;
52
		$this->commercialRouteManager = $commercialRouteManager;
53
		$this->orbitalBaseHelper = $orbitalBaseHelper;
54
		$this->routeSectorBonus = $routeSectorBonus;
55
		$this->routeColorBonus = $routeColorBonus;
56
		$this->sessionWrapper = $session;
57
		$this->sessionToken = $session->get('token');
58
	}
59
	
60
	public function loot($ob, &$link, &$box, $id, $place, $commanderSession) {
61
		$link .= '<a href="#" class="actionbox-sh" data-target="' . $id . '"><img src="' . MEDIA . 'map/action/loot.png" alt="pillage" /></a>';
62
63
		$box .= '<div data-id="' . $id . '" class="act-bull" style="display:' . (($id == 1) ? 'block' : 'none') . ';" >';
64
			$box .= '<h5>Effectuer un pillage</h5>';
65
			# check si au moins un commandant est disponible
66
			$S_COM2 = $this->commanderManager->getCurrentSession();
0 ignored issues
show
Bug introduced by
The method getCurrentSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
67
			$this->commanderManager->changeSession($commanderSession);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
68
			$commanderQuantity = 0;
69
			for ($i = 0; $i < $this->commanderManager->size(); $i++) { 
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
70
				if ($this->commanderManager->get($i)->getStatement() == Commander::AFFECTED) {
71
	  				$commanderQuantity++;
72
				}
73
			}
74
			if ($commanderQuantity > 0) {
75
				# check si assez de PA
76
				if ($place->getRSystem() == $ob->getSystem()) {
77
					$time = Game::getTimeTravelInSystem($ob->getPosition(), $place->getPosition());
78
				} else {
79
					$time = Game::getTimeTravelOutOfSystem($ob->getXSystem(), $ob->getYSystem(), $place->getXSystem(), $place->getYSystem());
0 ignored issues
show
Bug introduced by
The call to getTimeTravelOutOfSystem() misses a required argument $destinationY.

This check looks for function calls that miss required arguments.

Loading history...
80
				}
81
82
				for ($i = 0; $i < $this->commanderManager->size(); $i++) {
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
83
					if ($this->commanderManager->get($i)->getStatement() == Commander::AFFECTED) {
84
						$box .= '<a href="' . Format::actionBuilder('loot', $this->sessionToken, ['commanderid' => $this->commanderManager->get($i)->getId(), 'placeid' => $place->getId(), 'redirect' => $place->getId()]) . '" class="commander">';
85
							$box .= '<img class="avatar" src="' . MEDIA . 'commander/small/c1-l1-c' . $this->sessionWrapper->get('playerInfo')->get('color') . '.png" alt="' . $this->commanderManager->get($i)->getName() . '" />';
86
							$box .= '<span class="label">';
87
								$box .= '<strong>' . $this->commanderManager->get($i)->getName() . '</strong><br />';
88
								$box .= $this->commanderManager->get($i)->getPev() . ' pev<br />';
89
								$box .= Format::numberFormat($this->commanderManager->get($i)->getPev() * COEFFLOOT) . ' de soute';
90
							$box .= '</span>';
91
							$box .= '<span class="value">';
92
								$box .= Chronos::secondToFormat($time, 'lite') . ' <img alt="temps" src="' . MEDIA . 'resources/time.png" class="icon-color">';
93
							$box .= '</span>';
94
						$box .= '</a>';
95
					}
96
				}
97
			} else {
98
				$box .= '<p class="info">Vous n\'avez aucun commandant en fonction sur ' . $ob->getName() . '. <a href="' . APP_ROOT . 'bases/base-' . $ob->getId() . '/view-school">Affectez un commandant</a> et envoyez un pillage depuis ' . $ob->getName() . '.</p>';
99
			}
100
			$this->commanderManager->changeSession($S_COM2);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
101
		$box .= '</div>';
102
	}
103
104
	public function conquest($ob, &$link, &$box, $id, $place, $commanderSession, $movingCommandersSession, $technologies) {
105
		$link .= '<a href="#" class="actionbox-sh" data-target="' . $id . '"><img src="' . MEDIA . 'map/action/colonize.png" alt="conquête" /></a>';
106
107
		$box .= '<div data-id="' . $id . '" class="act-bull" style="display:' . (($id == 1) ? 'block' : 'none') . ';" >';
108
			$box .= '<h5>Effectuer une conquête</h5>';
109
			# check si technologie CONQUEST débloquée
110
			if ($technologies->getTechnology(Technology::CONQUEST) == 1) {
111
				# check si la technologie BASE_QUANTITY a un niveau assez élevé
112
				$maxBasesQuantity = $technologies->getTechnology(Technology::BASE_QUANTITY) + 1;
113
				$obQuantity = $this->sessionWrapper->get('playerBase')->get('ob')->size();
114
				$msQuantity = $this->sessionWrapper->get('playerBase')->get('ms')->size();
115
				$coloQuantity = 0;
116
				$S_COM2 = $this->commanderManager->getCurrentSession();
0 ignored issues
show
Bug introduced by
The method getCurrentSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
117
				$this->commanderManager->changeSession($movingCommandersSession);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
118
				for ($i = 0; $i < $this->commanderManager->size(); $i++) { 
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
119
					if ($this->commanderManager->get($i)->getTravelType() == Commander::COLO) {
120
						$coloQuantity++;
121
					}
122
				}
123
				$this->commanderManager->changeSession($S_COM2);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
124
				if ($obQuantity + $msQuantity + $coloQuantity < $maxBasesQuantity) {
125
					# check si au moins un commandant est disponible
126
					$S_COM2 = $this->commanderManager->getCurrentSession();
0 ignored issues
show
Bug introduced by
The method getCurrentSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
127
					$this->commanderManager->changeSession($commanderSession);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
128
					$commanderQuantity = 0;
129
					for ($i = 0; $i < $this->commanderManager->size(); $i++) { 
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
130
						if ($this->commanderManager->get($i)->getStatement() == Commander::AFFECTED) {
131
							$commanderQuantity++;
132
						}
133
					}
134
					if ($commanderQuantity > 0) {
135
						# check si assez de crédits
136
						$creditPrice = ($obQuantity + $coloQuantity) * CREDITCOEFFTOCONQUER;
137
138
						if ($this->sessionWrapper->get('playerInfo')->get('credit') >= $creditPrice) {
139
							# check si assez de points d'attaque
140
							if ($place->getRSystem() == $ob->getSystem()) {
141
								$time = Game::getTimeTravelInSystem($ob->getPosition(), $place->getPosition());
142
							} else {
143
								$time = Game::getTimeTravelOutOfSystem($ob->getXSystem(), $ob->getYSystem(), $place->getXSystem(), $place->getYSystem());
0 ignored issues
show
Bug introduced by
The call to getTimeTravelOutOfSystem() misses a required argument $destinationY.

This check looks for function calls that miss required arguments.

Loading history...
144
							}
145
146
							for ($i = 0; $i < $this->commanderManager->size(); $i++) {
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
147
								if ($this->commanderManager->get($i)->getStatement() == Commander::AFFECTED) {
148
									$box .= '<a href="' . Format::actionBuilder('conquer', $this->sessionToken, ['commanderid' => $this->commanderManager->get($i)->getId(), 'placeid' => $place->getId(), 'redirect' => $place->getId()]) . '" class="commander">';
149
										$box .= '<img class="avatar" src="' . MEDIA . 'commander/small/c1-l1-c' . $this->sessionWrapper->get('playerInfo')->get('color') . '.png" alt="' . $this->commanderManager->get($i)->getName() . '" />';
150
										$box .= '<span class="label">';
151
											$box .= '<strong>' . $this->commanderManager->get($i)->getName() . '</strong><br />';
152
											$box .= $this->commanderManager->get($i)->getPev() . ' pev';
153
										$box .= '</span>';
154
										$box .= '<span class="value">';
155
											$box .= Chronos::secondToFormat($time, 'lite') . ' <img alt="temps" src="' . MEDIA . 'resources/time.png" class="icon-color"><br />';
156
											$box .= Format::numberFormat($creditPrice) . ' <img alt="credit" src="' . MEDIA . 'resources/credit.png" class="icon-color">';
157
										$box .= '</span>';
158
									$box .= '</a>';
159
								}
160
							}
161
						} else {
162
							$box .= '<p class="info">Vous n\'avez pas assez de crédits pour lancer la conquête. Il faut ' . $creditPrice . ' crédits.</p>';
163
						}
164
					} else {
165
						$box .= '<p class="info">Vous n\'avez aucun commandant en fonction sur ' . $ob->getName() . '. <a href="' . APP_ROOT . 'bases/base-' . $ob->getId() . '/view-school">Affectez un commandant</a> et envoyez un pillage depuis ' . $ob->getName() . '.</p>';
166
					}
167
					$this->commanderManager->changeSession($S_COM2);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
168
				} else {
169
					$box .= '<p class="info">Pour pouvoir conquérir une planète supplémentaire, il faut augmenter le niveau de la technologie ' . TechnologyResource::getInfo(Technology::BASE_QUANTITY, 'name') . '.</p>';
0 ignored issues
show
Bug introduced by
The method getInfo() does not seem to exist on object<Asylamba\Modules\...rce\TechnologyResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
170
				}
171
			} else {
172
				$box .= '<p class="info">Pour pouvoir conquérir une planète, il faut développer la technologie ' . TechnologyResource::getInfo(Technology::CONQUEST, 'name') . '. </p>';
0 ignored issues
show
Bug introduced by
The method getInfo() does not seem to exist on object<Asylamba\Modules\...rce\TechnologyResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
173
			}
174
		$box .= '</div>';
175
	}
176
177
	public function colonize($ob, &$link, &$box, $id, $place, $commanderSession, $movingCommandersSession, $technologies) {
178
		$link .= '<a href="#" class="actionbox-sh" data-target="' . $id . '"><img src="' . MEDIA . 'map/action/colonize.png" alt="colonisation" /></a>';
179
180
		$box .= '<div data-id="' . $id . '" class="act-bull" style="display:' . (($id == 1) ? 'block' : 'none') . ';" >';
181
			$box .= '<h5>Effectuer une colonisation</h5>';
182
			# check si technologie COLONIZATION débloquée
183
			if ($technologies->getTechnology(Technology::COLONIZATION) == 1) {
184
				# check si la technologie BASE_QUANTITY a un niveau assez élevé
185
				$maxBasesQuantity = $technologies->getTechnology(Technology::BASE_QUANTITY) + 1;
186
				$obQuantity = $this->sessionWrapper->get('playerBase')->get('ob')->size();
187
				$msQuantity = $this->sessionWrapper->get('playerBase')->get('ms')->size();
188
				$coloQuantity = 0;
189
				$S_COM2 = $this->commanderManager->getCurrentSession();
0 ignored issues
show
Bug introduced by
The method getCurrentSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
190
				$this->commanderManager->changeSession($movingCommandersSession);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
191
				for ($i = 0; $i < $this->commanderManager->size(); $i++) { 
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
192
					if ($this->commanderManager->get($i)->getTravelType() == Commander::COLO) {
193
						$coloQuantity++;
194
					}
195
				}
196
				$this->commanderManager->changeSession($S_COM2);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
197
				if ($obQuantity + $msQuantity + $coloQuantity < $maxBasesQuantity) {
198
					# check si au moins un commandant est disponible
199
					$S_COM2 = $this->commanderManager->getCurrentSession();
0 ignored issues
show
Bug introduced by
The method getCurrentSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
200
					$this->commanderManager->changeSession($commanderSession);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
201
					$commanderQuantity = 0;
202
					for ($i = 0; $i < $this->commanderManager->size(); $i++) { 
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
203
						if ($this->commanderManager->get($i)->getStatement() == Commander::AFFECTED) {
204
							$commanderQuantity++;
205
						}
206
					}
207
					if ($commanderQuantity > 0) {
208
						# check si assez de crédits
209
						$creditPrice = ($obQuantity + $coloQuantity) * CREDITCOEFFTOCOLONIZE;
210
211
						if ($this->sessionWrapper->get('playerInfo')->get('credit') >= $creditPrice) {
212
							# check si assez de points d'attaque
213
							if ($place->getRSystem() == $ob->getSystem()) {
214
								$time = Game::getTimeTravelInSystem($ob->getPosition(), $place->getPosition());
215
							} else {
216
								$time = Game::getTimeTravelOutOfSystem($ob->getXSystem(), $ob->getYSystem(), $place->getXSystem(), $place->getYSystem());
0 ignored issues
show
Bug introduced by
The call to getTimeTravelOutOfSystem() misses a required argument $destinationY.

This check looks for function calls that miss required arguments.

Loading history...
217
							}
218
219
							for ($i = 0; $i < $this->commanderManager->size(); $i++) { 
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
220
								if ($this->commanderManager->get($i)->getStatement() == Commander::AFFECTED) {
221
									$box .= '<a href="' . Format::actionBuilder('colonize', $this->sessionToken, ['commanderid' => $this->commanderManager->get($i)->getId(), 'placeid' => $place->getId(), 'redirect' => $place->getId()]) . '" class="commander">';
222
										$box .= '<img class="avatar" src="' . MEDIA . 'commander/small/c1-l1-c' . $this->sessionWrapper->get('playerInfo')->get('color') . '.png" alt="' . $this->commanderManager->get($i)->getName() . '" />';
223
										$box .= '<span class="label">';
224
											$box .= '<strong>' . $this->commanderManager->get($i)->getName() . '</strong><br />';
225
											$box .= $this->commanderManager->get($i)->getPev() . ' pev';
226
										$box .= '</span>';
227
										$box .= '<span class="value">';
228
											$box .= Chronos::secondToFormat($time, 'lite') . ' <img alt="temps" src="' . MEDIA . 'resources/time.png" class="icon-color"><br />';
229
											$box .= Format::numberFormat($creditPrice) . ' <img alt="credit" src="' . MEDIA . 'resources/credit.png" class="icon-color">';
230
										$box .= '</span>';
231
									$box .= '</a>';
232
								}
233
							}
234
						} else {
235
							$box .= '<p class="info">Vous n\'avez pas assez de crédits pour envoyer la colonisation. Il faut ' . $creditPrice . ' crédits.</p>';
236
						}
237
					} else {
238
						$box .= '<p class="info">Vous n\'avez aucun commandant en fonction sur ' . $ob->getName() . '. <a href="' . APP_ROOT . 'bases/base-' . $ob->getId() . '/view-school">Affectez un commandant</a> et envoyez un pillage depuis ' . $ob->getName() . '.</p>';
239
					}
240
					$this->commanderManager->changeSession($S_COM2);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
241
				} else {
242
					$box .= '<p class="info">Pour pouvoir coloniser une planète supplémentaire, il faut augmenter le niveau de la technologie ' . TechnologyResource::getInfo(Technology::BASE_QUANTITY, 'name') . '.</p>';
0 ignored issues
show
Bug introduced by
The method getInfo() does not seem to exist on object<Asylamba\Modules\...rce\TechnologyResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
243
				}
244
			} else {
245
				$box .= '<p class="info">Pour pouvoir coloniser une planète, il faut développer la technologie ' . TechnologyResource::getInfo(Technology::COLONIZATION, 'name') . '.</p>';
0 ignored issues
show
Bug introduced by
The method getInfo() does not seem to exist on object<Asylamba\Modules\...rce\TechnologyResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
246
			}
247
		$box .= '</div>';
248
	}
249
250
	public function proposeRC($ob, &$link, &$box, $id, $place) {
251
		$tmpLink = '<a href="#" class="actionbox-sh" data-target="' . $id . '"><img src="' . MEDIA . 'map/action/proposeRC.png" alt="conquête" /></a>';
252
		
253
		# gérer soit l'un soit l'autre
254
		$box .= '<div data-id="' . $id . '" class="act-bull" style="display:' . (($id == 1) ? 'block' : 'none') . ';" >';
255
			$sendResources = FALSE;
256
			$proposed = FALSE;
257
			$notAccepted = FALSE;
258
			$standby = FALSE;
259
			if ($ob->getRPlayer() == $place->getRPlayer()) {
260
				if ($ob->getRPlace() != $place->getId()) {
261
					$sendResources = TRUE;
262
				}
263
			} else {
264
				if ($ob->getLevelCommercialPlateforme() > 0) {
265
					if ($place->getLevelCommercialPlateforme() > 0) {
266
						# check si on a déjà une route avec ce joueur
267
						if (($cr = $this->commercialRouteManager->getExistingRoute($ob->getId(), $place->getId())) !== null) {
268
							switch($cr->getStatement()) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after SWITCH keyword; 0 found
Loading history...
269
								case CommercialRoute::PROPOSED: $notAccepted = TRUE; break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
270
								case CommercialRoute::ACTIVE: $sendResources = TRUE; break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
271
								case CommercialRoute::STANDBY: $standby = TRUE; break;
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
272
							}
273
						}
274
						if ($sendResources == FALSE) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
275
							if ($proposed == TRUE) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
276
								$box .= '<h5>Route commerciale en suspens</h5>';
277
								$box .= '<p>Le joueur n\'a pas encore accepté votre proposition de route commerciale. ';
278
								$box .= 'Si vous voulez voir le statut de la route ou annuler votre proposition, rendez-vous dans la ';
279
								$box .= '<a href="' . APP_ROOT . 'bases/base-' . $ob->getRPlace() . '/view-commercialplateforme">plateforme commerciale</a>';
280
								$box .= '.</p>';
281
							} elseif ($notAccepted == TRUE) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
282
								$box .= '<h5>Route commerciale en suspens</h5>';
283
								$box .= '<p>Ce joueur vous a proposé une route commerciale. ';
284
								$box .= 'Si vous voulez l\'accepter ou la refuser, rendez-vous dans la ';
285
								$box .= '<a href="' . APP_ROOT . 'bases/base-' . $ob->getRPlace() . '/view-commercialplateforme">plateforme commerciale</a>';
286
								$box .= '.</p>';
287
							} elseif ($standby == TRUE) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
288
								$box .= '<h5>Route commerciale en suspens</h5>';
289
								$box .= '<p>En temps de guerre, toutes les transactions entre votre base et la sienne sont bloquées. ';
290
								$box .= 'Si vous voulez voir le statut de la route ou y mettre fin, rendez-vous dans la ';
291
								$box .= '<a href="' . APP_ROOT . 'bases/base-' . $ob->getRPlace() . '/view-commercialplateforme">plateforme commerciale</a>';
292
								$box .= '.</p>';
293
							} else {
294
								$maxRoute = $this->orbitalBaseHelper->getBuildingInfo(6, 'level', $ob->getLevelCommercialPlateforme(), 'nbRoutesMax');
295
								if ($this->commercialRouteManager->countBaseActiveAndStandbyRoutes($ob->getId()) < $maxRoute) {
296
									$distance = Game::getDistance($ob->getXSystem(), $place->getXSystem(), $ob->getYSystem(), $place->getYSystem());
297
									$bonusA = ($ob->getSector() != $place->getRSector()) ? $this->routeSectorBonus : 1;
298
									$bonusB = ($this->sessionWrapper->get('playerInfo')->get('color')) != $place->getPlayerColor() ? $this->routeColorBonus : 1;
299
									$price = Game::getRCPrice($distance);
300
									$income = Game::getRCIncome($distance, $bonusA, $bonusB);
301
302
									$box .= '<h5>Proposer une route commerciale</h5>';
303
304
									$box .= '<div class="rc">';
305
										$box .= '<p>Longueur de la route <strong>' . Format::numberFormat($distance) . ' Al.</strong></p>';
306
										$box .= '<p>Coût de la mise en place <strong>' . Format::numberFormat($price) . ' <img alt="credit" src="' . MEDIA . 'resources/credit.png" class="icon-color"></strong></p>';
307
										$box .= '<p>Revenu par relève <strong>' . Format::numberFormat($income) . ' <img alt="credit" src="' . MEDIA . 'resources/credit.png" class="icon-color"></strong></p>';
308
309
										if ($this->sessionWrapper->get('playerInfo')->get('credit') >= $price) {
310
											# bouton actif
311
											$box .= '<a class="button" href="' . Format::actionBuilder('proposeroute', $this->sessionToken, ['basefrom' => $ob->getRPlace(), 'baseto' => $place->getId(), 'redirect' => $place->getId()]) . '">';
312
												$box .= 'proposer';
313
											$box .= '</a>';
314
										} else {
315
											# bouton pas actifs
316
											$box .= '<span class="button">';
317
												$box .= 'crédits insuffisants';
318
											$box .= '</span>';
319
										}
320
									$box .= '</div>';
321
								} else {
322
									$box .= '<h5>Proposer une route commerciale</h5>';
323
									$box .= '<p class="info">Toutes vos routes commerciales sont déjà créées. Pour pouvoir proposer une nouvelle route, il faut soit augmenter le niveau de votre plateforme commerciale, soit annuler une route existante.</p>';
324
								}
325
							}
326
						}
327
					} else {
328
						$box .= '<h5>Proposer une route commerciale</h5>';
329
						$box .= '<p class="info">Impossible de proposer une route commerciale à ce joueur car il n\'a pas encore de plateforme commerciale.</p>';
330
					}
331
				} else {
332
					$box .= '<h5>Proposer une route commerciale</h5>';
333
					$box .= '<p class="info">Pour proposer une route commerciale, il faut construire la plateforme commerciale.</p>';
334
				}
335
			}
336
			if ($sendResources == TRUE) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
337
				$tmpLink = '<a href="#" class="actionbox-sh" data-target="' . $id . '"><img src="' . MEDIA . 'map/action/sendResource.png" alt="ressources" /></a>';
338
				$box .= '<h5>Envoyer des ressources</h5>';
339
340
				// ENVOI DE RESSOURCES
341
				$storageSpace = OrbitalBaseResource::getBuildingInfo(1, 'level', $ob->getLevelRefinery(), 'storageSpace');
0 ignored issues
show
Bug introduced by
The method getBuildingInfo() does not seem to exist on object<Asylamba\Modules\...ce\OrbitalBaseResource>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
342
				$currentStorage = $ob->getResourcesStorage();
343
				$maxResourcesToSend = $currentStorage - ($storageSpace * OBM_STOCKLIMIT);
344
				if ($maxResourcesToSend <= 0) {
345
					$box .= '<p class="info">Pour pouvoir envoyer des ressources, il faut que votre entrepôt soit à ' . OBM_STOCKLIMIT * 100 . '% rempli.</p>';
346
				} else {	
347
					$box .= '<div class="rc">';
348
						$box .= '<p>Ressources en stock <strong>' . Format::numberFormat($currentStorage) . ' <img alt="ressource" src="' . MEDIA . 'resources/resource.png" class="icon-color"></strong></p>';
349
						$box .= '<p>Capacité d\'envoi maximum <strong>' . Format::numberFormat($maxResourcesToSend) . ' <img alt="ressource" src="' . MEDIA . 'resources/resource.png" class="icon-color"></strong></p>';
350
351
						$box .= '<form action="' . Format::actionBuilder('giveresource', $this->sessionToken, ['baseid' => $ob->getRPlace(), 'otherbaseid' => $place->getId(), 'redirect' => $place->getId()]) . '" method="POST">';
352
							$box .= '<p><input type="text" value="0" name="quantity" /></p>';
353
							$box .= '<p><input type="submit" value="envoyer" /></p>';
354
						$box .= '</form>';
355
					$box .= '</div>';
356
				}
357
			}
358
			
359
		$box  .= '</div>';
360
		$link .= $tmpLink;
361
	}
362
363
	public function motherShip($ob, &$link, &$box, $id) {
0 ignored issues
show
Unused Code introduced by
The parameter $ob is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
364
		$link .= '<a href="#" class="actionbox-sh" data-target="' . $id . '"><img src="' . MEDIA . 'map/action/motherShip.png" alt="vaisseau mère" /></a>';
365
366
		$box .= '<div data-id="' . $id . '" class="act-bull" style="display:' . (($id == 1) ? 'block' : 'none') . ';" >';
367
			$box .= '<h5>Envoyer un vaisseau-mère</h5>';
368
			$box .= '<p class="info">la fonctionnalité n\'est pas encore implémentée. Soyez un peu patient !</p>';
369
		$box .= '</div>';
370
	}
371
372
	public function move($ob, &$link, &$box, $id, $place, $commanderSession) {
373
		$link .= '<a href="#" class="actionbox-sh" data-target="' . $id . '"><img src="' . MEDIA . 'map/action/move.png" alt="flotte" /></a>';
374
375
		$box .= '<div data-id="' . $id . '" class="act-bull" style="display:' . (($id == 1) ? 'block' : 'none') . ';" >';
376
			$box .= '<h5>Déplacer une flotte</h5>';
377
			# check s'il y a une place libre dans la destination
378
			if (count($place->commanders) < 3) {
379
				# check si au moins 1 commandant disponible
380
				$S_COM2 = $this->commanderManager->getCurrentSession();
0 ignored issues
show
Bug introduced by
The method getCurrentSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
381
				$this->commanderManager->changeSession($commanderSession);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
382
				$commanderQuantity = 0;
383
				for ($i = 0; $i < $this->commanderManager->size(); $i++) { 
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
384
					if ($this->commanderManager->get($i)->getStatement() == Commander::AFFECTED) {
385
						$commanderQuantity++;
386
					}
387
				}
388
				if ($commanderQuantity > 0) {
389
					# check si assez de PA
390
					if ($place->getRSystem() == $ob->getSystem()) {
391
						$time = Game::getTimeTravelInSystem($ob->getPosition(), $place->getPosition());
392
					} else {
393
						$time = Game::getTimeTravelOutOfSystem($ob->getXSystem(), $ob->getYSystem(), $place->getXSystem(), $place->getYSystem());
0 ignored issues
show
Bug introduced by
The call to getTimeTravelOutOfSystem() misses a required argument $destinationY.

This check looks for function calls that miss required arguments.

Loading history...
394
					}
395
396
					for ($i = 0; $i < $this->commanderManager->size(); $i++) {
0 ignored issues
show
Bug introduced by
The method size() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
397
						$box .= '<a href="' . Format::actionBuilder('movefleet', $this->sessionToken, ['commanderid' => $this->commanderManager->get($i)->getId(), 'placeid' => $place->getId(), 'redirect' => $place->getId()]) . '" class="commander">';
398
							$box .= '<img class="avatar" src="' . MEDIA . 'commander/small/c1-l1-c' . $this->sessionWrapper->get('playerInfo')->get('color') . '.png" alt="' . $this->commanderManager->get($i)->getName() . '" />';
399
							$box .= '<span class="label">';
400
								$box .= '<strong>' . $this->commanderManager->get($i)->getName() . '</strong><br />';
401
								$box .= $this->commanderManager->get($i)->getPev() . ' pev';
402
							$box .= '</span>';
403
							$box .= '<span class="value">';
404
								$box .= Chronos::secondToFormat($time, 'lite') . ' <img alt="temps" src="' . MEDIA . 'resources/time.png" class="icon-color"><br />';
405
							$box .= '</span>';
406
						$box .= '</a>';
407
					}
408
				} else {
409
					$box .= '<p class="info">Vous n\'avez aucun commandant susceptible d\'être transféré sur cette base.</p>';
410
				}
411
				$this->commanderManager->changeSession($S_COM2);
0 ignored issues
show
Bug introduced by
The method changeSession() does not seem to exist on object<Asylamba\Modules\...nager\CommanderManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
412
			} else {
413
				$box .= '<p class="info">Cette base n\'a pas la capacité d\'accueillir une flotte supplémentaire.</p>';
414
			}
415
		$box .= '</div>';
416
	}
417
}