📄 armament_action_processing_task.php
字号:
<?php
//include_once("functions/class_mysql.php");
//require_once("functions/func_common.php");//加载函数文件
//include_once("configs/Configs.php");
/////////////////////////////////////////玩家触发自动处理军事行动队列////////////////////////////////////////
//$num=rand(1,2);
//if($num=="1") and `w_id`='".$task_id."'
// $query=$db->query("select * from war_task where `w_end_time`<='".time()."' and (g_assis='0' or r_assis='0') order by w_end_time asc,w_id asc limit 0,1;");
$query=$db->query("select * from war_task where (`u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."') or (`to_u_id`='".$_COOKIE['UserId']."' and `to_c_id`='".$_COOKIE['CityId']."') and `w_end_time`<='".time()."' and (g_assis='0' or r_assis='0') order by w_end_time asc,w_id asc limit 0,1");
$war_array=$db->fetch_array($query);
if($war_array['w_end_time']<=time()){//任务时间满足
if($war_array['w_task_type']=="1" and $war_array['is_complate']=="0" and $war_array['g_assis']=="0"){//任务类型:-----前进
$db->query("update war_task set g_assis=1 where w_id=".$war_array['w_id']."");
if ($war_array['w_type']==5 || $war_array['w_type']==3 || $war_array['w_type']==0 || $war_array['w_type']==1 || $war_array['w_type']==4 || $war_array['w_type']==4 || $war_array['w_type']==7) {
//判断被打玩家是否己经用了免战牌
$mian_useif=0;
$query_mian=$db->query("select id from add_goods_info where type='2' and m_gid='80' and u_id='".$war_array['to_u_id']."';");
$nus=$db->num_rows($query_mian);
if ($nus) {
//被打者己使用免战自牌
//更新战斗部队
$nt=time();
$ne=$nt+($war_array['w_end_time']-$war_array['w_start_time']);
$db->query("update war_task set w_task_type='0',w_flag='0',is_complate='1',w_start_time='".$nt."',w_end_time='".$ne."' where w_id='".$war_array['w_id']."';");
//写信通知
//查询攻击人昵称
$query_n=$db->query("select p_nickname from player_info where u_id='".$war_array['u_id']."';");
$note_n=$db->fetch_array($query_n);
// 写入信息表
$information_ls=' 您攻击城池 ( 坐标为 '.$war_array['w_to'].' ),该玩家己使用免战牌道具,在此期间该不能攻击该玩家,同时该玩家也无法做出攻击动作!';
$db->query("insert into e_mail (e_name,e_username,e_title,e_text,e_times,e_read,e_type) values ('系统消息','".$note_n['p_nickname']."','您攻击的玩家在免战状态','".$information_ls."','".time()."','0','1');");
$mian_useif=1;
}
//-----------------------------
//判断攻打方是否己经用了免战牌
$query_mian=$db->query("select id from add_goods_info where type='2' and m_gid='80' and u_id='".$war_array['u_id']."';");
$nus=$db->num_rows($query_mian);
if ($nus) {
//攻打者己使用免战自牌
//更新战斗部队
$nt=time();
$ne=$nt+($war_array['w_end_time']-$war_array['w_start_time']);
$db->query("update war_task set w_task_type='0',w_flag='0',is_complate='1',w_start_time='".$nt."',w_end_time='".$ne."' where w_id='".$war_array['w_id']."';");
//写信通知
//查询攻击人昵称
$query_n=$db->query("select p_nickname from player_info where u_id='".$war_array['u_id']."';");
$note_n=$db->fetch_array($query_n);
// 写入信息表
$information_ls=' 使用免战牌期间不能攻击任意玩家和黄巾军,同时您在此期间其它玩家也不能对您发动攻击!';
$db->query("insert into e_mail (e_name,e_username,e_title,e_text,e_times,e_read,e_type) values ('系统消息','".$note_n['p_nickname']."','您处于免战状态','".$information_ls."','".time()."','0','1');");
$mian_useif=1;
}
}
if ($mian_useif==0){
//攻击类型
switch ($war_array['w_type']){
///////////////////////
//联合进攻
///////////////////////
case 6:{
include("armament_unite_processing_task.php");
break;
}
//-----------------------------------------筑城开始(占领空城)------------------------------------
case 5:{
//判断是否存在相同的战争任务,存在则按照先后顺序处理
// $query=$db->query("select w_id,w_end_time from war_task where `w_to`='".$war_array['w_to']."'");
// $exists_result = $db->num_rows($query);
// $exists_result_time = $db->fetch_array($query);
// if($exists_result>0 and $war_array['w_end_time'] > $exists_result_time['w_end_time']){
// //设置当前COOK的值
// $player_id = $exists_result_time['u_id'];
// $city_id = $exists_result_time['c_id'];
// }else{
// //设置当前COOK的值
// $player_id = $_COOKIE['UserId'];
// $city_id = $_COOKIE['CityId'];
// }
//判断目标城池是否被占领
$city_area_data = explode(":",$war_array['w_to']);
$query=$db->query("select c_id from city where `c_area`='".$city_area_data[0]."' and `c_area_x`='".$city_area_data[1]."'");
$city_area_result = $db->num_rows($query);
if($city_area_result>0){
//将当前任务改为返回
$w_end_time = $exists_result_time['w_end_time'] + $war_array['w_time'] * 60;
$db->query("update war_task set `w_task_type`='0',`w_start_time`='".$exists_result_time['w_end_time']."',`w_end_time`='".$w_end_time."',is_complate='1' where `u_id`='".$war_array['u_id']."' and `w_id`='".$war_array['w_id']."'");
$w_flag= 0;
//$db->query("update gen set `g_status`='0' where `g_uid`='".$player_id."' `g_cid`='".$war_array['to_c_id']."' and `g_gid`='".$war_array['w_gen']."'");
//写入战争结果
$db->query("INSERT INTO `war_result` ( `w_id` , `u_id` , `c_id` , `w_type` , `w_to` , `to_u_id` , `to_c_id` , `w_flag` , `w_soldier_uplimit` , `w_myself_result` , `w_enemy_result` , `w_date` )
VALUES ('', '".$war_array['u_id']."', '".$city_id."', '".$war_array['w_type']."', '".$war_array['w_to']."','".$war_array['to_u_id']."','".$war_array['to_c_id']."', '".$w_flag."', '0', '目标城池已被占领', '', '".$war_array['w_end_time']."') ");
}else{//目标城池没有被占领
//初始化数据(包括:城池表、建筑物表、生产安排表、研究表):调用处理文件
include("armament_action_init_data.php");
//更新武将数量
//$db->query("update city set `c_officers`=(`c_officers`-'1') where `u_id`='".$player_id."' and `c_id`='".$war_array['c_id']."'");
$c_id = $city_id;
//武将驻留,即将带兵武将更改为此空城的武将
//$db->query("update gen set `g_status`='0',`g_cid`='".$c_id."' where `g_uid`='".$player_id."' and `g_gid`='".$war_array['w_gen']."'");
//增加携带资源
$db->query("update resource set `rices`=(`rices`+'".$war_array['w_take_rices']."'),`golds`=(`golds`+'".$war_array['w_take_golds']."') ,`woods`=(`woods`+'".$war_array['w_take_woods']."'),`ores`=(`ores`+'".$war_array['w_take_irons']."') where `u_id`='".$war_array['u_id']."' and `c_id`='".$c_id."'");
// $query=$db->query("select * from gen g1,m_gen g2 where g1.`g_gid`=g2.`id` and g1.`g_uid`='".$war_array['u_id']."' and g1.`g_cid`='".$c_id."' and g1.`g_gid`='".$war_array['w_gen']."'");
// $genname = $db->fetch_array($query);
//防御队列
//$db->query("INSERT INTO `city_recovery` ( `id` , `u_id` , `c_id` , `g_id` , `g_name` , `soldier_class` , `soldier_num` , `war` )
//VALUES ('', '".$war_array['u_id']."', '".$c_id."', '".$war_array['w_gen']."', '".$genname['ge_name']."', '0|0|0|0|0|0', '0|0|0|0|0|0', '0');");
//将战争结果插入到战争结果表中
$db->query("INSERT INTO `war_result` ( `w_id` , `u_id` , `c_id` , `w_type` , `w_to` ,`to_u_id` ,`to_c_id` , `w_flag` , `w_soldier_uplimit` , `w_myself_result` , `w_enemy_result` , `w_date` )
VALUES ('', '".$war_array['u_id']."', '".$war_array['c_id']."', '".$war_array['w_type']."', '".$war_array['w_to']."','".$war_array['to_u_id']."','".$war_array['to_c_id']."', '1', '0', '占领分城成功', '', '".$war_array['w_end_time']."') ");
//删除已完成的战争任务
$db->query("delete from war_task where `w_id`='".$war_array['w_id']."'");
//刷新当前页面
refresh();
}
break;
}
//-------------------------------------筑城结束(占领空城)------------------------------------
//-------------------------------------输送开始(军队)------------------------------------
case 2:{
//更新输送方与接受方的士兵数与总士兵数
$soldier_type = explode("|",$war_array['w_soldier_type']);
$soldier_num = explode("|",$war_array['w_soldier_num']);
$cid = explode("|",$war_array['w_to']);
$query = $db->query("select count(*) from soldier where `u_id`='".$war_array['to_u_id']."' and `c_id`='".$war_array['to_c_id']."'");
if(!$db->result($query,0)) {
$db->query("INSERT INTO `soldier` ( `s_id` , `u_id` , `c_id` , `bu_zhu` , `tan_zhi` , `zz_bing` , `pd_shou` , `dg_shou` , `be_shi` , `bmy_chong` , `zc_dui` , `xds_shi` , `zz_che` , `xz_ying` , `jwj_bing` , `xlt_qi` , `wdf_jun` , `hb_qi` , `pl_che` , `np_che` )
VALUES ('', '".$war_array['to_u_id']."', '".$war_array['to_c_id']."', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');");
}
if($soldier_type_name_en<>"") foreach ($soldier_type_name_en as $i2=>$m2){
$i2--;
$city_soldier_num += $soldier_num[$i2];
//接受方,增加士兵
if(!$soldier_num[$i2]) continue;
$db->query("update soldier set `".$soldier_type_name_en[$soldier_type[$i2]]."`=(`".$soldier_type_name_en[$soldier_type[$i2]]."`+'".$soldier_num[$i2]."') where `u_id`='".$war_array['to_u_id']."' and `c_id`='".$war_array['to_c_id']."' ");
}
//$soldier_type = explode("|",$war_array['w_soldier_type']);
//$soldier_num = explode("|",$war_array['w_soldier_num']);
for($i33=0;$i33<count($soldier_type);$i33++){
if($soldier_num[$i33]>0){
$war_result.= $soldier_type_name[$i33+1]."(".$soldier_num[$i33].")";
}
}
//增加携带资源
$db->query("update resource set `rices`=(`rices`+'".$war_array['w_take_rices']."'),`golds`=(`golds`+'".$war_array['w_take_golds']."'),`woods`=(`woods`+'".$war_array['w_take_woods']."'),`ores`=(`ores`+'".$war_array['w_take_irons']."') where `u_id`='".$war_array['to_u_id']."' and `c_id`='".$war_array['to_c_id']."'");
//将战争结果插入到战争结果表中
$db->query("INSERT INTO `war_result` ( `w_id` , `u_id` , `c_id` , `w_type` , `w_to` ,`to_u_id` ,`to_c_id` , `w_flag` , `w_soldier_uplimit` , `w_myself_result` , `w_enemy_result` , `w_date` )
VALUES ('', '".$war_array['u_id']."', '".$war_array['c_id']."', '".$war_array['w_type']."', '".$cid[1]."','".$war_array['to_u_id']."','".$war_array['to_c_id']."', '1', '0', '".$war_result."', '', '".$war_array['w_end_time']."') ");
//删除已完成的战争任务
$db->query("delete from war_task where `w_id`='".$war_array['w_id']."'");
//unset($war_result);
break;
}
//-------------------------------------输送结束(军队)------------------------------------
//-------------------------------------间谍开始(获取情报)------------------------------------
case 3:{
include_once("armament_refresh_soldier.php");
//读取攻击方军情刺探等级
$query=$db->query("select s_army from study where `u_id`='".$war_array['u_id']."'");
$study_result=$db->fetch_array($query);
$me_study_s_army=$study_result['s_army'];
//读取防御方军情刺探等级
$query=$db->query("select s_army from study where `u_id`='".$war_array['to_u_id']."'");
$de_study_result=$db->fetch_array($query);
$di_study_s_army=$de_study_result['s_army'];
//////////////////////////////////////////ying//////////////////////////////////////////
//返回时间
$come_back_time=0;
$come_back_time=$war_array['w_end_time']-$war_array['w_start_time'];
$come_back_time+=$war_array['w_end_time'];
//等级相同时
if ($me_study_s_army==$di_study_s_army) { //无死亡,无消息
$db->query("update war_task set w_task_type='0',w_flag='0',notice='1',is_complate='1',w_start_time='".$war_array['w_end_time']."',w_end_time='".$come_back_time."' where `u_id`='".$war_array['u_id']."' and `w_id`='".$war_array['w_id']."';");
///////////////战争统计/////////
$w_query=$db->query("select * from war_stat where u_id='".$_COOKIE['UserId']."'");
$w_num=$db->num_rows($w_query);
if($w_num<1){
$db->query("INSERT INTO `war_stat`(`id` , `u_id`, `s_recon`)VALUES ('', '".$_COOKIE['UserId']."','1')");
}else{
$db->query("update war_stat set s_recon=s_recon+1 where u_id='".$_COOKIE['UserId']."'");
}
///////////////////////////
//写入信息
$db->query("INSERT INTO `war_result` ( `w_id` , `u_id` , `c_id` , `w_type` , `w_to` ,`to_u_id` ,`to_c_id` , `w_flag` , `w_soldier_uplimit` , `w_myself_result` , `w_enemy_result` , `w_date` ) VALUES ('', '".$war_array['u_id']."', '".$war_array['c_id']."', '".$war_array['w_type']."', '".$war_array['w_to']."','".$war_array['to_u_id']."','".$war_array['to_c_id']."', '0', '0', '间谍探查失败', '', '".$war_array['w_end_time']."') ");
}elseif ($me_study_s_army<$di_study_s_army) { //无消息,有死亡
$grade_dis=$di_study_s_army-$me_study_s_army;
//死亡概率,高一级就涨20%;
$dear_probability=$grade_dis*20;
$probability=rand(1,100);
if ($probability<=$dear_probability) {//死亡
$db->query("delete from war_task where `w_id`='".$war_array['w_id']."';");
// $db->query("update soldier set `tan_zhi`=(`tan_zhi`-'".$war_array['w_soldier_num']."') where u_id='".$war_array['u_id']."' and c_id='".$war_array['c_id']."';");
///////////////战争统计/////////
$w_query=$db->query("select * from war_stat where u_id='".$_COOKIE['UserId']."'");
$w_num=$db->num_rows($w_query);
if($w_num<1){
$db->query("INSERT INTO `war_stat`(`id` , `u_id`, `s_recon`)VALUES ('', '".$_COOKIE['UserId']."','1')");
}else{
$db->query("update war_stat set s_recon=s_recon+1 where u_id='".$_COOKIE['UserId']."'");
}
///////////////////////////
//写入信息
$info_ms='间谍探察失败,死亡'.$war_array['w_soldier_num'].'个间谍';
$db->query("INSERT INTO `war_result` ( `w_id` , `u_id` , `c_id` , `w_type` , `w_to` ,`to_u_id` ,`to_c_id` , `w_flag` , `w_soldier_uplimit` , `w_myself_result` , `w_enemy_result` , `w_date` ) VALUES ('', '".$war_array['u_id']."', '".$war_array['c_id']."', '".$war_array['w_type']."', '".$war_array['w_to']."','".$war_array['to_u_id']."','".$war_array['to_c_id']."', '0', '0', '".$info_ms."', '', '".$war_array['w_end_time']."') ");
}else { //无死亡
$db->query("update war_task set w_task_type='0',w_flag='0',notice='1',is_complate='1',w_start_time='".$war_array['w_end_time']."',w_end_time='".$come_back_time."' where `u_id`='".$war_array['u_id']."' and `w_id`='".$war_array['w_id']."';");
//写入信息
$db->query("INSERT INTO `war_result` ( `w_id` , `u_id` , `c_id` , `w_type` , `w_to` ,`to_u_id` ,`to_c_id` , `w_flag` , `w_soldier_uplimit` , `w_myself_result` , `w_enemy_result` , `w_date` ) VALUES ('', '".$war_array['u_id']."', '".$war_array['c_id']."', '".$war_array['w_type']."', '".$war_array['w_to']."','".$war_array['to_u_id']."','".$war_array['to_c_id']."', '0', '0', '间谍探查失败', '', '".$war_array['w_end_time']."') ");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -