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

📄 repair_citywall_hand.php

📁 Download you own three BR
💻 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");//加载数据库类文件

if($_POST['action']=="repair_citywall"){
	
	//////////////////////////获取玩家当前建筑物等级数量//////////////////////
	$b_current_query=$db->query("select `b`.*,`c`.`total_house`,`c`.`free_house` from building as b,city as c where `b`.`u_id`=`c`.`u_id` and `b`.`c_id`=`c`.`c_id` and `b`.`c_id`='".$_COOKIE["CityId"]."' and `b`.`u_id`='".$_COOKIE["UserId"]."'");
	$b_current_result=$db->fetch_array($b_current_query);
	
	$repair_percent = trim(intval($_POST['repair_percent']));
	if(!is_numeric($repair_percent) or !$repair_percent) echomsg("请输入城墙修复百分比");
	
	$query=$db->query("select b.b_city_wall,b.b_citywall_fy,b.b_citywall_status,r.rices,r.ores,r.golds,r.woods from building as b,resource as r where b.`u_id`=r.`u_id` and r.`u_id`='".$_COOKIE['UserId']."' and  b.`c_id`='".$_COOKIE['CityId']."' ");
	$repair_result = $db->fetch_array($query);
	if($repair_percent > 100 - $repair_result['b_citywall_status']) echomsg("超过当前最大修复百分比");
	//花费基础表
	$query=$db->query("select * from building_attribute where `b_type`='12'");
    $task_base_result=$db->fetch_array($query);
	
	//修复所需消耗资源
   	$repair_rices= $repair_percent / 100 * ($task_base_result['b_rices'] * pow(1+$citywall_resource_percent,$repair_result['b_city_wall']-1));
   	$repair_irons= $repair_percent / 100 * ($task_base_result['b_irons'] * pow(1+$citywall_resource_percent,$repair_result['b_city_wall']-1));
   	$repair_golds= $repair_percent / 100 * ($task_base_result['b_golds'] * pow(1+$citywall_resource_percent,$repair_result['b_city_wall']-1));
   	//修复所需消耗时间,升级时间的1%
   	$repair_time = $repair_percent / 100 * ($citywall_build_time * pow(1+$citywall_build_percent,$repair_result['b_city_wall']-1));
   
   	//判断资源是否足够
   	if($repair_rices > $repair_result['rices']) echomsg("粮食不足!");
   	if($repair_irons > $repair_result['ores']) echomsg("铁矿不足!");
   	if($repair_golds > $repair_result['golds']) echomsg("黄金不足!");
   	
//   	加上督造斯
   				if($b_current_result['officer_house']>="1"){
		  	    	$repair_time *= 0.5;
		  	    }
		  	    
		  	    if($b_current_result['officer_house']>="2"){
		  	    	$repair_time *= 0.6;
		  	    }
		  	    
		  	    if($b_current_result['officer_house']>="3"){
		  	    	$repair_time *= 0.7;
		  	    }
		  	    
		  	    if($b_current_result['officer_house']>="4"){
			  	    for($bi=1;$bi<=$b_current_result['officer_house']-3;$bi++){
			  	    	$repair_time *= 0.8;
			  	    }
		  	    }
		  
		  		if($repair_time<1) $repair_time = 1;
		  		
   	$start_time = time();
   	$end_time = $start_time + round($repair_time,0) * 60;
		  		
   	//插入到修复任务表中
   	$db->query("update citywall_repair_task set `repair_percent`='".$repair_percent."',`need_time`='".round($repair_time,0)."' where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
   	$query = $db->affected_rows();
   	if(!$query) $db->query("INSERT INTO `citywall_repair_task` ( `id` , `u_id` , `c_id` , `repair_percent` , `need_time` , `start_time` , `end_time` ) 
   	 VALUES ('', '".$_COOKIE['UserId']."', '".$_COOKIE['CityId']."', '".$repair_percent."', '".round($repair_time,0)."', '".$start_time."', '".$end_time."');");
	
	echomsg("","build.php?build_page=recovery");
   }

   
?>

⌨️ 快捷键说明

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