DuelController::actionCommon()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
class DuelController extends GameController
3
{
4
    protected function beforeAction($action)
5
    {
6
        parent::beforeAction($action);
7
8
        if (Yii::app()->player->model->level < Yii::app()->params['duelLevelRequirement']) {
9
            $this->render('lowlevel', [
10
                'levelRequirement' => Yii::app()->params['duelLevelRequirement']
11
            ]);
12
            return false;
13
        }
14
        return true;
15
    }
16
17
18
    public function actionIndex($page = 0)
19
    {
20
        $duelList = new DuelList();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
21
        $duelList->page = $page;
0 ignored issues
show
Bug introduced by
The property page cannot be accessed from this context as it is declared private in class DuelList.

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.

Loading history...
22
        $duelList->fetchOpponents();
23
24
        $this->render('index', [
25
            'list'=>$duelList->opponents,
0 ignored issues
show
Bug introduced by
The property opponents cannot be accessed from this context as it is declared private in class DuelList.

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.

Loading history...
26
            'pagination' => $duelList->pagination,
0 ignored issues
show
Bug introduced by
The property pagination cannot be accessed from this context as it is declared private in class DuelList.

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.

Loading history...
27
            'count' => $duelList->count,
0 ignored issues
show
Bug introduced by
The property count cannot be accessed from this context as it is declared private in class DuelList.

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.

Loading history...
28
            'page_size' => Yii::app()->params['listPerPage'],
29
            'page'=>$page,
30
            ]);
31
    }
32
33
    public function actionCommon()
34
    {
35
        $duelList = new DuelList();
36
        $duelList->fetchCommonRivals();
37
38
        $this->render('commonrivals', [
39
            'list'=>$duelList->opponents,
0 ignored issues
show
Bug introduced by
The property opponents cannot be accessed from this context as it is declared private in class DuelList.

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.

Loading history...
40
            ]);
41
    }
42
43
    public function actionHistory()
44
    {
45
        $duelList = new DuelList();
46
        $duelList->fetchLastRivals();
47
48
        $this->render('history', [
49
            'list'=>$duelList->opponents,
0 ignored issues
show
Bug introduced by
The property opponents cannot be accessed from this context as it is declared private in class DuelList.

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.

Loading history...
50
            ]);
51
    }
52
53
    public function actionGo($opponentId = 0)
54
    {
55
        $duel = new Duel();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
56
        $duel->caller = Yii::app()->player->uid;
0 ignored issues
show
Bug introduced by
The property caller cannot be accessed from this context as it is declared private in class Duel.

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.

Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

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

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
57
        $duel->opponent = $opponentId;
0 ignored issues
show
Bug introduced by
The property opponent cannot be accessed from this context as it is declared private in class Duel.

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.

Loading history...
58
        $duel->fetchClubChallengeState();
59
60
        try {
61
            if ($duel->validateDuel()) {
62
                $duel->play();
63
            }
64
        } catch (CFlashException $e) {
65
            Yii::app()->user->setFlash('error', $e->getMessage());
66
        }
67
68
        $this->render('go', [
69
            'duel'=>$duel,
70
            ]);
71
    }
72
73
    public function actionReplay($id)
74
    {
75
        $duel = new Duel;
76
        try {
77
            $duel->replay((int)$id);
78
        } catch (CFlashException $e) {
79
            Yii::app()->user->setFlash('error', $e->getMessage());
80
            $this->redirect('/duel');
81
        }
82
83
        $this->render('replay', [
84
            'duel'=>$duel,
85
            ]);
86
    }
87
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
88