Файл: resources.php
Строк: 131
<?php
include_once("settings.php");
include_once("game_header.php");
include_once("shop.php");
include_once("player_thing.php");
include_once("thing.php");
include_once("log.php");
include_once("messages.php");
include_once("constants.php");
//check player state
checkPlayerState($player);
//FIX ME
if($room_id!=1){
header("Location: area.php");
break;
}
if(!isset($mode)) $mode="";
$player_thing = new CPlayerThings($db,$vnum);
$things = new CThing($db);
$level_mining=$skill->getSkillLevel(SKILL_MINING);
/* type mining resource */
$type_res=array();
//allow players get resources
if($room_id==1){
$type_res[]=8;//iron
$type_res[]=23;//aluminium
$type_res[]=11;//coal
$type_res[]=24;//gold
$type_res[]=25;//titan
}
switch($mode)
{
case 'manager'://visit to controlman
//check tool on player
$tool=$player_thing->getThingVnum(7);
if($tool!=-1){
$smarty->assign('TOOL',1);
}else{
$mining_skill=$skill->getSkillLevel(SKILL_MINING);
if($mining_skill<5){
$player_thing->addThing(7);
}
}
//check mountain skill
if($skill->getSkillProgress(SKILL_MINING)==true){
$smarty->assign('MOUNTAIN',1);
$smarty->assign('MINING_LEVEL',$skill->getSkillLevel(SKILL_MINING));
}else{
$skill->setSkill(SKILL_MINING);
}
$resources_txt=$smarty->fetch($templ_path.'/resources_manager.tpl');
break;
case 'mining':
$info_msg="";
if(!isset($_GET["obj"])){
header("Location: resources.php");
exit();
}
$obj = $_GET["obj"];
$things->setVnum($obj);
//check type objects, must be wood
$type_obj = $things->getType();
if($type_obj != "ore"){
header("Location: resources.php");
exit();
}
//check tool in players bag
$tool = $player_thing->getWearThing(WEAR_TWO_HAND);
$tool_obj = $player_thing->getThingID($tool);
if(($tool_obj!=7) && ($tool_obj!=28)) {
$info_msg="юЕН ЧЩ УПВТБМЙУШ ДПВЩЧБФШ ФХФ ТХДХ. оЕ РБМШГЕН ОБДЕАУШ. чБН ОХЦОП ЧЪСФШ Ч ТХЛХ ЛЙТЛХ ЙМЙ ЮФП РПНПЭОЕЕ.";
session_register("info_msg");
header("Location: resources.php");
exit();
}
//check player level and level things
$things_level = $things->getLevel();
if($things_level-5>$level_mining){
$info_msg="чБЫ ХТПЧЕОШ УМЙЫЛПН НБМ ДМС ДПВЩЮЙ ЬФПЗП ТЕУХТУБ";
session_register("info_msg");
header("Location: resources.php");
exit();
}
//check player things in bag
$things_count=$player_thing->getCountThings();
if($things_count>=MAX_PLAYER_ITEM){
$info_msg="ч ЧБЫ ЙОЧЕОФБТШ ВПМШЫЕ ОЙЮЕЗП ОЕ ЧМЕЪЕФ";
session_register("info_msg");
header("Location: resources.php");
exit();
}
//start mining
$player->setWork(STATE_WORK,ACTION_MINIG,$obj);
$uuid=getUniqValue();
$player->setUuid($uuid);
//add log messages
$log_player = new CLogPlayers($db,$vnum,$uuid);
$msg=getStartMining();
$log_player->addLogMsg($msg);
//refresh
header("Location: resources.php");
exit();
break;
case 'stop':
//stop minings
$player->setState(STATE_STAND);
//refresh
header("Location: resources.php");
exit();
break;
default:
if(isset($info_msg))
{
$smarty->assign('INFO_MSG',$info_msg);
session_unregister("info_msg");
}
/* list resource in room */
foreach($type_res as $v)
{
$things->setVnum($v);
$thing_name=$things->getName();
$thing_level=$things->getLevel();
$smarty->append("things",array(
'VNUM' => $v,
'NAME' => $thing_name,
'LEVEL' => $thing_level,
));
}
$smarty->assign('LEVEL_MINING',$level_mining);
$resources_txt=$smarty->fetch($templ_path.'/resources.tpl');
break;
}
$smarty->assign('MAIN',$resources_txt);
echo($smarty->fetch($templ_path.'/game.tpl'));
?>