1
|
|
|
<?php |
2
|
|
|
class SiteController extends GameController |
3
|
|
|
{ |
4
|
|
|
public function actionIndex() |
5
|
|
|
{ |
6
|
|
|
$wall = new Wall; |
|
|
|
|
7
|
|
|
$wall->uid = Yii::app()->player->uid; |
|
|
|
|
8
|
|
|
$wall->fetchPosts(); |
9
|
|
|
|
10
|
|
|
if (Yii::app()->player->model->level < 2) { |
11
|
|
|
Yii::app()->user->setFlash('info', 'Kezdetnek teljesíts pár megbízást. :) A megbízásokat a '. CHtml::link('Navigáció', ['#left-panel'], ['data-role'=>'button', 'data-inline'=>'true', 'id'=>'nav', 'data-icon'=>'bars', 'data-iconpos'=>'notext']) . ' ikon lenyomásával érheted el.'); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
$this->render('index', [ |
15
|
|
|
'posts'=>$wall->posts, |
|
|
|
|
16
|
|
|
'banner'=>(date("nd") == Yii::app()->params['smsDate']) ? Yii::app()->params['smsText'] : '', |
|
|
|
|
17
|
|
|
]); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function actionCredits() |
21
|
|
|
{ |
22
|
|
|
$this->render('credits'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function actionStory() |
26
|
|
|
{ |
27
|
|
|
$this->render('story'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function actionHelp() |
31
|
|
|
{ |
32
|
|
|
$help = new Help; |
33
|
|
|
$news = []; |
34
|
|
|
foreach ($help->topics as $topic => $name) { |
|
|
|
|
35
|
|
|
$help->topic = (string)$topic; |
|
|
|
|
36
|
|
|
$help->fetchItems(1); |
37
|
|
|
$items = $help->items; |
|
|
|
|
38
|
|
|
|
39
|
|
|
$news[$topic] = [ |
40
|
|
|
'title'=>$name, |
41
|
|
|
'body'=>array_shift($items) |
42
|
|
|
]; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$this->render('help', [ |
46
|
|
|
'news'=>$news, |
47
|
|
|
]); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function actionHelpTopic($t = '') |
51
|
|
|
{ |
52
|
|
|
$help = new Help; |
|
|
|
|
53
|
|
|
$topics = $help->topics; |
|
|
|
|
54
|
|
|
if (!array_key_exists($t, $topics)) { |
55
|
|
|
Yii::app()->user->setFlash('error', 'A választott súgótémakör nem létezik.'); |
56
|
|
|
$this->redirect(['site/help']); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$help->topic = $t; |
|
|
|
|
60
|
|
|
$help->fetchItems(); |
61
|
|
|
|
62
|
|
|
$this->render('helptopic', [ |
63
|
|
|
'title'=>$topics[$t], |
64
|
|
|
'items'=>$help->items, |
|
|
|
|
65
|
|
|
]); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function actionSms($id = 1) |
69
|
|
|
{ |
70
|
|
|
$store = new Store; |
|
|
|
|
71
|
|
|
$store->uid = Yii::app()->player->model->uid; |
|
|
|
|
72
|
|
|
if (!array_key_exists($id, $store->packagesSms)) { |
73
|
|
|
$id = 1; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$this->render('sms', [ |
77
|
|
|
'package'=>$store->packagesSms[$id], |
78
|
|
|
]); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function actionStore() |
82
|
|
|
{ |
83
|
|
|
$store = new Store; |
|
|
|
|
84
|
|
|
$store->uid = Yii::app()->player->model->uid; |
|
|
|
|
85
|
|
|
|
86
|
|
|
$r = Yii::app()->request; |
87
|
|
|
|
88
|
|
|
$duelShield = new DuelShield(); |
|
|
|
|
89
|
|
|
$duelShield->uid = $store->uid; |
|
|
|
|
90
|
|
|
|
91
|
|
|
//duelShield |
92
|
|
|
$shield = (int)$r->getPost('shield', 0); |
93
|
|
|
try { |
94
|
|
|
if ($shield) { |
95
|
|
|
if ($duelShield->activate($shield)) { |
96
|
|
|
Yii::app()->user->setFlash('success', "Bekapcsoltad a párbaj-pajzsot."); |
|
|
|
|
97
|
|
|
$this->redirect(['']); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
} catch (CFlashException $e) { |
101
|
|
|
Yii::app()->user->setFlash('error', $e->getMessage()); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
//energy drink |
105
|
|
|
$energy = (int)$r->getPost('energy', 0); |
106
|
|
|
try { |
107
|
|
|
if ($energy) { |
108
|
|
|
if ($store->refillEnergy()) { |
109
|
|
|
Yii::app()->user->setFlash('success', "Megittál egy energiaitalt, ezáltal teljesen feltöltődtél. Remélem ízlett."); |
|
|
|
|
110
|
|
|
$this->redirect(['']); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
} catch (CFlashException $e) { |
114
|
|
|
Yii::app()->user->setFlash('error', $e->getMessage()); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
//missing set items |
118
|
|
|
$setItem = (int)$r->getPost('setItem', 0); |
119
|
|
|
try { |
120
|
|
|
if ($setItem) { |
121
|
|
|
if ($store->buySetItem($setItem)) { |
122
|
|
|
Yii::app()->user->setFlash('success', "Megvetted a kiválasztott szett elemet. Ilyen típusút jövő héten vásárolhatsz legközelebb."); |
|
|
|
|
123
|
|
|
$this->redirect(['']); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
} catch (CFlashException $e) { |
127
|
|
|
Yii::app()->user->setFlash('error', $e->getMessage()); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
$this->render('store', [ |
131
|
|
|
'store'=>$store, |
132
|
|
|
'duelShield' => $duelShield, |
133
|
|
|
'shieldPrices' => $duelShield->getPrices(), |
134
|
|
|
'banner'=>(date("nd") == Yii::app()->params['smsDate']) ? Yii::app()->params['smsText'] : '', |
|
|
|
|
135
|
|
|
]); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function actionLogout() |
139
|
|
|
{ |
140
|
|
|
Yii::app()->user->logout(); |
141
|
|
|
$this->redirect(Yii::app()->homeUrl); |
142
|
|
|
} |
143
|
|
|
} |
|
|
|
|
144
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.