diff --git a/classes/quests_class.php b/classes/quests_class.php
index b6c089f..28ff511 100644
--- a/classes/quests_class.php
+++ b/classes/quests_class.php
@@ -1,590 +1,600 @@
-
+query('SELECT * FROM `quests` WHERE `id` = ?i', $pl)->fetch_assoc();
- $r = 1;
+ $r = 1;
- $qlst = mysql_fetch_array(mysql_query('SELECT `id`, `vals` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" LIMIT 1'));
- if(isset($qlst['id']) && $qlst['vals'] != 'win' && $qlst['vals'] != 'end' && $qlst['vals'] != 'bad') {
- $r = 2;
- }
- unset($qlst, $qlst2);
+ $qlst = db::c()->query('SELECT `vals` FROM `actions` WHERE `uid` = ?i AND `vars` = "?s"', $uid, 'start_quest'. $pl['id'])->fetch_assoc();
+ if (db::c()->getAffectedRows() AND !in_array($qlst['vals'],['win','end','vals'])) $r = 2;
- $d = $this->expl($pl['tr_date']);
+ unset($qlst, $qlst2);
- if(isset($d['tr_endq'])) {
- $i = 0;
- $e = explode(',', $d['tr_endq']);
- while($i < count($e)) {
- $qlst = mysql_fetch_array(mysql_query('SELECT `id`, `vals` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$e[$i].'" AND `vals` = "win" LIMIT 1'));
- if(!isset($qlst['id'])) {
- $r = 3;
- }
- $i++;
- }
- unset($qn, $qlst, $qlst2);
- }
+ $d = $this->expl($pl['tr_date']);
- if(isset($d['tr_zdr'])) {
- $qlst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` != "go" ORDER BY `time` DESC LIMIT 1'));
- if($qlst['time']+($d['tr_zdr']*60*60)-time() > 0) {
- $r = 4;
- }
- unset($qlst);
- }
+ if (isset($d['tr_endq'])) {
+ $i = 0;
+ $e = explode(',', $d['tr_endq']);
+ while ($i < count($e)) {
+ $qlst = mysql_fetch_array(mysql_query('SELECT `id`, `vals` FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $e[$i] . '" AND `vals` = "win" LIMIT 1'));
+ if (!isset($qlst['id'])) {
+ $r = 3;
+ }
+ $i++;
+ }
+ unset($qn, $qlst, $qlst2);
+ }
- if(isset($d['tr_tm1'])) {
- $d['tr_tm1'] = str_replace('d', date('d'), $d['tr_tm1']);
- $d['tr_tm1'] = str_replace('m', date('m'), $d['tr_tm1']);
- $d['tr_tm1'] = str_replace('y', date('y'), $d['tr_tm1']);
- $d['tr_tm2'] = str_replace('d', date('d'), $d['tr_tm2']);
- $d['tr_tm2'] = str_replace('m', date('m'), $d['tr_tm2']);
- $d['tr_tm2'] = str_replace('y', date('y'), $d['tr_tm2']);
- }
+ if (isset($d['tr_zdr'])) {
+ $qlst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" ORDER BY `time` DESC LIMIT 1'));
+ if ($qlst['time'] + ($d['tr_zdr'] * 60 * 60) - time() > 0) {
+ $r = 4;
+ }
+ unset($qlst);
+ }
- if(isset($d['tr_raz'])) {
- $qlst = $this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" LIMIT '.$d['tr_raz'], 2);
- if($d['tr_raz'] > 0 && $d['tr_raz']-$qlst[0] <= 0) {
- $r = 5;
- }
- unset($qlst);
- }
+ if (isset($d['tr_tm1'])) {
+ $d['tr_tm1'] = str_replace('d', date('d'), $d['tr_tm1']);
+ $d['tr_tm1'] = str_replace('m', date('m'), $d['tr_tm1']);
+ $d['tr_tm1'] = str_replace('y', date('y'), $d['tr_tm1']);
+ $d['tr_tm2'] = str_replace('d', date('d'), $d['tr_tm2']);
+ $d['tr_tm2'] = str_replace('m', date('m'), $d['tr_tm2']);
+ $d['tr_tm2'] = str_replace('y', date('y'), $d['tr_tm2']);
+ }
- if(isset($d['tr_raz2'])) {
- $qlst = $this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "'.$uid.'" AND `vars` = "start_quest'.$pl['id'].'" AND `vals` != "go" AND `vals` != "win" LIMIT '.$d['tr_raz2'], 2);
- if($d['tr_raz2']-$qlst[0] <= 0) {
- $r = 6;
- }
- unset($qlst);
- }
- return $r;
- }
+ if (isset($d['tr_raz'])) {
+ $qlst = $this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
+ if ($d['tr_raz'] > 0 && $d['tr_raz'] - $qlst[0] <= 0) {
+ $r = 5;
+ }
+ unset($qlst);
+ }
- public function __clone() {
- trigger_error('Дублирование не допускается.', E_USER_ERROR);
- }
-
- public function startq($id, $val = NULL, $uid) {
- $pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `id` = "'.mysql_real_escape_string($id).'" LIMIT 1'));
- if(isset($pl['id'])) {
- $tms = (time()+60*60*$pl['time']);
- $this->addAction(time(), 'start_quest'.$pl['id'], 'go', $uid, $tms);
- $this->error = 'Вы успешно получили задание "'.$pl['name'].'"';
- } else {
- $this->error = 'Не удалось получить данное задание ...';
- }
- }
-
- public function list_quest($pl, $u) {
- $r = ''; $t = ''; $nagr = ''; $tr = '';
- $qlst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "'.$u.'" AND `vars` = "start_quest'.$pl['id'].'" ORDER BY `time` DESC LIMIT 1'));
-
- $ds = $this->expl($pl['win_date']);
- if(isset($ds['add_cr'])) {
- $nagr .= 'Деньги : '.$ds['add_cr'].' кр. ';
- }
- if(isset($ds['add_point'])) {
- $nagr .= ' Репутация : '.$ds['add_point'].' ед. ';
- }
- if(isset($ds['add_exp'])) {
- $nagr .= ' Опыт : '.$ds['add_exp'].' ед. ';
- }
-
- $d = $this->expl($pl['act_date']);
- if(isset($d['heal'])) {
- $tr .= 'Вылечить '.$d['heal'].' игроков от травм.
';
- }
- if(isset($d['tr_win_haot'])) {
- $tr .= 'Выйграть '.$d['tr_win_haot'].' хаотических поединков.
';
- }
- if(isset($d['kill_clone'])) {
- $tr .= 'Выйграть '.$d['kill_clone'].' поединков против своего клона.
';
- }
- // if(isset($d['tr_win'])) {
- // $tr .= 'Выйграть '.$d['tr_win'].' физических поединков против игроков.
';
- // }
- if(isset($d['kill_bot'])) {
- $x = '';
- $ex = explode(',', $d['kill_bot']);
- $i = 0;
- while($i < count($ex)) {
- $ex2 = explode('=', $ex[$i]);
- $bot2 = mysql_fetch_array(mysql_query('SELECT `id`, `login` FROM `users` WHERE `id` = "'.$ex2[0].'" LIMIT 1'));
- if(isset($bot2['id'])) {
- $x .= ' • '.$bot2['login'].' '.$ex2[1].'
';
- }
- $i++;
- }
-
- if($x != '') {
- $x = trim($x, ', ');
- $tr .= 'Убить ботов:
'.$x.'';
- }
- }
- if($tr != '') {
- $ts = 'Требования :
'.$tr;
+ if (isset($d['tr_raz2'])) {
+ $qlst = $this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
+ if ($d['tr_raz2'] - $qlst[0] <= 0) {
+ $r = 6;
+ }
+ unset($qlst);
+ }
+ return $r;
}
- $za = '';
- if($qlst['time']+($pl['heal']*60*60)-time() > 0) {
- $tms = $this->timeOut($qlst['time']+($pl['heal']*60*60)-time());
- $za = 'Задержка еще : '.$tms.'
';
+ public function __clone()
+ {
+ trigger_error('Дублирование не допускается.', E_USER_ERROR);
}
-
- $d = $this->expl($pl['tr_date']);
- $r .= '