PlayerSkills::setDribbling()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace OSS\CoreBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Entity
9
 */
10
class PlayerSkills implements PlayerSkillsAverageInterface
11
{
12
    /**
13
     * @var int $playerId
14
     *
15
     * @ORM\Id
16
     * @ORM\GeneratedValue
17
     * @ORM\Column(type="integer")
18
     */
19
    private $id;
20
21
    /**
22
     * @var Player
23
     * 
24
     * @ORM\OneToOne(targetEntity="Player", cascade={"all"})
25
     */
26
    private $player;
27
28
    /**
29
     * @var int
30
     * 
31
     * @ORM\Column(type="integer")
32
     */
33
    private $tackling = 1;
34
35
    /**
36
     * @var int
37
     * 
38
     * @ORM\Column(type="integer")
39
     */
40
    private $passing = 1;
41
42
    /**
43
     * @var int
44
     *
45
     * @ORM\Column(type="integer")
46
     */
47
    private $shooting = 1;
48
49
    /**
50
     * @var int
51
     *
52
     * @ORM\Column(type="integer")
53
     */
54
    private $heading = 1;
55
56
    /**
57
     * @var int
58
     *
59
     * @ORM\Column(type="integer")
60
     */
61
    private $speed = 1;
62
63
    /**
64
     * @var int
65
     *
66
     * @ORM\Column(type="integer")
67
     */
68
    private $crossing = 1;
69
70
    /**
71
     * @var int
72
     *
73
     * @ORM\Column(type="integer")
74
     */
75
    private $technics = 1;
76
77
    /**
78
     * @var int
79
     *
80
     * @ORM\Column(type="integer")
81
     */
82
    private $intelligence = 1;
83
84
    /**
85
     * @var int
86
     *
87
     * @ORM\Column(type="integer")
88
     */
89
    private $safety = 1;
90
91
    /**
92
     * @var int
93
     *
94
     * @ORM\Column(type="integer")
95
     */
96
    private $dribbling = 1;
97
98
    /**
99
     * @var int
100
     * 
101
     * @ORM\Column(type="integer")
102
     */
103
    private $changeTackling = 0;
104
105
    /**
106
     * @var int
107
     * 
108
     * @ORM\Column(type="integer")
109
     */
110
    private $changePassing = 0;
111
112
    /**
113
     * @var int
114
     *
115
     * @ORM\Column(type="integer")
116
     */
117
    private $changeShooting = 0;
118
119
    /**
120
     * @var int
121
     *
122
     * @ORM\Column(type="integer")
123
     */
124
    private $changeHeading = 0;
125
126
    /**
127
     * @var int
128
     *
129
     * @ORM\Column(type="integer")
130
     */
131
    private $changeSpeed = 0;
132
133
    /**
134
     * @var int
135
     *
136
     * @ORM\Column(type="integer")
137
     */
138
    private $changeCrossing = 0;
139
140
    /**
141
     * @var int
142
     *
143
     * @ORM\Column(type="integer")
144
     */
145
    private $changeTechnics = 0;
146
147
    /**
148
     * @var int
149
     *
150
     * @ORM\Column(type="integer")
151
     */
152
    private $changeIntelligence = 0;
153
154
    /**
155
     * @var int
156
     *
157
     * @ORM\Column(type="integer")
158
     */
159
    private $changeSafety = 0;
160
161
    /**
162
     * @var int
163
     *
164
     * @ORM\Column(type="integer")
165
     */
166
    private $changeDribbling = 0;
167
168
    /**
169
     * @var int
170
     * 
171
     * @ORM\Column(type="integer")
172
     */
173
    private $trainingValueTackling = 0;
174
175
    /**
176
     * @var int
177
     * 
178
     * @ORM\Column(type="integer")
179
     */
180
    private $trainingValuePassing = 0;
181
182
    /**
183
     * @var int
184
     *
185
     * @ORM\Column(type="integer")
186
     */
187
    private $trainingValueShooting = 0;
188
189
    /**
190
     * @var int
191
     *
192
     * @ORM\Column(type="integer")
193
     */
194
    private $trainingValueHeading = 0;
195
196
    /**
197
     * @var int
198
     *
199
     * @ORM\Column(type="integer")
200
     */
201
    private $trainingValueSpeed = 0;
202
203
    /**
204
     * @var int
205
     *
206
     * @ORM\Column(type="integer")
207
     */
208
    private $trainingValueCrossing = 0;
209
210
    /**
211
     * @var int
212
     *
213
     * @ORM\Column(type="integer")
214
     */
215
    private $trainingValueTechnics = 0;
216
217
    /**
218
     * @var int
219
     *
220
     * @ORM\Column(type="integer")
221
     */
222
    private $trainingValueIntelligence = 0;
223
224
    /**
225
     * @var int
226
     *
227
     * @ORM\Column(type="integer")
228
     */
229
    private $trainingValueSafety = 0;
230
231
    /**
232
     * @var int
233
     *
234
     * @ORM\Column(type="integer")
235
     */
236
    private $trainingValueDribbling = 0;
237
238
    /**
239
     * @return int
240
     */
241
    public function getId()
242
    {
243
        return $this->id;
244
    }
245
246
    /**
247
     * @return Player
248
     */
249 28
    public function getPlayer()
250
    {
251 28
        return $this->player;
252
    }
253
254
    /**
255
     * @return int
256
     */
257 34
    public function getTackling()
258
    {
259 34
        return $this->tackling;
260
    }
261
262
    /**
263
     * @return int
264
     */
265 29
    public function getPassing()
266
    {
267 29
        return $this->passing;
268
    }
269
270
    /**
271
     * @return int
272
     */
273 34
    public function getShooting()
274
    {
275 34
        return $this->shooting;
276
    }
277
278
    /**
279
     * @return int
280
     */
281 29
    public function getCrossing()
282
    {
283 29
        return $this->crossing;
284
    }
285
286
    /**
287
     * @return int
288
     */
289 29
    public function getDribbling()
290
    {
291 29
        return $this->dribbling;
292
    }
293
294
    /**
295
     * @return int
296
     */
297 29
    public function getHeading()
298
    {
299 29
        return $this->heading;
300
    }
301
302
    /**
303
     * @return int
304
     */
305 29
    public function getIntelligence()
306
    {
307 29
        return $this->intelligence;
308
    }
309
310
    /**
311
     * @return int
312
     */
313 29
    public function getSafety()
314
    {
315 29
        return $this->safety;
316
    }
317
318
    /**
319
     * @return int
320
     */
321 29
    public function getSpeed()
322
    {
323 29
        return $this->speed;
324
    }
325
326
    /**
327
     * @return int
328
     */
329 29
    public function getTechnics()
330
    {
331 29
        return $this->technics;
332
    }
333
334
    /**
335
     * @param Player $player
336
     */
337 28
    public function setPlayer(Player $player)
338
    {
339 28
        $this->player = $player;
340 28
        if (null === $player->getSkills()) {
341 1
            $player->setSkills($this);
342 1
        }
343 28
    }
344
345
    /**
346
     * @param int $id
347
     */
348
    public function setId($id)
349
    {
350
        $this->id = $id;
351
    }
352
353
    /**
354
     * @param int $amount
355
     */
356 5
    public function setCrossing($amount)
357
    {
358 5
        $this->setSkill('crossing', $amount);
359 5
    }
360
361
    /**
362
     * @param int $amount
363
     */
364 4
    public function setTechnics($amount)
365
    {
366 4
        $this->setSkill('technics', $amount);
367 4
    }
368
369
    /**
370
     * @param int $amount
371
     */
372 4
    public function setSpeed($amount)
373
    {
374 4
        $this->setSkill('speed', $amount);
375 4
    }
376
377
    /**
378
     * @param int $amount
379
     */
380 4
    public function setHeading($amount)
381
    {
382 4
        $this->setSkill('heading', $amount);
383 4
    }
384
385
    /**
386
     * @param int $amount
387
     */
388 4
    public function setIntelligence($amount)
389
    {
390 4
        $this->setSkill('intelligence', $amount);
391 4
    }
392
393
    /**
394
     * @param int $amount
395
     */
396 4
    public function setSafety($amount)
397
    {
398 4
        $this->setSkill('safety', $amount);
399 4
    }
400
401
    /**
402
     * @param int $amount
403
     */
404 6
    public function setDribbling($amount)
405
    {
406 6
        $this->setSkill('dribbling', $amount);
407 6
    }
408
409
    /**
410
     * @param int $amount
411
     */
412 6
    public function setTackling($amount)
413
    {
414 6
        $this->setSkill('tackling', $amount);
415 6
    }
416
417
    /**
418
     * @param int $amount
419
     */
420 4
    public function setPassing($amount)
421
    {
422 4
        $this->setSkill('passing', $amount);
423 4
    }
424
425
    /**
426
     * @param int $amount
427
     */
428 4
    public function setShooting($amount)
429
    {
430 4
        $this->setSkill('shooting', $amount);
431 4
    }
432
433
    /**
434
     * @param int $amount
435
     */
436 3
    public function increaseTackling($amount)
437
    {
438 3
        $this->increaseSkill('tackling', $amount);
439 3
    }
440
441
    /**
442
     * @param int $amount
443
     */
444 3
    public function decreaseTackling($amount)
445
    {
446 3
        $this->decreaseSkill('tackling', $amount);
447 3
    }
448
449
    /**
450
     * @param int $amount
451
     */
452 3
    public function increasePassing($amount)
453
    {
454 3
        $this->increaseSkill('passing', $amount);
455 3
    }
456
457
    /**
458
     * @param int $amount
459
     */
460 3
    public function decreasePassing($amount)
461
    {
462 3
        $this->decreaseSkill('passing', $amount);
463 3
    }
464
465
    /**
466
     * @param int $amount
467
     */
468 3
    public function increaseShooting($amount)
469
    {
470 3
        $this->increaseSkill('shooting', $amount);
471 3
    }
472
473
    /**
474
     * @param int $amount
475
     */
476 3
    public function decreaseShooting($amount)
477
    {
478 3
        $this->decreaseSkill('shooting', $amount);
479 3
    }
480
481
    /**
482
     * @param int $amount
483
     */
484 3
    public function increaseHeading($amount)
485
    {
486 3
        $this->increaseSkill('heading', $amount);
487 3
    }
488
489
    /**
490
     * @param int $amount
491
     */
492 3
    public function decreaseHeading($amount)
493
    {
494 3
        $this->decreaseSkill('heading', $amount);
495 3
    }
496
497
    /**
498
     * @param int $amount
499
     */
500 3
    public function increaseSpeed($amount)
501
    {
502 3
        $this->increaseSkill('speed', $amount);
503 3
    }
504
505
    /**
506
     * @param int $amount
507
     */
508 3
    public function decreaseSpeed($amount)
509
    {
510 3
        $this->decreaseSkill('speed', $amount);
511 3
    }
512
513
    /**
514
     * @param int $amount
515
     */
516 3
    public function increaseCrossing($amount)
517
    {
518 3
        $this->increaseSkill('crossing', $amount);
519 3
    }
520
521
    /**
522
     * @param int $amount
523
     */
524 3
    public function decreaseCrossing($amount)
525
    {
526 3
        $this->decreaseSkill('crossing', $amount);
527 3
    }
528
529
    /**
530
     * @param int $amount
531
     */
532 3
    public function increaseTechnics($amount)
533
    {
534 3
        $this->increaseSkill('technics', $amount);
535 3
    }
536
537
    /**
538
     * @param int $amount
539
     */
540 3
    public function decreaseTechnics($amount)
541
    {
542 3
        $this->decreaseSkill('technics', $amount);
543 3
    }
544
545
    /**
546
     * @param int $amount
547
     */
548 3
    public function increaseIntelligence($amount)
549
    {
550 3
        $this->increaseSkill('intelligence', $amount);
551 3
    }
552
553
    /**
554
     * @param int $amount
555
     */
556 3
    public function decreaseIntelligence($amount)
557
    {
558 3
        $this->decreaseSkill('intelligence', $amount);
559 3
    }
560
561
    /**
562
     * @param int $amount
563
     */
564 3
    public function increaseSafety($amount)
565
    {
566 3
        $this->increaseSkill('safety', $amount);
567 3
    }
568
569
    /**
570
     * @param int $amount
571
     */
572 3
    public function decreaseSafety($amount)
573
    {
574 3
        $this->decreaseSkill('safety', $amount);
575 3
    }
576
577
    /**
578
     * @param int $amount
579
     */
580 3
    public function increaseDribbling($amount)
581
    {
582 3
        $this->increaseSkill('dribbling', $amount);
583 3
    }
584
585
    /**
586
     * @param int $amount
587
     */
588 3
    public function decreaseDribbling($amount)
589
    {
590 3
        $this->decreaseSkill('dribbling', $amount);
591 3
    }
592
593
    /**
594
     * @return float
595
     */
596 20
    public function getAverage()
597
    {
598 20
        return ($this->tackling + $this->passing + $this->shooting + $this->heading + $this->speed + $this->crossing + $this->technics + $this->intelligence + $this->safety + $this->dribbling) / 10;
599
    }
600
601 1
    public function initWithRandomValues()
602
    {
603 1
        $this->tackling = rand(1, 100);
604 1
        $this->passing = rand(1, 100);
605 1
        $this->shooting = rand(1, 100);
606 1
        $this->heading = rand(1, 100);
607 1
        $this->speed = rand(1, 100);
608 1
        $this->crossing = rand(1, 100);
609 1
        $this->technics = rand(1, 100);
610 1
        $this->intelligence = rand(1, 100);
611 1
        $this->safety = rand(1, 100);
612 1
        $this->dribbling = rand(1, 100);
613 1
    }
614
615
    /**
616
     * @param int $value
617
     */
618 24
    public function setAll($value)
619
    {
620 24
        $this->tackling = $value;
621 24
        $this->passing = $value;
622 24
        $this->shooting = $value;
623 24
        $this->heading = $value;
624 24
        $this->speed = $value;
625 24
        $this->crossing = $value;
626 24
        $this->technics = $value;
627 24
        $this->intelligence = $value;
628 24
        $this->safety = $value;
629 24
        $this->dribbling = $value;
630 24
    }
631
632
    /**
633
     * @param int $value
634
     */
635 7
    public function setAllTrainingValues($value)
636
    {
637 7
        $this->trainingValueTackling = $value;
638 7
        $this->trainingValuePassing = $value;
639 7
        $this->trainingValueShooting = $value;
640 7
        $this->trainingValueHeading = $value;
641 7
        $this->trainingValueSpeed = $value;
642 7
        $this->trainingValueCrossing = $value;
643 7
        $this->trainingValueTechnics = $value;
644 7
        $this->trainingValueIntelligence = $value;
645 7
        $this->trainingValueSafety = $value;
646 7
        $this->trainingValueDribbling = $value;
647 7
    }
648
649
    /**
650
     * @return int
651
     */
652 17
    public function getMarketValue()
653
    {
654 17
        return round(pow($this->getAverage(), 6) / 10000);
655
    }
656
657
    /**
658
     * @return int
659
     */
660 12
    public function getTrainingValueTackling()
661
    {
662 12
        return $this->trainingValueTackling;
663
    }
664
665
    /**
666
     * @param int $amount
667
     */
668 1
    public function setTrainingValueTackling($amount)
669
    {
670 1
        $this->trainingValueTackling = $amount;
671 1
    }
672
673
    /**
674
     * @return int
675
     */
676 10
    public function getTrainingValuePassing()
677
    {
678 10
        return $this->trainingValuePassing;
679
    }
680
681
    /**
682
     * @param int $amount
683
     */
684 1
    public function setTrainingValuePassing($amount)
685
    {
686 1
        $this->trainingValuePassing = $amount;
687 1
    }
688
689
    /**
690
     * @return int
691
     */
692 10
    public function getTrainingValueShooting()
693
    {
694 10
        return $this->trainingValueShooting;
695
    }
696
697
    /**
698
     * @param int $amount
699
     */
700 1
    public function setTrainingValueShooting($amount)
701
    {
702 1
        $this->trainingValueShooting = $amount;
703 1
    }
704
705
    /**
706
     * @return int
707
     */
708 10
    public function getTrainingValueHeading()
709
    {
710 10
        return $this->trainingValueHeading;
711
    }
712
713
    /**
714
     * @param int $amount
715
     */
716 1
    public function setTrainingValueHeading($amount)
717
    {
718 1
        $this->trainingValueHeading = $amount;
719 1
    }
720
721
    /**
722
     * @return int
723
     */
724 10
    public function getTrainingValueSpeed()
725
    {
726 10
        return $this->trainingValueSpeed;
727
    }
728
729
    /**
730
     * @param int $amount
731
     */
732 1
    public function setTrainingValueSpeed($amount)
733
    {
734 1
        $this->trainingValueSpeed = $amount;
735 1
    }
736
737
    /**
738
     * @return int
739
     */
740 10
    public function getTrainingValueCrossing()
741
    {
742 10
        return $this->trainingValueCrossing;
743
    }
744
745
    /**
746
     * @param int $amount
747
     */
748 1
    public function setTrainingValueCrossing($amount)
749
    {
750 1
        $this->trainingValueCrossing = $amount;
751 1
    }
752
753
    /**
754
     * @return int
755
     */
756 10
    public function getTrainingValueTechnics()
757
    {
758 10
        return $this->trainingValueTechnics;
759
    }
760
761
    /**
762
     * @param int $amount
763
     */
764 1
    public function setTrainingValueTechnics($amount)
765
    {
766 1
        $this->trainingValueTechnics = $amount;
767 1
    }
768
769
    /**
770
     * @return int
771
     */
772 10
    public function getTrainingValueIntelligence()
773
    {
774 10
        return $this->trainingValueIntelligence;
775
    }
776
777
    /**
778
     * @param int $amount
779
     */
780 1
    public function setTrainingValueIntelligence($amount)
781
    {
782 1
        $this->trainingValueIntelligence = $amount;
783 1
    }
784
785
    /**
786
     * @return int
787
     */
788 10
    public function getTrainingValueSafety()
789
    {
790 10
        return $this->trainingValueSafety;
791
    }
792
793
    /**
794
     * @param int $amount
795
     */
796 1
    public function setTrainingValueSafety($amount)
797
    {
798 1
        $this->trainingValueSafety = $amount;
799 1
    }
800
801
    /**
802
     * @return int
803
     */
804 10
    public function getTrainingValueDribbling()
805
    {
806 10
        return $this->trainingValueDribbling;
807
    }
808
809
    /**
810
     * @param int $amount
811
     */
812 1
    public function setTrainingValueDribbling($amount)
813
    {
814 1
        $this->trainingValueDribbling = $amount;
815 1
    }
816
817
    /**
818
     * @param int $amount
819
     */
820 6
    public function addTrainingValueTackling($amount)
821
    {
822 6
        $this->trainingValueTackling += $amount;
823 6
    }
824
825
    /**
826
     * @param int $amount
827
     */
828 6
    public function addTrainingValuePassing($amount)
829
    {
830 6
        $this->trainingValuePassing += $amount;
831 6
    }
832
833
    /**
834
     * @param int $amount
835
     */
836 6
    public function addTrainingValueShooting($amount)
837
    {
838 6
        $this->trainingValueShooting += $amount;
839 6
    }
840
841
    /**
842
     * @param int $amount
843
     */
844 6
    public function addTrainingValueHeading($amount)
845
    {
846 6
        $this->trainingValueHeading += $amount;
847 6
    }
848
849
    /**
850
     * @param int $amount
851
     */
852 6
    public function addTrainingValueSpeed($amount)
853
    {
854 6
        $this->trainingValueSpeed += $amount;
855 6
    }
856
857
    /**
858
     * @param int $amount
859
     */
860 6
    public function addTrainingValueCrossing($amount)
861
    {
862 6
        $this->trainingValueCrossing += $amount;
863 6
    }
864
865
    /**
866
     * @param int $amount
867
     */
868 6
    public function addTrainingValueTechnics($amount)
869
    {
870 6
        $this->trainingValueTechnics += $amount;
871 6
    }
872
873
    /**
874
     * @param int $amount
875
     */
876 6
    public function addTrainingValueIntelligence($amount)
877
    {
878 6
        $this->trainingValueIntelligence += $amount;
879 6
    }
880
881
    /**
882
     * @param int $amount
883
     */
884 6
    public function addTrainingValueSafety($amount)
885
    {
886 6
        $this->trainingValueSafety += $amount;
887 6
    }
888
889
    /**
890
     * @param int $amount
891
     */
892 6
    public function addTrainingValueDribbling($amount)
893
    {
894 6
        $this->trainingValueDribbling += $amount;
895 6
    }
896
897
    /**
898
     * @return int
899
     */
900 2
    public function getChangeTackling()
901
    {
902 2
        return $this->changeTackling;
903
    }
904
905
    /**
906
     * @return int
907
     */
908 2
    public function getChangePassing()
909
    {
910 2
        return $this->changePassing;
911
    }
912
913
    /**
914
     * @return int
915
     */
916 2
    public function getChangeShooting()
917
    {
918 2
        return $this->changeShooting;
919
    }
920
921
    /**
922
     * @return int
923
     */
924 2
    public function getChangeHeading()
925
    {
926 2
        return $this->changeHeading;
927
    }
928
929
    /**
930
     * @return int
931
     */
932 2
    public function getChangeSpeed()
933
    {
934 2
        return $this->changeSpeed;
935
    }
936
937
    /**
938
     * @return int
939
     */
940 2
    public function getChangeCrossing()
941
    {
942 2
        return $this->changeCrossing;
943
    }
944
945
    /**
946
     * @return int
947
     */
948 2
    public function getChangeTechnics()
949
    {
950 2
        return $this->changeTechnics;
951
    }
952
953
    /**
954
     * @return int
955
     */
956 2
    public function getChangeIntelligence()
957
    {
958 2
        return $this->changeIntelligence;
959
    }
960
961
    /**
962
     * @return int
963
     */
964 2
    public function getChangeSafety()
965
    {
966 2
        return $this->changeSafety;
967
    }
968
969
    /**
970
     * @return int
971
     */
972 2
    public function getChangeDribbling()
973
    {
974 2
        return $this->changeDribbling;
975
    }
976
977 1
    public function decreaseTrainingValues()
978
    {
979 1
        $this->trainingValueTackling -= 5;
980 1
        $this->trainingValuePassing -= 5;
981 1
        $this->trainingValueShooting -= 5;
982 1
        $this->trainingValueHeading -= 5;
983 1
        $this->trainingValueSpeed -= 5;
984 1
        $this->trainingValueCrossing -= 5;
985 1
        $this->trainingValueTechnics -= 5;
986 1
        $this->trainingValueIntelligence -= 5;
987 1
        $this->trainingValueSafety -= 5;
988 1
        $this->trainingValueDribbling -= 5;
989 1
    }
990
991 3
    public function updateSkills()
992
    {
993 3
        $this->updateSkill('tackling');
994 3
        $this->updateSkill('passing');
995 3
        $this->updateSkill('shooting');
996 3
        $this->updateSkill('heading');
997 3
        $this->updateSkill('speed');
998 3
        $this->updateSkill('crossing');
999 3
        $this->updateSkill('technics');
1000 3
        $this->updateSkill('intelligence');
1001 3
        $this->updateSkill('safety');
1002 3
        $this->updateSkill('dribbling');
1003 3
    }
1004
1005
    /**
1006
     * @param string $skill
1007
     */
1008 3
    private function updateSkill($skill)
1009
    {
1010 3
        $changeProperty = 'change' . ucfirst($skill);
1011 3
        $trainingValueProperty = 'trainingValue' . ucfirst($skill);
1012 3
        $this->$changeProperty = max(-10, min(10, $this->calculateSkillChange($this->$trainingValueProperty)));
1013 3
        $this->$skill = max(1, min(100, $this->$skill + $this->$changeProperty));
1014 3
        $this->$trainingValueProperty = 0;
1015 3
    }
1016
1017
    /**
1018
     * @param int $trainingValue
1019
     *
1020
     * @return int
1021
     */
1022 3
    private function calculateSkillChange($trainingValue)
1023
    {
1024 3
        $change = 0;
1025 3
        for ($i = 0; $i < abs($trainingValue) && $change < 10; $i++) {
1026 3
            if (rand(1, 100) == 1) {
1027 3
                $change++;
1028 3
            }
1029 3
        }
1030
1031 3
        if ($trainingValue < 0) {
1032 1
            $change *= -1;
1033 1
        }
1034
1035 3
        return $change;
1036
    }
1037
1038
    /**
1039
     * @param string $skill
1040
     * @param int $amount
1041
     */
1042 3
    private function increaseSkill($skill, $amount)
1043
    {
1044 3
        $this->$skill = max(1, min(100, $this->$skill + $amount));
1045 3
    }
1046
1047
    /**
1048
     * @param string $skill
1049
     * @param int $amount
1050
     */
1051 3
    private function decreaseSkill($skill, $amount)
1052
    {
1053 3
        $this->$skill = max(1, min(100, $this->$skill - $amount));
1054 3
    }
1055
1056
    /**
1057
     * @param string $skill
1058
     * @param int $amount
1059
     */
1060 7
    private function setSkill($skill, $amount)
1061
    {
1062 7
        $this->$skill = max(1, min(100, $amount));
1063 7
    }
1064
1065
    /**
1066
     * @param PlayerSkillsAverageInterface $a
1067
     * @param PlayerSkillsAverageInterface $b
1068
     *
1069
     * @return bool
1070
     */
1071 2
    static public function compareAverage(PlayerSkillsAverageInterface $a, PlayerSkillsAverageInterface $b)
1072
    {
1073 2
        return $a->getAverage() < $b->getAverage();
1074
    }
1075
}
1076