1
This commit is contained in:
parent
d256efc357
commit
75ed033beb
10
boundle.sh
Executable file
10
boundle.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
tag_name=`git status |grep '# On branch '|sed 's/# On branch //g'`
|
||||
dir_name=`basename $PWD`
|
||||
package_name=${dir_name}.tar.gz
|
||||
#echo $tag_name
|
||||
#echo $dir_name
|
||||
#echo $package_name
|
||||
|
||||
tar --exclude=*.git -chzf target/${package_name} webapp config res reload.sh restart.sh reloadres.sh
|
314
webapp/controller/BagController.class.php
Normal file
314
webapp/controller/BagController.class.php
Normal file
@ -0,0 +1,314 @@
|
||||
<?php
|
||||
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
class BagController{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig(crc32($account_id));
|
||||
$conn = new phpcommon\Mysql(array(
|
||||
'host' => $mysql_conf['host'],
|
||||
'port' => $mysql_conf['port'],
|
||||
'user' => $mysql_conf['user'],
|
||||
'passwd' => $mysql_conf['passwd'],
|
||||
'dbname' => 'gamedb2004_' . $mysql_conf['instance_id']
|
||||
));
|
||||
return $conn;
|
||||
}
|
||||
|
||||
protected function getBag($bag_id)
|
||||
{
|
||||
$g_conf_bag_cluster = require('../res/bag@bag.php');
|
||||
$bag_conf = getBagConfig($g_conf_bag_cluster, $bag_id);
|
||||
$b = array(
|
||||
'id' => $bag_conf['id'],
|
||||
'name' => $bag_conf['name'],
|
||||
'fuction' => $bag_conf['fuction'],
|
||||
);
|
||||
return $b;
|
||||
}
|
||||
|
||||
protected function getItem($item_id)
|
||||
{
|
||||
$g_conf_item_cluster = require('../res/item@item.php');
|
||||
$item_conf = getItemConfig($g_conf_item_cluster, $item_id);
|
||||
$it = array(
|
||||
'id' => $item_conf['id'],
|
||||
'diamond' => $item_conf['diamond'],
|
||||
'dprice' => $item_conf['dprice'],
|
||||
'type' => $item_conf['fuction'],
|
||||
'diamond_hour' => $item_conf['diamond_hour']
|
||||
);
|
||||
return $it;
|
||||
}
|
||||
|
||||
protected function getParameter($para_id)
|
||||
{
|
||||
$g_conf_para_cluster = require('../res/parameter@parameter.php');
|
||||
$para_conf = getParameterConfig($g_conf_para_cluster, $para_id);
|
||||
$p = array(
|
||||
'id' => $para_conf['id'],
|
||||
'param_name' => $para_conf['param_name'],
|
||||
'param_value' => $para_conf['param_value'],
|
||||
);
|
||||
return $p;
|
||||
}
|
||||
|
||||
public function getBagInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$bag_list = array();
|
||||
$rows = $conn->execQuery('SELECT * FROM bag WHERE accountid=:account_id;',
|
||||
array(
|
||||
':account_id' => $account_id
|
||||
));
|
||||
if ($rows) {
|
||||
foreach ($rows as $row){
|
||||
$active_time = 0;
|
||||
$color_id = 0;
|
||||
if (time() >= $row['active_time'] && $row['active_time'] != 0) {
|
||||
$ret = $conn->execScript('UPDATE bag SET active_time=0, color_id=0, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:account_id AND id=:id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':id' => $row['id'],
|
||||
':modify_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$active_time = 0;
|
||||
$color_id = 0;
|
||||
} else {
|
||||
if ($row['active_time'] != 0) {
|
||||
$active_time = $row['active_time'];
|
||||
}
|
||||
$color_id = $row['color_id'];
|
||||
}
|
||||
array_push($bag_list, array(
|
||||
'id' => $row['id'],
|
||||
'active_time' => $active_time,
|
||||
'status' => $row['status'],
|
||||
'color_id' => $color_id,
|
||||
));
|
||||
}
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'bag_list' => $bag_list
|
||||
));
|
||||
}
|
||||
|
||||
public function exchangeBagItem() {
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$item_id = $_REQUEST['item_id'];
|
||||
$color_id = $_REQUEST['color_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
if(!$conn){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$b = $this->getBag($item_id);
|
||||
$bag_meta_table = require('../res/bag@bag.php');
|
||||
//正在装备的道具
|
||||
if ($b['fuction'] != 5) {
|
||||
foreach ($bag_meta_table as $bag_info) {
|
||||
$id = $bag_info['id'];
|
||||
$bag = $this->getBag($id);
|
||||
if ($bag['fuction'] != $b['fuction']) {
|
||||
continue;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT status, active_time FROM bag WHERE accountid=:accountid AND id=:id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':id' => $id,
|
||||
));
|
||||
if ($row['status'] != 0 || !$row) {
|
||||
continue;
|
||||
}
|
||||
$status = 2;
|
||||
if ($row['active_time'] == 0) {
|
||||
$status = 1;
|
||||
}
|
||||
$using_ret = $conn->execScript('UPDATE bag SET status=:status, color_id=0, modify_time=:modify_time ' .
|
||||
' WHERE accountid = :account_id AND id = :id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':id' => $id,
|
||||
':status' => $status,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if(!$using_ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
//要装备的道具
|
||||
$row = $conn->execQueryOne('SELECT status FROM bag WHERE accountid=:accountid AND id=:id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':id' => $item_id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具');
|
||||
return;
|
||||
}
|
||||
|
||||
$exchange_ret = $conn->execScript('UPDATE bag SET status=0, color_id=:color_id, modify_time=:modify_time ' .
|
||||
' WHERE accountid = :account_id AND id = :id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':id' => $item_id,
|
||||
':color_id' => $color_id,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if(!$exchange_ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'item_id' => $item_id,
|
||||
'color_id' => $color_id
|
||||
));
|
||||
}
|
||||
|
||||
public function downItem()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$item_id = $_REQUEST['item_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
if(!$conn){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$b = $this->getBag($item_id);
|
||||
|
||||
$row = $conn->execQueryOne('SELECT status,active_time FROM bag WHERE accountid=:accountid AND id=:id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':id' => $item_id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个道具');
|
||||
return;
|
||||
}
|
||||
$status = 2;
|
||||
if ($row['active_time'] == 0) {
|
||||
$status = 1;
|
||||
}
|
||||
$exchange_ret = $conn->execScript('UPDATE bag SET status=:status, color_id=0, modify_time=:modify_time ' .
|
||||
' WHERE accountid = :account_id AND id = :id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':id' => $item_id,
|
||||
':status' => $status,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if(!$exchange_ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'item_id' => $item_id,
|
||||
'color_id' => 0
|
||||
));
|
||||
}
|
||||
|
||||
public function downItemColor()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$item_id = $_REQUEST['item_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
if(!$conn){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
|
||||
$exchange_ret = $conn->execScript('UPDATE bag SET status=:status, color_id=0, modify_time=:modify_time ' .
|
||||
' WHERE accountid = :account_id AND id = :id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':id' => $item_id,
|
||||
':status' => $status,
|
||||
':modify_time' => time()
|
||||
));
|
||||
if(!$exchange_ret){
|
||||
die();
|
||||
return;
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'item_id' => $item_id,
|
||||
'color_id' => 0
|
||||
));
|
||||
}
|
||||
|
||||
public function tryItem()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
|
||||
return;
|
||||
}
|
||||
$item_id = $_REQUEST['item_id'];
|
||||
error_log($item_id);
|
||||
$conn = $this->getMysql($account_id);
|
||||
if(!$conn){
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward($item_id, 1, $account_id, 1);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'item_id' => $item_id,
|
||||
'color_id' => 0
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
@ -244,13 +244,14 @@ class PassController{
|
||||
$seaPoint = $this->getSeasonPoint($passid);
|
||||
$delim = ':';
|
||||
$drop_multiply = explode($delim, $seaPoint['reward']);
|
||||
$reward = array();
|
||||
array_push($reward, array(
|
||||
'item_id' => $drop_multiply[0],
|
||||
'item_num' => $drop_multiply[1],
|
||||
'time' => $drop_multiply[2],
|
||||
));
|
||||
$addreward = new classes\AddReward();
|
||||
$all_item_list = $addreward->addReward($r['item_id'], $r['item_num'], $account_id, $r['time']);
|
||||
$all_item_list = $addreward->addReward($drop_multiply[0], $drop_multiply[1], $account_id, $drop_multiply[2]);
|
||||
|
||||
$coin_num = $addreward->getCoinNum($account_id);
|
||||
$diamond_num = $addreward->getDiamondNum($account_id);
|
||||
@ -320,7 +321,7 @@ class PassController{
|
||||
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|
||||
|| $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1)
|
||||
{
|
||||
$drop_multiply = $this->getExplode($seaPoint['reward']);
|
||||
$drop_multiply = $this->getExplode($seaPoint['weekreward']);
|
||||
for($i = 0; $i < count($drop_multiply); $i++) {
|
||||
array_push($reward, array(
|
||||
'item_id' => $drop_multiply[$i][0],
|
||||
@ -332,9 +333,9 @@ class PassController{
|
||||
}
|
||||
}
|
||||
$addreward = new classes\AddReward();
|
||||
$all_item_list = array();
|
||||
foreach ($reward as $r) {
|
||||
$addreward->addReward($r['item_id'], $r['item_num'], $account_id, $r['time']);
|
||||
$items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time']);
|
||||
$items = $addreward->addReward($r['item_id'], $r['item_num'], $account_id, $r['time']);
|
||||
foreach($items as $i) {
|
||||
array_push($all_item_list, array(
|
||||
'item_id' => $i['item_id'],
|
||||
|
@ -274,6 +274,7 @@ class SignController{
|
||||
$num_array = $this->getExplode($s['num']);
|
||||
$time_array = $this->getExplode($s['time']);
|
||||
$addreward = new classes\AddReward();
|
||||
$all_item_list = array();
|
||||
for ($i = 0; $i < count($item_id_array); $i++) {
|
||||
$item_id = $item_id_array[$i][0];
|
||||
error_log(json_encode($item_id_array));
|
||||
@ -285,8 +286,8 @@ class SignController{
|
||||
'item_num' => $num,
|
||||
'time' => $time,
|
||||
));
|
||||
$addreward->addReward($item_id, $num, $account_id, $time);
|
||||
$items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time']);
|
||||
$items = $addreward->addReward($item_id, $num, $account_id, $time);
|
||||
|
||||
foreach($items as $i) {
|
||||
array_push($all_item_list, array(
|
||||
'item_id' => $i['item_id'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user