php class AreaController extends BaseController public function indexA

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
class AreaController extends BaseController {
public function indexAction() {
//$this->view->disable();
$actions = LocationsActions::find();
foreach($actions as $action){
$line = LocationLines::FindFirst([
'conditions' => 'action = ?1 AND action_ = ?2 AND action_ <> ?1',
'bind' => [1 => $this->auth->user->action, 2 => $action->id]
]);
if($action->id !== $this->auth->user->action and $line) $arr[$action->id] = [
'top' => (($action->left / 222) * 100),
'left' => (($action->top / 300) * 100)
];
}
$this->view->setVars([
'user' => $this->auth->user,
'arr' => $arr
]);
}
public function newActionAction() {
$this->view->disable();
$act = $this->dispatcher->getParam('act');
$location = Locations::findFirstById(1);
$action = LocationsActions::findFirstById($act);
$line = LocationLines::findFirst([
'conditions' => 'action = ?1 AND action_ = ?2',
'bind' => [1 => $this->auth->user->action, 2 => $act]
]);
if($line && $action && $action->location == $location->id ){
if($action->type == 3){
$__user = $this->auth->user;
$__user->area = 0;
$__user->put = 0;
$__user->round = 1;
$__user->attack = 1;
$__user->save();
$mob = Monsters::findFirstById($action->monster);
$check = Attack::findFirstByUser($this->auth->user->id);
if($mob and !$check){
$__attack = new Attack();
$__attack->user = $this->auth->user->id;
$__attack->location = 1;
$__attack->mob = $mob->id;
$__attack->hp = $mob->hp;
$__attack->effect = 0;
$__attack->time = time();
$__attack->kill = 0;
$__attack->save();
$_area = Area::find();
$areas = Areas::find();
foreach ($areas as $area) {
$dash[$area->x][$area->y] = $area->area;
}
$randi = rand(2,4);
for ($i>0; $i<$randi; ++$i) {
while (true) {
$area = $_area[rand(0,5)];
if ($area->chanse >= rand(1, 100)) {
$rand = $area->id == 6 ? 5 : $area->id;
break;
}
}
$x = rand(0,2);
$y = rand(0,2);
$check = Areas::findFirst([
'columns' => 'x,y',
'conditions' => 'user = ?1 AND x = ?2 AND y = ?3',
'bind' => [1 => $this->auth->user->id, 2 => $x, 3 => $y]
]);
if(!$check and count($this->functions->check($x, $y, $dash)) < 3){
$__areas = new Areas();
$__areas->user = $this->auth->user->id;
$__areas->x = $x;
$__areas->y = $y;
$__areas->area = $rand;
$__areas->save();
}
else{
--$i;
}
}
}
}
}
$this->response->redirect('area/action/');
}
public function actionAction() {
$areas = Areas::find([
'conditions' => 'user = ?1',
'bind' => [1 => $this->auth->user->id]
]);
foreach ($areas as $area) $dash[$area->x][$area->y] = $area->area;
for ($y = 0; $y < 3; ++$y) {
for ($x = 0; $x < 3; ++$x) {
if(!$dash[$x][$y]){
$left = [
0 => 23.47417840375587,
1 => 41.78403755868545,
2 => 60.09389671361502,
];
$top = [
0 => 25,
1 => 48.71794871794872,
2 => 73.07692307692308,
];
$arr[$x.'_'.$y] = [
'top' => $top[$y],
'left' => $left[$x]
];
}
}
}
$this->view->setVars([
'user' => $this->auth->user,
'arr' => $arr
]);
//$this->view->disable();
}
}