📄 lurcher_educate_create_task.php
字号:
<?php
//读取研究表study
$query=$db->query("select s.s_army,r.golds,r.rices from study as s,resource as r where s.`u_id`=r.`u_id` and s.`u_id`='".$_COOKIE['UserId']."'");
$study_result=$db->fetch_array($query);
//当前间谍数量
$query=$db->query("select * from lurcher where `u_id`='".$_COOKIE['UserId']."' and `c_id`='".$_COOKIE['CityId']."'");
$lurcher=$db->fetch_array($query);
//间谍训练任务队列
if($_POST['action']=="lurcher_educate"){
//读取用户提交的表单数据|||||||||||||||||||||||||||||||||||||||||||||||||||
if(!eregi("^[0-9]+$",trim($_POST['l_num']))) echomsg("请输入训练数量!");
$l_num=trim($_POST['l_num']);
if(($l_num<1 or strlen($l_num)<1)) echomsg("");
//计算所需资源、时间////||||||||||||||||||||||||||||||||||||||||||||||||
$l_rices= $l_num * $lurcher_educate_rices;
$l_golds= $l_num * $lurcher_educate_golds;
$l_times= $lurcher_educate_time; //所需时间:以分钟为单位
$max_educate = $study_result['s_army'] * 2 - $lurcher['lurcher_num'];
if($l_num > $max_educate) echomsg("条件不足,需研究科技更高等级的[军情刺探]!");
if($l_rices > $study_result['rices']) echomsg("粮食资源不足!");
if($l_golds > $study_result['golds']) echomsg("黄金资源不足!");
//扣除资源:
$query=$db->query("update resource set `free_stores`=(`free_stores`-'".($l_rices+$l_golds)."'),`rices`=(`rices`-'".$l_rices."'),`golds`=(`golds`-'".$l_golds."') where `u_id`='".$_COOKIE['UserId']."'");
if($query){
$l_start_time = time();
$l_end_time = $l_start_time + $l_times * 60;
//加速
$l_end_time = $l_end_time * $speed_percent;
$query=$db->query("insert into lurcher_task(`id`,`u_id`,`c_id`,`l_num`,`l_time`,`l_start_time`,`l_end_time`,`l_sort`) values('','".$_COOKIE['UserId']."','".$_COOKIE['CityId']."','".$l_num."','".$l_times."','".$l_start_time."','".$l_end_time."','')");
update_resource();
if($query) echomsg("","lurcher_educate.php");
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -