Advancement::getSkillImprovement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
/**
3
 * @property integer $uid
4
 * @property integer $dollarImprovement
5
 * @property integer $skillImprovement
6
 */
7
class Advancement extends CModel
8
{
9
    private $uid;
10
    
11
    public function attributeNames()
12
    {
13
        return [];
14
    }
15
16
    // getters
17
    public function getUid()
18
    {
19
        return (int)$this->uid;
20
    }
21
    
22
    public function getDollarImprovement()
23
    {
24
        return 30 + (5 * Yii::app()->player->model->level);
25
    }
26
27
    public function getSkillImprovement()
28
    {
29
        $di = $this->getDollarImprovement();
30
31
        //strongest bait
32
        $bait = Yii::app()->db->createCommand()
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 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...
33
            ->select('id, skill, price')
34
            ->from('baits')
35
            ->where('level<=:level', [':level'=>(int)Yii::app()->player->model->level])
36
            ->order('level DESC')
37
            ->limit(1)
38
            ->queryRow();
39
        $skill = round($di / $bait['price'] * $bait['skill'] / 2 * 0.8);
40
        return (int)$skill;
41
    }
42
43
    public function setUid($uid)
44
    {
45
        $this->uid = (int)$uid;
46
    }
47
        
48
    public function incrementForStatuspoint($id)
49
    {
50
        $player = Yii::app()->player->model;
51
        if (!$player->itsMe()) {
52
            return false;
53
        }
54
        if ($player->status_points < 1) {
55
            return false;
56
        }
57
58
        $mapIdAttribute = [
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 13 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...
59
            1=>['energy_max'=>1, 'energy'=>1],
60
            ['skill'=>2, 'skill_extended'=>2],
61
            ['strength'=>2],
62
            ['dollar'=>$this->getDollarImprovement()]
63
            ];
64
        $mapIdAttribute[2]['skill'] = $mapIdAttribute[2]['skill_extended'] = $this->getSkillImprovement();
65
66
        $increment = isset($mapIdAttribute[$id]) ? $mapIdAttribute[$id] : false;
67
68
        if ($increment) {
69
            $player->updateAttributes($increment, ['status_points'=>1]);
70
            //badge
71
            $b = new ProfileBadgeActivator();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 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...
72
            $b->uid = $this->uid;
73
74
            if ($id==1) {
75
                $b->triggerMaxNrg($player->energy_max);
76
            }
77
            if ($id==2) {
78
                $b->triggerSkill($player->skill);
79
            }
80
            if ($id==3) {
81
                $b->triggerStrength($player->strength);
82
            }
83
        }
84
        return true;
85
    }
86
}
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...
87