📄 local_market.php
字号:
<?php
require_once("configs/Configs.php");//是否已经登录
require_once("functions/login_flag.php");//是否已经登录
include_once("functions/class_mysql.php");//加载数据库类文件
include_once("functions/func_common.php");
//调用相关处理进程
require_once("all_processing.php");
/////金锭 金砖买卖处理
if ($_GET['is_upload']=='upload') {
if ($sys_safe_if) {
echomsg("交易暂时关闭","?");
}else {
//查询是否在战争中;
//include_once("warfare_safe.php");
$query=$db->query("select * from m_goods where id='".$_GET['god']."' ;");
$list=$db->fetch_array($query);
$ids = $list['id']; //基础物品表-ID;
$style_num= $list['s_stylenum'];//基础物品表-类别数字;
$shoping = $list['s_name']; //基础物品表-商品名称;
$type = $list['s_type']; //基础物品表-物品分类;
$sort = $list['s_sort']; //基础物品表-类别;
$price = $list['s_price']; //基础物品表-出售价格;
$effect = $list['s_effect']; //基础物品表-效果;
$level = $list['s_level']; //基础物品表-等级;
$s_type = $list['s_type']; //基础物品表-分类;
//金锭,金砖各一千个;
if ($shoping=='金锭') {
//查询玩家内政表里有多少金锭和金砖到一千个禁止购买;
$query_player_case=$db->query("select id from interior_goods where i_uid='".$_COOKIE['UserId']."' and i_goodsname='金锭';");
$player_case_num=$db->num_rows($query_player_case);
if ($player_case_num>=$cashmoney_max_nummber) echomsg("金锭数量己达上限!");
}
if ($shoping=='金砖') {
//查询玩家内政表里有多少金锭和金砖到一千个禁止购买;
$query_player_case=$db->query("select id from interior_goods where i_uid='".$_COOKIE['UserId']."' and i_goodsname='金砖';");
$player_case_num=$db->num_rows($query_player_case);
if ($player_case_num>=$cashmoney_max_nummber2) echomsg("金砖数量己达上限!");
}
////////////////////判断是否有购买数量,购买所有商品是否有足购的钱////////////////////////////////////////////////////
if ($_GET['goods_type_num']==7) {
//所要花费的元宝;
$cashmoney_sum=$price;
}else {
//所要花费的金钱;
$money_sum=$price;
}
//查询玩家当前的金钱和元宝数
$query=$db->query("select golds from resource where u_id='".$_COOKIE['UserId']."' and c_id='".$_COOKIE['CityId']."';");
$list_con=$db->fetch_array($query);
if ($list_con['golds']<$money_sum) {
echomsg("没有足够的钱来购买物品!");
}
$reduce_money=$price;//物品相应数量应该减少的钱数;
$db->query("update resource set `golds`=(`golds`-'".$reduce_money."'),`free_stores`=(`free_stores`-'".$reduce_money."') where `u_id`='".$_COOKIE['UserId']."' and c_id='".$_COOKIE['CityId']."';");//扣除玩家的金钱,减少仓库的存储量;
//写入玩家内政物品表;
if ($sort=='兵书'||$sort=='经书') {
$sort='书藉';//把兵书,经书,医书,奇书,统一定为书藉类型;
}
$query_tyw=$db->query("select * from interior_goods where i_uid='".$_COOKIE['UserId']."'
and i_goodsname='".$shoping."' ");
$list_ty3=$db->fetch_array($query_tyw);
$id_ty3=$list_ty3['id'];
$num=$list_ty3['num'];
if($id_ty3!=''){
$num=$num+1;
$db->query("update interior_goods set num='".$num."' where i_uid='".$_COOKIE['UserId']."' and i_goodsname='".$shoping."' ");
}else{
$db->query("insert into interior_goods (`id`,`i_uid`,`s_id`,`i_style`,`i_style_num`,`i_goodsname`,`i_effect`,`i_state`,`i_level`,`s_type`,num) values (null,'".$_COOKIE['UserId']."','".$ids."','".$sort."','".$style_num."','".$shoping."','".$effect."','2','".$level."','".$s_type."','1') ");
}
//更新资源页面;
refresh();
echomsg("购买完成!","?");
}
}
if ($_POST['reso_put']=="giveput") {//判断是否有提交
// print_r($_POST);
//查询是否在战争中;
// include_once("warfare_safe.php");
if ($_POST['gold3']==""&&$_POST['gold1']==""&&$_POST['gold2']==""&&$_POST['woods']==""&&$_POST['iron']==""&&$_POST['oil']=="") {
echomsg("没有交易数量!","?");
}
if (!ereg("^[0-9]*$",$_POST['gold3'])||!ereg("^[0-9]*$",$_POST['gold1'])||!ereg("^[0-9]*$",$_POST['gold2'])||!ereg("^[0-9]*$",$_POST['woods'])||!ereg("^[0-9]*$",$_POST['iron'])||!ereg("^[0-9]*$",$_POST['oil'])) {
echomsg("只能是数字!","?");
}
if ($_POST['gold3']<>'0'||$_POST['gold1']<>'0'||$_POST['gold2']<>'0'||$_POST['woods']<>'0'||$_POST['iron']<>'0'||$_POST['oil']<>'0') {
//兑换数目;
$du_num=array(
1=>70, //黄金换木材;
2=>65, //黄金换矿石;
3=>50, //黄金换粮食;
4=>91, //木材换黄金;
5=>85, //矿石换黄金;
6=>65 //粮食换黄金;
);
//兑换品种;
$du_type=array(
1=>$_POST['gold3'], //黄金换木材;
2=>$_POST['gold1'], //黄金换矿石;
3=>$_POST['gold2'], //黄金换粮食;
4=>$_POST['woods'], //木材换黄金;
5=>$_POST['iron'], //矿石换黄金;
6=>$_POST['oil'] //粮食换黄金;
);
//查询玩家资源信息;
$query=$db->query("select * from resource where u_id='".$_COOKIE['UserId']."' and c_id='".$_COOKIE['CityId']."';");
$resource_info=$db->fetch_array($query);
if ($resource_info['woods']<(int)($du_type['4'])) {
echomsg("木材不够!","?");
}
if ($resource_info['ores']<(int)($du_type['5'])) {
echomsg("铁矿不够!","?");
}
if ($resource_info['rices']<(int)($du_type['6'])) {
echomsg("粮食不够!","?");
}
//对兑换所有物品需要的黄金进行算;
$money=0;
for ($i=1;$i<4;$i++)
{
$money=$money+(int)($du_type[$i]);
}
$money=$money-(int)($du_type['4']/$du_num['4'])-(int)($du_type['5']/$du_num['5'])-(int)($du_type['6']/$du_num['6']);
//判断黄金够不够;
if ($resource_info['golds']<$money) {
echomsg("黄金不够!","?");
}
//进行资源兑换;
$woods=$du_num['1']*$du_type['1']-$du_type['4'];
$ores =$du_num['2']*$du_type['2']-$du_type['5'];
$rices=$du_num['3']*$du_type['3']-$du_type['6'];
$query=$db->query("update resource set golds=(golds-'".$money."') , woods=(woods+'".$woods."') ,ores=(ores+'".$ores."'),rices=(rices+'".$rices."') where u_id='".$_COOKIE['UserId']."' and c_id='".$_COOKIE['CityId']."';");
refresh();
$db->close();
echomsg("操作成功!","?");
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>本地交易市场</title>
<link href="css/id.css" rel="stylesheet" type="text/css">
<link href="css/css.css" rel="stylesheet" type="text/css">
<link type="text/css" href="css/build.css" rel="stylesheet">
<script type="text/javascript">
function keycode() {
if(event.keyCode==13) {
event.returnValue=false;
}
}
</script>
<style>
body{
margin-top:0px;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -