📄 armament_unite_task.php
字号:
<?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_unite.php?action_type=".$action_type);
//----公共判断-----//
$query=$db->query("select u_id,c_id,c_area,c_area_x,c_area_y from city where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
$player_public_result = $db->fetch_array($query);
////判断是否对一个目标重复发起进攻
$area_xyz=$area.":".$area_x;
$query=$db->query("select * from war_task where `u_id`='".$_COOKIE['UserId']."' and `w_to`='".$area_xyz."'and `w_type`='6'");
$is_re=$db->num_rows($query);
if($is_re)echomsg("你已派遣部队出征到该目标","armament_unite.php?action_type=".$action_type);
//判断是否玩家发起和参加对目标的进攻
$query=$db->query("select * from union_action where (`u_id`='".$_COOKIE['UserId']."' or `group_uid1`='".$_COOKIE['UserId']."' or `group_uid2`='".$_COOKIE['UserId']."' or `group_uid3`='".$_COOKIE['UserId']."' or `group_uid4`='".$_COOKIE['UserId']."')and `area_xy`='".$area_xyz."'and `title`='1' ");
$is_g=$db->num_rows($query);
if(!$is_g)echomsg("你未发起或参加对该目标的联合进攻","armament_unite.php?action_type=".$action_type);
//判断是否为空城
$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);
//判断目标城池是否在保护期内
$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);
//判断武将是否已经出征
$query_2 = $db->query("select count(*) from war_task where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."' and `w_gen`='".$gen."'");
if($db->result($query_2,0)) echomsg($gen_name."已经出征,无法再次派遣!","armament_unite.php?action_type=".$action_type);
//判断是否为防御武将
if($gen_info['g_fy']=="1"){
// $db->query("delete from city_recovery where `g_gid`='".$gen_info['g_gid']."' and `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
echomsg("防御武将,无法派遣出征","armament_unite.php?action_type=".$action_type);
}
//检测坐标有效性
if(!is_numeric($area) or !is_numeric($area_x)) echomsg("坐标输入不规范!","armament_unite.php?action_type=".$action_type);
//if(!is_numeric($soldier_num_list[1]) or !is_numeric($soldier_num_list[2]) or !is_numeric($soldier_num_list[3]) or !is_numeric($soldier_num_list[4]) or !is_numeric($soldier_num_list[5]) or !is_numeric($soldier_num_list[6])) echomsg("士兵数输入不规范","armament_action.php?action_type=".$action_type);
//判断攻击对象是否为自己和是否有效
if($area==$player_public_result['c_area'] and $area_x==$player_public_result['c_area_x']) echomsg("无法对自己进行".$war_type[$action_type],"armament_unite.php?action_type=".$action_type);
if($_COOKIE['UserId']==$is_empty_city2['u_id']) echomsg("无法对自己进行".$war_type[$action_type],"armament_unite.php?action_type=".$action_type);
//判断对方等级是否低于我方
$query=$db->query("select p_grade from player_info where `u_id`='".$_COOKIE['UserId']."'");
$wo_result = $db->fetch_array($query);
if($wo_result['p_grade'] >= $is_empty_city2['p_grade']){
$grade1 = $wo_result['p_grade'] - $player_info_result['p_grade'];
}else{
$grade2 = $player_info_result['p_grade'] - $wo_result['p_grade'];
}
$grade = abs($grade);
// if($grade1>6 or $grade2>8) echomsg("你与对方等级相差太大,无法派兵出征","armament_unite.php?action_type=".$action_type);
//if($_COOKIE['UserId']<>"245") echomsg("你与对方等级相差太大,无法派兵出征","armament_action.php?action_type=".$action_type);
//echomsg("你与对方等级相差太大,无法派兵出征","armament_action.php?action_type=".$action_type);
//判断出征间隔时间,不能小于5秒
$query = $db->query("select w_start_time from war_task where `u_id`='".$_COOKIE['UserId']."'");
while($war_time = $db->fetch_array($query)){
if(time()-$war_time['w_start_time']<=30) echomsg("出征间隔不能少于5秒!","armament_unite.php?action_type=".$action_type);
}
//判断一天之内联合进攻次数
$all_ac=0;
$query=$db->query("select * from union_action where `u_id`='".$_COOKIE['UserId']."' or group_uid1='".$_COOKIE['UserId']."' or group_uid2='".$_COOKIE['UserId']."' or group_uid3='".$_COOKIE['UserId']."' or group_uid4='".$_COOKIE['UserId']."';");
while ($union_result = $db->fetch_array($query)) {
if ($union_result['times']+24*60*60<=time()) {
$db->query("delete from union_action where id='".$union_result['id']."';");
}else {
$all_ac++;
}
}
if($all_ac>=3) echomsg("1天最多只能联合进攻3次!","armament_unite.php?action_type=".$action_type);
$actiontimes=0;
$query_guai=$db->query("select * from city_boss where w_to_x='".$area."' and w_to_y='".$area_x."';");
$guai_num=$db->num_rows($query_guai);
//目标城池是否存在
if (!$guai_num) {
if($is_empty_city<1) echomsg("目标城池为空,无法进行".$war_type[$action_type],"armament_unite.php?action_type=".$action_type);
}
$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);
$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);
//出征消耗
$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_unite.php?action_type=".$action_type);
//if($rices['golds']< $golds) echomsg($golds."黄金不足,无法出征!","armament_action.php?action_type=".$action_type);
if($rices2['woods']< $woods) echomsg("木材不足,无法出征!","armament_unite.php?action_type=".$action_type);
if($rices2['ores']< $irons) echomsg("铁矿不足,无法出征!","armament_unite.php?action_type=".$action_type);
//判断是否拥有足够的粮食
//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']."'");
//更改武将状态;
$db->query("update gen set g_status='1' where id='".$gen_info['id']."';");
// $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']."' ");
}
// $soldier_type = $army_type1;
// $soldier_num = $army_num;
$w_to = $area.":".$area_x;
$soldier_type = $_POST['soldier_type'];
$soldier_num = $_POST['soldier_num'];
$city_name_task = $row['c_name'];
//插入战争任务表
$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']."')");
//echo $_COOKIE['CityId'];exit;
//update_resource();
refresh();
if($query) echomsg("","war_info.php");
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -