📄 building_max.php
字号:
<?php
//获取建筑最大建造数量
require_once("../functions/class_mysql.php");
$query=$db->query("select * from resource as r,city as c where r.`u_id`=c.`u_id` and r.`u_id`='".$_COOKIE['UserId']."' and c.`c_id`='".$_COOKIE['CityId']."' ");
$result=$db->fetch_array($query);
if($_GET['b_type']=="1"){//伐木场
if($result['free_woodlands']<$_GET['woodlands'] or $result['woods']<$_GET['woods'] or $result['golds']<$_GET['golds']){
echo "0";exit;
}
$temp_woodlands=floor($result['free_woodlands']/$_GET['woodlands']);
$temp_woods=floor($result['woods']/$_GET['woods']);
$temp_golds=floor($result['golds']/$_GET['golds']);
echo min($temp_woodlands,$temp_woods,$temp_golds);
exit;
}
if($_GET['b_type']=="2"){//采矿场
if($result['free_hills']<$_GET['hills'] or $result['woods']<$_GET['woods'] or $result['golds']<$_GET['golds']){
echo "0";exit;
}
$temp_hills=floor($result['free_hills']/$_GET['hills']);
$temp_woods=floor($result['woods']/$_GET['woods']);
$temp_golds=floor($result['golds']/$_GET['golds']);
echo min($temp_hills,$temp_woods,$temp_golds);
exit;
}
if($_GET['b_type']=="3"){//金矿
if($result['free_hills']<$_GET['hills'] or $result['woods']<$_GET['woods'] or $result['ores']<$_GET['irons'] or $result['golds']<$_GET['golds']){
echo "0";exit;
}
$temp_hills=floor($result['free_hills']/$_GET['hills']);
$temp_woods=floor($result['woods']/$_GET['woods']);
$temp_irons=floor($result['ores']/$_GET['irons']);
$temp_golds=floor($result['golds']/$_GET['golds']);
echo min($temp_hills,$temp_woods,$temp_irons,$temp_golds);
exit;
}
if($_GET['b_type']=="4"){//农田
if($result['free_woodlands']<$_GET['woodlands'] or $result['woods']<$_GET['woods'] or $result['golds']<$_GET['golds']){
echo "0";exit;
}
$temp_woodlands=floor($result['free_woodlands']/$_GET['woodlands']);
$temp_woods=floor($result['woods']/$_GET['woods']);
$temp_golds=floor($result['golds']/$_GET['golds']);
echo min($temp_woodlands,$temp_woods,$temp_golds);
exit;
}
if($_GET['b_type']=="5"){//民居
if($result['free_flats']<$_GET['flats'] or $result['rices']<$_GET['rices'] or $result['woods']<$_GET['woods'] or $result['golds']<$_GET['golds']){
echo "0";exit;
}
$temp_flats=floor($result['free_flats']/$_GET['flats']);
$temp_rices=floor($result['rices']/$_GET['rices']);
$temp_woods=floor($result['woods']/$_GET['woods']);
$temp_golds=floor($result['golds']/$_GET['golds']);
echo min($temp_flats,$temp_rices,$temp_woods,$temp_golds);
exit;
}
if($_GET['b_type']=="8"){//兵营
if($result['free_flats']<$_GET['flats'] or $result['rices']<$_GET['rices'] or $result['woods']<$_GET['woods'] or $result['ores']<$_GET['irons'] or $result['golds']<$_GET['golds']){
echo "0";exit;
}
$temp_flats=floor($result['free_flats']/$_GET['flats']);
$temp_rices=floor($result['rices']/$_GET['rices']);
$temp_woods=floor($result['woods']/$_GET['woods']);
$temp_irons=floor($result['ores']/$_GET['irons']);
$temp_golds=floor($result['golds']/$_GET['golds']);
echo min($temp_flats,$temp_rices,$temp_woods,$temp_irons,$temp_golds);
exit;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -