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

📄 armament_action_boss1.php

📁 Download you own three BR
💻 PHP
📖 第 1 页 / 共 3 页
字号:
		
		//////////////////////守方打攻方//////////////////////
		$k=0;
		$kf=0;
		$last_power_temp_ls=0;
		//减防后剩于伤害值
		$last_power_temp=$boss_all_power_ls-$gon_all_comm;
			//如果小于等于0,不破防不死兵;
			if ($last_power_temp>0) {
				$end_i=0;
				//计算有几种士兵;$gon_soldier_num_temp士兵数数组
				$gon_num=count($gon_soldier_num_temp);
				//循环开始;
				while ($kf<$gon_now_num)
				{
					$k++;
					//每个士兵种类应该分以的伤害为(int)($last_power_temp/$gon_now_num);
					$last_power_temp=$last_power_temp-$last_power_temp_ls;
					if ($last_power_temp_ls<>0) $last_power_temp_ls=0;
					if ($last_power_temp<1 || $gon_now_num<1) 
					{
						break;
					}else {
						$power_one=(int)($last_power_temp/$gon_now_num);
						if ($power_one<1) break;
					}										
					for ($i=0;$i<$gon_num;$i++)
					{											
						if ($power_one<$gon_soldier_one_life[$i]) {
							$end_i=$end_i+1;
						}else {
							if ($gon_soldier_num_temp[$i]>0)//如果此兵种还有士兵的话
							{																							
								//死亡士兵公式:(int)($power_one/$gon_soldier_one_life[$i])
								$dear_num=(int)($power_one/$gon_soldier_one_life[$i]);												
								
								//echo $last_power_temp.'|'.$gon_now_num.'|'.$power_one.'|'.$gon_soldier_one_life[$i].'|'.$dear_num.'|'.$gon_soldier_num_temp[$i].'<br/>';	
								
								//如果现有兵数减去死亡兵数大于0,减去对应兵数,总伤害减少;
								if ($gon_soldier_num_temp[$i]-$dear_num>0) {
									$last_power_temp_ls=$last_power_temp_ls+$dear_num*$gon_soldier_one_life[$i];
									$gon_soldier_num_temp[$i]=$gon_soldier_num_temp[$i]-$dear_num;
								}else {
									//如果现有兵数减去死亡兵数小于或等于0,对应兵数为0,减少相应总伤减害;
									$last_power_temp_ls=$last_power_temp_ls+$gon_soldier_num_temp[$i]*$gon_soldier_one_life[$i];
									$gon_soldier_num_temp[$i]=0;
									$gon_now_num=$gon_now_num-1;												
								}
							}else $end_i=$end_i+1;
						}
					}
					$kf++;
				}
				//循环结束;
			}
		////////////////////////守方打攻方结束/////////////////////////
		}
	}
	
	
	//////////////////////
	//结果
	/////////////////////
	
	//攻方
	$gon_end_soldier_all=0;       //现士兵数;
	$gon_num_soldier_all=0;       //死亡士兵数;
	$boss_gen_explo_all=0;         //武将总获得经验;
	//计录攻方最后死亡兵种(兵数);
	$gon_end_dear_army='';
	//计录攻方最后剩作兵种(兵数);
	$gon_end_life_army='';
	
	$ls=count($gon_soldier_num_temp_ls);
	for ($i=0;$i<count($gon_soldier_num_temp_ls);$i++)
	{
		//记录现在有士兵数
		$gon_end_life_army_array[$i]=0;
		
		if ($gon_soldier_num_temp_ls[$i]>0) {
		
			//单兵死亡数$gon_num_ls;
			$gon_num_ls=$gon_soldier_num_temp_ls[$i]-$gon_soldier_num_temp[$i];
			
			//死亡士兵数
			$gon_num_soldier_all=$gon_num_soldier_all+$gon_num_ls;
			
			//士兵死亡数,例:兵种名称(死亡数);
			$gon_end_dear_army=$gon_end_dear_army.$gon_soldier_name_temp[$i].'('.$gon_num_ls.')';
			
			//记录现在有士兵数
			$gon_end_life_army_array[$i]=$gon_soldier_num_temp[$i];
												
			//死亡士兵更新表;
			//$db->query("update soldier set ".$soldier_type_name_en[$gon_soldier_type_array_num_temp[$i]]."=(".$soldier_type_name_en[$gon_soldier_type_array_num_temp[$i]]."-'".$gon_num_ls."') where  u_id='".$war_array['u_id']."' and c_id='".$war_array['c_id']."'");
												
			//守方武将经验数:
//			$boss_gen_explo_all=$boss_gen_explo_all+$war_gen_add_score[$gon_soldier_type_array_num_temp[$i]]*$gon_num_ls;
			
			//算士兵现在总数
			$gon_end_soldier_all=$gon_end_soldier_all+$gon_soldier_num_temp[$i];
		}
	}
	//守方玩家经验;公式:100+(死亡兵数[$gon_num_soldier_all]*1)
	$boss_player_explo=0;
	$boss_player_explo=100+($gon_num_soldier_all*1);
	
	
	
	
	
	//守方
	$boss_end_soldier_all=0;       //现士兵数;
	$boss_num_soldier_all=0;       //死亡士兵数;
	$gon_gen_explo_all=0;         //武将总获得经验;
	//计录守方最后死亡兵种(兵数);
	$boss_end_dear_army='';
	
	for ($i=0;$i<count($boss_soldier_num_temp_ls);$i++)
	{
		if ($boss_soldier_num_temp_ls[$i]>0) {
		
			//单兵死亡数$gon_num_ls
			$boss_num_ls=$boss_soldier_num_temp_ls[$i]-$boss_soldier_num_temp[$i];
			
			//分类记录死亡士兵数
			$boss_dear_num_type[$i]=$boss_num_ls;
			
			//死亡士兵数
			$boss_num_soldier_all=$boss_num_soldier_all+$boss_num_ls;
			
			//士兵死亡数,例:兵种名称(死亡数);
			$boss_end_dear_army=$boss_end_dear_army.$boss_soldier_name_temp[$i].'('.$boss_num_ls.')';
			
			//死亡士兵更新表;
			//$db->query("update soldier set ".$soldier_type_name_en[$fang_soldier_type_array_num_temp[$i]]."=(".$soldier_type_name_en[$fang_soldier_type_array_num_temp[$i]]."-'".$fang_num_ls."') where  u_id='".$war_array['to_u_id']."' and c_id='".$war_array['to_c_id']."'");
			
			//攻方武将经验数:
			$gon_gen_explo_all=$gon_gen_explo_all+$enemy_soldier_type[$boss_soldier_type_array_num_temp[$i]][6]*$boss_num_ls;
			
			//算士兵现在总数
			$boss_end_soldier_all=$boss_end_soldier_all+$boss_soldier_num_temp[$i];
		}
	}
	//攻方玩家经验;公式:100+(死亡兵数[$fang_num_soldier_all]*1)
	$gon_player_explo=0;
	$gon_player_explo=round((100+$boss_num_soldier_all*1)/$num_g);
	
	
	//////////////////////////
	//结果;
	/////////////////////////
	
		//武将加经验
		if ($gon_gen_num_if) {//如果攻方有武将的话;
			//攻方武将加经验;
				for($i=0;$i<$num_g;$i++){
		$db->query("update gen set g_exploit=(g_exploit + '".$gon_gen_explo_all."') where g_gid='".$war_array3[$i]['w_gen']."';");		
									}
			//攻击方武将属性(入表用);
			$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 && $boss_end_soldier_all>0) {
		//$end_info="平局";
		$end_if=2;
		
		//攻方玩家经验;
		for($i=0;$i<$num_g;$i++)
								{
									$db->query("update player_info set p_score=(p_score + '".$fang_num_soldier_all."') where u_id='".$war_array3[$i]['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_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 && $boss_end_soldier_all<1) {
		///////////////////////////////////start///////////////////////////////////////
		//$end_info="攻方胜";掠夺资开始,并有5%—20%概率被俘或被杀,被俘或被杀机率各一半;
		$end_if=1;
		
		//守方城墙损失;
//		$city_citywall=rand(10,30);
		//现在玩家城墙值;
//		$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);								
//		//减少城墙值;
//		$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']."';");
		
		
		//攻方玩家经验;
		for($i=0;$i<$num_g;$i++){
	$db->query("update player_info set p_score=(p_score + '".$fang_num_soldier_all."') where u_id='".$war_array3[$i]['u_id']."';");
							}
		///////////
		//资源掠夺;
		///////////
		$loot_golds=0;
		for ($i=0;$i<count($boss_soldier_type_array_num_temp);$i++)
		$loot_golds=$loot_golds+ $boss_dear_num_type[$i]*$enemy_soldier_type[$boss_soldier_type_array_num_temp[$i]][7];       //抢夺黄金
		
		
			//计算剩余兵的携带量;
			//引用临时变量清空区
			$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));
				}
			}
			
		//如果守方有武将
		$gon_get_goods=0;
		$loot_gen_golds=0;
		if ($boss_gen_num_if<6) {
			$enemy_count_num=count($enemy_gen_goods_rate[$boss_gen_num_if]);

⌨️ 快捷键说明

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