196 lines
6.0 KiB
PHP
196 lines
6.0 KiB
PHP
<?
|
|
if(!defined('GAME')) { die(); }
|
|
|
|
class noob {
|
|
|
|
//Ïåðåìåííûå
|
|
public static $info = array(); //òåêóùèé êâåñò
|
|
|
|
/*
|
|
Ïðîâåðêà äåéñòâèÿ
|
|
*/
|
|
public static function test1($var) {
|
|
global $u;
|
|
$r = false;
|
|
$var = explode('=',$var);
|
|
if( $var[0] == 'slot' ) {
|
|
//Îäåò ëè â ñëîò ïðåäìåò
|
|
$test = mysql_fetch_array(mysql_query('SELECT `id`,`item_id` FROM `items_users` WHERE `uid` = "'.$u->info['id'].'" AND `inOdet` = "'.mysql_real_escape_string($var[1]).'" AND `delete` = 0 LIMIT 1'));
|
|
if(isset($test['id'])) {
|
|
if($var[2] == 0 || $var[2] == $test['item_id'] ) {
|
|
$r = true;
|
|
}
|
|
}
|
|
}
|
|
return $r;
|
|
}
|
|
|
|
/*
|
|
Ïðîâåðêè êâåñòà
|
|
*/
|
|
public static function testAll() {
|
|
global $u;
|
|
//Äîï ïðîâåðêè
|
|
$go = 1;
|
|
//Îïûò
|
|
$ex = explode('>',self::$info['module']);
|
|
if( $ex[0] == 'exp' ) {
|
|
if( $ex[1] < $u->info['exp'] ) {
|
|
self::$info['module'] = '';
|
|
}
|
|
}
|
|
$ex = explode('<',self::$info['module']);
|
|
if( $ex[0] == 'exp' ) {
|
|
if( $ex[1] < $u->info['exp'] ) {
|
|
mysql_query('UPDATE `users` SET `fnq` = "'.self::$info['next'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
|
|
self::$info['module'] = '';
|
|
}
|
|
}
|
|
//Îñòàëüíîå
|
|
$ex = explode('=',self::$info['module']);
|
|
if( $ex[0] == 'slots' ) {
|
|
//Íàäåòûå ïðåäìåòû â ñëîòû
|
|
$ex2 = explode(',',$ex[1]);
|
|
$i = 0; $gd = 1;
|
|
while( $i < count($ex2) ) {
|
|
if( !isset($u->stats['wp' . $ex2[$i] . 'id']) ) {
|
|
$gd = 0;
|
|
}
|
|
$i++;
|
|
}
|
|
if( $gd == 1 ) {
|
|
self::$info['module'] = '';
|
|
}
|
|
}
|
|
//
|
|
$go = 1;
|
|
//Òðåáîâàíèÿ
|
|
$e1 = explode('|',self::$info['tr']);
|
|
$i = 0;
|
|
while( $i < count($e1) ) {
|
|
$ex = explode('=',$e1[$i]);
|
|
//
|
|
if( $ex[0] == 'exp' ) {
|
|
if( $ex[1] == '>' ) {
|
|
if( $ex[2] > $u->info['exp'] ) {
|
|
$go = 0;
|
|
}
|
|
}elseif( $ex[1] == '<' ) {
|
|
if( $ex[2] < $u->info['exp'] ) {
|
|
$go = 0;
|
|
}
|
|
}
|
|
}
|
|
//
|
|
$i++;
|
|
}
|
|
//
|
|
//
|
|
return $go;
|
|
}
|
|
|
|
|
|
/*
|
|
Íà÷àëî ïðîâåðêè îáó÷åíèÿ
|
|
*/
|
|
public static function start() {
|
|
global $u;
|
|
if( $u->info['fnq'] == 0 ) {
|
|
$u->info['fnq'] = 1;
|
|
mysql_query('UPDATE `users` SET `fnq` = "'.$u->info['fnq'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
|
|
}else{
|
|
if( $u->info['level'] > 2 ) {
|
|
mysql_query('UPDATE `users` SET `fnq` = "-1" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
|
|
}
|
|
}
|
|
if( $u->info['fnq'] == 0 ) {
|
|
//Íà÷àëî îáó÷åíèÿ
|
|
/*$humor = array(
|
|
0 => array(
|
|
':maniac: Ñèëüíî íå áåéòå ;)',':beggar: Áóäåò ïîïðîøàéíè÷àòü - áåéòå!',':pal: Âîçìîæíî ñâåòëûé!',
|
|
':vamp: Âîçìîæíî òåìíûé!',':susel: Ñóäÿ ïî çäîðîâåííîìó á
|
|
':friday: Íå äîëãî äóìàâ îí íà÷àë èñêàòü ñîáóòûëüíèêà!',':doc: Ëåêàðü: Íîâè÷îê! Äà, äà! Òû! Åñëè òåáÿ ñëîìàþò - ó çíàõàðÿ òåáÿ ñîáåðóò îáðàòíî!'
|
|
),
|
|
1 => array(
|
|
':maniac: Ïîìíèòå! Äåâî÷åê íå áüåì ;)',':nail: Îíà êðàñèò íîãòè, íå îòâëåêàéòå âñå ñðàçó ;)',':pal: Âîçìîæíî ñâåòëàÿ!',
|
|
':vamp: Âîçìîæíî òåìíàÿ!',':rev: Ñóäÿ ïî êðàñèâîé îäåæäå - ýòî æåíùèíà!',':hug: È ñðàçó æå êèíóëàñü âñåõ öåëîâàòü!',
|
|
':angel2: Àíãåë ñîøåë ñ íåáåñ...'
|
|
)
|
|
);
|
|
$humor = $humor[$u->info['sex']];
|
|
*/
|
|
$u->info['fnq'] = 1;
|
|
mysql_query('UPDATE `users` SET `fnq` = "'.$u->info['fnq'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
|
|
//Îòïðàâëÿåì ñîîáùåíèå â ÷àò î íîâè÷êå
|
|
//$u->send('','','','','','Â íàøåì ìèðå ïîÿâèëñÿ íîâûé èãðîê "<b>' . $u->info['login'] . '</b>"! '.$humor[rand(0,count($humor)-1)].'',time(),6,0,0,0,1,0);
|
|
}else{
|
|
self::$info = mysql_fetch_array(mysql_query('SELECT * FROM `an_quest` WHERE `id` = "'.$u->info['fnq'].'" LIMIT 1'));
|
|
if(isset(self::$info['id'])) {
|
|
//Òåñòèðóåì êâåñò
|
|
$go = self::testAll();
|
|
if( $go == 0 ) {
|
|
//Òðåáîâàíèÿ íå ïîäõîäÿò
|
|
self::$info = array();
|
|
}elseif( $u->info['marker'] == self::$info['module'] || self::$info['module'] == '' || (self::$info['module'] == 'next' && isset($_GET['nextfnq'])) || self::test1(self::$info['module']) == true ) {
|
|
//Êâåñò âûïîëíåí, äåéñòâèå ñäåëàíî!
|
|
if( self::$info['room'] == '' || self::$info['room'] == $u->room['name'] ) {
|
|
//Âûäàåì íàãðàäó
|
|
$nag = explode('|',self::$info['win']);
|
|
if( $nag[3] != '0' ) {
|
|
//Âûäàåì ïðåäìåò
|
|
$ng = explode(',',$nag[3]);
|
|
$i = 0;
|
|
while( $i < count($ng) ) {
|
|
$ngi = explode(',',$ng[$i]);
|
|
$j = 0;
|
|
while( $j < count($ngi) ) {
|
|
$ngj = explode('=',$ngi[$j]);
|
|
// id = srok = data
|
|
$ngjs = '';
|
|
if( $ngj[1] > 0 ) {
|
|
$ngjs .= '|srok='.$ngj[1].'';
|
|
}
|
|
$u->addItem($ngj[0], $u->info['id'], $ngjs);
|
|
$j++;
|
|
}
|
|
$i++;
|
|
}
|
|
}
|
|
if( $nag[4] != '0' ) {
|
|
//Âûäàåì çóáû
|
|
$u->info['money4'] += $nag[4];
|
|
mysql_query('UPDATE `users` SET `money4` = "'.$u->info['money4'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
|
|
}
|
|
|
|
$u->info['fnq'] = self::$info['next'];
|
|
mysql_query('UPDATE `users` SET `fnq` = "'.$u->info['fnq'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
|
|
self::$info = mysql_fetch_array(mysql_query('SELECT * FROM `an_quest` WHERE `id` = "'.$u->info['fnq'].'" LIMIT 1'));
|
|
$go = self::testAll();
|
|
if( $go == 0 || self::$info['act'] == 'deadline' ) {
|
|
//Òðåáîâàíèÿ íå ïîäõîäÿò
|
|
self::$info = array();
|
|
}
|
|
}
|
|
}else{
|
|
//Òåêóùèé êâåñò
|
|
}
|
|
|
|
if(isset(self::$info['id'])) {
|
|
self::$info['info'] = str_replace('{login}',$u->info['login'],self::$info['info']);
|
|
self::$info['info'] = str_replace('{level}',$u->info['level'],self::$info['info']);
|
|
self::$info['info'] = str_replace("\r\n",'<br>',self::$info['info']);
|
|
echo '<script>top.noob.takeData("'.self::$info['id'].'","'.self::$info['ico_bot'].'","'.self::$info['name_bot'].'","'.self::$info['name'].'","'.self::$info['act'].'","'.self::$info['next'].'","'.str_replace('"','"',self::$info['info']).'");</script>';
|
|
}else{
|
|
echo '<script>top.noob.no();</script>';
|
|
}
|
|
}else{
|
|
//Êâåñò íå íàéäåí
|
|
echo '<script>top.noob.no();</script>';
|
|
}
|
|
//
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
?>
|