?? my_gen_mod.php
字號:
<?php
///////////////////////裝備數組付值///////////////////////////////
$goods_array=array(1=>'武器',
2=>'鎧甲',
3=>'兵符',
4=>'書藉',
5=>'坐騎'
);
/////////////////////////下拉選項擇列表名///////////////////////////////////////
$select_array=array(1=>'wuqi', //武器
2=>'kaijia', //鎧甲
3=>'binfu', //兵符
4=>'shuji', //書藉
5=>'zhuoqi' //坐騎
);
//查詢該武將是否有裝備,并寫入數組:1:武器,2:鎧甲,3:兵符,4:書藉,5:坐騎;
for ($i=1;$i<6;$i++)
{
$query=$db->query("select * from genequip where g_style='".$goods_array[$i]."' and u_id='".$_COOKIE['UserId']."' and g_id='".$_GET['mgend']."';");
$nus=$db->num_rows($query);
$na_list=$db->fetch_array($query);
if ($nus>0) {
$equip_gif[$i]=1;
//查詢物品對應基礎物品表內的id
$query_id=$db->query("select a.id from m_goods a left join interior_goods b on (b.s_id=a.id) where b.id='".$na_list['i_id']."';");
$id_list=$db->fetch_array($query_id);
$equip_gif_name[$i]=$id_list['id'];
$equip_name[$i]=$na_list['g_name'];
$equip_level[$i]=$na_list['g_level'];
//查詢物品效果;
$query_ef=$db->query("select a.i_effect from interior_goods a left join genequip b on (a.id=b.i_id) where b.i_id='".$na_list['i_id']."';");
$ef_list=$db->fetch_array($query_ef);
$equip_ef[$i]=$ef_list['i_effect'];
//裝備后增加的數值;
$query_num=$db->query("select b.* from interior_goods a left join m_goods b on (a.s_id=b.id) where a.id='".$na_list['i_id']."';");
$add_num_list=$db->fetch_array($query_num);
if ($i==1) {
$add_num[1]=$add_num_list['s_power']; //武力;
}elseif ($i==2) {
$add_num[2]='0';
$add_num[3]=$add_num_list['s_liftblood']; //帶兵數;
}elseif ($i==4) {
if ($add_num_list['s_stylenum']==4) {
// echomsg($add_num_list['s_stylenum']);
$add_num[4]=$add_num_list['s_commend']; //統率;
}elseif ($add_num_list['s_stylenum']==5) {
// echomsg($add_num_list['s_intellect']);
$add_num[5]=$add_num_list['s_intellect']; //智力;
}
}elseif ($i==5) {
$add_num[6]='0';
}
}else {
$equip_gif[$i]=0;
$equip_gif_name[$i]=0;
$equip_name[$i]=0;
$equip_level[$i]=0;
$equip_ef[$i]=0;
}
}
/////////////////
//
//武將移動;
//
/////////////////
if($_POST['form_action']=='move') {
//判斷武將是否在本城內;
$query_gen_city_id=$db->query("select g_cid from gen where id='".$_POST['gen_move_id']."'and g_uid='".$_COOKIE['UserId']."';");
$list_gen_city_id=$db->fetch_array($query_gen_city_id);
if($list_gen_city_id['g_cid']==$_POST['city_move']) echomsg("該武將在此城池中!");
//查詢目標城池是否有招賢館;
$query_build=$db->query("select b_pub from building where u_id='".$_COOKIE['UserId']."' and c_id='".$_POST['city_move']."';");
$build_list=$db->fetch_array($query_build);
if ($build_list['b_pub']<1) {
echomsg("目標城池沒有招賢館,武將不能移動!");
}
//查詢是否還有其它武將向此城移動
$query_gen_move=$db->query("select id from gen_move where u_id='".$_COOKIE['UserId']."' and e_c_id='".$_POST['city_move']."';");
$num_if=$db->num_rows($query_gen_move);
//查詢目標城池武將數量;
$query_gen_sum=$db->query("select id from gen where g_uid='".$_COOKIE['UserId']."' and g_cid='".$_POST['city_move']."';");
$city_gen_sum=$db->num_rows($query_gen_sum);
//計算武將容納上線;
if (($build_list['b_pub']%2)==0) {
$progen=$build_list['b_pub']/2;
}else {
$progen=(int)($build_list['b_pub']/2)+1;
}
if ($progen<=($city_gen_sum+$num_if)) {
echomsg("目標城池武將容納己達上限,請先升級目標城池招賢館等級!目標城池現有武將".$city_gen_sum."人,將要移動到此城池的武將有".$num_if."人");
}
//判斷武將是否是防御武將;
$query_gen_state=$db->query("select g_fy,g_status from gen where id='".$_POST['gen_move_id']."';");
$gen_state_list=$db->fetch_array($query_gen_state);
if ($gen_state_list['g_fy']=='1') {
echomsg("該武將為防御武將,不能進行此操作;");
}
if ($gen_state_list['g_status']<>0) {
echomsg("該武將為非空閑狀態,不能進行此操作;");
}
$end_times=time()+30*60;
//寫入武將移動表
$db->query("insert into gen_move (id, u_id ,c_id ,genid, e_c_id, end_times) values (null,'".$_COOKIE['UserId']."','".$_COOKIE['CityId']."','".$_POST['gen_move_id']."','".$_POST['city_move']."','".$end_times."');");
//更新武將狀態;
$db->query("update gen set g_status='6' where id='".$_POST['gen_move_id']."';");
echomsg("操作成功!","my_gen.php");
}
////////////////////////////解雇武將////////////////////////////////////////////
if ($_GET['action']=="下野") {
//判斷是否是防御武將;
$query=$db->query("select g_fy,g_status from gen where id='".$_GET['id']."' and g_uid='".$_COOKIE['UserId']."';");
$g_fy=$db->fetch_array($query);
if ($g_fy['g_fy']=='1') {
echomsg("該武將為防御武將,不可解雇!如要解雇請先設其它武將防御,再進行解雇!");
}
if ($g_fy['g_status']<>0) {
echomsg("該武將為非空閑狀態,不可解雇!");
}
//刪除武將;
$query=$db->query("delete from `gen` where `id`='".$_GET['id']."' and g_uid='".$_COOKIE['UserId']."';");
//當前城市武將人數減1;
$query=$db->query("update city set c_officers=(c_officers-1) where c_id='".$_COOKIE['CityId']."';");
refresh();
echomsg("解雇成功!","my_gen.php");
}
////////////////////////////設為防御武將////////////////////////////////////////////
if ($_GET['action']=="防御") {
//查詢玩家原有的防御武將;
$query=$db->query("select * from gen where g_fy=1 and g_uid='".$_COOKIE['UserId']."' and g_cid='".$_COOKIE['CityId']."';");
while ($list=$db->fetch_array($query)) {
$query=$db->query("update gen set g_fy=0 where id='".$list['id']."';");
}
//更新為防御武將;
$query=$db->query("update gen set g_fy=1 where id='".$_GET['mgend']."' and g_uid='".$_COOKIE['UserId']."';");
echomsg("設置成功!","?ac=genlist&&mgend=".$_GET['mgend']);
}
////////////////////////////設為防御武將////////////////////////////////////////////
if ($_GET['action']=="非防御") {
$query=$db->query("update gen set g_fy='0' where id='".$_GET['mgend']."' and g_uid='".$_COOKIE['UserId']."';");
echomsg("設置成功!","?ac=genlist&&mgend=".$_GET['mgend']);
}
//////////////////////武將賞賜//////////////////////////////////////////////////////////////////
if ($_POST['action']=='give') {
if ($_POST['golds']<=0) {
echomsg("黃金數不能為空!");
}
if (!ereg("^[0-9]*$",$_POST['golds'])) {
echomsg("只能輸入數字!");
}
//判斷從第一次賞賜到現在是否超過24小時
$query=$db->query("select largess_times from gen where id='".$_GET['mgend']."' and g_uid='".$_COOKIE['UserId']."';");
$largess_times_list=$db->fetch_array($query);
if (($largess_times_list['largess_times']+24*60*60)>=time()) {
//更新賞賜次數為0;
$query=$db->query("update gen set largess_num='0' where id='".$_GET['mgend']."' and g_uid='".$_COOKIE['UserId']."';");
}
//判斷一天之內是否賞賜超過5次
$query=$db->query("select largess_num from gen where id='".$_GET['mgend']."' and g_uid='".$_COOKIE['UserId']."';");
$largess_num_list=$db->fetch_array($query);
if ($largess_num_list['largess_num']=='5') {
echomsg("每個武將一天只可賞賜五次!","?ac=genlist&&mgend=".$_GET['mgend']);
}
//--------選擇賞賜黃金---------------------------------------------------
$query=$db->query("update resource set `golds`=(`golds`-'".$_POST['golds']."') where `u_id`='".$_COOKIE['UserId']."' and c_id='".$_COOKIE['CityId']."';");
$num=(int)($_POST['golds']/1000);
//賞賜次數是不是為0;
if ($largess_num_list['largess_num']=='0') {
$query=$db->query("update gen set `g_fealty`=(`g_fealty`+'".$num."'),largess_num=(largess_num+'1'),largess_times='".time()."' where `id`='".$_GET['mgend']."';");
}else {
$query=$db->query("update gen set `g_fealty`=(`g_fealty`+'".$num."'),largess_num=(largess_num+'1') where `id`='".$_GET['mgend']."';");
}
//查詢玩家武將忠誠;
$query=$db->query("select g_fealty from gen where id='".$_GET['mgend']."';");
$list=$db->fetch_array($query);
if ($list['g_fealty']>'100') {
//更新武將忠誠為100;
$query=$db->query("update gen set g_fealty='100' where id='".$_GET['mgend']."';");
}
refresh();
echomsg("操作成功!","?ac=genlist&&mgend=".$_GET['mgend']);
}
//////////////////////武將任免操作//////////////////////////////////////////////////////////////////////
if ($_POST['action2']=='remian') {
if ($_POST['business']=='0') {
echomsg("請選擇官職名稱!");
}
$query=$db->query("select `bu_name` from m_business where `id`='".$_POST['business']."';");
$list=$db->fetch_array($query);
$name=$list['bu_name'];
//修改玩家武將信息表
if ($_POST['business']==-1) {
$query=$db->query("update gen set `g_name`='暫無官職' where `id`='".$_GET['mgend']."';");
}else {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -