Изменил(а) на 'Куски кода'

Ivor Barhansky 2022-02-18 12:57:47 +00:00
parent 1bbefb9d8c
commit 14dc0276fa

@ -3,4 +3,41 @@
Запрос времени три часа назад
```sql
select hour(timediff(now(), `time`)) > 3
```
Ботогенератор
```php
function create_bot ($level): object
{
$stats = [
'str' => 10,
'dex' => 10,
'intu' => 10,
'endu' => 10,
'inte' => 10,
'wis' => 10,
];
$free_points = 3 + (2 * $level);
while ($free_points > 0) {
$stats[array_rand($stats)] += 1;
$free_points--;
}
$obj = (object)[];
foreach ($stats as $k=>$v){
$obj->$k = $v;
}
//Бонус даётся только за стат выше 10.
$obj->eva = $obj->dex - 10;
$obj->acc = $obj->dex - 10;
$obj->krit = $obj->intu - 10;
$obj->maxHealth = round(($obj->endu * 3) + ($obj->endu / 2) * ($level - 1) + ($obj->endu / 5) * (($level - 1) * ($level - 2) / 2));
$obj->maxMana = round(($obj->wis * 3) + ($obj->wis / 2) * ($level - 1) + ($obj->wis / 5) * (($level - 1) * ($level - 2) / 2));
return $obj;
}
```