From 14dc0276fab05388e5ea7fa6eb6430c6c0af20b2 Mon Sep 17 00:00:00 2001 From: Ivor Barhansky Date: Fri, 18 Feb 2022 12:57:47 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'=D0=9A=D1=83=D1=81=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4=D0=B0'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...81%D0%BA%D0%B8-%D0%BA%D0%BE%D0%B4%D0%B0.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/%D0%9A%D1%83%D1%81%D0%BA%D0%B8-%D0%BA%D0%BE%D0%B4%D0%B0.md b/%D0%9A%D1%83%D1%81%D0%BA%D0%B8-%D0%BA%D0%BE%D0%B4%D0%B0.md index 6f58bd3..3b8c64b 100644 --- a/%D0%9A%D1%83%D1%81%D0%BA%D0%B8-%D0%BA%D0%BE%D0%B4%D0%B0.md +++ b/%D0%9A%D1%83%D1%81%D0%BA%D0%B8-%D0%BA%D0%BE%D0%B4%D0%B0.md @@ -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; +} ``` \ No newline at end of file