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

📄 armament_action_processing_task.php

📁 Download you own three BR
💻 PHP
📖 第 1 页 / 共 5 页
字号:
								//攻方玩家经验;公式:100+(死亡兵数[$fang_num_soldier_all]*1)
								$gon_player_explo=0;
								$gon_player_explo=100+($fang_num_soldier_all*1);
								
								//////////////////////////
								//结果;
								/////////////////////////
								
									//武将加经验
									if ($gon_gen_num_if) {//如果攻方有武将的话;
										//攻方武将加经验;
										$db->query("update gen set g_exploit=(g_exploit + '".$gon_gen_explo_all."') where id='".$gon_gen_id."';");
										//攻击方武将属性(入表用);
										$gon_gen_attribute=$gon_gen_attribute.'|'.$gon_gen_explo_all.'|'.$gon_player_explo;
									}else {
										//攻击方武将属性(入表用);
										$gon_gen_attribute=$gon_gen_attribute.'|0|'.$gon_player_explo;
									}
									if ($fang_gen_num_if) {//如果守方有武将的话;
										//守方武将加经验;
										$db->query("update gen set g_exploit=(g_exploit + '".$fang_gen_explo_all."') where id='".$fang_gen_id."';");
										//防守方武将属性(入表用);
										$fang_gen_attribute=$fang_gen_attribute.'|'.$fang_gen_explo_all.'|'.$fang_player_explo;
									}else {
										//防守方武将属性(入表用);
										$fang_gen_attribute=$fang_gen_attribute.'|0|'.$fang_player_explo;
									}
																
	//							echo 	$gon_gen_explo_all.'|'.$fang_gen_explo_all.'<br/>';
	//							echo    $gon_gen_num_if.'><'.$gon_gen_attribute.'<br/>';
	//							echo    $fang_gen_num_if.'><'.$fang_gen_attribute.'<br/>';
	//							exit;
									
									
								$rn_ls=rand(1,100);
								if ($gon_end_soldier_all>0 && $fang_end_soldier_all>0) {
									//$end_info="平局";
									$end_if=2;
									
									//攻方玩家经验;
									$db->query("update player_info set p_score=(p_score + '".$gon_player_explo."') where u_id='".$war_array['u_id']."';");
									
									//守方玩家经验
									$db->query("update player_info set p_score=(p_score + '".$fang_player_explo."') where u_id='".$war_array['to_u_id']."';");
									
									//现在玩家城墙值;
									$query_citywall=$db->query("select  b_citywall_fy from building where u_id='".$war_array['to_u_id']."' and c_id='".$war_array['to_c_id']."';");
									$list_citywall=$db->fetch_array($query_citywall);
									//如果城墙值比第一次攻值高,城墙防御不减
									if ($gon_all_power_first>=$list_citywall['b_citywall_fy']) {
										//守方城墙损失;
										$city_citywall=rand(5,20);																	
										//减少城墙值;
										$list_citywall['b_citywall_fy']=$list_citywall['b_citywall_fy']-($list_citywall['b_citywall_fy']/100 * $city_citywall);
										//更新城墙值;
										$db->query("update building set b_citywall_fy='".$list_citywall['b_citywall_fy']."',b_citywall_status=(b_citywall_status-'".$city_citywall."') where  u_id='".$war_array['to_u_id']."' and c_id='".$war_array['to_c_id']."';");
									}else {
										$list_citywall['b_citywall_fy']=0;
									}	
								}elseif($gon_end_soldier_all>0 && $fang_end_soldier_all<1) {
									///////////////////////////////////start///////////////////////////////////////
									//$end_info="攻方胜";掠夺资开始,并有5%—20%概率被俘或被杀,被俘或被杀机率各一半;
									$end_if=1;
									//现在玩家城墙值;
									$query_citywall=$db->query("select  b_citywall_fy from building where u_id='".$war_array['to_u_id']."' and c_id='".$war_array['to_c_id']."';");
									$list_citywall=$db->fetch_array($query_citywall);
									//如果城墙值比第一次攻值高,城墙防御不减
									if ($gon_all_power_first>=$list_citywall['b_citywall_fy']) {
										//守方城墙损失;
										$city_citywall=rand(10,30);																
										//减少城墙值;
										$list_citywall['b_citywall_fy']=$list_citywall['b_citywall_fy']-($list_citywall['b_citywall_fy']/100 * $city_citywall);
										//更新城墙值;
										$db->query("update building set b_citywall_fy='".$list_citywall['b_citywall_fy']."',b_citywall_status=(b_citywall_status-'".$city_citywall."') where  u_id='".$war_array['to_u_id']."' and c_id='".$war_array['to_c_id']."';");
									}else {
										$list_citywall['b_citywall_fy']=0;
									}
									
									//攻方玩家经验;
									$db->query("update player_info set p_score=(p_score + '".$gon_player_explo."') where u_id='".$war_array['u_id']."';");
									//守方玩家经验
									$db->query("update player_info set p_score=(p_score + '".$gon_num_soldier_all."') where u_id='".$war_array['to_u_id']."';");
									
									///////////
									//资源掠夺;
									///////////
									
									//查询守方资源;
									$query_fang_resource=$db->query("select golds,rices,ores,woods from resource where u_id='".$war_array['to_u_id']."' and c_id='".$war_array['to_c_id']."';");
									$list_fang_resource=$db->fetch_array($query_fang_resource);
									//默认最大抢夺比率20%,抢夺比率$gon_loot_add
									$loot_golds=($loot_base+$gon_loot_add) * $list_fang_resource['golds'];       //抢夺黄金
									$loot_rices=($loot_base+$gon_loot_add) * $list_fang_resource['rices'];       //抢夺粮食
									$loot_ores =($loot_base+$gon_loot_add) * $list_fang_resource['ores'];        //抢夺矿石
									$loot_woods=($loot_base+$gon_loot_add) * $list_fang_resource['woods'];       //抢夺木头
									
										//计算剩余兵的携带量;
										//引用临时变量清空区
										$gon_take_num_temp=0;								//临时全部队总携带量
										//计算有几种士兵;
										$gon_num=count($gon_soldier_num_temp);
										for ($gi=0;$gi<$gon_num;$gi++)
										{
											if ($gon_soldier_num_temp[$gi]>0) {											
												//计算士兵附属属性:携带量,近战加攻,近战加防,远程/机械加防,远程/机械加攻;
													//临时总携带量,公式:兵数*(单兵携带量+(单兵携带量*加成[$gon_take_add]))
													$gon_take_num_temp=$gon_take_num_temp+$gon_soldier_num_temp[$gi]*($gon_soldier_one_take[$gi]+($gon_soldier_one_take[$gi]*$gon_take_add));
											}
										}
									//抢得黄金资源;
									if ($gon_take_num_temp>$loot_golds) {
										$loot_end_golds=$loot_golds;
									}else {
										$loot_end_golds=$gon_take_num_temp;
									}
									//抢得粮食资源;
									if ($gon_take_num_temp>$loot_rices) {
										$loot_end_rices=$loot_rices;
									}else {
										$loot_end_rices=$gon_take_num_temp;
									}
									//抢得矿石资源;
									if ($gon_take_num_temp>$loot_ores) {
										$loot_end_ores=$loot_ores;
									}else {
										$loot_end_ores=$gon_take_num_temp;
									}
									//抢得木头资源
									if ($gon_take_num_temp>$loot_woods) {
										$loot_end_woods=$loot_woods;
									}else {
										$loot_end_woods=$gon_take_num_temp;
									}
									
									$loot_end_golds=(int)($loot_end_golds);
									$loot_end_rices=(int)($loot_end_rices);
									$loot_end_ores =(int)($loot_end_ores);
									$loot_end_woods=(int)($loot_end_woods);
									//掠夺物资信息入表用;
									$resourse_all_info='';
									$resourse_all_info='黄金('.$loot_end_golds.')&nbsp;&nbsp;粮食('.$loot_end_rices.')&nbsp;&nbsp;铁矿('.$loot_end_ores.')&nbsp;&nbsp;木头('.$loot_end_woods.')';
									
									//扣除守方资源;
									$db->query("update resource set golds=(golds-'".$loot_end_golds."'),rices=(rices-'".$loot_end_rices."'),ores=(ores-'".$loot_end_ores."'),woods=(woods-'".$loot_end_woods."') where u_id='".$war_array['to_u_id']."' and c_id='".$war_array['to_c_id']."';");
									//增加攻方资源;
									$db->query("update resource set golds=(golds+'".$loot_end_golds."'),rices=(rices+'".$loot_end_rices."'),ores=(ores+'".$loot_end_ores."'),woods=(woods+'".$loot_end_woods."') where u_id='".$war_array['u_id']."' and c_id='".$war_array['c_id']."';");
										
									
									//如果守方有武将的话;
									if ($fang_gen_num_if) {
										if ($rn_ls>=5 && $rn_ls<=20) {
											//判断被俘还是被杀;
											$rn_ls=rand(1,2);
											if ($rn_ls==1) {
												//被俘
												$db->query("update gen set g_status='3',g_fy='0',g_fealty=(g_fealty-'5')  where id='".$fang_gen_id."' ;");
												//查询武将国家;
												$gen_city=$db->query("select ga_type from gen a left join m_gen b on (a.g_gid=b.id) where a.id='".$fang_gen_id."';");
												$list_city=$db->fetch_array($gen_city);
												//写入监狱表;
												$db->query("insert into gen_prison (id,u_id,g_u_id,g_cid,gen_id,country,g_gid,g_power,g_intellect,g_commend,g_fealty,g_grade,times,pri_num) values (null,'".$war_array['u_id']."','".$war_array['to_u_id']."','".$war_array['to_c_id']."','".$fang_gen_id."','".$list_city['ga_type']."','".$list_fang_gen['g_gid']."','".$list_fang_gen['g_power']."','".$list_fang_gen['g_intellect']."','".$list_fang_gen['g_commend']."','".$list_fang_gen['g_fealty']."','".$list_fang_gen['g_grade']."','".time()."','3');");
												$fang_gen_info='武将被俘';
												$fang_gen_start=2;
											}else {
												//被杀
												$db->query("update gen set g_status='2',g_fy='0',g_fealty=(g_fealty-'10')  where id='".$fang_gen_id."' ;");
												$fang_gen_info='武将被杀';
												$fang_gen_start=1;
											}
										}else {
											$fang_gen_start=0;
										}
									}
									///////////////////////////////////end/////////////////////////////////////////								
								}elseif ($gon_end_soldier_all<1 && $fang_end_soldier_all>0) {
									//////////////////////////////////////start//////////////////////////
									//$end_info="守方胜";有5%—20%概率被俘或被杀,被俘或被杀机率各一半;
									$end_if=0;
									//现在玩家城墙值;
									$query_citywall=$db->query("select  b_citywall_fy from building where u_id='".$war_array['to_u_id']."' and c_id='".$war_array['to_c_id']."';");
									$list_citywall=$db->fetch_array($query_citywall);
									//如果城墙值比第一次攻值高,城墙防御不减
									if ($gon_all_power_first>=$list_citywall['b_citywall_fy']) {
										//守方城墙损失;
										$city_citywall=rand(1,10);																	
										//减少城墙值;
										$list_citywall['b_citywall_fy']=$list_citywall['b_citywall_fy']-($list_citywall['b_citywall_fy']/100 * $city_citywall);
										//更新城墙值;
										$db->query("update building set b_citywall_fy='".$list_citywall['b_citywall_fy']."',b_citywall_status=(b_citywall_status-'".$city_citywall."') where  u_id='".$war_array['to_u_id']."' and c_id='".$war_array['to_c_id']."';");
									}else {
										$list_citywall['b_citywall_fy']=0;
									}	
									
									//攻方玩家经验;
									$db->query("update player_info set p_score=(p_score + '".$fang_num_soldier_all."') where u_id='".$war_array['u_id']."';");
									//守方玩家经验
									$db->query("update player_info set p_score=(p_score + '".$fang_player_explo."') where u_id='".$war_array['to_u_id']."';");
									
									if ($gon_gen_num_if) {//如果攻方有武将的话;									
										if ($rn_ls>=5 && $rn_ls<=20) {
											//判断被俘还是被杀;
											$rn_ls=rand(1,2);
											if ($rn_ls==1) {
												//被俘
												$db->query("update gen set g_status='3',g_fy='0',g_fealty=(g_fealty-'5')  where id='".$gon_gen_id."' ;");
												//查询武将国家;
												$gen_city=$db->query("select ga_type from gen a left join m_gen b on (a.g_gid=b.id) where a.id='".$gon_gen_id."';");
												$list_city=$db->fetch_array($gen_city);
												//写入监狱表;
												$db->query("insert into gen_prison (id,u_id,g_u_id,g_cid,gen_id,country,g_gid,g_power,g_intellect,g_commend,g_fealty,g_grade,times,pri_num) values (null,'".$war_array['to_u_id']."','".$war_array['u_id']."','".$war_array['c_id']."','".$gon_gen_id."','".$list_city['ga_type']."','".$list_gon_gen['g_gid']."','".$list_gon_gen['g_power']."','".$list_gon_gen['g_intellect']."','".$list_gon_gen['g_commend']."','".$list_gon_gen['g_fealty']."','".$list_gon_gen['g_grade']."','".time()."','3');");
												$gon_gen_info='武将被俘';
												$gon_gen_start=2;
											}else {
												//被杀
												$db->query("update gen

⌨️ 快捷键说明

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