2023-03-31 18:42:06 +00:00
< ? php
2024-05-15 13:42:28 +00:00
use Model\ActionModel ;
use User\ItemsModel ;
2023-12-01 21:27:45 +00:00
if ( ! defined ( 'GAME' )) {
die ();
2022-06-06 21:30:34 +00:00
}
2023-12-01 21:27:45 +00:00
if ( isset ( $po [ 'finish_file' ]) && $po [ 'finish_file' ] == 'tznanie' ) {
//Добавляем слот
mysql_query (
'UPDATE `actions` SET `val` = "cast" WHERE (`vals` = "1044" OR `vals` = "1045" OR `vals` = "1046" OR `vals` = "1047") AND `val` != "cast" AND `vars` = "read" AND `uid` = "' . $u -> info [ 'id' ] . '" LIMIT 1'
);
} else {
$st [ 'timeRead' ] = 0 ;
if ( isset ( $tst [ 'id' ])) {
//Уже что-то изучаем
$u -> error = 'Так не пойдет, вы уже что-то изучаете' ;
} else {
2024-05-15 13:42:28 +00:00
$tst = ( bool ) ActionModel :: testCount ([ " uid = $u->info ['id'] " , 'vars = read' , " vals = { $itm [ 'item_id' ] } " ]);
if ( $tst ) {
2023-12-01 21:27:45 +00:00
$u -> error = 'Вы уже изучили данное знание' ;
} else {
$fn = '' ;
$tom_iz = 0 ;
if (( $itm [ 'item_id' ] >= 1045 && $itm [ 'item_id' ] <= 1047 ) || ( $itm [ 'item_id' ] >= 4812 && $itm [ 'item_id' ] <= 4813 )) {
2024-05-15 13:42:28 +00:00
$tst2 = ( bool ) ActionModel :: testCount ([ " uid = $u->info ['id'] " , 'vars = read' , " vals = { $itm [ 'item_id' ] } - 1 " ]);
if ( ! $tst2 ) {
2023-12-01 21:27:45 +00:00
$tom_iz = 1 ;
}
unset ( $tst2 );
}
if ( $tom_iz == 0 ) {
if (( $itm [ 'item_id' ] >= 1044 && $itm [ 'item_id' ] <= 1047 ) || $itm [ 'item_id' ] == 4813 || $itm [ 'item_id' ] == 4812 ) {
mysql_query ( 'UPDATE `stats` SET `priemslot` = `priemslot` + 1 WHERE `id` = "' . $itm [ 'uid' ] . '" LIMIT 1' );
$fn .= 'finish_file=tznanie' ;
}
if ( $itm [ 'item_id' ] == 4811 ) {
mysql_query ( 'UPDATE `stats` SET `priemslot` = `priemslot` + 2 WHERE `id` = "' . $itm [ 'uid' ] . '" LIMIT 1' );
$fn .= 'finish_file=tznanie' ;
}
$u -> error = 'Вы изучили "' . $itm [ 'name' ] . '".' ;
$u -> addAction ( time () + $st [ 'timeRead' ], 'read' , $itm [ 'item_id' ]);
2024-05-15 13:42:28 +00:00
ItemsModel :: addIznos ( $itm [ 'id' ]);
2023-12-01 21:27:45 +00:00
} else {
$u -> error = 'Требует изучения предыдущего тома' ;
}
unset ( $tom_iz );
}
}
2022-06-06 21:30:34 +00:00
}