game/_incl_data/class/Admin/Monster.php

136 lines
4.7 KiB
PHP
Raw Normal View History

2023-11-02 13:57:39 +00:00
<?php
namespace Admin;
use Core\Db;
readonly class Monster
{
public array $info;
public function __construct(int $monsterid)
{
$this->info = Db::getRow('select * from aaa_monsters where uid = ?', [$monsterid]);
if ($_SERVER['REQUEST_METHOD'] === OAUTH_HTTP_METHOD_POST) {
$this->save();
}
}
private function save(): void
{
$params['uid'] = $this->info['uid'];
$params['start_room'] = (int)$_POST['bot_sroom'];
$params['start_day'] = (int)$_POST['bot_sday'];
$params['start_dd'] = (int)$_POST['bot_sdd'];
$params['start_mm'] = (int)$_POST['bot_smm'];
$params['start_hh'] = (int)$_POST['bot_shh'];
$params['start_min'] = (int)$_POST['bot_smin'];
$params['back_day'] = (int)$_POST['bot_bday'];
$params['back_dd'] = (int)$_POST['bot_bdd'];
$params['back_mm'] = (int)$_POST['bot_bmm'];
$params['back_hh'] = (int)$_POST['bot_bhh'];
$params['back_min'] = (int)$_POST['bot_bmin'];
$params['start_text'] = $_POST['bot_stext'];
$params['back_text'] = $_POST['bot_btext'];
$params['win_text'] = $_POST['bot_wintext'];
$params['lose_text'] = $_POST['bot_losetext'];
$params['nich_text'] = $_POST['bot_nichtext'];
$params['win_back'] = $_POST['bot_winback'];
$params['time_restart'] = $_POST['bot_trs'];
$params['win_itm'] = $_POST['bot_winitm'];
$params['win_money1'] = $_POST['bot_winmoney1'];
$params['win_money2'] = $_POST['bot_winmoney2'];
$params['win_exp'] = $_POST['bot_winexp'];
$params['win_eff'] = $_POST['bot_wineff'];
$params['win_ico'] = $_POST['bot_winico'];
$params['lose_itm'] = $_POST['bot_loseitm'];
$params['lose_money'] = $_POST['bot_losemoney1'];
$params['lose_money2'] = $_POST['bot_losemoney2'];
$params['lose_exp'] = $_POST['bot_loseexp'];
$params['lose_eff'] = $_POST['bot_loseeff'];
$params['lose_ico'] = $_POST['bot_loseico'];
if (!isset(
$params['uid'],
$params['start_room'],
$params['start_day'],
$params['back_day'],
$params['start_dd'],
$params['start_mm'],
$params['start_hh'],
$params['start_min'],
$params['back_min'],
$params['back_dd'],
$params['back_mm'],
$params['back_hh'],
$params['start_text'],
$params['back_text'],
$params['win_text'],
$params['lose_text'],
$params['nich_text'],
$params['win_money1'],
$params['win_money2'],
$params['lose_money'],
$params['lose_money2'],
$params['win_exp'],
$params['lose_exp'],
$params['win_itm'],
$params['lose_itm'],
$params['win_eff'],
$params['lose_eff'],
$params['win_ico'],
$params['lose_ico'],
$params['win_back'],
$params['time_restart']
)) {
return;
}
Db::sql('replace into aaa_monsters
(uid, start_room, start_day, back_day, start_dd, start_mm, start_hh, start_min,
back_min, back_dd, back_mm, back_hh, start_text, back_text, win_text, lose_text,
nich_text, win_money1, win_money2, lose_money, lose_money2, win_exp, lose_exp,
win_itm, lose_itm, win_eff, lose_eff, win_ico, lose_ico, win_back, time_restart)
values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [
$params['uid'],
$params['start_room'],
$params['start_day'],
$params['back_day'],
$params['start_dd'],
$params['start_mm'],
$params['start_hh'],
$params['start_min'],
$params['back_min'],
$params['back_dd'],
$params['back_mm'],
$params['back_hh'],
$params['start_text'],
$params['back_text'],
$params['win_text'],
$params['lose_text'],
$params['nich_text'],
$params['win_money1'],
$params['win_money2'],
$params['lose_money'],
$params['lose_money2'],
$params['win_exp'],
$params['lose_exp'],
$params['win_itm'],
$params['lose_itm'],
$params['win_eff'],
$params['lose_eff'],
$params['win_ico'],
$params['lose_ico'],
$params['win_back'],
$params['time_restart'],
]);
echo '<b style="color: red">Новые данные были успешно сохранены!</b>';
}
}