Файл: smelt.php
Строк: 132
<?php
include_once("settings.php");
include_once("game_header.php");
include_once("player_thing.php");
include_once("players.php");
include_once("messages.php");
include_once("chain.php");
//check player state
checkPlayerState($player);
//FIX ME
if($room_id!=1){
    header("Location: area.php");
    break;
}
if(!isset($mode)) $mode="";
$players = new CPlayers($db);
$work = $players->getPlayersInRoomAndAction($room_id,ACTION_WOODCUT);
$smarty->assign('WORK',$work);
if(!isset($mode)) $mode="";
$player_thing = new CPlayerThings($db,$vnum);
$skills = new CSkill($db,$vnum);
$level_smelt=$skills->getSkillLevel(SKILL_SMELT);
$things = new CThing($db); 
/* type mining resource */
$type_res=array();
if($room_id==1){
    //$smarty->assign('COPPER',1);
    //$smarty->assign('BRONZE',1);
    $type_res[]=18;//ore bar
    $type_res[]=26;//aluminium bar
    $type_res[]=21;//steel bar
}
switch($mode)
{
    case 'manager'://visit to controlman
        
        //check mountain skill
        if($skills->getSkillProgress(SKILL_SMELT)==true){
            $smarty->assign('SMELT',1);
        }else{
            $skills->setSkill(SKILL_SMELT);
        }
        $smelt=$smarty->fetch($templ_path.'/smelt_manager.tpl');
        break;
    case 'smelt':
        if(!isset($_GET["obj"])){
            header("Location: smelt.php");
            exit();
        }
        $obj = $_GET["obj"];
        $things->setVnum($obj);
        //check type objects, must be bar
        $type_obj = $things->getType();
        if($type_obj != "bar"){
            header("Location: smelt.php");
            exit();
        }
        $info_msg="";
        
        //check components
        $chain = new CChain($db,$obj);
        if($chain->checkComponents($player_thing)==false){
            $info_msg="х ЧБУ ОЕФ ОХЦОЩИ ЛПНРПОЕОФ";
            session_register("info_msg");
            header("Location: smelt.php");
            exit();
        }
        
        //check player level and level things
        $things_level = $things->getLevel();
        if($things_level-5>$level_smelt){
            $info_msg="чБЫ ХТПЧЕОШ УМЙЫЛПН НБМ ДМС РМБЧЛЙ ЬФЙИ УМЙФЛПЧ";
            session_register("info_msg");
            header("Location: smelt.php");
            exit();
        }
        //start smelt
         $player->setWork(STATE_WORK,ACTION_SMELT,$obj);
         $uuid=getUniqValue();
         $player->setUuid($uuid);
         //add log messages
         $log_player = new CLogPlayers($db,$vnum,$uuid);
         $msg=getStartSmelt();
         $log_player->addLogMsg($msg);
         //refresh
         header("Location: smelt.php");
          exit();
        
        break;
    default:
        //show messages
        if(isset($info_msg))
        {
            $smarty->assign('INFO_MSG',$info_msg);
            session_unregister("info_msg");
        }
        //get ores in player bag
        $ores=$player_thing->getAllThingsOneType("ore");
        foreach($ores as $v)
        {
            $things->setVnum($v['vnum_obj']);
            $thing_name=$things->getName();
            $smarty->append("ores",array(
                'VNUM' => $v['vnum_obj'],
                'NAME' => $thing_name,
                'COUNT' => $v['count']
            ));
        }
        //show smelt resource in room
        $chain = new CChain($db);
        foreach($type_res as $v)
        {
            $things->setVnum($v);
            $thing_name=$things->getName();
            $thing_level=$things->getLevel();
            $chain->setVnum($v);
            $comp=$chain->getComponents();
            $things->setVnum($comp['vnum_1']);
            $comp_text="<b>".$things->getName()."</b> ".$comp['count_1']." ЫФ.";
            if($comp['count_2']!=0){
                //two components
                $things->setVnum($comp['vnum_2']);
                $comp_text.=" <b>".$things->getName()."</b> ".$comp['count_2']." ЫФ.";
            }
            
            $smarty->append("things",array(
                'VNUM' => $v,
                'NAME' => $thing_name,
                'LEVEL' => $thing_level,
                'COMP_TEXT' => $comp_text,
            ));
        }
        //player level smelt
        $smarty->assign('LEVEL_SMELT',$level_smelt);
        $smelt=$smarty->fetch($templ_path.'/smelt.tpl');
        break;
}
$smarty->assign('MAIN',$smelt);
echo($smarty->fetch($templ_path.'/game.tpl'));
?>