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

📄 auto_grow_resource1.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`='".$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){//循环执行资源计算//////////////////////////////
	          
		  	  //生产建筑物等级
			  $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 city as c,resource as r,player_info as p where c.`u_id`=r.`u_id` and r.`u_id`=p.`u_id` and c.`c_id`=r.`c_id` and p.`u_id`='".$_COOKIE['UserId']."' and c.`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`='".$UserId."' ");
			  $study_result=$db->fetch_array($query);
		  	
		  	  //生产时间>=1小时
		  	  //$growtime = (time()-$grow['last_grow_time'])/$produce_time;
		  	  $grow_time = ($nowtime-$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  = add_workers($b_base_result['b_base'],$grade);
		  	  echo $b_base;
		  	  //条件满足
		  	  if($grow['last_grow_time']>0 and $b_base>0){
			  	  
		  	  	  $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;
			  	  //}
			  	  //$grow_time=round($grow_time/$produce_time);//生产时间:按小时计算
			  	  $grow_time=$grow_time * 1000;
				  
			  	  	      //开始计算产量//////////////////////
			  	  	      switch ($grow['b_type']){
						 	 	case 1:{//伐木场资源计算
						 	 		$update_resource[$grow['b_type']]=  round($grow_time / add_workers($base_result['b_base'],$grade));//基*等级*1.1的(等级-1)次方(取四位小数)
						 	 		$update_resource[$grow['b_type']] = ($study_result['s_cutting']) ? $update_resource[1] + $update_resource[1] * pow(1+$s_cutting_percent,$study_result['s_cutting']-1) : $update_resource[1];
						 	 		break;
						 	 	}
						 	 	case 2:{//矿石资源计算
						 	 		$update_resource[$grow['b_type']]=  round($grow_time / add_workers($base_result['b_base'],$grade));//基*等级*1.1的(等级-1)次方(取四位小数)
						 	 		$update_resource[$grow['b_type']] = ($study_result['s_mining']) ? $update_resource[2] + $update_resource[2] * pow(1+$s_mining_percent,$study_result['s_mining']-1) : $update_resource[2];
						 	 		break;
						 	 	}
						 	 	case 3:{//金矿资源计算
						 	 		$update_resource[$grow['b_type']]=  round($grow_time / add_workers($base_result['b_base'],$grade));//基*等级*1.1的(等级-1)次方(取四位小数)
						 	 		$update_resource[$grow['b_type']] = ($study_result['s_golds']) ? $update_resource[3] + $update_resource[3] * pow(1+$s_golds_percent,$study_result['s_golds']-1) : $update_resource[3];
						 	 		break;
						 	 	}
						 	 	case 4:{//农田资源计算
						 	 		$update_resource[$grow['b_type']]=  round($grow_time / add_workers($base_result['b_base'],$grade));//基*等级*1.1的(等级-1)次方(取四位小数)
						 	 		$update_resource[$grow['b_type']] = ($study_result['s_flooding']>0) ? $update_resource[4] + $update_resource[4] * pow(1+$s_flooding_percent,$study_result['s_flooding']-1) : $update_resource[4];
						 	 		break;
					 	 	 	}
					       }//结束计算产量/////////////////////////////
					       //更新资源最后结算时间、总生产时间
						   //$last_grow_time=$nowtime;
						   //$total_grow_time=$grow_time;
	                       if($update_resource[$grow['b_type']]>0){
						   $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']."'");
	                       }
			  	}
			    
          }/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
          echo $update_resource[4]."|".$update_resource[3]."|".$update_resource[2]."|".$update_resource[1];exit;
          $report_time=time();
		  
		  //---仓库不足,记录到报表日志中
          if($update_resource1 + $building_result['woods'] > $building_result['woods_uplimit']){
          	 $update_resource1 = ($building_result['woods_uplimit'] > $building_result['woods']) ? $update_resource1 - ($building_result['woods_uplimit'] - $building_result['woods']) : $update_resource1;
          }else $update_resource1=0;
          if($update_resource2 + $building_result['ores'] > $building_result['ores_uplimit']){
          	 $update_resource2 = ($building_result['ores_uplimit'] > $building_result['ores']) ? $update_resource2 - ($building_result['ores_uplimit'] - $building_result['ores']) : $update_resource2;
          }else $update_resource2=0;
          if($update_resource3 + $building_result['golds'] > $building_result['golds_uplimit']){
          	 $update_resource3 = ($building_result['golds_uplimit'] > $building_result['golds']) ? $update_resource3 - ($building_result['golds_uplimit'] - $building_result['golds']) : $update_resource3;
          }else $update_resource3=0;
          if($update_resource4 + $building_result['rices'] > $building_result['irces_uplimit'] ){//木材
          	 $update_resource4 = ($building_result['rices_uplimit'] > $building_result['rices']) ? $update_resource4 - ($building_result['rices_uplimit'] - $building_result['rices']) : $update_resource4;
          }else $update_resource4=0;
          $update_resource1 = ($update_resource1>0) ? $update_resource1 :0;
          $update_resource2 =($update_resource2>0) ? $update_resource2 :0;
          $update_resource3 =($update_resource3>0) ? $update_resource3 :0;
          $update_resource4 =($update_resource4>0) ? $update_resource4 :0;
          if(($update_resource1 + $building_result['woods'] > $building_result['woods_uplimit']) or ($update_resource2 + $building_result['ores'] > $building_result['ores_uplimit']) or ($update_resource3 + $building_result['golds'] > $building_result['golds_uplimit']) or ($update_resource4 + $building_result['rices'] > $building_result['irces_uplimit'])){
	          //算出丢弃资源
	          $db->query("insert into report(`id`,`u_id`,`c_id`,`r_type1`,`r_type2`,`r_value`,`r_info_type`,`r_date`,`r_beizhu`) values('','".$UserId."','".$CityId."','1','1|2|3|4','".((int)$update_resource1."|".(int)$update_resource2."|".(int)$update_resource3."|".(int)$update_resource4)."','2','".$report_time."','".$report_stores_info1."')");
           }
          
          $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'];
		  //echo $update_resource[4]."<br />";
		  
		  $update_resource[1] = ($update_resource[1]>0) ? $update_resource[1] : 0;
		  $update_resource[2] = ($update_resource[2]>0) ? $update_resource[2] : 0;
		  $update_resource[3] = ($update_resource[3]>0) ? $update_resource[3] : 0;
		  $update_resource[4] = ($update_resource[4]>0) ? $update_resource[4] : 0;
		  //更新资源
		  $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']."'");
	
		  //报表记录 -- 资源增长开始:产量增长顺利、人口不足导致产量下降、仓库不足导致资源停止增长|||||||||||||||||||||||||\
		  if($building_result['free_house'] < $building_result['total_house']){
		  	 //---产量增长顺利
		  	$db->query("insert into report(`id`,`u_id`,`c_id`,`r_type1`,`r_type2`,`r_value`,`r_info_type`,`r_date`,`r_beizhu`) values('','".$UserId."','".$CityId."','1','1|2|3|4','".((int)$update_resource[1]."|".(int)$update_resource[2]."|".(int)$update_resource[3]."|".(int)$update_resource[4])."','1','".$report_time."','0')");
		  }else{
		  	 //---人口不足,提醒玩家建设民居
		  	$db->query("insert into report(`id`,`u_id`,`c_id`,`r_type1`,`r_type2`,`r_value`,`r_info_type`,`r_date`,`r_beizhu`) values('','".$UserId."','".$CityId."','0','0','0','2','".$report_time."','".$report_house_info1."')");
		  }
		  
?>

⌨️ 快捷键说明

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