1
|
|
|
<?php |
2
|
|
|
class MissionsController extends GameController |
3
|
|
|
{ |
4
|
|
|
public function actionIndex() |
5
|
|
|
{ |
6
|
|
|
$this->redirect(['missions/list', 'id'=>Yii::app()->player->model->last_location]); |
7
|
|
|
} |
8
|
|
|
|
9
|
|
|
public function actionList($id = 1) |
10
|
|
|
{ |
11
|
|
|
$location = new Location(); |
12
|
|
|
$location->setId($id); |
13
|
|
|
if (!$location->isVisited()) { |
14
|
|
|
Yii::app()->player->model->rewriteAttributes(['last_location'=>1]); |
15
|
|
|
$this->render('not_visited'); |
16
|
|
|
return false; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
$location->setActive(); |
20
|
|
|
|
21
|
|
|
//list missions |
22
|
|
|
$location->fetchRoutine(); |
23
|
|
|
$location->fetchMissions(); |
24
|
|
|
|
25
|
|
|
//complete selected mission |
26
|
|
|
$mission_id = Yii::app()->request->getPost('mission_id', 0); |
27
|
|
|
$completedId = 0; |
28
|
|
|
$error = ''; |
29
|
|
|
if ($mission_id) { |
30
|
|
|
$error = ''; |
31
|
|
|
try { |
32
|
|
|
$locAction = new LocationAction(); |
33
|
|
|
$locAction->location = $location; |
|
|
|
|
34
|
|
|
$locAction->completeMission($mission_id); |
35
|
|
|
$completedId = $locAction->completedId; |
|
|
|
|
36
|
|
|
} catch (CFlashException $e) { |
37
|
|
|
$error = $e->getMessage(); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
//name of location |
42
|
|
|
$name = [ |
43
|
|
|
'location' => $location->getName(), |
44
|
|
|
'county' => $location->getCounty(), |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
//navigation from current location |
48
|
|
|
$nav = $location->getNavigationLinks(); |
49
|
|
|
|
50
|
|
|
//tutorial |
51
|
|
|
$tutorialToShow = 0; |
52
|
|
|
if ($id==1) { |
53
|
|
|
//only in first location |
54
|
|
|
$tutorial = new Tutorial; |
55
|
|
|
$tutorial->state = Yii::app()->player->model->tutorial_mission; |
|
|
|
|
56
|
|
|
$tutorial->location = $location; |
|
|
|
|
57
|
|
|
$tutorialToShow = $tutorial->descriptionToShow; |
|
|
|
|
58
|
|
|
} |
59
|
|
|
$this->render('index', [ |
60
|
|
|
'location' => $location, |
61
|
|
|
'name' => $name, |
62
|
|
|
'missions'=>$location->missions, |
|
|
|
|
63
|
|
|
'missionTypeList'=>$location->missionTypes, |
|
|
|
|
64
|
|
|
'nav' => $nav, |
65
|
|
|
'mission_id'=>$mission_id, |
66
|
|
|
'completedId'=>$completedId, |
67
|
|
|
'routine'=>$location->routineStars, |
68
|
|
|
'tutorialToShow'=>$tutorialToShow, |
69
|
|
|
'error'=>$error, |
70
|
|
|
]); |
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function actionMap() |
75
|
|
|
{ |
76
|
|
|
$this->layout = 'fullscreen'; |
77
|
|
|
|
78
|
|
|
$location = new Location(); |
79
|
|
|
$visited = $location->listVisited(); |
80
|
|
|
|
81
|
|
|
$center = Yii::app()->params['mapCenterCoords']; //id 1 |
82
|
|
|
$last = []; |
83
|
|
|
$locations = []; |
84
|
|
|
foreach ($visited as $v) { |
85
|
|
|
$id = (int)$v['id']; |
86
|
|
|
$txtRoutine = ''; |
87
|
|
|
if ($v['routine']) { |
88
|
|
|
$routine = $location->getRoutineStars($v['routine']); |
89
|
|
|
$txtRoutine = 'HelyszĂnen megszerzett rutinod: <br/>'; |
90
|
|
|
$txtRoutine .= $location->getRoutineImages($routine); |
91
|
|
|
} else { |
92
|
|
|
$last[] = $id; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
$locations[] = "[{$v['position']}, '{$v['title']}', {$id}, '{$txtRoutine}']"; |
96
|
|
|
if (isset($v['last'])) { |
97
|
|
|
$center = $v['position']; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
$this->render('map', [ |
102
|
|
|
'visited'=>$visited, |
103
|
|
|
'locations'=>implode(",\n", $locations), |
104
|
|
|
'center'=>$center, |
105
|
|
|
'last'=>implode(', ', $last) |
106
|
|
|
]); |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.