📄 armament_unite_processing_task.php
字号:
$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']."'");
//守方武将经验数:
$fang_gen_explo_all=$fang_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)
$fang_player_explo=0;
$fang_player_explo=100+($gon_num_soldier_all*1);
//守方
$fang_end_soldier_all=0; //现士兵数;
$fang_num_soldier_all=0; //死亡士兵数;
$gon_gen_explo_all=0; //武将总获得经验;
//计录守方最后死亡兵种(兵数);
$fang_end_dear_army='';
for ($i=0;$i<count($fang_soldier_num_temp_ls);$i++)
{
if ($fang_soldier_num_temp_ls[$i]>0) {
//单兵死亡数$gon_num_ls
$fang_num_ls=$fang_soldier_num_temp_ls[$i]-$fang_soldier_num_temp[$i];
//死亡士兵数
$fang_num_soldier_all=$fang_num_soldier_all+$fang_num_ls;
//士兵死亡数,例:兵种名称(死亡数);
$fang_end_dear_army=$fang_end_dear_army.$fang_soldier_name_temp[$i].'('.$fang_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_fp['to_u_id']."' and c_id='".$war_array_fp['to_c_id']."'");
//攻方武将经验数:
$gon_gen_explo_all=round($gon_gen_explo_all+$war_gen_add_score[$fang_soldier_type_array_num_temp[$i]]*$fang_num_ls/$num_g);
//算士兵现在总数
$fang_end_soldier_all=$fang_end_soldier_all+$fang_soldier_num_temp[$i];
}
}
//攻方玩家经验;公式:100+(死亡兵数[$fang_num_soldier_all]*1)
$gon_player_explo=0;
$gon_player_explo=round((100+$fang_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 && $fang_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_fp['to_u_id']."';");
//守方城墙损失;
$city_citywall=rand(5,20);
//现在玩家城墙值;
$query_citywall=$db->query("select b_citywall_fy from building where u_id='".$war_array_fp['to_u_id']."' and c_id='".$war_array_fp['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_fp['to_u_id']."' and c_id='".$war_array_fp['to_c_id']."';");
}elseif($gon_end_soldier_all>0 && $fang_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_fp['to_u_id']."' and c_id='".$war_array_fp['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_fp['to_u_id']."' and c_id='".$war_array_fp['to_c_id']."';");
//攻方玩家经验;
for($i=0;$i<$num_g;$i++)
{
$db->query("update player_info set p_score=(p_score + '".$gon_player_explo."') where u_id='".$war_array3[$i]['u_id']."';");
}
///////////
//资源掠夺;
///////////
//查询守方资源;
$query_fang_resource=$db->query("select golds,rices,ores,woods from resource where u_id='".$war_array_fp['to_u_id']."' and c_id='".$war_array_fp['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.') 粮食('.$loot_end_rices.') 铁矿('.$loot_end_ores.') 木头('.$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_fp['to_u_id']."' and c_id='".$war_array_fp['to_c_id']."';");
//增加攻方资源;
$loot_end_golds1=round($loot_end_golds/$num_g);
$loot_end_rices1=round($loot_end_rices/$num_g);
$loot_end_ores1=round($loot_end_ores/$num_g);
$loot_end_woods1=round($loot_end_woods/$num_g);
$resourse_all_info11='黄金('.$loot_end_golds1.') 粮食('.$loot_end_rices1.') 铁矿('.$loot_end_ores1.') 木头('.$loot_end_woods1.')';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -