⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lands_explore.php

📁 Download you own three BR
💻 PHP
字号:
<?php
require_once("configs/Configs.php");//加载配置文件
require_once("functions/login_flag.php");//是否已经登录
require_once("functions/func_common.php");//加载函数文件
require_once("functions/class_mysql.php");//加载数据库类文件

//处理土地探索任务
require_once("land_explore_processing.php");

//获取当前总资源信息
//$query=$db->query("select c.total_house,c.free_house,c.total_hills,c.free_hills,c.total_woodlands,c.free_woodlands,c.total_flats,c.free_flats,r.rices from resource as r,city as c where r.`u_id`=c.`u_id` and  r.`u_id`='".$UserId."' and c.`c_id`='".$CityId."'");
//$remain_person=$db->fetch_array($query);
$alow_explore_person=$remain_person['total_house']-$remain_person['free_house'];//当前空闲人口

//探索陆地开始
if($_POST['action']=="explore_do"){
  $query=$db->query("select * from land_explore where `u_id`='".$UserId."' and `c_id`='".$CityId."'");
  $row_temp=$db->fetch_array($query);
	if($row_temp['l_flag']<>"0"){//判断是否已经在探索中...先暂时一次只能进行一个探索任务
		if($_COOKIE['city_type']==0){
			$query = $db->query("select total_size from sub_city_land where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
			$sub_total_size = $db->fetch_array($query);
			$city_size = $sub_total_size['total_size'];
		}
		if($remain_person['total_flats'] + $remain_person['total_woodlands'] + $remain_person['total_hills'] >= $city_size)	echomsg("当前城池已经没有陆地可供探索!");
		
		$explore_person=trim($_POST['explore_person']);
		if($explore_person=="" or $explore_person<=0) echomsg("请指派探索人数");
	    $explore_land_type=$_POST['land_type'];
	    if($explore_person>$init_explore_person) echomsg("您没有足够的探索者");
		$eat_rices=$explore_person * $explore_eat_rices;//探索者消耗粮食
		$explore_need_time=$explore_time;
		
		//根据内政物品减少相应的探索时间//
		$query=$db->query("select s_landform from study where `u_id`='".$UserId."' and `c_id`='".$CityId."'");
		$study_result=$db->fetch_array($query);
		$explore_need_time = ($study_result['s_landform']>0) ? $explore_need_time - $explore_need_time * ($study_result['s_landform'] * $s_explore_percent)  : $explore_need_time;

		//////////////////////////////

		if($eat_rices > $remain_person['rices']) echomsg("您没有足够的粮食");
		
		//探索消耗粮食,同时减少仓库空间
		$query=$db->query("update resource set `rices`=`rices`-'".$eat_rices."',`free_stores`=`free_stores` - '".($eat_rices)."' where `u_id`='".$UserId."'");
		
		/////////////////上月报表接口//////////////////////////////
		
		/////////////////////////////////////////////////////////
		
		if($query)
		$db->query("insert into land_explore(`l_id`,`u_id`,`c_id`,`l_person`,`l_type`,`l_time`,`l_start_time`,`l_end_time`) values('','".$UserId."','".$CityId."','".$explore_person."',
		  '".$explore_land_type."','".$explore_need_time."','".time()."','".(time()+$explore_need_time * 60)."') ");
		//删除上一次探索完成的记录
		$db->query("delete from land_explore where `u_id`='".$UserId."' and `c_id`='".$CityId."' and `l_flag`='1'");
		echo "<script>";
   	    echo "parent.infomation.refresh_resource();";
   	    echo "</script>";
		echomsg("","?");
	}else echomsg("探索任务正在进行");
}

//获取探索任务
//$query=$db->query("select * from land_explore where `u_id`='".$UserId."' and `c_id`='".$CityId."'");
//while($row=$db->fetch_array($query)) $explore_list[]=$row;

$rs=$db->query("select l_person from land_explore where `u_id`='".$UserId."' and `c_id`='".$CityId."' and `l_flag`='0'");
$explore_total_person=$db->fetch_array($rs);

//取消探索任务
if($_GET['action']=="chanel_explore"){
	
	if($explore_list <> "") foreach ($explore_list as $row){

		if($row['l_flag']=="0"){
			//还原粮食资源
			//$query=$db->query("update resource r,city c set `c`.`free_house`=`c`.`free_house` - '".$row['l_person']."',`r`.`rices`=`r`.`rices`+'".($row['l_person'] * $explore_eat_rices)."' where `r`.`u_id`=`c`.`u_id` and r.`u_id`='".$UserId."' and c.`c_id`='".$CityId."'");
            $query=$db->query("update resource set `rices`=`rices`+'".($row['l_person'] * $explore_eat_rices)."',`free_stores`=`free_stores`+'".($row['l_person'] * $explore_eat_rices)."' where `u_id`='".$UserId."'");
            break;
		}
	}
	
	$db->query("delete from land_explore where `u_id`='".$UserId."' and `c_id`='".$CityId."' and `l_flag`='0' and `l_id`='".$_GET['explore_id']."'");
	update_resource();
	echomsg("","?");
	
}

//获取探索时间
if($explore_list<>"") foreach($explore_list as $i=>$m){
	$complate_time=$m['l_end_time'];
	$remain_hours=(floor(($complate_time-time())/3600)<1) ? 0 : floor(($complate_time-time())/3600);
	$remain_minutes=(floor(($complate_time-time()-($remain_hours*3600))/60)<1) ? 0 : floor(($complate_time-time()-($remain_hours*3600))/60);
	$remain_seconds=($complate_time-time()) - (($remain_hours*3600)  + ($remain_minutes*60));
}
	


$db->close();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>土地探索</title>

<link href="css/id.css" rel="stylesheet" type="text/css">
<link href="css/css.css" rel="stylesheet" type="text/css">
<link type="text/css" href="css/build.css" rel="stylesheet">
<link type="text/css" href="css/box.css" rel="stylesheet">

<style>
body{
margin-top:0px;
}
.li_description {list-style:square; color:RED;}
</style>

</head>

<body>
<script language="javascript">
function show_max(){
   if(document.getElementsByName("max_select")[0].checked==true){
   	  document.explore.explore_person.value='30';
   }else{
      document.explore.explore_person.value='';
   }
   
   
}

<?php if($remain_hours or $remain_minutes or $remain_seconds) { ?>  
var hour,min,sec
hour=<?php echo $remain_hours;?>;
min=<?php echo $remain_minutes;?>;
sec=<?php echo $remain_seconds;?>;
function tick() {
sec-=1;
if (sec==-1){
min-=1
sec=59
}
if (min==-1){
if (hour!=0){
hour-=1
min=59
}
}
if (sec<=0 && min<=0 && hour<=0){
Clock1.innerHTML ="<a href=?>已完成</a>";
Clock2.innerHTML ="已完成";
<?php 
if($explore_list<>"") foreach ($explore_list as $i=>$m){
  if($i>1) break;
  if($m['l_result']=="" or $m['l_result']=="0") { 
?>
self.window.location='?';
<?php } } ?>
}else{
Clock1.innerHTML =hour+"小时"+min+"分"+sec+"秒";
window.setTimeout("tick();", 1000);
}
}
window.onload = tick;
<?php } ?>
</script>

<!--导航-->
<?php require_once("study_daohang.htm");?>

<div id="mb_01">
	<div class="page_build_title">土地探索</div><a name="top"></a>
</div>
<div id="mb_04">

<!--替换区域开始-->

<form name="explore" action="" method="POST">
<input type="hidden" name="action" value="explore_do">

<div class="produce_line2" style="padding-top:20px;">
		<span>已派出的探索者:</span><span  class="wy_05"><?php if($explore_total_person['l_person']>0) echo $explore_total_person['l_person'];else echo "0";?>人</span>
		<span>探索一次最大可指派:</span><span  class="wy_05"><?php echo $init_explore_person;?>人</span>
		<span>一个探索者消耗:<span class="wy_05">100粮食</span></span>
</div>


<!--替换区域开始-->

<form name="explore" action="" method="POST">
<input type="hidden" name="action" value="explore_do">
  
<!--------队列阴影框----------->
<div class="out" style="margin-top:10px;">
  <div class="in">
    <div class="fox">
	  <div class="fom">
	    <!--------内部队列框----------->
		  <div class="med1_01">
		    <img src="images/med_01.gif" class="bac"/ >
			 <div class="produce_02"><strong>搜索人数</strong></div>
			 <div class="produce_04"><strong>陆地类型</strong></div>
			 <div class="produce_041"><strong>所需时间</strong></div>
			 <div class="produce_04"><strong>剩余时间</strong></div>
			 <div class="produce_042"><strong>发现陆地</strong></div>
			 <div class="produce_161"><strong>操作命令</strong></div>
		     <img src="images/med_02.gif"  class="bac"/>		 
	      </div>
	      
   <?php if($explore_list<>"") foreach ($explore_list as $i=>$m){ ?>
		  <div class="produce_07" style="color:#4C2805 "><?php echo $m['l_person'];?></div>
		  <div class="produce_03" style="color:#4C2805 "><?php echo $lands_type[$m['l_type']];?></div>
		  <div class="produce_03" style="color:#4C2805; ">
		  <?php 
			  $need_time= $m['l_time'];
			  $need_time = $need_time * 60;
			  $hours = (int)($need_time / 3600);
			  $minutes = (int)($need_time % 3600 / 60);
			  $seconds = (int)($need_time % 60);
			  if($hours<24){
			      echo $hours."小时".$minutes."分".$seconds."秒";
			  }else{
			  	  $days = round($hours / 24,0);
			  	  $hours = substr($hours % 24,0,2);
			  	  echo $days."天".$hours."小时".$minutes."分".$seconds."秒";
			  }
		  ?>
		  </div>
		  <div class="produce_03" style="color:#4C2805; font-weight: bold;"><span id="Clock1"></span></div>
		  <div class="produce_033" style="color:#4C2805; ">
		  <?php 
		  if($m['l_result']=="" or $m['l_result']=="0") echo "正在探索";
		  else{
		  	$explore_land=explode("|",$m['l_result']);
		  	$explore_hills=$explore_land[0];
		  	$explore_woodlands=$explore_land[1];
		  	$explore_flats=$explore_land[2];
		  	if($explore_hills<>"") echo $explore_hills."山地";
		  	if($explore_woodlands<>"") echo $explore_woodlands."林地";
		  	if($explore_flats<>"") echo $explore_flats."平地";
		  }
		  ?>
		  </div>
		  <div class="produce_032" style="color:#096F88; font-weight: bold;">
		  <span id="Clock2"><?php if($m['l_flag']=="0") { ?><a href="?action=chanel_explore&explore_id=<?php echo $m['l_id'];?>"><span style="color:RED;">取消探索</span></a><?php }else echo "已完成"; ?></span>
		  </div>
		  <?php } ?>
		  <div>
		    <img src="images/med_03.gif" class="bac" />
			 <div class="produce_102" style="padding-top:5px;">
			<?php if(!$explore_total_person['l_person']) { ?>
			 指派:<input type="text" name="explore_person" size="6" value="<?php //if($alow_explore_person>=30) echo "30";elseif($alow_explore_person>0 and $alow_explore_person<30) echo $alow_explore_person;else echo "0";?>" size="12">个探索者,<input type="checkbox" name="max_select" onclick="show_max();">最大<select name="land_type" style="display:none;">
			
			 <option value="all_lands">所有陆地</option>
			</select><a href="javascript:this.explore.submit();" class="d">【开始探索】</a> 一次只能进行一项探索任务
			<?php }else{ ?>
			正在执行探索任务...
			<?php } ?>
			</div>
		 <img src="images/med_04.gif" class="bac" />
		 </div>
		<!--------内部队列框----------->
	  </div>
	</div>
  </div>
</div>
<!--------------队列阴影框----------->
</form>

<div style="padding-bottom:120px;"> </div>

<div id="mb_03"></div>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -