Merge remote-tracking branch 'origin/master'
# Conflicts: # admin/admin.php # classes/Battles/User.php # classes/Battles/UserStats.php # fbattle.php # functions.php
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Battles\Admin;
|
||||
|
||||
use Battles\Bank;
|
||||
use Battles\Database\Db;
|
||||
use Battles\GameConfigs;
|
||||
use Battles\User;
|
||||
|
||||
class Clan
|
||||
{
|
||||
public static function getUnapprovedList(): string
|
||||
{
|
||||
$list = '';
|
||||
$rows = Db::getInstance()->ofetchAll('select * from clans where status = 0');
|
||||
foreach ($rows as $row) {
|
||||
$id = $row->owner_id;
|
||||
$login = User::getInstance($id)->getLogin();
|
||||
$full = $row->full_name;
|
||||
$short = $row->short_name;
|
||||
$info = nl2br($row->info);
|
||||
$list .= <<<UNREGCLANLIST
|
||||
<div>
|
||||
<fieldset style="display: inline;">
|
||||
<legend>$full [$short]</legend>
|
||||
Глава клана: <span class="abils">$login</span><br>
|
||||
Описание:<div class="abils">$info</div>
|
||||
<BR>
|
||||
<button onclick="location.href='?regclan=$id'">Зарегистрировать</button>
|
||||
<button onclick="location.href='?remclan=$id'">Отказать</button>
|
||||
</fieldset>
|
||||
</div>
|
||||
UNREGCLANLIST;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function allowRegister($id)
|
||||
{
|
||||
Db::getInstance()->execute('UPDATE clans SET status = 1 WHERE status = 0 AND owner_id = ?', $id);
|
||||
}
|
||||
|
||||
public static function disallowRegister($id)
|
||||
{
|
||||
$bank = new Bank($id);
|
||||
Db::getInstance()->execute('DELETE FROM clans WHERE status = 0 AND owner_id = ?', $id);
|
||||
$bank::setBankMoney($bank->getMoney() + GameConfigs::CLAN['clan_register_cost'], $id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Battles\Admin;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class Item
|
||||
{
|
||||
public static function add(array $params): void
|
||||
{
|
||||
$query = 'insert into items (
|
||||
name, item_type, durability,
|
||||
need_strength, need_dexterity, need_intuition, need_endurance, need_intelligence, need_wisdom,
|
||||
add_strength, add_dexterity, add_intuition, add_endurance, add_intelligence, add_wisdom,
|
||||
add_accuracy, add_evasion, add_criticals, add_min_physical_damage, add_max_physical_damage,
|
||||
image, weight)
|
||||
values (
|
||||
:name, :item_type, :durability,
|
||||
:need_strength, :need_dexterity, :need_intuition, :need_endurance, :need_intelligence, :need_wisdom,
|
||||
:add_strength, :add_dexterity, :add_intuition, :add_endurance, :add_intelligence, :add_wisdom,
|
||||
:add_accuracy, :add_evasion, :add_criticals, :add_min_physical_damage, :add_max_physical_damage,
|
||||
:image, :weight)';
|
||||
$values = [
|
||||
'name' => $params['name'] ?? uniqid(),
|
||||
'item_type' => $params['item_type'],
|
||||
'durability' => $params['durability'] ?? 1,
|
||||
'need_strength' => $params['need_strength'] ?? 0,
|
||||
'need_dexterity' => $params['need_dexterity'] ?? 0,
|
||||
'need_intuition' => $params['need_intuition'] ?? 0,
|
||||
'need_endurance' => $params['need_endurance'] ?? 0,
|
||||
'need_intelligence' => $params['need_intelligence'] ?? 0,
|
||||
'need_wisdom' => $params['need_wisdom'] ?? 0,
|
||||
'add_strength' => $params['add_strength'] ?? 0,
|
||||
'add_dexterity' => $params['add_dexterity'] ?? 0,
|
||||
'add_intuition' => $params['add_intuition'] ?? 0,
|
||||
'add_endurance' => $params['add_endurance'] ?? 0,
|
||||
'add_intelligence' => $params['add_intelligence'] ?? 0,
|
||||
'add_wisdom' => $params['add_wisdom'] ?? 0,
|
||||
'add_accuracy' => $params['add_accuracy'] ?? 0,
|
||||
'add_evasion' => $params['add_evasion'] ?? 0,
|
||||
'add_criticals' => $params['add_criticals'] ?? 0,
|
||||
'add_min_physical_damage' => $params['add_min_physical_damage'] ?? 0,
|
||||
'add_max_physical_damage' => $params['add_max_physical_damage'] ?? 0,
|
||||
'image' => $params['image'] ?? 'noitem.png',
|
||||
'weight' => $params['weight'] ?? 1,
|
||||
];
|
||||
Db::getInstance()->execute($query, $values);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Battles\Admin;
|
||||
|
||||
use Battles\Database\Db;
|
||||
|
||||
class User
|
||||
{
|
||||
private const INVISIBILITY_EFFECT = 1022;
|
||||
|
||||
public static function getInvisiblesList(): string
|
||||
{
|
||||
$list = '';
|
||||
$row = Db::getInstance()->ofetchAll('select id, login from users left join users_effects ue on users.id = ue.owner_id where type = ' . self::INVISIBILITY_EFFECT);
|
||||
foreach ($row as $item) {
|
||||
$list .= '[id] = ' . $item->id . ', ' . $item->login . '<br>';
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -62,14 +62,18 @@ class Chat
|
||||
return $wrappedMessage;
|
||||
}
|
||||
|
||||
public function addMessage(string $msg)
|
||||
public function sendMessage(string $msg)
|
||||
{
|
||||
$this->db->execute('insert into chat (user_id, msg) values (?,?)', [User::getInstance()->getId(), $msg]);
|
||||
}
|
||||
|
||||
public static function addSYSMessage( string $msg, ?int $receiver_id = null)
|
||||
public static function sendSys(string $msg, ?int $receiver_id = null)
|
||||
{
|
||||
Db::getInstance()->execute('insert into chat (user_id, msg, receiver_id, type) values (?,?,?,?)', [User::getInstance()->getId(), $msg, $receiver_id, 'sys']);
|
||||
Db::getInstance()->execute('insert into chat (user_id, msg, receiver_id, type) values (-1,?,?,?)', [$msg, $receiver_id, 'sys']);
|
||||
}
|
||||
public static function sendTelegraf(string $msg, int $receiver_id)
|
||||
{
|
||||
Db::getInstance()->execute('insert into chat (user_id, msg, receiver_id, type) values (-1,?,?,?)', [$msg, $receiver_id, 'sms']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,18 +13,20 @@ use stdClass;
|
||||
|
||||
class DressedItems
|
||||
{
|
||||
private $USERID;
|
||||
private $dressedItem;
|
||||
private static $db;
|
||||
private int $USERID;
|
||||
private stdClass $dressedItem;
|
||||
private static Db $db;
|
||||
private object $dressed;
|
||||
|
||||
/**
|
||||
* DressedItems constructor.
|
||||
* @param int $user_id ID игрока.
|
||||
* @param int $user_id ID игрока.
|
||||
*/
|
||||
public function __construct(int $user_id)
|
||||
{
|
||||
self::$db = Db::getInstance();
|
||||
$this->USERID = $user_id;
|
||||
$this->dressed = self::$db->ofetchAll('select * from inventory where dressed_slot > 0 and owner_id = ?', $this->USERID);
|
||||
}
|
||||
|
||||
public static function getDressedItemBySlot($itemSlot, $ownerId)
|
||||
@@ -34,9 +36,8 @@ class DressedItems
|
||||
|
||||
public function getItemsInSlots(): stdClass
|
||||
{
|
||||
$items = self::$db->ofetchALL('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot > 0', $this->USERID);
|
||||
$this->dressedItem = new stdClass();
|
||||
foreach ($items as $item) {
|
||||
foreach ($this->dressed as $item) {
|
||||
$i = $item->dressed_slot;
|
||||
$this->dressedItem->$i = $item;
|
||||
}
|
||||
@@ -55,8 +56,35 @@ class DressedItems
|
||||
Inventory::undressOne($slot_id, $this->USERID);
|
||||
}
|
||||
}
|
||||
|
||||
public static function undressAllItems($user_id)
|
||||
{
|
||||
return self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?', $user_id);
|
||||
}
|
||||
|
||||
public function checkRequirements()
|
||||
{
|
||||
$stats = (new UserStats($this->USERID))->getFullStats();
|
||||
$q = 'select count(*) from inventory where
|
||||
dressed_slot > 0 and
|
||||
need_strength > ? and
|
||||
need_dexterity > ? and
|
||||
need_intuition > ? and
|
||||
need_endurance > ? and
|
||||
need_intelligence > ? and
|
||||
need_wisdom > ? and
|
||||
owner_id = ?';
|
||||
$args = [
|
||||
$stats->strength,
|
||||
$stats->dexterity,
|
||||
$stats->intuition,
|
||||
$stats->endurance,
|
||||
$stats->intelligence,
|
||||
$stats->wisdom,
|
||||
$this->USERID
|
||||
];
|
||||
if (self::$db->fetchColumn($q, $args) > 0) {
|
||||
self::undressAllItems($this->USERID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,12 @@ class CureInjury extends Magic
|
||||
{
|
||||
$this->target = $this->target == $_SESSION['uid'] ? User::getInstance() : User::getInstance($this->target);
|
||||
$this->login = $this->target->getLogin();
|
||||
return ($this->isVisible(User::getInstance(), $this->target) && $this->isNotDead(User::getInstance()) && $this->enoughMana(User::getInstance()) && $this->isNotInBattle(User::getInstance()));
|
||||
return (
|
||||
$this->isVisible(User::getInstance(), $this->target) &&
|
||||
$this->isNotDead(User::getInstance()) &&
|
||||
$this->enoughMana(User::getInstance()) &&
|
||||
$this->isNotInBattle(User::getInstance())
|
||||
);
|
||||
}
|
||||
|
||||
public static function cast($target, $type): self
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user