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

📄 armament_action_task.php

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

//当前拥有士兵数
$query=$db->query("select * from soldier where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
$soldier_result=$db->fetch_array($query);

//读取士兵训练基础表
$query2=$db->query("select * from soldier_attribute");
while($row2=$db->fetch_array($query2)) $soldier_list[]=$row2;

//我的武将列表
$hero_query=$db->query("select * from gen g1,m_gen g2 where g1.`g_gid`=g2.`id` and g1.`g_uid`='".$_COOKIE['UserId']."' and g1.`g_cid`='".$_COOKIE['CityId']."' and g1.`g_status`='0'");
while($row=$db->fetch_array($hero_query)) $my_hero_list[]=$row;
//////////////////////////////////////////

//军事行动任务队列
if($_GET['action']=="attack"){
  //if($_COOKIE['UserId']<>"245" and $_COOKIE['UserId']<>"236" and  $_COOKIE['UserId']<>"478") echomsg("你与对方等级相差太大,无法派兵出征","armament_action.php?action_type=".$action_type);
		
  //////////////////////////获取基础表单数据////////////////////////////////////////////////
 $action_type = (int)$_POST['action_type'];
  $area = (int)trim($_POST['area']);
  $area_x = (int)trim($_POST['area_x']);
  //$area_y = (int)trim($_POST['area_y']);
  $c_id2 = explode("|",$_POST['city_id2']);
  $gen_data = explode("|",$_POST['gen']);//选择的武将
  $gen = $gen_data[0];
  $gen_name = $gen_data[1];
  if($action_type<0 or $action_type>7) echomsg("没有此攻击方式","armament_action.php?action_type=".$action_type);
  
  ///////////////////////////////////////////士兵种类及数量////////////////////////////
  
  if($action_type=="5"){//筑城(占领空城)
  	 $soldier_type = 8;
  	 $soldier_num = 1;
  	 $total_soldier_num =1;
  	 /*echo $soldier_type.'<br/>';
  	 echo $soldier_num;
  	 exit;*/
  }elseif($action_type=="3"){//探子派遣
  	 $soldier_num = (int)trim($_POST['tai_num']);
  	 //echo $soldier_num;exit;
  	 if(!is_numeric($soldier_num) or $soldier_num<1) echomsg("间谍任务,需要派遣1个以上的探子!","armament_action.php?action_type=".$action_type);
  	 $total_soldier_num = $soldier_num;
  	 /*echo $soldier_type.'<br/>';
  	 echo $soldier_num;
  	 exit;*/
  }else{//掠夺和输送
  	 /*echo $soldier_type.'<br/>';
  	 echo $soldier_num;
  	 exit;*/
  	 /*for($i=1;$i<=count($soldier_list);$i++){
  	 	if((int)$_POST['soldier_num'.$i]<1) $_POST['soldier_num'.$i]=0;
  	 	if(!is_numeric((int)trim($_POST['soldier_num'.$i]))) echomsg("士兵数量输入不规范!","armament_action.php?action_type=".$action_type);
  	 	$total_soldier_num += (int)$_POST['soldier_num'.$i];
  	 	if($i==count($soldier_list)) $soldier_type .= $i;
  	 	else $soldier_type .= $i."|";
  	 	if($i==count($soldier_list)) $soldier_num .= (int)$_POST['soldier_num'.$i];
  	 	else $soldier_num .= (int)$_POST['soldier_num'.$i]."|";
  	 }*/
  	  
  	 $soldier_type = $_POST['soldier_type'];
  	 $get_post=Code_unpass($_POST['soldier_num']);
  	    if (!$get_post[0]==$_COOKIE['array_code']) echomsg("非正常提交!","soldier_educate.php?build_page=army");
  	    setcookie("array_code","",time()-30,"/");
	$_COOKIE['array_code']="";
	 $soldier_num=$get_post[1];
	  $_POST['soldier_num']=$get_post[1];
 for($i=2;$i<=17;$i++){
  $_POST['soldier_num']=$_POST['soldier_num']."|".$get_post[$i];
  $soldier_num=$soldier_num."|".$get_post[$i];
 }
   foreach ($soldier_list as $i2=>$m2){
  	   	  $i2++; $get_post=Code_unpass( $_POST['soldier_num'.$i2]); 	   	
	  $_POST['soldier_num'.$i2]=$get_post[1];  

}

for($i3=1;$i3<17;$i3++){
	if($soldier_result[$soldier_type_name_en[$_POST['soldier_type'.$i3]]]<$_POST['soldier_num'.$i3])echomsg("非正式提交!","soldier_educate.php?build_page=army");
	//echo $soldier_result[$soldier_type_name_en[$_POST['soldier_type'.$i3]]]."|".$_POST['soldier_num'.$i3]."<br>";
}
//exit;
  }
  
  //$soldier_type = $_POST['soldier_type'];
  //$soldier_num = $_POST['soldier_num'];
  
  //根据读取用户提交的表单数据进行判断|||||||||||||||||||||||||||||||||||||||||||||||||||
  //----公共判断-----//
  $public_falg="player_public_info";
  include("public_function_class.php");//调用公共文件库
  //判断是否为空城
  $query=$db->query("select c_type,u_id,c_id from city where `c_area`='".$area."' and `c_area_x`='".$area_x."' ");
  $is_empty_city=$db->num_rows($query);
  $is_empty_city2=$db->fetch_array($query);
  //判断目标城池是否在保护期内
  //echo $area."|".$area_x."|".$is_empty_city2['u_id'];exit;
  $query = $db->query("select * from player_info where `u_id`='".$is_empty_city2['u_id']."'");
  $player_info_result = $db->fetch_array($query);
  
  $query = $db->query("select * from player_info where `u_id`='".$_COOKIE['UserId']."'");
  $me_player_info_result = $db->fetch_array($query);
  
  if(time() < $me_player_info_result['create_date']+$me_player_info_result['protect_date']*24*60*60) echomsg("您当前处于保护期内,无法发起军事行动","armament_action.php?action_type=".$action_type);
        
  //echo $player_info_result['p_grade'];exit;
  //玩家选择的武将是否存在
  $query = $db->query("select id,g_fy,g_gid,g_command,bf_command from gen where `g_uid`='".$_COOKIE['UserId']."' and `g_gid`='".$gen."' and `g_cid`='".$_COOKIE['CityId']."'");
  $gen_exists = $db->num_rows($query);
  $gen_info =$db ->fetch_array($query);
  $query  = $db->query("select * from resource where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
  $study_result = $db->fetch_array($query);
    
  switch ($action_type){
  	case 2:
  	case 5:{
  		if($study_result['golds'] < (int)$_POST['golds'] or $study_result['rices'] < (int)($_POST['rices']) or $study_result['woods'] < (int)($_POST['woods']) or $study_result['ores'] < (int)($_POST['irons'])){
  			echomsg("运输资源超出最大携带量!","armament_action.php?action_type=".$action_type);
  		}
  		if((int)$_POST['take_num'] < ((int)$_POST['golds'] + (int)$_POST['rices'] + (int)$_POST['woods'] + (int)$_POST['irons'])  ){
  			echomsg("运输资源超出最大携带量!","armament_action.php?action_type=".$action_type);
  		}
  		break;
  	}  	
  }
  
  switch ($action_type){
  	case 2:{//输送(军队)
  		
  		//判断目标城池是否建造了军营
  		$query = $db->query("select b_barracks from building where `u_id`='".$is_empty_city2['u_id']."' and `c_id`='".$is_empty_city2['c_id']."'");
  		$barracks_grade = $db->fetch_array($query);
  		if(!$barracks_grade['b_barracks']) echomsg("目标城池还没有建造军营!","armament_action.php?action_type=".$action_type);
  		$current_city_soldier_num=0;
  		//判断目标城池士兵人数
	  		//当前城池士兵数/////////
			$query=$db->query("select * from soldier where `u_id`='".$is_empty_city2['u_id']."' and `c_id`='".$is_empty_city2['c_id']."'");
			$current_city_soldier = $db->fetch_array($query);
			if($soldier_type_name_en) foreach ($soldier_type_name_en as $si=>$sm){
			    if(!$current_city_soldier[$sm]) continue; 
				$current_city_soldier_num += $current_city_soldier[$sm];
			}
			//当前城市拍卖等待上架士兵数统计
			$query_safe_ls_soldier=$db->query("select sum(s_num) as soldier_num from player_lin where u_id='".$is_empty_city2['u_id']."' and c_id='".$is_empty_city2['c_id']."' and s_style='1';");
			$list_safe_ls_soldier=$db->fetch_array($query_safe_ls_soldier);
			$current_city_soldier_num+=$list_safe_ls_soldier['soldier_num'];
			
			//当前城市拍卖巳上架士兵数统计
			$query_safe_soldier=$db->query("select sum(s_num) as soldier_num from player_safe where u_id='".$is_empty_city2['u_id']."' and c_id='".$is_empty_city2['c_id']."' and s_style='1';");
			$list_safe_soldier=$db->fetch_array($query_safe_soldier);
			$current_city_soldier_num+=$list_safe_soldier['soldier_num'];
			
			//当前出征士兵数
			$query_war_soldier=$db->query("select * from war_task where u_id='".$is_empty_city2['u_id']."' and c_id='".$is_empty_city2['c_id']."';");
			while ($list_war_soldier=$db->fetch_array($query_war_soldier)){
				$soldier_n_a=explode("|",$list_war_soldier['w_soldier_num']);
				$count_n=count($soldier_n_a);
				for ($i=0;$i<$count_n;$i++){
					$current_city_soldier_num+=$soldier_n_a[$i];
				}
			}
			
			//当前要运到目标城池的士兵数
			$query_war_soldier=$db->query("select * from war_task where w_type='2' and to_u_id='".$is_empty_city2['u_id']."' and to_c_id='".$is_empty_city2['c_id']."';");
			while ($list_war_soldier=$db->fetch_array($query_war_soldier)){
				$soldier_n_a=explode("|",$list_war_soldier['w_soldier_num']);
				$count_n=count($soldier_n_a);
				for ($i=0;$i<$count_n;$i++){
					$current_city_soldier_num+=$soldier_n_a[$i];
				}
			}
			//当前目标城池训练士兵数
			$query_soldier_task=$db->query("select sum(s_num) as soall from soldier_task where u_id='".$is_empty_city2['u_id']."' and c_id='".$is_empty_city2['c_id']."';");
			$list_soldier_task=$db->fetch_array($query_soldier_task);
			$current_city_soldier_num+=$list_soldier_task['soall'];
			
			//减少每种士兵数量与总士兵数
	  	    foreach ($soldier_list as $i3=>$m3){

⌨️ 快捷键说明

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