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

📄 armament_produce_create_task.php

📁 Download you own three BR
💻 PHP
字号:
<?php
//武器装备生产任务队列
if($_POST['action']=="armament_produce"){
  
  //读取用户提交的表单数据|||||||||||||||||||||||||||||||||||||||||||||||||||
  if(!eregi("^[0-9]+$",trim($_POST['arm_num']))) echomsg("请输入需要生产的武器数量!");
  $arm_type=$_POST['a_type'];
  $arm_num=trim($_POST['arm_num']);
  if(($arm_num<1 or strlen($arm_num)<1)) echomsg("");
  
  //根据提交生产的武器装备类型读取相应的所消耗资源的基础值||||||||||||||||||||||||
  $query=$db->query("select * from armament_attribute where `a_type`='".$arm_type."'");
  $task_base_result=$db->fetch_array($query);

  //获取当前城池及总资源的最新数据////|||||||||||||||||||||||||||||||||||||||||
  $query=$db->query("select * from resource as r,city as c where r.`u_id`=c.`u_id` and r.`u_id`='".$_COOKIE['UserId']."' and c.`c_id`='".$_COOKIE['CityId']."'");
  $task_totalresource_result=$db->fetch_array($query);

  //计算所需消耗资源及时间////||||||||||||||||||||||||||||||||||||||||||||||||
  //$armamenting_rices= $arm_num * $task_base_result['a_rices'];
  $armamenting_woods= $arm_num * $task_base_result['a_woods'];//木材
  $armamenting_irons= $arm_num * $task_base_result['a_irons'];//矿石
  $armamenting_golds= $arm_num * $task_base_result['a_golds'];//黄金
    //根据武将智力算出建造提升的速度
  	if($_POST['hero']<>"-1"){
  		$g_intellect=explode("|",$_POST['hero']);
  		$hero_spead_time=$g_intellect[1]*$hero_spead_percent;
  	}else $hero_spead_time=0;
  $armamenting_times= $arm_num * $task_base_result['a_time']; //所需时间:以分钟为单位
  $armamenting_times = round($armamenting_times - $armamenting_times * $hero_spead_time,0);//武将加速
  
  //使用仓库空间大小
  $allready_used_store=$armamenting_woods + $armamenting_irons + $armamenting_golds;
   	 	
  //进行生产判断:消耗资源及所需研究等级要求||||||||||||||||||||||||||||||||||||||||||
  switch ($arm_type){
  	case 1:
  	case 2:{
  		if($work_house_result['b_work_house']<1) echomsg("需要升级武器工房1级");
  		if($study_result['s_smelt']<1 and $arm_type=="1" or $study_result['s_smelt']<4 and $arm_type=="2") echomsg($task_base_result['need_study']);
  		break;
  	}
  	case 3:
  	case 4:
  	case 5:{
  		if($work_house_result['b_work_house']<2) echomsg("需要升级武器工房2级");
  		if($study_result['s_arm']<1 and $arm_type=="3" or $study_result['s_loricae']<1 and $arm_type=="4" or $study_result['s_loricae']<2 and $study_result['s_smelt']<10 and $arm_type=="5") echomsg($task_base_result['need_study']);
  		break;
  	}
  	case 6:
  	case 7:
  	case 8:{
  		if($work_house_result['b_work_house']<3) echomsg("需要升级武器工房3级");
  		if($study_result['s_arm']<2 and $arm_type=="6" or $study_result['s_arm']<2 and $arm_type=="7" or $study_result['s_arm']<5 and $arm_type=="8") echomsg($task_base_result['need_study']);
  		break;
  	}
  	case 9:
  	case 10:{
  		if($work_house_result['b_work_house']<4) echomsg("需要升级武器工房4级");
  		if($study_result['s_arm']<5 and $arm_type=="9" or $study_result['s_loricae']<4 and $arm_type=="10") echomsg($task_base_result['need_study']);
  		break;
  	}
  	case 11:
  	case 12:{
  		if($work_house_result['b_work_house']<5) echomsg("需要升级武器工房5级");
  		if($study_result['s_engine']<2 and $study_result['s_wheel']<2 and $arm_type=="11" or $study_result['s_arm']<7 and $study_result['s_trajectory']<2 and $study_result['s_engine']<1 and $arm_type=="12") echomsg($task_base_result['need_study']);
  		break;
  	}
  	case 13:
  	case 14:
  	case 15:{
  		if($work_house_result['b_work_house']<6) echomsg("需要升级武器工房6级");
  		if($study_result['s_arm']<11 and $study_result['s_steel']<1 and $arm_type=="13" or $study_result['s_loricae']<9 and $study_result['s_steel']<1 and $arm_type=="14" or $study_result['s_loricae']<15 and $study_result['s_steel']<2 and $arm_type=="15") echomsg($task_base_result['need_study']);
  		break;
  	}
  	case 16:
  	case 17:{
  		if($work_house_result['b_work_house']<7) echomsg("需要升级武器工房7级");
  		if($study_result['s_arm']<13 and $study_result['s_steel']<3 and $arm_type=="16" or $study_result['s_arm']<17 and $study_result['s_steel']<5 and $arm_type=="17") echomsg($task_base_result['need_study']);
  		break;
  	}
  	case 18:
  	case 19:{
  		if($work_house_result['b_work_house']<8) echomsg("需要升级武器工房8级");
  		if($study_result['s_arm']<19 and $study_result['s_trajectory']<4 and $study_result['s_engine']<3 and $study_result['s_wheel']<3 and $arm_type=="18" or $study_result['s_arm']<20 and $study_result['s_trajectory']<5 and $study_result['s_engine']<5 and $study_result['s_wheel']<5 and $arm_type=="19") echomsg($task_base_result['need_study']);
  		break;
  	}
  }
  //判断资源是否足够
  if($armamenting_woods > $task_totalresource_result['woods']) echomsg("木材资源不足!");
  if($armamenting_irons > $task_totalresource_result['ores']) echomsg("铁矿资源不足!");
  if($armamenting_golds > $task_totalresource_result['golds']) echomsg("黄金资源不足!");
  
  if($query){
   	    //扣除成功,将武器装备生产放入武器装备生产队列表中
   	    //判断已经存在几个队列
   	    $query=$db->query("select count(id) from armament_task where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
   	    $rn=$db->result($query,0);
   	    if($rn>=5) echomsg("生产队列已满!");
   	    
   	    //进行资源扣除: ---  武器装备生产、升级
		$query=$db->query("update resource as r,city as c set r.`free_stores`=(r.`free_stores`-'".(int)$allready_used_store."'),r.`rices`=(r.`rices`-'".(int)$armamenting_rices."')
   	 ,r.`woods`=(r.`woods`-'".(int)$armamenting_woods."'),r.`ores`=(r.`ores`-'".(int)$armamenting_irons."'),r.`golds`=(r.`golds`-'".(int)$armamenting_golds."') where r.`u_id`=c.`u_id` and r.`u_id`='".$_COOKIE['UserId']."' and c.`c_id`='".$_COOKIE['CityId']."'");

   	    //[用做内测加速调整]/////////////////////////////////////////////
   	    $armamenting_times=$armamenting_times * $speed_percent;
   	    ////////////////////////////////////////////////////////////
   	    
   	    //首先判断是否已经存在武器生产队列
   	    $query=$db->query("select a_sort,a_end_time from armament_task where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."' order by id desc limit 1");
   	    $row=$db->fetch_array($query);
   	    if($row['a_sort']){//如果已存在,则获取它的完成时间
   	    	$a_sort=$row['a_sort']+1;
   	    }else{
   	    	$a_start_time=time();
   	    	$a_sort=1;
   	    	$a_end_time=$a_start_time + $armamenting_times * 60;//结束时间
   	    } 
   	    
   	    $query=$db->query("insert into armament_task(`id`,`u_id`,`c_id`,`a_type`,`a_num`,`a_time`,`a_start_time`,`a_end_time`,`a_sort`) values('','".$_COOKIE['UserId']."','".$_COOKIE['CityId']."','".$arm_type."','".$arm_num."','".$armamenting_times."','".$a_start_time."','".$a_end_time."','".$a_sort."')");
   	    
   	    update_resource();
   	    if($query) echomsg("","?arm_produce=arm");
   	 }
}

//获取武器装备生产任务队列
$query=$db->query("select * from armament_task where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."' order by a_sort");
while($row=$db->fetch_array($query)) $current_task_list[]=$row;

//取消武器装备生产队列
if($_GET['a_action']=="clear_armamenting_task"){
	
	if($_GET['arm_sum']>1){
		foreach ($current_task_list as $i=>$m){
			if($i==1){
				$db->query("update armament_task set `a_end_time`='".(time()+$m['a_time']*60)."' where `id`='".$m['id']."'");
				break;
			}
		}
	}
	
	//根据提交生产的武器装备类型读取相应的所消耗资源的基础值||||||||||||||||||||||||
    $query=$db->query("select * from armament_attribute where `a_type`='".$_GET['a_type']."'");
	$task_base_result=$db->fetch_array($query);
	
	//取得当前要取消的武器装备生产任务的信息
	$query=$db->query("select * from armament_task where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."' and `id`='".$_GET['a_id']."'");
	$chanel_result=$db->fetch_array($query);
	
	$chanel_result['a_rices'] = $chanel_result['a_num'] * $task_base_result['a_rices'];
	$chanel_result['a_woods'] = $chanel_result['a_num'] * $task_base_result['a_woods'];
	$chanel_result['a_irons'] = $chanel_result['a_num'] * $task_base_result['a_irons'];
	$chanel_result['a_golds'] = $chanel_result['a_num'] * $task_base_result['a_golds'];
	
	$allready_used_store = $chanel_result['a_rices'] + $chanel_result['a_woods'] + $chanel_result['a_irons'] + $chanel_result['a_golds'];

	//取消生产任务时,还原资源
   	 $query=$db->query("update resource as r,city as c set r.`free_stores`=(r.`free_stores`+'".($allready_used_store)."'),r.`rices`=(r.`rices`+'".($chanel_result['a_rices'])."')
   	 ,r.`woods`=(r.`woods`+'".($chanel_result['a_woods'])."'),r.`ores`=(r.`ores`+'".($chanel_result['a_irons'])."'),r.`golds`=(r.`golds`+'".($chanel_result['a_golds'])."')  where r.`u_id`=c.`u_id` and r.`u_id`='".($_COOKIE['UserId'])."' and c.`c_id`='".$_COOKIE['CityId']."'");

	$query=$db->query("delete from armament_task where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$CityId."' and `id`='".$_GET['a_id']."'");
	update_resource();
	if($query) echomsg("","?");
}


//获取当前任务的完成时间差
if($current_task_list<>"") foreach($current_task_list as $i=>$m){
	if($i==0){
		$complate_time=$m['a_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));
        break;
	}
}

?>

⌨️ 快捷键说明

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