📄 armament_action_do.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");//加载数据库类文件
//当前用户研究等级;
$query123=$db->query("select * from study where `u_id` = '".$_COOKIE['UserId']."';");
$list123=$db->fetch_array($query123);
$now=array(1=>$list123['s_smelt'],2=>$list123['s_map'],3=>$list123['s_army'],4=>$list123['s_command'],5=>$list123['s_landform'],6=>$list123['s_arm'],7=>$list123['s_loricae'],8=>$list123['s_gee'],9=>$list123['s_recovery'],10=>$list123['s_engine'],11=>$list123['s_trajectory'],12=>$list123['s_mining'],13=>$list123['s_cutting'],14=>$list123['s_golds'],15=>$list123['s_flooding'],16=>$list123['s_steel'],17=>$list123['s_wheel'],18=>$list123['s_tactics'],19=>$list123['s_position']);
//当前拥有士兵数
$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;
//////////////////////////////////////////
$query=$db->query("select * from study where `u_id`='".$_COOKIE['UserId']."'");
$study_grade=$db->fetch_array($query);
$query = $db->query("select * from resource where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
$resource_result = $db->fetch_array($query);
//发起攻击开始
//require("armament_action_task.php");
//根据目标城池计算花费、距离和时间/////////////////////////////////////////////////////////////////////////
$action_type = $_POST['attack_type'];
$area = (int)trim($_POST['area']);
$area_x = (int)trim($_POST['area_x']);
$c_id2 = explode("|",$_POST['city_id']);
if(!$area or !$area_x){
$area1 = explode(":",$c_id2[2]);
$area = $area1[0];
$area_x = $area1[1];
}
$city_n=$db->query("select u_id from city where c_area='".$area."' and c_area_x='".$area_x."';");
$lis=$db->fetch_array($city_n);
$query_uid=$lis['u_id'];
//查询此玩家是否在免战牌保护期内
$query_no=$db->query("select * from add_goods_info where u_id='".$query_uid."' and type='2';");
$note_n=$db->num_rows($query_no);
$not_time=$note_g['stop_times']-time();
if ($note_n>0) echomsg("该玩家己使用免战牌!","armament_action.php?action_type=".$action_type);
//自己用了免战牌,不可以攻击别人
if ($action_type=='0' || $action_type=='7' || $action_type=='5' || $action_type=='3') {
//查询此玩家是否在免战牌保护期内
$query_no=$db->query("select * from add_goods_info where u_id='".$_COOKIE['UserId']."' and type='2';");
$note_n=$db->num_rows($query_no);
if ($note_n>0) echomsg("您己使用免战牌,不可对它人进行攻击!","armament_action.php?action_type=".$action_type);
}
$soldier_type = $_POST['soldier_type'];
$gen_speed_add=0;
//查询是否打玩家
if ($action_type=='0') {
$query_bos=$db->query("select id from city_boss where w_to_x='".$area."' and w_to_y='".$area_x."';");
$num_ls=$db->num_rows($query_bos);
if ($num_ls>=1) {
echomsg("掠夺只针对玩家有效!","armament_action.php?action_type=".$action_type);
}
}
//查询是否打玩家
if ($action_type=='7') {
$query_bos=$db->query("select id from city_boss where w_to_x='".$area."' and w_to_y='".$area_x."';");
$num_ls=$db->num_rows($query_bos);
if ($num_ls<1) {
echomsg("讨伐只针对黄巾军有效或该坐标黄金军己被消灭!","armament_action.php?action_type=".$action_type);
}
}
//echo $c_id[2]."+".$area_x."+".$action_type;exit;
if(!$area and !$area_x and $action_type<>"2" and $_GET['action']<>"attack") echomsg("请输入目标城池坐标!","armament_action.php?action_type=".$action_type);
elseif(!$c_id2[2] and $action_type=="2" and $_GET['action']<>"attack") echomsg("请输入目标城池坐标!","armament_action.php?action_type=".$action_type);
if($action_type==0) if($_POST['gen']<'0') echomsg("请选择武将!","armament_action.php?action_type=".$action_type);
if($_POST['tai_num']>$soldier_result['tan_zhi']) echomsg("输入的数量超过实际数量!","armament_action.php?action_type=".$action_type);
$soldier_counter=0;
///-------------军队花费-----------------
if($action_type=="5"){//筑城(占领空城)
if ($area>$area_max || $area_x>$area_x_max) echomsg("超过地图最大坐标!","armament_action.php?action_type=".$action_type);
$soldier_type = $_POST['soldier_type'];
$soldier_num = 1;
$total_soldier_num =1;
$query=$db->query("select s_action_rices,move_spead,take_num from soldier_attribute where `s_type`='8'");
$temp_result = $db->fetch_array($query);
$action_rices = $temp_result['s_action_rices'];
if($study_grade['s_map']){
$move_spead_temp1 = $temp_result['move_spead'] * $study_grade['s_map'] * 0.01;
}
if($study_grade['s_wheel']){
$move_spead_temp2 = $temp_result['move_spead'] * $study_grade['s_wheel'] * 0.02;
}
if($study_grade['s_gee']){
$move_spead_temp3 = $temp_result['move_spead'] * $study_grade['s_gee'] * 0.03;
}
$move_spead = $temp_result['move_spead'] + $move_spead_temp1 + $move_spead_temp2 + $move_spead_temp3;
$take_num = $temp_result['take_num'] + $temp_result['take_num'] * 0.1 * $study_grade['s_command'];
$soldier_counter=1;
if(!is_numeric($soldier_num) or $soldier_num<1) echomsg("筑城需要派遣筑城队!","armament_action.php?action_type=".$action_type);
}elseif($action_type=="3"){//探子派遣
$soldier_counter = 0;
$soldier_num = (int)trim($_POST['tai_num']);
//echo $soldier_num;exit;
if(!is_numeric($soldier_num) or $soldier_num<0) echomsg("间谍任务,需要派遣1个以上的探子!","armament_action.php?action_type=".$action_type);
$total_soldier_num = (int)trim($_POST['tai_num']);
$query=$db->query("select s_action_rices,move_spead,take_num from soldier_attribute where `s_type`='2'");
$temp_result = $db->fetch_array($query);
$action_rices = $temp_result['s_action_rices'] * $total_soldier_num;
if($study_grade['s_map']){
$move_spead_temp1 = $temp_result['move_spead'] * $study_grade['s_map'] * 0.01;
}
if($study_grade['s_wheel']){
$move_spead_temp2 = $temp_result['move_spead'] * $study_grade['s_wheel'] * 0.02;
}
if($study_grade['s_gee']){
$move_spead_temp3 = $temp_result['move_spead'] * $study_grade['s_gee'] * 0.03;
}
$move_spead = $temp_result['move_spead'] + $move_spead_temp1 + $move_spead_temp2 + $move_spead_temp3;
$take_num = $temp_result['take_num'] * $soldier_num;
$take_num = $take_num + $take_num * 0.1 * $study_grade['s_command'];
$soldier_counter=1;
$soldier_type=2;
//echo $soldier_num;exit;
}else{//掠夺和输送
for($i=1;$i<=count($soldier_list);$i++){
if($i=="2" or $i=="8"){
$_POST['soldier_num'.$i] = 0;
}else{
if((int)trim($_POST['soldier_num'.$i])){
if(!is_numeric((int)trim($_POST['soldier_num'.$i]))) echomsg("士兵数量输入不规范!","armament_action.php?action_type=".$action_type);
$query=$db->query("select s_action_rices,s_action_woods,s_action_irons,move_spead,take_num from soldier_attribute where `s_type`='".$i."'");
$temp_result = $db->fetch_array($query);
$action_rices += $temp_result['s_action_rices'] * (int)trim($_POST['soldier_num'.$i]);
$action_woods += $temp_result['s_action_woods'] * (int)trim($_POST['soldier_num'.$i]);
$action_irons += $temp_result['s_action_irons'] * (int)trim($_POST['soldier_num'.$i]);
//$move_spead += $temp_result['move_spead'] * (int)trim($_POST['soldier_num'.$i]);
if($study_grade['s_map']){
$move_spead_temp1 = $temp_result['move_spead'] * $study_grade['s_map'] * 0.01;
}
if($study_grade['s_wheel']){
$move_spead_temp2 = $temp_result['move_spead'] * $study_grade['s_wheel'] * 0.02;
}
if($study_grade['s_gee']){
$move_spead_temp3 = $temp_result['move_spead'] * $study_grade['s_gee'] * 0.03;
}
$move_spead += $temp_result['move_spead'] + $move_spead_temp1 + $move_spead_temp2 + $move_spead_temp3;
//echo $temp_result['move_spead']."|".$move_spead_temp1."|".$move_spead_temp2."|".$move_spead_temp3;exit;
//echo $temp_result['move_spead']."+".$temp_result['move_spead'] * pow(0.1,$study_grade['s_map']);exit;
//$move_spead += $temp_result['move_spead'];
$take_num += $temp_result['take_num'] * (int)trim($_POST['soldier_num'.$i]);
$take_num += $take_num + $take_num * 0.1 * $study_grade['s_command'];
$soldier_counter +=1;
}
}
$total_soldier_num += (int)trim($_POST['soldier_num'.$i]);
if($i==count($soldier_list)) $soldier_type .= $i;
else $soldier_type .= $i."|";
if($i==count($soldier_list)) $soldier_num .= (int)trim($_POST['soldier_num'.$i]);
else $soldier_num .= (int)trim($_POST['soldier_num'.$i])."|";
}
$gen_data = explode("|",$_POST['gen']);//选择的武将
$gen = $gen_data[0];
$gen_name = $gen_data[1];
//玩家选择的武将是否存在
$query = $db->query("select * from gen where `g_uid`='".$_COOKIE['UserId']."' and `g_gid`='".$gen."' and `g_cid`='".$_COOKIE['CityId']."'");
$gen_exists_if = $db->num_rows($query);
$gen_info_if =$db ->fetch_array($query);
//部队速度加成
$gen_speed_add=$gen_info_if['g_speed'];
if ($action_type<>"2"){
if (!$gen_exists_if) echomsg("你选择的武将不存在!","armament_action.php?action_type=".$action_type);
if($total_soldier_num > ($gen_info_if['g_command']+$gen_info_if['bf_command'])) echomsg("超过了武将".$gen_name."(".($gen_info_if['g_command']+$gen_info_if['bf_command']).")的最大带兵数!","armament_action.php?action_type=".$action_type);
}
if(!is_numeric($total_soldier_num) or $total_soldier_num<1) echomsg("请至少派遣1个士兵!","armament_action.php?action_type=".$action_type);
}
///-------------攻击距离-------a=(x2-x1)取正后的数字,b=(y2-y1)取正后的数字---距离公式:【(a-1)*120+1920】+【(b-1)*120+1920】
//---攻击方坐标
$query = $db->query("select * from city where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
$wo_zb = $db->fetch_array($query);
$a = abs((int)trim($_POST['area']) - $wo_zb['c_area']);
$b = abs((int)trim($_POST['area_x']) - $wo_zb['c_area_x']);
$max_x = $area_x_max;
$max_y = $area_y_max;
$x1 = (int)trim($_POST['area']);
$y1 = (int)trim($_POST['area_x']);
$y1 = (int)trim($_POST['area_x']);
$x = $wo_zb['c_area'];
$y = $wo_zb['c_area_x'];
//echo $x1.":".$x."<br />";
//echo $y1.":".$y."<br />";
//echo $max_x.":".$max_y."<br />";
if ($x1>$x){
//算x轴
if (($x1-$x)>($max_x/2)) {
$x_num=$max_x-$x1+1;
}else {
$x_num=$x1-$x;
}
}else {
if (($x-$x1)>($max_x/2)) {
$x_num=$max_x-$x+1;
}else {
$x_num=$x-$x1;
}
}
if ($y1>$y){
//算y轴
if (($y1-$y)>($max_y/2)) {
$y_num=$max_y-$y1+1;
}else {
$y_num=$y1-$y;
}
}else {
if (($y-$y1)>($max_y/2)) {
$y_num=$max_y-$y+1;
}else {
$y_num=$y-$y1;
}
}
//echo $x_num.":".$y_num;exit;
$distince = $x_num*120+$y_num*120+1920;
//$distince = 1920 + ((($x_num)*120) + (($y_num)*120));
//echo $move_spead;exit;
//--所需时间----=====目标距离÷(兵种速度相加÷兵种数量)=N分钟
//echo $distince."|".$temp_result['move_spead']."|".$soldier_counter;exit;
$move_spead+=$move_spead*($now[2]/100);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -