📄 armament_unite_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");//加载数据库类文件
//当前拥有士兵数
$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);
$gen_speed_add=0;
//根据目标城池计算花费、距离和时间/////////////////////////////////////////////////////////////////////////
$action_type=$_POST['attack_type'];
$area = (int)trim($_POST['area']);
$area_x = (int)trim($_POST['area_x']);
$area_xy=$area.':'.$area_x;
//判断24小时内是否被打过
$query_group_area=$db->query("select * from group_area where area_xy='".$area_xy."' and group_if='1'");
$list_group_area=$db->fetch_array($query_group_area);
// echo $area_xy;
// echo "select * from group_area where area_xy='".$area_xy."' and group_if='1'";
// print_r($list_group_area);
// exit;
if($list_group_area['times']+24*60*60>=time()) {
echomsg("该玩家24小时内被联合进攻过一次,暂时不能对其联合进攻!","armament_unite.php?action_type=".$action_type);
}else {
$db->query("delete from group_area where id='".$list_group_area['id']."';");
}
$c_id2 = explode("|",$_POST['city_id']);
if(!$area or !$area_x){
$area1 = explode(":",$c_id2[2]);
$area = $area1[0];
$area_x = $area1[1];
}
$soldier_type = $_POST['soldier_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_unite.php?action_type=".$action_type);
elseif(!$c_id2[2] and $action_type=="2" and $_GET['action']<>"attack") echomsg("请输入目标城池坐标!","armament_unite.php?action_type=".$action_type);
if($_POST['gen']<'0') echomsg("请选择武将!","?action_type=".$action_type);
$soldier_counter=0;
///-------------军队花费-----------------
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_unite.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;
}
}
if($soldier_counter>1)echomsg("最多只能派一种兵!!","armament_unite.php?action_type=".$action_type);
$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 (!$gen_exists_if) echomsg("你选择的武将不存在!","armament_unite.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_unite.php?action_type=".$action_type);
if(!is_numeric($total_soldier_num) or $total_soldier_num<1) echomsg("请至少派遣1个士兵!","armament_unite.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);
$move_spead+=$move_spead*($now[8]*2/100);
$move_spead+=$move_spead*($now[17]*3/100);
$action_time =intval ($distince / (($move_spead+($move_spead+$move_spead*$gen_speed_add)) / $soldier_counter));
//echo $action_time;exit;
$total_resource = $resource_result['golds'] + $resource_result['ores'] + $resource_result['woods'] + $resource_result['rices'];
$take_num = min($take_num,$total_resource);
// echo $soldier_type.'<br/>';
// echo $soldier_num;
$db->close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>军事行动</title>
<link href="css/id.css" rel="stylesheet" type="text/css">
<link href="css/css.css" rel="stylesheet" type="text/css">
<link type="text/css" href="css/build.css" rel="stylesheet">
<style>
body{
margin-top:0px;
}
a.info {
position:relative; z-index:0; color:#000; text-decoration:none;}
a.info:hover {
z-index:1;background-color:#E7CBA5;}
a.info span {
display: none; }
a.info:hover span { display:block; position:absolute; padding-left:5px; padding-right:5px; padding-top:5px; padding-bottom:5px;width:180px; border:2px solid #fff; line-height:16px; background-color:#E7CB94; color:#000000; text-align: left; text-decoration:none; margin-top:-8px;margin-left:-65px;}
/*.img_style { filter:Gray(enabled=true); }*/
.img_style { filter:Gray(enabled=false);}
.img_style1 { filter:Gray(enabled=false);}
.img_style0 { filter:Gray(enabled=true);}
</style>
</head>
<body oncontextmenu="return false">
<script>
if (top.location == self.location)top.location='/';
function showControl(obj){
var value;
value = obj.options[obj.selectedIndex].value;
if(value == 2) {
document.getElementById("text2").innerText = '输送到';
zc_che.style.display="none";
all_arm.style.display="";
my_gen_list.style.display="none";
city_area.style.display="none";
max_soldier_info.style.display="none";
my_city_list.style.display="";
//war.style.display="none";
show_02.style.display="";
lurcher_1.style.display="none";
//lurcher_2.style.display="none";
//lurcher_3.style.display="none";
}else
if(value == 5) {
document.getElementById("text2").innerText = '分城坐标';
zc_che.style.display="";
all_arm.style.display="none";
my_city_list.style.display="none";
city_area.style.display="";
my_gen_list.style.display="";
max_soldier_info.style.display="";
//war.style.display="none";
show_02.style.display="";
lurcher_1.style.display="none";
//lurcher_2.style.display="none";
//lurcher_3.style.display="none";
}else
if(value == 3) {
document.getElementById("text2").innerText = '探索坐标';
zc_che.style.display="none";
all_arm.style.display="none";
my_city_list.style.display="none";
city_area.style.display="";
my_gen_list.style.display="none";
max_soldier_info.style.display="none";
//war.style.display="none";
show_02.style.display="none";
lurcher_1.style.display="";
//lurcher_2.style.display="";
//lurcher_3.style.display="";
}
else{
zc_che.style.display="none";
all_arm.style.display="";
city_area.style.display="";
document.getElementById("text2").innerText = '攻击目标';
my_gen_list.style.display="";
max_soldier_info.style.display="";
my_city_list.style.display="none";
//war.style.display="";
show_02.style.display="";
lurcher_1.style.display="none";
//lurcher_2.style.display="none";
//lurcher_3.style.display="none";
}
}
function choice(val,val2,g_name){
var val,val2;
for(i=0;i<<?php echo count($my_hero_list);?>;i++){
if(i!=val){
eval("document.getElementById('gen_header"+i+"').className=\"img_style1\";");
}else{
eval("document.getElementById('gen_header"+val+"').className=\"img_style\";");
}
}
val2 = parseInt(val2);
document.getElementsByName("gen")[val].checked=true;
document.getElementById("gen_uplimit").innerHTML='<br /><span style=\"color:RED; font-weight:bold;\" id="\"gen_uplimit\">'+val2+'</span>';
//document.attackForm.gen_max_soldier_num.value = val2;
}
function checkForm(obj){
//alert(parseInt(obj.golds.value));
if(obj.action_type=="5" || obj.action_type=="2"){
var g,w,r,i,max,max2;
g = obj.golds.value;
w = obj.woods.value;
r = obj.rices.value;
i = obj.irons.value;
mg = obj.max_golds.value;
mw = obj.max_woods.value;
mr = obj.max_rices.value;
mi = obj.max_irons.value;
max = obj.take_num.value;
max2 =(g + w + r + i);
if(max2>max){
alert("超出总携带量");
return false;
}
if(g>mg){
alert("超出黄金最大携带量");
return false;
}
if(g>mw){
alert("超出木材最大携带量");
return false;
}
if(g>mr){
alert("超出粮食最大携带量");
return false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -