2020-09-16 15:13:25 +00:00
|
|
|
<?php
|
|
|
|
# Date: 16.09.2020 (08:45)
|
2020-10-28 20:21:08 +00:00
|
|
|
namespace Battles\Magic;
|
2020-09-16 15:13:25 +00:00
|
|
|
class Magic
|
|
|
|
{
|
|
|
|
protected $status;
|
|
|
|
|
2021-01-25 17:59:55 +00:00
|
|
|
protected function isVisible($caster, $target):bool
|
2020-09-16 15:13:25 +00:00
|
|
|
{
|
|
|
|
if ($caster->battle != $target->battle || $caster->room != $target->room) {
|
|
|
|
$this->status = 'Вы не видите цель!';
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-25 17:59:55 +00:00
|
|
|
protected function isNotDead($caster):bool
|
2020-09-16 15:13:25 +00:00
|
|
|
{
|
|
|
|
if ($caster->health < 1) {
|
|
|
|
$this->status = 'Вы мертвы!';
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-25 17:59:55 +00:00
|
|
|
protected function enoughMana($caster):bool
|
2020-09-16 15:13:25 +00:00
|
|
|
{
|
|
|
|
if ($caster->mana < 1) {
|
|
|
|
$this->status = 'Недостаточно пыли!';
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-25 17:59:55 +00:00
|
|
|
protected function isNotInBattle($caster):bool
|
2020-09-16 15:13:25 +00:00
|
|
|
{
|
|
|
|
if ($caster->battle) {
|
|
|
|
$this->status = 'Невозможно применить в поединке!';
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2021-01-25 18:00:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Проверка на успех заклинания. Чем выше интеллект, тем выше шанс успеха.
|
|
|
|
* @param $caster - заклинатель (массив значений из базы).
|
|
|
|
* @param int $difficulty - сложность произнесения заклинания. Чем выше значение, тем сложнее проверка. 40 - самая сложная проверка.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2021-01-28 21:05:34 +00:00
|
|
|
protected function isSuccess($caster, int $difficulty = 40):bool
|
2021-01-25 18:00:36 +00:00
|
|
|
{
|
|
|
|
# 40 - потолок стата.
|
|
|
|
if ($difficulty > 40) {
|
|
|
|
$difficulty = 40;
|
|
|
|
}
|
|
|
|
return mt_rand(1,$difficulty) < $caster->intelligence;
|
|
|
|
}
|
2020-09-16 15:13:25 +00:00
|
|
|
}
|