This commit is contained in:
2022-06-11 02:18:04 +03:00
parent 4bd6a08e8a
commit b8f837b6cf
6 changed files with 94 additions and 70 deletions
+22 -7
View File
@@ -1,11 +1,26 @@
<?php
# Date: 16.09.2020 (08:45)
namespace Battles\Magic;
use Battles\Database\Db;
class Magic
{
protected $status;
protected string $status;
private Db $db;
private object $magic;
protected function isVisible($caster, $target):bool
public function __construct(Db $db, int $id)
{
$this->magic = $db->ofetch('select * from magic where id = ?', $id);
}
public function getMagic(): object
{
return $this->magic;
}
protected function isVisible($caster, $target): bool
{
if ($caster->battle != $target->battle || $caster->room != $target->room) {
$this->status = 'Вы не видите цель!';
@@ -15,7 +30,7 @@ class Magic
}
}
protected function isNotDead($caster):bool
protected function isNotDead($caster): bool
{
if ($caster->health < 1) {
$this->status = 'Вы мертвы!';
@@ -25,7 +40,7 @@ class Magic
}
}
protected function enoughMana($caster):bool
protected function enoughMana($caster): bool
{
if ($caster->mana < 1) {
$this->status = 'Недостаточно пыли!';
@@ -35,7 +50,7 @@ class Magic
}
}
protected function isNotInBattle($caster):bool
protected function isNotInBattle($caster): bool
{
if ($caster->battle) {
$this->status = 'Невозможно применить в поединке!';
@@ -52,12 +67,12 @@ class Magic
*
* @return bool
*/
protected function isSuccess($caster, int $difficulty = 40):bool
protected function isSuccess($caster, int $difficulty = 40): bool
{
# 40 - потолок стата.
if ($difficulty > 40) {
$difficulty = 40;
}
return mt_rand(1,$difficulty) < $caster->intelligence;
return mt_rand(1, $difficulty) < $caster->intelligence;
}
}