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

📄 armament_action_task.php

📁 Download you own three BR
💻 PHP
📖 第 1 页 / 共 3 页
字号:
  
   $query=$db->query("select c_id,c_name,u_id from city where `c_area`='".$area."' and `c_area_x`='".$area_x."'");
   $is_empty_city=$db->num_rows($query);
   $row = $db->fetch_array($query);

  //---分攻击类型进行判断---//
  switch ($action_type){
  	case 5:{//筑城(占领空城)
  		if(!ereg("^[0-9]+$",$area) or !ereg("^[0-9]+$",$area_x)) echomsg("坐标输入不规范!","armament_action.php?action_type=".$action_type);
		
  		//当前需要1辆筑城队
  		if($soldier_list <> "") foreach ($soldier_list as $i=>$m) {
	       if($m['s_type']==8 and $soldier_result[$soldier_type_name_en[$m['s_type']]]<1) echomsg("当前需要筑城队,请到军事训练中进行训练!","soldier_educate.php");
        }
        //判断当前坐标ID是否超出范围
        if($area < $area_min or $area > $area_max or $area_x < $area_x_min or $area_x > $area_x_max) echomsg("城池坐标输入不正确!","armament_action.php?action_type=".$action_type);
  		//根据输入的坐标判断是否是空城
  		$city_name_task = $row['c_name'];
  		if($is_empty_city>0) echomsg("无法占领玩家城池!","armament_action.php?action_type=".$action_type);
        break;
  	}
  	case 2:{//输送士兵
  		//判断玩家输送的士兵与当前拥有士兵进行比较
  		foreach ($soldier_list as $i2=>$m2){
  			$i2++;
  			//if(!is_numeric($_POST['soldier_num'.$i2])) echomsg("士兵输入数据不符","armament_action.php?action_type=".$action_type);
  			if($soldier_result[$soldier_type_name_en[$m2['s_type']]] < (int)trim($_POST['soldier_num'.$i2])) echomsg("输送士兵数大于当前城池拥有士兵数!","armament_action.php?action_type=".$action_type);
  		}
  		break;
  	}
  }
  
  //计算攻击所需时间
  /*
  if($action_type==2){
  	 $area2 = explode(":",$c_id[2]);
  	 $area = $area2[0];
  	 $query=$db->query("select c_id,c_name,u_id from city where `c_area`='".$area."' and `c_area_x`='".$area2[1]."' ");
     $row = $db->fetch_array($query);
  }
  if($action_type==3){
	  $war_base_time = $lurcher_time;
  }  
  if($area==$player_public_result['c_area']){
		  	$action_time = $war_base_time;
		  }else{
		  	if($area > $player_public_result['c_area']) $add_num = $area - $player_public_result['c_area'];
		  	else $add_num = $player_public_result['c_area'] - $area;
		  	$action_time = $war_base_time + $add_num * $war_base_time_add;
  }
  */
  $action_time = (int)$_POST['hour'] * 60;
  $action_time += (int)$_POST['minute'];
  //$action_time *= 60;
  
  //[用做内测加速调整]/////////////////////////////////////////////   
  $action_time2=$action_time * $war_add_spead; 
  ////////////////////////////////////////////////////////////
  
  $action_start_time=time();
  $action_end_time = $action_start_time + $action_time2 * 60;
  
  $query=$db->query("select * from resource where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
  $rices2=$db->fetch_array($query);
  //基础数据
  $query=$db->query("select * from soldier_attribute where `s_type`='8'");
  $s_base_result=$db->fetch_array($query);
  
  //出征消耗
  $rices = (int)$_POST['rices'] + (int)$_POST['action_rices'];
  $golds = (int)$_POST['golds'] + (int)$_POST['action_golds'];
  $woods = (int)$_POST['woods'] + (int)$_POST['action_woods'];
  $irons = (int)$_POST['irons'] + (int)$_POST['action_irons'];
  
  if($rices2['rices']< $rices) echomsg("粮食不足,无法出征!","armament_action.php?action_type=".$action_type);
  //if($rices['golds']< $golds) echomsg($golds."黄金不足,无法出征!","armament_action.php?action_type=".$action_type);
  if($rices2['woods']< $woods) echomsg("木材不足,无法出征!","armament_action.php?action_type=".$action_type);
  if($rices2['ores']< $irons) echomsg("铁矿不足,无法出征!","armament_action.php?action_type=".$action_type);
  
  switch ($action_type){
  	case 5:{//筑城
  		  if($rices2['rices']< $_POST['rices']) echomsg("携带粮食不足,无法出征!","armament_action.php?action_type=".$action_type);
		  if($rices2['golds']< $_POST['golds']) echomsg("携带黄金不足,无法出征!","armament_action.php?action_type=".$action_type);
		  if($rices2['woods']< $_POST['woods']) echomsg("携带木材不足,无法出征!","armament_action.php?action_type=".$action_type);
		  if($rices2['ores']< $_POST['irons']) echomsg("携带铁矿不足,无法出征!","armament_action.php?action_type=".$action_type);
  	   //判断粮食是否足够
  	   //if($rices['rices']<$total_eat_rices) echomsg("没有足够的粮食用于占领空城!","armament_action.php?action_type=".$action_type);
  	   //减少资源和仓库
  	   $db->query("update resource set `rices`=(`rices`-'".$rices."'),`golds`=(`golds`-'".$golds."'),`woods`=(`woods`-'".$woods."'),`ores`=(`ores`-'".$irons."')  where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
  		
	   //更新武将工作状态
	   $query=$db->query("update gen set `g_status`='1' where `g_uid`='".$UserId."' and `g_cid`='".$CityId."' and `g_gid`='".$gen."'");
	   //减少当前城池的士兵数总数
	   //$db->query("update city set `free_barracks`=(`free_barracks`-1) where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
	   if($query) $db->query("update soldier set `zc_dui`=(`zc_dui`-'1') where `u_id`='".$UserId."' and `c_id`='".$CityId."'");
       $w_to = $area.":".$area_x;
	   break;
  	}
  	case 2:{//输送
  		 if($rices2['rices']< $_POST['rices']) echomsg("携带粮食不足,无法出征!","armament_action.php?action_type=".$action_type);
		  if($rices2['golds']< $_POST['golds']) echomsg("携带黄金不足,无法出征!","armament_action.php?action_type=".$action_type);
		  if($rices2['woods']< $_POST['woods']) echomsg("携带木材不足,无法出征!","armament_action.php?action_type=".$action_type);
		  if($rices2['ores']< $_POST['irons']) echomsg("携带铁矿不足,无法出征!","armament_action.php?action_type=".$action_type);
  	  
  	   //判断粮食是否足够
  	   //if($rices['rices'] < $total_eat_rices) echomsg("没有足够的粮食用于占领新城!","armament_action.php?action_type=".$action_type);
  	   //减少资源和仓库
  	   $db->query("update resource set `rices`=(`rices`-'".$rices."'),`golds`=(`golds`-'".$golds."'),`woods`=(`woods`-'".$woods."'),`ores`=(`ores`-'".$irons."')  where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
  		
  	   //减少每种士兵数量与总士兵数
  	   foreach ($soldier_list as $i2=>$m2){
  	   	  $i2++;
  	   	 // echo $_POST['soldier_type'.$i2]."|".$_POST['soldier_num'.$i2]."<br>";
  	   	  if(!(int)$_POST['soldier_num'.$i2]) continue;
  	   	  //echo $soldier_type_name_en[$_POST['soldier_type'.$i2]];exit;
  	   	 $db->query("update soldier set `".$soldier_type_name_en[$_POST['soldier_type'.$i2]]."`=(`".$soldier_type_name_en[$_POST['soldier_type'.$i2]]."`-'".trim((int)$_POST['soldier_num'.$i2])."') where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."' ");	   	
  	   }
  	   //exit;
  	   $w_to = $c_id2[0]."|".$c_id2[2];
  	   $city_name_task = $c_id2[1];
  	   
  	   break;
  	}
  	case 3:{
  		//减少当前探子数量和资源
  		$db->query("update soldier as s,resource as r set s.`tan_zhi`=(s.`tan_zhi`-'".$soldier_num."'),r.`rices`=(r.`rices`-'".$lurcher_need_golds."') where s.`u_id`=r.`u_id` and s.`c_id`=r.`c_id` and r.`u_id`='".$_COOKIE['UserId']."' and r.`c_id`='".$_COOKIE['CityId']."'");
  		$w_to = $area.":".$area_x;
  		$action_start_time=time();
  		$action_end_time = $action_start_time + $action_time2 * 60;
  		$total_eat_rices = 0;
  		
  		break;
  	}
  	case 0:
  	case 1:
  	case 4:
  	case 7:{
  		//判断是否拥有足够的粮食
  		//if($rices['rices']<$total_eat_rices) echomsg("没有足够的粮食用于".$war_type[$action_type]."战!","armament_action.php?action_type=".$action_type);
  	    //减少粮食资源和仓库
  	     $db->query("update resource set `rices`=(`rices`-'".$rices."'),`woods`=(`woods`-'".$woods."'),`ores`=(`ores`-'".$irons."')  where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
  		
	   //武将工作状态
	   $query=$db->query("update gen set `g_status`='1' where `g_uid`='".$_COOKIE['UserId']."' and `g_cid`='".$_COOKIE['CityId']."' and `g_gid`='".$gen."'");
	   
	   	//$soldier_type = explode("|",$army_type1);
		//$soldier_num = explode("|",$army_num);
	   //减少每种士兵数量与总士兵数
  	   foreach ($soldier_list as $i2=>$m2){
  	   	  $i2++;
  	   	  //echo $_POST['soldier_type'.$i2]."|".$_POST['soldier_num'.$i2]."<br>";
  	   	  if(!(int)$_POST['soldier_num'.$i2]) continue;
  	   	  //echo $soldier_type_name_en[$_POST['soldier_type'.$i2]];exit;
  	   	  $db->query("update soldier set `".$soldier_type_name_en[$_POST['soldier_type'.$i2]]."`=(`".$soldier_type_name_en[$_POST['soldier_type'.$i2]]."`-'".trim((int)$_POST['soldier_num'.$i2])."') where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."' ");	   	
  	   }
  	  // exit;
  	  //$soldier_type = $army_type1;
  	  //$soldier_num = $army_num;
  	  $w_to = $area.":".$area_x;
  	  $city_name_task = $row['c_name'];
	  break;
  	}
  }
  
   //插入战争任务表
   $query=$db->query("INSERT INTO `war_task` ( `w_id` , `u_id` , `c_id` ,`to_u_id` , `to_c_id`, `w_type` , `w_task_type` , `w_to` ,`w_eat_rices`,`w_eat_woods`,`w_eat_irons`,`w_city_name` , `w_soldier_type` , `w_soldier_num` , `w_gen` ,`w_gen_name`, `w_time` , `w_start_time` , `w_end_time`,`w_take_golds`,`w_take_rices`,`w_take_woods`,`w_take_irons` ) 
   VALUES ('', '".$_COOKIE['UserId']."', '".$_COOKIE['CityId']."','".$row['u_id']."', '".$row['c_id']."', '".$action_type."', '1', '".$w_to."', '".$_POST['action_rices']."','".$_POST['action_woods']."','".$_POST['action_irons']."', '".$city_name_task."', '".$soldier_type."', '".$soldier_num."', '".$gen."', '".$gen_name."', '".$action_time."', '".$action_start_time."', '".$action_end_time."', '".$_POST['golds']."', '".$_POST['rices']."', '".$_POST['woods']."', '".$_POST['irons']."')");
   $t_id=$db->insert_id();
   $no_times=$now_time+24*60*60;
   $db->query("insert into user_a_num (u_id,to_x,to_y,times,t_id) values ('".$_COOKIE['UserId']."','".$area."','".$area_x."','".$no_times."','".$t_id."');");
   //echo $_COOKIE['CityId'];exit;
   //update_resource();
   refresh();
   if($query) echomsg("","armament_action.php");
}
?>
  <script   language="JavaScript">     
  <!--     
  javascript:window.history.forward(1);     
  //-->     
  </script>  

⌨️ 快捷键说明

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