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

📄 auto_grow_resource2.php

📁 Download you own three BR
💻 PHP
字号:
<?php
		  //require_once("configs/Configs.php");
		  //require_once("functions/class_mysql.php");
		  //require_once("functions/func_common.php");
		  //require_once("functions/func_common.php");
		  //////////////////////////////////////更新玩家在线状态开始///////////////////////////////////////////////
		  //$db->query("update player_info set `online`='1',`login_time`='".time()."' where `u_id`='".$UserId."'");
		  //////////////////////////////////////更新玩家在线状态结束///////////////////////////////////////////////
		  
		  ////////////////////////////////////处理系统任务开始//////////////////////////////////////////////////////////
		  //require_once("system_task_processing.php");
		  ////////////////////////////////////////////////////////////////////////////////////////////////////////
  		  
		  ////////////////////////////////////城墙修复/////////////////////////////////////////////////////////////
		  //require_once("repair_citywall_processing.php");
		  ////////////////////////////////////////////////////////////////////////////////////////////////////////
		  
		  
		  ////////////////////////////////////////资源增长开始//////////////////////////////////////////////////////
		  
		  //获取玩家每项建筑物的生产时间:resource_grow
		  $query=$db->query("select * from resource_grow where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
		  while($row=$db->fetch_array($query)) $resource_grow_list[]=$row;
		  
		  //开始按照生产安排进行资源增长
		  $nowtime  =time();
		  if($resource_grow_list) foreach ($resource_grow_list as $i=>$grow){//循环执行资源计算//////////////////////////////
	          if(!$grow['total_grow']) continue;
		  	  //echo "ok";
		  	  //生产建筑物等级
			  $query=$db->query("select * from building where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
		      $b_num=$db->fetch_array($query);
		      //基础数据
		      $query=$db->query("select * from building_attribute where `b_type`='".$grow['b_type']."'");
		      $b_base_result=$db->fetch_array($query);
		      //城池信息
			  $query=$db->query("select * from resource where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
			  $building_result=$db->fetch_array($query);
			  //读取研究技术等级表
		      $query=$db->query("select s_cutting,s_mining,s_golds,s_flooding from study where `u_id`='".$_COOKIE['UserId']."' ");
			  $study_result=$db->fetch_array($query);
			  
			  $query = $db->query("select `c_land_type` from `city` where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
			  $land_type =$db->fetch_array($query);
		  	
		  	  //生产时间>=1小时
		  	  //$growtime = (time()-$grow['last_grow_time'])/$produce_time;
		  	  $grow_time = (time()-$grow['last_grow_time']);
		  	  $grow_num  =  $b_num[$b_type_name_en[$grow['b_type']]];
		  	  $grade  = $grow_num;//建筑物的等级
		  	  $grow_time = ($grade>0) ? $grow_time : 0;
		  	  $b_base  = $grow['total_grow'];
		  	  $b_base = ($b_base) ? $b_base :1;
		  	  if($grow['total_grow']) $produce_temp = round(3600 / $grow['total_grow'],0);
		  	  //echo "3600/".$grow['total_grow']."+".$produce_resource_name[$grow['b_type']]."|".$produce_temp."|".$grow_time."=".round(($grow_time/$produce_temp),0);exit;
		  	  //echo $grow_time;exit;
		  	  //条件满足
		  	  if($grow['last_grow_time'] and $grow['total_grow'] and $grow['worker_percent'] and $produce_temp){
		  	  	  $report_time=time();
			  	  //$update_resource[$grow['b_type']]=  $grow_time / $b_base;
			  	  //echo ceil($update_resource[$grow['b_type']]);exit;
		  	  	  //$login_time=($nowtime-$building_result['login_time'])/(24*60*60);
			  	  //$query=$db->query("select * from building_attribute where `b_type`='".$grow['b_type']."'");
	              //$base_result=$db->fetch_array($query);
			  	  //登录时间:5天内已登录
			  	  //if($login_time<5){//计算所有资源//////////
					 //$grow_time =  5*24*60*60;
			  	  //}
				             $update_resource[$grow['b_type']]=  round(($grow_time/$produce_temp),0);
				          
						     switch($land_type['c_land_type']){
						     	case 1:{
						     		$update_resource[$grow['b_type']] += $update_resource[$grow['b_type']] * 0.02;
						     		break;
						     	}
						     	case 2:{
						     		if($grow['b_type']=="4"){
						     			$update_resource[$grow['b_type']] += $update_resource[$grow['b_type']] * 0.06;
						     		}
						     		break;
						     	}
						     	case 3:{
						     		if($grow['b_type']=="1"){
						     			$update_resource[$grow['b_type']] += $update_resource[$grow['b_type']] * 0.06;
						     		}
						     		break;
						     	}
						     	case 4:{
						     		if($grow['b_type']=="2"){
						     			$update_resource[$grow['b_type']] += $update_resource[$grow['b_type']] * 0.06;
						     		}
						     		break;
						     	}
						     	case 5:{
						     		if($grow['b_type']=="3"){
						     			$update_resource[$grow['b_type']] += $update_resource[$grow['b_type']] * 0.06;
						     		}
						     		break;
						     	}
						     	
						     }
						   $update_resource[$grow['b_type']] = round($update_resource[$grow['b_type']],0) * 2;
						     
	                       if($update_resource[$grow['b_type']]){
						   	    $db->query("update resource_grow set `last_grow_time`='".$nowtime."' where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."' and `b_type`='".$grow['b_type']."'");
	                       }

			  	}
			    
          }
          
          					  if($update_resource[1] + $building_result['woods'] > $building_result['woods_uplimit']){
					          	 $update_resource[1] = ($building_result['woods_uplimit'] > $building_result['woods']) ? $update_resource[1] - ($building_result['woods_uplimit'] - $building_result['woods']) : $update_resource[1];
					          }else $update_resource[1]=0;
					          if($update_resource[2] + $building_result['ores'] > $building_result['ores_uplimit']){
					          	 $update_resource[2] = ($building_result['ores_uplimit'] > $building_result['ores']) ? $update_resource[2] - ($building_result['ores_uplimit'] - $building_result['ores']) : $update_resource[2];
					          }else $update_resource[2]=0;
					          if($update_resource[3] + $building_result['golds'] > $building_result['golds_uplimit']){
					          	 $update_resource[3] = ($building_result['golds_uplimit'] > $building_result['golds']) ? $update_resource[3] - ($building_result['golds_uplimit'] - $building_result['golds']) : $update_resource[3];
					          }else $update_resource[3]=0;
					          if($update_resource[4] + $building_result['rices'] > $building_result['irces_uplimit'] ){//木材
					          	 $update_resource[4] = ($building_result['rices_uplimit'] > $building_result['rices']) ? $update_resource[4] - ($building_result['rices_uplimit'] - $building_result['rices']) : $update_resource[4];
					          }else $update_resource[4]=0;
					          
					          $update_resource[1] = ($update_resource[1]) ? $update_resource[1] :0;
					          $update_resource[2] =($update_resource[2]) ? $update_resource[2] :0;
					          $update_resource[3] =($update_resource[3]) ? $update_resource[3] :0;
					          $update_resource[4] =($update_resource[4]) ? $update_resource[4] :0;
					          					          
					          $update_resource[4] = ($building_result['rices_uplimit'] - $building_result['rices'] > $update_resource[4]) ?  $update_resource[4] : $building_result['irces_uplimit'] - $building_result['rices'];
							  $update_resource[1] = ($building_result['woods_uplimit'] - $building_result['woods'] > $update_resource[1]) ?  $update_resource[1] : $building_result['woods_uplimit'] - $building_result['woods'];
							  $update_resource[2] = ($building_result['ores_uplimit'] - $building_result['ores'] > $update_resource[2]) ?  $update_resource[2] : $building_result['ores_uplimit'] - $building_result['ores'];
							  $update_resource[3] = ($building_result['golds_uplimit'] - $building_result['golds'] > $update_resource[3]) ?  $update_resource[3] : $building_result['golds_uplimit'] - $building_result['golds'];
							  							  
							  //更新资源
							  $db->query("update resource set `woods`=`woods`+'".(int)$update_resource[1]."',`rices`=`rices`+'".(int)$update_resource[4]."',`ores`=`ores`+'".(int)$update_resource[2]."',`golds`=`golds`+'".(int)$update_resource[3]."' where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");

         
		  
?>

⌨️ 快捷键说明

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