Реализация ChatMessageDTO.
This commit is contained in:
+152
-109
@@ -968,99 +968,105 @@ class User
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if ($id['users'] - $id['users_finish'] < 2) {
|
||||
$win = [];
|
||||
$sp = mysql_query(
|
||||
'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `finish` = "0" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100'
|
||||
if ($id['users'] - $id['users_finish'] >= 2) {
|
||||
return;
|
||||
}
|
||||
$win = [];
|
||||
$sp = mysql_query(
|
||||
'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `finish` = "0" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100'
|
||||
);
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
$ur = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
$ur = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$ub = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($ur['id']) && isset($ub['id']) && $ub['lose'] <= 0 && $ub['nich'] <= 0) {
|
||||
$win = $ub;
|
||||
$winr = $ur;
|
||||
}
|
||||
$ub = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($ur['id']) && isset($ub['id']) && $ub['lose'] <= 0 && $ub['nich'] <= 0) {
|
||||
$win = $ub;
|
||||
$winr = $ur;
|
||||
}
|
||||
}
|
||||
|
||||
/* завершаем БС */
|
||||
if (isset($win['id']) && $win['lose'] == 0 && $win['nich'] == 0 && $win['id'] > 0) {
|
||||
//есть победитель
|
||||
$bsep = 0;
|
||||
if ($winr['level'] < 6) {
|
||||
$bsep = 2500;
|
||||
} elseif ($winr['level'] < 7) {
|
||||
$bsep = 5000;
|
||||
} elseif ($winr['level'] < 8) {
|
||||
$bsep = 15000;
|
||||
} elseif ($winr['level'] < 9) {
|
||||
$bsep = 25000;
|
||||
} else {
|
||||
$bsep = 50000;
|
||||
}
|
||||
/* Выдаем приз */
|
||||
$mn = (round($id['money'] / 100 * 85));
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `money` = `money` + "' . $mn . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `exp` = `exp` + "' . $bsep . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1'
|
||||
);
|
||||
/* чат */
|
||||
mysql_query(
|
||||
"INSERT INTO `chat` (`new`,`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`) VALUES ('1','capitalcity','0','','" . $winr['login'] . "','Поздравляем! Вы победили в турнире "Башня Смерти"! Получено опыта: " . $bsep . ", деньги: " . $mn . " кр.','-1','6','0')"
|
||||
);
|
||||
mysql_query(
|
||||
"INSERT INTO `chat` (`new`,`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`) VALUES ('1','capitalcity','0','','','<font color=red>Внимание!</font> Завершился турнир "Башня Смерти", победитель турнира: <strong>" . $winr['login'] . "</strong>! Поздравляем!','-1','5','0')"
|
||||
);
|
||||
$this->addDelo(
|
||||
1, $uid,
|
||||
'"<font color=#C65F00>WinTournament.' . $this->info['city'] . '</font>" (Башня Смерти): Получено "<strong>' . $mn . '</strong> кр."',
|
||||
time(), $this->info['city'], 'WinTournament.' . $this->info['city'] . '', 0, 0
|
||||
);
|
||||
$chat = new Chat();
|
||||
$cmsg = new ChatMessage();
|
||||
|
||||
/* завершаем БС */
|
||||
if (isset($win['id']) && $win['lose'] == 0 && $win['nich'] == 0 && $win['id'] > 0) {
|
||||
//есть победитель
|
||||
$bsep = 0;
|
||||
if ($winr['level'] < 6) {
|
||||
$bsep = 2500;
|
||||
} elseif ($winr['level'] < 7) {
|
||||
$bsep = 5000;
|
||||
} elseif ($winr['level'] < 8) {
|
||||
$bsep = 15000;
|
||||
} elseif ($winr['level'] < 9) {
|
||||
$bsep = 25000;
|
||||
} else {
|
||||
//нет победителя
|
||||
//Выдаем травму
|
||||
|
||||
/* чат */
|
||||
mysql_query(
|
||||
"INSERT INTO `chat` (`new`,`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`) VALUES ('1','capitalcity','0','','','<font color=red>Внимание!</font> Завершился турнир "Башня Смерти", победитель турнира: отсутствует.','-1','5','0')"
|
||||
);
|
||||
$bsep = 50000;
|
||||
}
|
||||
|
||||
$sp = mysql_query(
|
||||
'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100'
|
||||
/* Выдаем приз */
|
||||
$mn = (round($id['money'] / 100 * 85));
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `money` = `money` + "' . $mn . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1'
|
||||
);
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
$ur = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
|
||||
)
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `exp` = `exp` + "' . $bsep . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1'
|
||||
);
|
||||
/* чат */
|
||||
$cmsg->setTo($winr['login']);
|
||||
$cmsg->setText("Поздравляем! Вы победили в турнире "Башня Смерти"! Получено опыта: $bsep, деньги: $mn кр.");
|
||||
$cmsg->setType(6);
|
||||
$chat->sendMsg($cmsg);
|
||||
|
||||
$cmsg->setTo('');
|
||||
$cmsg->setIsAlert(true);
|
||||
$cmsg->setText("Завершился турнир "Башня Смерти", победитель турнира: <strong>{$winr['login']}</strong>! Поздравляем!");
|
||||
$cmsg->setType(5);
|
||||
$chat->sendMsg($cmsg);
|
||||
|
||||
$this->addDelo(
|
||||
1, $uid,
|
||||
'"<span style="color: #C65F00; ">WinTournament.' . $this->info['city'] . '</span>" (Башня Смерти): Получено "<strong>' . $mn . '</strong> кр."',
|
||||
time(), $this->info['city'], 'WinTournament.' . $this->info['city'] . '', 0, 0
|
||||
);
|
||||
} else {
|
||||
/* чат */
|
||||
$cmsg->setIsAlert(true);
|
||||
$cmsg->setType(5);
|
||||
$cmsg->setText('Завершился турнир «Башня Смерти», победитель турнира: отсутствует.');
|
||||
}
|
||||
|
||||
$sp = mysql_query(
|
||||
'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100'
|
||||
);
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
$ur = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$ub = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($ub['id'])) {
|
||||
//del
|
||||
mysql_query('DELETE FROM `users` WHERE `id` = "' . $ub['id'] . '" LIMIT 1');
|
||||
mysql_query('DELETE FROM `stats` WHERE `id` = "' . $ub['id'] . '" LIMIT 1');
|
||||
mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500');
|
||||
mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500');
|
||||
//upd
|
||||
mysql_query(
|
||||
'UPDATE `bs_zv` SET `finish` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
|
||||
);
|
||||
$ub = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($ub['id'])) {
|
||||
//del
|
||||
mysql_query('DELETE FROM `users` WHERE `id` = "' . $ub['id'] . '" LIMIT 1');
|
||||
mysql_query('DELETE FROM `stats` WHERE `id` = "' . $ub['id'] . '" LIMIT 1');
|
||||
mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500');
|
||||
mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500');
|
||||
//upd
|
||||
mysql_query(
|
||||
'UPDATE `bs_zv` SET `finish` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query('UPDATE `users` SET `inUser` = "0" WHERE `id` = "' . $pl['uid'] . '" LIMIT 1');
|
||||
}
|
||||
mysql_query('UPDATE `users` SET `inUser` = 0 WHERE `id` = "' . $pl['uid'] . '" LIMIT 1');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9063,10 +9069,15 @@ LIMIT 1'
|
||||
}
|
||||
}
|
||||
if (isset($u['id']) && ($e['type1'] < 11 || ($e['type1'] > 16 && $e['type1'] < 23)) && $e['noch'] == 0) {
|
||||
$text = 'Закончилось действие эффекта "<strong>' . $e['name'] . '</strong>"';
|
||||
mysql_query(
|
||||
"INSERT INTO `chat` (`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`,`new`) VALUES ('" . $u['city'] . "','" . $u['room'] . "','','" . $u['login'] . "','" . $text . "','-1','6','0',1)"
|
||||
);
|
||||
$text = "Закончилось действие эффекта «<strong>{$e['name']}</strong>»";
|
||||
$cmsg = new ChatMessage();
|
||||
$cmsg->setCity($u['city']);
|
||||
$cmsg->setRoom($u['room']);
|
||||
$cmsg->setTo($u['login']);
|
||||
$cmsg->setText($text);
|
||||
$cmsg->setType(6);
|
||||
(new Chat())->sendMsg($cmsg);
|
||||
|
||||
if ($u['battle'] > 0) {
|
||||
$lastHOD = mysql_fetch_array(
|
||||
mysql_query(
|
||||
@@ -11187,27 +11198,59 @@ LIMIT 1'
|
||||
return $rt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Уродец, дублирующий Chat то тут то там.
|
||||
* Сидишь, никого не трогаешь, правишь и вдруг класс User тебя с размаху мордой в грязь!
|
||||
* Привет пачка вызовов буквально отовсюду, потому что класс User это же так удобно, класс User он же везде...
|
||||
* @param string $color
|
||||
* @param int $room
|
||||
* @param string $city
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
* @param string $text
|
||||
* @param int $time
|
||||
* @param int $type
|
||||
* @param int $toChat
|
||||
* @param int $spam
|
||||
* @param int $sound
|
||||
* @param int $new
|
||||
* @param int $typeTime
|
||||
* @param int $global
|
||||
* @deprecated
|
||||
* @todo убрать нахуй заменив нативными вызовами.
|
||||
*/
|
||||
public function send(
|
||||
$color,
|
||||
$room,
|
||||
$city,
|
||||
$from,
|
||||
$to,
|
||||
$text,
|
||||
$time,
|
||||
$type,
|
||||
$toChat,
|
||||
$spam,
|
||||
$sound,
|
||||
$new = 1,
|
||||
$typeTime = 0,
|
||||
$global = 0
|
||||
string $color,
|
||||
int $room,
|
||||
string $city,
|
||||
string $from,
|
||||
string $to,
|
||||
string $text,
|
||||
int $time,
|
||||
int $type,
|
||||
int $toChat,
|
||||
int $spam,
|
||||
int $sound,
|
||||
int $new = 1,
|
||||
int $typeTime = 0,
|
||||
int $global = 0
|
||||
) {
|
||||
mysql_query(
|
||||
"INSERT INTO `chat` (`global`,`typeTime`,`new`,`sound`,`color`,`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`,`spam`) VALUES
|
||||
('" . $global . "','" . $typeTime . "','" . $new . "','" . $sound . "','" . $color . "','" . $city . "','" . $room . "','" . $from . "','" . $to . "','" . $text . "','" . $time . "','" . $type . "','" . $toChat . "','" . $spam . "')"
|
||||
);
|
||||
return mysql_insert_id();
|
||||
$cmsg = new ChatMessage();
|
||||
$cmsg->setColor($color);
|
||||
$cmsg->setCity($city);
|
||||
$cmsg->setRoom($room);
|
||||
$cmsg->setLogin($from);
|
||||
$cmsg->setTo($to);
|
||||
$cmsg->setText($text);
|
||||
$cmsg->setTime($time);
|
||||
$cmsg->setType($type);
|
||||
$cmsg->setToChat($toChat);
|
||||
$cmsg->setSpam($spam);
|
||||
$cmsg->setSound($sound);
|
||||
$cmsg->setNew($new);
|
||||
$cmsg->setTypeTime($typeTime);
|
||||
$cmsg->setGlobal($global);
|
||||
(new Chat())->sendMsg($cmsg);
|
||||
}
|
||||
|
||||
//получаем уровень
|
||||
|
||||
Reference in New Issue
Block a user