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.
Completed
Push — master ( 11c0a1...856a6b )
by Jacky
34s
created

TutorialHelper::isNextTechnoStepAlreadyDone()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 3
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * TutorialHelper
5
 *
6
 * @author Jacky Casas
7
 * @copyright Asylamba
8
 *
9
 * @package Zeus
10
 * @update 25.04.14
11
 */
12
namespace Asylamba\Modules\Zeus\Helper;
13
14
use Asylamba\Classes\Library\Session\SessionWrapper;
15
16
use Asylamba\Classes\Entity\EntityManager;
17
use Asylamba\Modules\Zeus\Manager\PlayerManager;
18
use Asylamba\Modules\Athena\Manager\OrbitalBaseManager;
19
use Asylamba\Modules\Athena\Manager\BuildingQueueManager;
20
use Asylamba\Modules\Promethee\Manager\TechnologyQueueManager;
21
use Asylamba\Modules\Promethee\Manager\TechnologyManager;
22
23
class TutorialHelper {
24
	/** @var EntityManager **/
25
	protected $entityManager;
26
	/** @var PlayerManager **/
27
	protected $playerManager;
28
	/** @var OrbitalBaseManager **/
29
	protected $orbitalBaseManager;
30
	/** @var BuildingQueueManager **/
31
	protected $buildingQueueManager;
32
	/** @var TechnologyQueueManager **/
33
	protected $technologyQueueManager;
34
	/** @var TechnologyManager **/
35
	protected $technologyManager;
36
	/** @var SessionWrapper **/
37
	protected $session;
38
	
39
	/**
40
	 * @param EntityManager $entityManager
41
	 * @param PlayerManager $playerManager
42
	 * @param OrbitalBaseManager $orbitalBaseManager
43
	 * @param BuildingQueueManager $buildingQueueManager
44
	 * @param TechnologyQueueManager $technologyQueueManager
45
	 * @param TechnologyManager $technologyManager
46
	 * @param SessionWrapper $session
47
	 */
48
	public function __construct(
49
		EntityManager $entityManager,
50
		PlayerManager $playerManager,
51
		OrbitalBaseManager $orbitalBaseManager,
52
		BuildingQueueManager $buildingQueueManager,
53
		TechnologyQueueManager $technologyQueueManager,
54
		TechnologyManager $technologyManager,
55
		SessionWrapper $session
56
	)
57
	{
0 ignored issues
show
Coding Style introduced by
The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Loading history...
58
		$this->entityManager = $entityManager;
59
		$this->playerManager = $playerManager;
60
		$this->orbitalBaseManager = $orbitalBaseManager;
61
		$this->buildingQueueManager = $buildingQueueManager;
62
		$this->technologyQueueManager = $technologyQueueManager;
63
		$this->technologyManager = $technologyManager;
64
		$this->session = $session;
65
	}
66
	
67
	public function checkTutorial() {
68
		# PAS UTILISEE POUR L'INSTANT (le sera quand il y aura une étape passive dans le tutoriel)
69
		$player = $this->session->get('playerId');
0 ignored issues
show
Unused Code introduced by
$player is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
70
		$stepTutorial = $this->session->get('playerInfo')->get('stepTutorial');
71
		$stepDone = $this->session->get('playerInfo')->get('stepDone');
72
73
		if ($stepTutorial > 0) {
74
			if ($stepDone == FALSE) {
75
				# check if current step is done
76
77
				# hint : checker seulement les actions passives
78
				switch ($stepTutorial) {
79
					case 1:
80
						$asdf = 'asdf';
0 ignored issues
show
Unused Code introduced by
$asdf is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
81
						break;
82
					case 2:
83
						$jlk = 'jkl';
0 ignored issues
show
Unused Code introduced by
$jlk is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
84
						break;
85
				}
86
			} 
87
		}
88
	}
89
90
	public function setStepDone() {
91
		$player = $this->playerManager->get($this->session->get('playerId'));
92
		
93
		$player->stepDone = TRUE;
94
95
		$this->session->get('playerInfo')->add('stepDone', TRUE);
96
		
97
		$this->entityManager->flush($player);
98
	}
99
100
	public function clearStepDone() {
101
		$player = $this->playerManager->get($this->session->get('playerId'));
102
		
103
		$player->stepDone = FALSE;
104
105
		$this->session->get('playerInfo')->add('stepDone', FALSE);
106
107
		$this->entityManager->flush($player);
108
	}
109
110
	public function isNextBuildingStepAlreadyDone($playerId, $buildingId, $level) {
111
		$nextStepAlreadyDone = FALSE;
112
113
		$playerBases = $this->orbitalBaseManager->getPlayerBases($playerId);
114
		foreach ($playerBases as $orbitalBase) { 
115
			if ($orbitalBase->getBuildingLevel($buildingId) >= $level) {
116
				$nextStepAlreadyDone = TRUE;
117
				break;
118
			} else {
119
				# verify in the queue
120
				$buildingQueues = $this->buildingQueueManager->getBaseQueues($orbitalBase->rPlace);
121
				foreach ($buildingQueues as $buildingQueue) {
122
					if ($buildingQueue->buildingNumber == $buildingId AND $buildingQueue->targetLevel >= $level) {
0 ignored issues
show
Coding Style introduced by
As per coding-style, PHP keywords should be in lowercase; expected and, but found AND.
Loading history...
123
						$nextStepAlreadyDone = TRUE;
124
						break;
125
					} 
126
				}
127
			}
128
		}
129
		return $nextStepAlreadyDone;
130
	}
131
132
	public function isNextTechnoStepAlreadyDone($playerId, $technoId, $level = 1) {
133
		$technology = $this->technologyManager->getPlayerTechnology($playerId);
134
		if ($technology->getTechnology($technoId) >= $level) {
135
			return true;
136
		}
137
		// verify in the queue
138
		if (($this->technologyQueueManager->getPlayerTechnologyQueue($playerId, $technoId)) !== null) {
139
			return true;
140
		}
141
		return false;
142
	}
143
}