-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomPlayer.php
More file actions
109 lines (69 loc) · 3.11 KB
/
RandomPlayer.php
File metadata and controls
109 lines (69 loc) · 3.11 KB
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
<?php
/**
* Description: returns player at random and properties at random
* @var $typePlayer string
* @var $property integer or float
*
*/
class RandomPlayer
{
public $typePlayer;
public $property;
public static $players = ['swordsman','brute','grappler'];
public static $swordsman = ['health' => ['from' => 40,'to' => 60],
'strength' => ['from' => 60,'to' => 70],
'defence' => ['from' => 20,'to' => 30],
'speed' => ['from' => 90,'to' => 100],
'luck' => ['from' => 0.3,'to' => 0.5]
];
public static $brute = ['health' => ['from' => 90,'to' => 100],
'strength' => ['from' => 65,'to' => 75],
'defence' => ['from' => 40,'to' => 50],
'speed' => ['from' => 40,'to' => 65],
'luck' => ['from' => 0.3,'to' => 0.35]
];
public static $grappler = ['health' => ['from' => 60,'to' => 100],
'strength' => ['from' => 75,'to' => 80],
'defence' => ['from' => 35,'to' => 40],
'speed' => ['from' => 60,'to' => 80],
'luck' => ['from' => 0.3,'to' => 0.4]
];
public static function returnPlayer() {
$ar = array_rand(self::$players);
return self::$players[$ar];
}
public static function playerProperties(string $typePlayer,string $property) {
switch($typePlayer) {
case 'swordsman':
if($property === 'luck') {
$random = array_rand(range(self::$swordsman[$property]['from'], self::$swordsman[$property]['to'],0.01));
$array = range(self::$swordsman[$property]['from'], self::$swordsman[$property]['to'],0.01);
} else {
$random = array_rand(range(self::$swordsman[$property]['from'], self::$swordsman[$property]['to']));
$array = range(self::$swordsman[$property]['from'], self::$swordsman[$property]['to']);
}
return $array[$random];
break;
case 'brute':
if($property === 'luck') {
$random = array_rand(range(self::$brute[$property]['from'], self::$brute[$property]['to'],0.01));
$array = range(self::$brute[$property]['from'], self::$brute[$property]['to'],0.01);
} else {
$random = array_rand(range(self::$brute[$property]['from'], self::$brute[$property]['to']));
$array = range(self::$brute[$property]['from'], self::$brute[$property]['to']);
}
return $array[$random];
break;
case 'grappler':
if($property === 'luck') {
$random = array_rand(range(self::$grappler[$property]['from'], self::$grappler[$property]['to'],0.01));
$array = range(self::$grappler[$property]['from'], self::$grappler[$property]['to'],0.01);
} else {
$random = array_rand(range(self::$grappler[$property]['from'], self::$grappler[$property]['to']));
$array = range(self::$grappler[$property]['from'], self::$grappler[$property]['to']);
}
return $array[$random];
break;
}
}
}