1
This commit is contained in:
parent
571b9cc330
commit
b8bb70a77f
@ -16,6 +16,7 @@ import datetime
|
||||
import redis
|
||||
import os
|
||||
import functools
|
||||
import test
|
||||
|
||||
|
||||
CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2004api_rankserver/config'
|
||||
@ -248,6 +249,7 @@ def _incrementUpdateRank(rushtime):
|
||||
|
||||
if __name__ == "__main__":
|
||||
q7.xPrint('pid %d' % os.getpid())
|
||||
test.say()
|
||||
f7.app.init('/data/logs/game2005_rankserver/logs')
|
||||
f7.udplog.info('rankserver start pid:' + str(os.getpid()))
|
||||
|
||||
|
@ -5,18 +5,25 @@ require 'phpcommon/common.php';
|
||||
|
||||
define('TEAMID_KEY', 'team_uuid:');
|
||||
//每日任务
|
||||
define('QUEST_DAY_LOGIN', 71001);
|
||||
define('QUEST_DAY_SHARE', 71002);
|
||||
define('QUEST_DAY_FIGHT', 71003);
|
||||
define('QUEST_DAY_SUPPLY', 71004);
|
||||
define('QUEST_DAY_UPDATEEQUIP', 71005);
|
||||
define('QUEST_DAY_TEAM', 71006);
|
||||
define('QUEST_DAY_RANK', 71007);
|
||||
define('QUEST_DAY_ALIVE', 71008);
|
||||
define('QUEST_DAY_HARM', 71009);
|
||||
define('QUEST_DAY_KILL', 71010);
|
||||
define('QUEST_DAY_HELP', 71011);
|
||||
define('QUEST_DAY_COMPLETE', 71012);
|
||||
define('QUEST_DAY_LOGIN', 70001);//每日登录
|
||||
define('PLAY_GAME', 70002);//参与N场比赛
|
||||
define('ALIVE_TIME', 70005);//累计生存多少分钟
|
||||
define('KILL_NUM',70007);//累计击杀10个敌人
|
||||
define('DAMAGE_NUM70006',70006);//造成800伤害
|
||||
define('Daily_AP_ID', 10011);//每日活跃度ID
|
||||
define('WEEK_AP_ID', 10012);//周活跃度ID
|
||||
define('HELP_OP70008',70008);//救起2个队友
|
||||
// define('QUEST_DAY_SHARE', 71002);
|
||||
// define('QUEST_DAY_FIGHT', 71003);
|
||||
// define('QUEST_DAY_SUPPLY', 71004);
|
||||
// define('QUEST_DAY_UPDATEEQUIP', 71005);
|
||||
// define('QUEST_DAY_TEAM', 71006);
|
||||
// define('QUEST_DAY_RANK', 71007);
|
||||
// define('QUEST_DAY_ALIVE', 71008);
|
||||
// define('QUEST_DAY_HARM', 71009);
|
||||
// define('QUEST_DAY_KILL', 71010);
|
||||
// define('QUEST_DAY_HELP', 71011);
|
||||
// define('QUEST_DAY_COMPLETE', 71012);
|
||||
//活动
|
||||
define('QUEST_ACTIVITY_LOGIN', 83001);
|
||||
define('QUEST_ACTIVITY_GAME', 83002);
|
||||
|
@ -12,15 +12,17 @@ class BaseAuthedController extends BaseController {
|
||||
|
||||
public function handlePre()
|
||||
{
|
||||
$this->accountId = $_REQUEST['account_id'];
|
||||
$this->accountId = $_REQUEST['account_id'];
|
||||
$this->sessionId = $_REQUEST['session_id'];
|
||||
if ($_REQUEST['c'] == 'Role' && $_REQUEST['a'] == 'battleReport') {
|
||||
return;
|
||||
}
|
||||
if (!phpcommon\isValidSessionId($this->accountId,
|
||||
$this->sessionId)) {
|
||||
phpcommon\sendError(500, '无效的session_id');
|
||||
die();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getAccountId()
|
||||
{
|
||||
return $this->accountId;
|
||||
@ -46,6 +48,7 @@ class BaseAuthedController extends BaseController {
|
||||
protected function getMysql($data)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig(crc32($data));
|
||||
//error_log("Sql01=====".json_encode($mysql_conf)."==".DBNAME_PREFIX . $mysql_conf['instance_id']);
|
||||
$conn = new phpcommon\Mysql(array(
|
||||
'host' => $mysql_conf['host'],
|
||||
'port' => $mysql_conf['port'],
|
||||
@ -143,6 +146,7 @@ class BaseAuthedController extends BaseController {
|
||||
protected function addItem($items)
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
error_log("准备添加道具======".json_encode($items));
|
||||
if ($this->isVirtualItem($item['item_id'])) {
|
||||
if ($item['item_id'] == $this->goldID) {
|
||||
$this->addGold($item['item_num']);
|
||||
@ -273,11 +277,11 @@ class BaseAuthedController extends BaseController {
|
||||
)
|
||||
);
|
||||
}
|
||||
protected function checkPriceEnough($price)
|
||||
protected function checkPriceEnough($_priceID,$_priceNum)
|
||||
{
|
||||
$priceStrArr = explode(":",$price);
|
||||
$tmpID = $priceStrArr[0];
|
||||
$priceNum = $priceStrArr[1];
|
||||
//$priceStrArr = explode(":",$price);
|
||||
$tmpID = $_priceID;
|
||||
$priceNum = $_priceNum;
|
||||
$accountID = $this->getAccountId();
|
||||
$conn = $this->getMysql($accountID);
|
||||
$sqlStr = null;
|
||||
@ -306,7 +310,7 @@ class BaseAuthedController extends BaseController {
|
||||
$tmpNum = $row[0]["coin_num"];
|
||||
if($tmpNum < $priceNum)
|
||||
{
|
||||
$code = 98;//金币不足
|
||||
$code = 88;//金币不足
|
||||
}
|
||||
|
||||
}
|
||||
@ -315,47 +319,18 @@ class BaseAuthedController extends BaseController {
|
||||
$tmpNum = $row[0]["diamond_num"];
|
||||
if($tmpNum < $priceNum)
|
||||
{
|
||||
$code = 97;//钻石不足
|
||||
$code = 87;//钻石不足
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;//道具不足
|
||||
$code = 86;//道具不足
|
||||
}
|
||||
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
protected function getShopItemByID($itemID)
|
||||
{
|
||||
$shopCfgArr = require('../res/newshop@newshop.php');
|
||||
$tmpArrLen = count($this->itemArr);
|
||||
error_log("数组长度======".$tmpArrLen."==".json_encode($this->itemArr));
|
||||
if($tmpArrLen <= 0)
|
||||
{
|
||||
foreach ($shopCfgArr as $item)
|
||||
{
|
||||
$goodsIDStr = $item["goods"];
|
||||
$tmpPriceStr = $item["price"];
|
||||
$goodsIDArrStr = explode("|",$goodsIDStr);
|
||||
$goodsPriceArrStr = explode("|",$tmpPriceStr);
|
||||
$len = count($goodsIDArrStr);
|
||||
for($i = 0 ; $i < $len ;$i++)
|
||||
{
|
||||
$goodsIDArr = explode(":",$goodsIDArrStr[$i]);
|
||||
$priceArr = explode(":",$goodsPriceArrStr[$i]);
|
||||
$goodsID = $goodsIDArr[0];
|
||||
$goodsNum = $goodsIDArr[1];
|
||||
$priceID = $priceArr[0];
|
||||
$priceNum = $priceArr[1];
|
||||
$itemInfo = array("goodsID"=>$goodsID,"goodsNum"=>$goodsNum,"priceID"=>$priceID,"priceNum"=>$priceNum);
|
||||
array_push($this->itemArr,$itemInfo);
|
||||
}
|
||||
error_log("testShopCfg======".json_encode($this->itemArr));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -85,413 +85,8 @@ class HangController extends BaseAuthedController {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$quest_list = array();
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
//任务
|
||||
$rowCount = $conn->execQueryRowCount('SELECT * FROM quest WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
if ($rowCount != 0) {
|
||||
$rows = $conn->execQuery('SELECT * FROM quest WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
array_push($quest_list, array(
|
||||
'type' => $row['quest_type'],
|
||||
'quest_id' => $row['quest_id'],
|
||||
'quest_num' => $row['quest_num'],
|
||||
'quest_state' => $row['quest_state']
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
//赛季
|
||||
//判断当前赛季
|
||||
$number = 0;
|
||||
$open_time = 0;
|
||||
$end_time = 0;
|
||||
$sea_reward = array();
|
||||
$sea_reward2 = array();
|
||||
$rank_status = 0;
|
||||
$season = metatable\getNowSeason();
|
||||
$number = metatable\getNowSeasonNum();
|
||||
$open_time = strtotime($season['time1']);
|
||||
$end_time = strtotime($season['time2']);
|
||||
$item_multiply = $this->getExplode($season['season_reward']);
|
||||
$item_multiply2 = $this->getExplode($season['season_reward2']);
|
||||
for($ii = 1; $ii <= count($item_multiply); $ii++) {
|
||||
$rowpass = $conn->execQueryOne('SELECT active_status, honor_status ' .
|
||||
' FROM passinfo WHERE accountid=:accountid AND passid=:passid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':passid' => $ii,
|
||||
));
|
||||
$rank_status = 0;
|
||||
$rank_status2 = 0;
|
||||
if (!$rowpass) {
|
||||
$ret = $conn->execScript('INSERT INTO passinfo(accountid, passid, active_status, honor_status, create_time, modify_time) ' .
|
||||
' VALUES(:accountid, :passid, 0, 0, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, passid=:passid, active_status=0, honor_status=0, modify_time=:modify_time;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':passid' => $ii,
|
||||
':create_time' => phpcommon\getNowTime(),
|
||||
':modify_time' => phpcommon\getNowTime()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$rank_status = 0;
|
||||
$rank_status2 = 0;
|
||||
} else {
|
||||
$rank_status = $rowpass['active_status'];
|
||||
$rank_status2 = $rowpass['honor_status'];
|
||||
}
|
||||
|
||||
$key = $ii - 1;
|
||||
array_push($sea_reward, array(
|
||||
'item_id' => $item_multiply[$key][0],
|
||||
'item_num' => $item_multiply[$key][1],
|
||||
'time' => $item_multiply[$key][2],
|
||||
'status' => $rank_status,
|
||||
'type' => 0,
|
||||
));
|
||||
array_push($sea_reward2, array(
|
||||
'item_id' => $item_multiply2[$key][0],
|
||||
'item_num' => $item_multiply2[$key][1],
|
||||
'time' => $item_multiply2[$key][2],
|
||||
'status' => $rank_status2,
|
||||
'type' => 1,
|
||||
));
|
||||
}
|
||||
if ($number == 0) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '赛季未开启');
|
||||
return;
|
||||
}
|
||||
//当前段位及积分
|
||||
$rank = 1;
|
||||
$rank_score = 0;
|
||||
$max_rank_score = 0;
|
||||
$min_rank_score = 0;
|
||||
$reward = array();
|
||||
$week_reward = array();
|
||||
$max_rank = 1;
|
||||
$row = $conn->execQueryOne('SELECT integral, pass_status, score, max_integral FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$pass_status = $row['pass_status'];
|
||||
$rank_status = 0;
|
||||
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
|
||||
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
|
||||
$seaPoint = $this->getSeasonPoint($ii);
|
||||
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|
||||
|| $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1)
|
||||
{
|
||||
$rank = $ii;
|
||||
$min_rank_score = $seaPoint['min'];
|
||||
$max_rank_score = $seaPoint['max'] + 1 - $seaPoint['min'];
|
||||
$rank_score = $row['integral'] - $seaPoint['min'] + 1;
|
||||
if ($seaPoint['max'] == -1) {
|
||||
$max_rank_score = $seaPoint['min'];
|
||||
$rank_score = $row['integral'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($row['max_integral'] >= $seaPoint['min'] && $row['max_integral'] <= $seaPoint['max']
|
||||
|| $row['max_integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1)
|
||||
{
|
||||
|
||||
$max_rank = $ii;
|
||||
}
|
||||
}
|
||||
|
||||
//等级积分
|
||||
$pass_array = metatable\getNowSeasoncard($row['score']);
|
||||
$pass_lv = metatable\getNowSeasoncardInfo($row['score']);
|
||||
$delim1 = '|';
|
||||
$drop_multiply = explode($delim1, $season['week_reward']);
|
||||
|
||||
$delim2 = ';';
|
||||
$mul = explode($delim2, $drop_multiply[$pass_lv - 1]);
|
||||
|
||||
$delim = ':';
|
||||
$week_array = array();
|
||||
for ($i2 = 0; $i2 < count($mul); $i2++) {
|
||||
$mul1 = explode($delim, $mul[$i2]);
|
||||
array_push($week_array, $mul1);
|
||||
}
|
||||
|
||||
for($s = 0; $s < count($week_array); $s++) {
|
||||
array_push($week_reward, array(
|
||||
'item_id' => $week_array[$s][0],
|
||||
'item_num' => $week_array[$s][1],
|
||||
'time' => $week_array[$s][2],
|
||||
'status' => $row['pass_status']
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
//背包
|
||||
$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;
|
||||
$status = $row['status'];
|
||||
if (phpcommon\getNowTime() >= $row['active_time'] && $row['active_time'] != 0) {
|
||||
$ret = $conn->execScript('UPDATE bag SET active_time=0, color_id=0, status=2, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:account_id AND id=:id;',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
':id' => $row['id'],
|
||||
':modify_time' => phpcommon\getNowTime()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$active_time = 0;
|
||||
$color_id = 0;
|
||||
$status = 2;
|
||||
} else {
|
||||
if ($row['active_time'] != 0) {
|
||||
$active_time = $row['active_time'];
|
||||
}
|
||||
$color_id = $row['color_id'];
|
||||
$status = $row['status'];
|
||||
}
|
||||
array_push($bag_list, array(
|
||||
'id' => $row['id'],
|
||||
'active_time' => $active_time,
|
||||
'status' => $status,
|
||||
'color_id' => $color_id,
|
||||
'num' => $row['num'],
|
||||
));
|
||||
}
|
||||
}
|
||||
//吃鸡
|
||||
$row = $conn->execQueryOne('SELECT daily_order1, daily_order2, daily_order3 FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$row) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$item_list = array();
|
||||
$daily_order1 = $row['daily_order1'];
|
||||
$daily_order2 = $row['daily_order2'];
|
||||
$daily_order3 = $row['daily_order3'];
|
||||
$p1 = $this->getParameter(LOGINBOX_TIME1);
|
||||
$p2 = $this->getParameter(LOGINBOX_TIME2);
|
||||
$p3 = $this->getParameter(LOGINBOX_TIME3);
|
||||
$p = $this->getParameter(LOGINBOX_TIME);
|
||||
$pt1 = $p1['value'];
|
||||
$pt2 = $p2['value'];
|
||||
$pt3 = $p3['value'];
|
||||
$pt = $p['value'];
|
||||
$nowTime = floor((phpcommon\getNowTime() - phpcommon\getdayseconds(phpcommon\getNowTime())) / 3600);
|
||||
if ($nowTime < $pt1) {
|
||||
$daily_order1 = 0;
|
||||
$daily_order2 = 0;
|
||||
$daily_order3 = 0;
|
||||
} else if ($nowTime >= $pt1 && $nowTime < $pt1 + $pt) {
|
||||
if ($daily_order1 == 0) {
|
||||
$daily_order1 = 1;
|
||||
} else {
|
||||
$daily_order1 = $row['daily_order1'];
|
||||
}
|
||||
$daily_order2 = 0;
|
||||
$daily_order3 = 0;
|
||||
} else if ($nowTime >= $pt1 + $pt && $nowTime < $pt2) {
|
||||
if ($daily_order1 <= 1) {
|
||||
$daily_order1 = 3;
|
||||
} else {
|
||||
$daily_order1 = $row['daily_order1'];
|
||||
}
|
||||
$daily_order2 = 0;
|
||||
$daily_order3 = 0;
|
||||
} else if ($nowTime >= $pt2 && $nowTime < $pt2 + $pt) {
|
||||
if ($daily_order1 <= 1) {
|
||||
$daily_order1 = 3;
|
||||
} else {
|
||||
$daily_order1 = $row['daily_order1'];
|
||||
}
|
||||
if ($daily_order2 == 0) {
|
||||
$daily_order2 = 1;
|
||||
} else {
|
||||
$daily_order2 = $row['daily_order2'];
|
||||
} $daily_order3 = 0;
|
||||
} else if ($nowTime >= $pt2 + $pt && $nowTime < $pt3) {
|
||||
if ($daily_order1 <= 1) {
|
||||
$daily_order1 = 3;
|
||||
} else {
|
||||
$daily_order1 = $row['daily_order1'];
|
||||
}
|
||||
if ($daily_order2 <= 1) {
|
||||
$daily_order2 = 3;
|
||||
} else {
|
||||
$daily_order2 = $row['daily_order2'];
|
||||
}
|
||||
$daily_order3 = 0;
|
||||
} else if ($nowTime >= $pt3 && $nowTime < $pt3 + $pt) {
|
||||
if ($daily_order1 <= 1) {
|
||||
$daily_order1 = 3;
|
||||
} else {
|
||||
$daily_order1 = $row['daily_order1'];
|
||||
}
|
||||
if ($daily_order2 <= 1) {
|
||||
$daily_order2 = 3;
|
||||
} else {
|
||||
$daily_order2 = $row['daily_order2'];
|
||||
}
|
||||
if ($daily_order3 == 0) {
|
||||
$daily_order3 = 1;
|
||||
} else {
|
||||
$daily_order3 = $row['daily_order3'];
|
||||
}
|
||||
} else if ($nowTime >= $pt3 + $pt) {
|
||||
if ($daily_order1 <= 1) {
|
||||
$daily_order1 = 3;
|
||||
} else {
|
||||
$daily_order1 = $row['daily_order1'];
|
||||
}
|
||||
if ($daily_order2 <= 1) {
|
||||
$daily_order2 = 3;
|
||||
} else {
|
||||
$daily_order2 = $row['daily_order2'];
|
||||
}
|
||||
if ($daily_order3 <= 1) {
|
||||
$daily_order3 = 3;
|
||||
} else {
|
||||
$daily_order3 = $row['daily_order3'];
|
||||
}
|
||||
}
|
||||
$stauts = 0;
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
if ($i == 0) {
|
||||
$status = $daily_order1;
|
||||
} else if ($i == 1) {
|
||||
$status = $daily_order2;
|
||||
} else if ($i == 2) {
|
||||
$status = $daily_order3;
|
||||
}
|
||||
array_push($item_list, array(
|
||||
'status' => $status
|
||||
));
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE user SET daily_order1=:daily_order1, daily_order2=:daily_order2, daily_order3=:daily_order3 ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':daily_order1' => $daily_order1,
|
||||
':daily_order2' => $daily_order2,
|
||||
':daily_order3' => $daily_order3
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
//登录信息
|
||||
$rowuser = $conn->execQueryOne('SELECT daily_first_login, first_login, game_times FROM user WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$rowuser) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE user SET daily_first_login=:daily_first_login, first_login=:first_login ' .
|
||||
'WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':first_login' => $rowuser['first_login'] + 1,
|
||||
':daily_first_login' => $rowuser['daily_first_login'] + 1,
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
//离线奖励
|
||||
$row = $conn->execQueryOne('SELECT * FROM hang WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$row) {
|
||||
$ret = $conn->execScript('INSERT INTO hang(accountid, hang_time, reward_id, reward_num, create_time, modify_time) ' .
|
||||
' VALUES(:accountid, :hang_time, 0, 0, :create_time, :modify_time) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, hang_time=:hang_time, reward_id=0, reward_num=0, modify_time=:modify_time;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':hang_time' => phpcommon\getNowTime(),
|
||||
':create_time' => phpcommon\getNowTime(),
|
||||
':modify_time' => phpcommon\getNowTime()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$num = 0;
|
||||
$onlinetime = phpcommon\getNowTime();
|
||||
} else {
|
||||
$addreward = new classes\AddReward();
|
||||
$p_num = $this->getParameter(OFFLINE_REWARD_NUMBER);
|
||||
$p_time_limit = $this->getParameter(OFFLINE_TIME_LIMIT);
|
||||
$p_val = $this->getParameter(OFFLINE_TIME_UNIT);
|
||||
$val = $addreward->getVipVal($account_id, 8);
|
||||
$max_time = $p_time_limit['value'] + $val;
|
||||
$num = floor((phpcommon\getNowTime() - $row['hang_time']) / $p_val['value'] * $p_num['value']);
|
||||
if ((phpcommon\getNowTime() - $row['hang_time']) >= $max_time) {
|
||||
$num = floor($max_time / $p_val['value'] * $p_num['value']);
|
||||
}
|
||||
$val2 = $addreward->getVipVal($account_id, 6);
|
||||
$num = floor($num + $num * $val2 / 100);
|
||||
$onlinetime = $row['hang_time'];
|
||||
}
|
||||
$cost = metatable\getParameterByName('season_card_cost');
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'quest_list' => $quest_list,
|
||||
'pass_status' => $pass_status,
|
||||
'season' => $number,
|
||||
'open_time' => $open_time,
|
||||
'end_time' => $end_time,
|
||||
'rank' => $rank,
|
||||
'rank_score' => $rank_score,
|
||||
'max_rank_score' => $max_rank_score,
|
||||
'reward' => $reward,
|
||||
'week' => $week_reward,
|
||||
'seareward' => $sea_reward,
|
||||
'seareward2' => $sea_reward2,
|
||||
'bag_list' => $bag_list,
|
||||
'item_list' => $item_list,
|
||||
'first_login' => $rowuser['first_login'] + 1,
|
||||
'daily_first_login' => $rowuser['daily_first_login'] + 1,
|
||||
'game_times' => $rowuser['game_times'],
|
||||
'min_rank_score' => $min_rank_score,
|
||||
'cost' => $cost,
|
||||
'pass_array' => $pass_array,
|
||||
'onlinenum' => $num,
|
||||
'max_rank' => $max_rank,
|
||||
'onlinetime' => $onlinetime,
|
||||
'errcode' => 0
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -166,22 +166,30 @@ class NBagController extends BaseAuthedController {
|
||||
$allYokeItem = array();
|
||||
$newItemCfg = require('../res/newitem@newitem.php');
|
||||
if($row) {
|
||||
error_log("GetYokeItem======".json_encode($newItemCfg));
|
||||
$len = count($row);
|
||||
for($i = 0; $i < $len ; $i++)
|
||||
{
|
||||
$itemID = $row[$i]["id"];
|
||||
$itemNum = $row[$i]["num"];
|
||||
$itemCfg = $newItemCfg[$itemID];
|
||||
if($itemCfg)
|
||||
//error_log("Item=====".json_encode($row[$i]));
|
||||
if(isset($newItemCfg[$itemID]))
|
||||
{
|
||||
if($itemCfg["type"] == 10)
|
||||
$itemCfg = $newItemCfg[$itemID];
|
||||
if($itemCfg)
|
||||
{
|
||||
$itemData = array("item_id"=>$itemID,"item_num"=>$itemNum);
|
||||
array_push($allYokeItem,$itemData);
|
||||
if($itemCfg["type"] == 10)
|
||||
{
|
||||
$itemData = array("item_id"=>$itemID,"item_num"=>$itemNum);
|
||||
array_push($allYokeItem,$itemData);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
error_log("未定义======".$itemID."==".$len."==".$i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
331
webapp/controller/NGunController.class.php
Normal file
331
webapp/controller/NGunController.class.php
Normal file
@ -0,0 +1,331 @@
|
||||
<?php
|
||||
require_once('mt/NewShop.php');
|
||||
class NGunController extends BaseAuthedController {
|
||||
|
||||
public function getGunInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
// $row = $conn->execQueryOne('SELECT guildcoin_num FROM user WHERE accountid=:accountid;',
|
||||
// array(
|
||||
// ':accountid' => $account_id
|
||||
// ));
|
||||
$sqlStr = "SELECT * FROM gun_intensify WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
error_log("GunTest3======");
|
||||
}
|
||||
else{
|
||||
error_log("GunTest4=======");
|
||||
}
|
||||
$this->sendDataToClient(0,"test02",$row);
|
||||
}
|
||||
public function skillLvUp()
|
||||
{
|
||||
$code = 100;
|
||||
$skillLv = 1;
|
||||
$skillLvData = 0;
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//$skil
|
||||
$skill_id = $_REQUEST['skill_id'];
|
||||
$skill_type_id = $_REQUEST['skill_type_id'];
|
||||
$gunSkillCfg = require('../res/guntalentlv@guntalentlv.php');
|
||||
$skillCfg = null;
|
||||
if($gunSkillCfg[$skill_id])
|
||||
{
|
||||
$skillCfg = $gunSkillCfg[$skill_id];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr3 = "SELECT skill_lv FROM gun_intensify WHERE accountid=:accountid AND gun_type_id=:gun_type_id AND skill_id=:skill_id";
|
||||
$row = $conn->execQuery($sqlStr3,array(':accountid' => $account_id,':gun_type_id' => $skill_type_id,':skill_id' => $skill_id));
|
||||
|
||||
if($row)
|
||||
{
|
||||
$skillLvData = 1;
|
||||
$skillLv = $row[0]["skill_lv"];
|
||||
error_log("查询到gunSkill=====".json_encode($row));
|
||||
}
|
||||
else
|
||||
{
|
||||
error_log("未查询到gunSkill=====");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;//技能不存在
|
||||
}
|
||||
$itemArr = array();
|
||||
$resultData = null;
|
||||
$lvUpNeedItemArr = array();
|
||||
if($skillCfg)
|
||||
{
|
||||
$needItemStr = $skillCfg["cost"];
|
||||
$needItemArr = explode("|",$needItemStr);
|
||||
$needItemLen = count($needItemArr);
|
||||
for($i = 0;$i < $needItemLen ;$i++)
|
||||
{
|
||||
$tmpStr = $needItemArr[$i];
|
||||
$tmpStrArr = explode(":",$tmpStr);
|
||||
$itemData = array("itemID"=>$tmpStrArr[0],"itemNum"=>$tmpStrArr[1]);
|
||||
array_push($lvUpNeedItemArr,$itemData);
|
||||
}
|
||||
//获得Money和钻石
|
||||
$money = 0;
|
||||
$diamond = 0;
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr3 = "SELECT coin_num,diamond_num FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr3,array(':accountid' => $account_id));
|
||||
|
||||
if($row)
|
||||
{
|
||||
$money = $row[0]["coin_num"];
|
||||
$diamond = $row[0]["diamond_num"];
|
||||
$leftMoney = $money;
|
||||
$leftDiamond = $diamond;
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 90;
|
||||
}
|
||||
//获得背包所有道具
|
||||
if($code == 100)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr3 = "SELECT * FROM bag WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr3,array(':accountid' => $account_id));
|
||||
|
||||
if($row) {//判断道具是否足够
|
||||
$needItemArrLen = count($lvUpNeedItemArr);
|
||||
$enoughN = 0;
|
||||
$allItemLen = count($row);
|
||||
for($i = 0; $i < $needItemArrLen; $i++)
|
||||
{
|
||||
$tempNeedItemID = $lvUpNeedItemArr[$i]["itemID"];
|
||||
$tempNeedItemNum = $lvUpNeedItemArr[$i]["itemNum"];
|
||||
error_log("技能升级01======".$tempNeedItemID."==".$tempNeedItemNum);
|
||||
if($tempNeedItemID == "10001")
|
||||
{
|
||||
$code = 97;//金币不足
|
||||
if($tempNeedItemNum <= $money)
|
||||
{
|
||||
$code = 100;
|
||||
$leftMoney = $money -$tempNeedItemNum;
|
||||
}
|
||||
}
|
||||
else if($tempNeedItemID == "10003")
|
||||
{
|
||||
$code = 96;//钻石不足
|
||||
if($tempNeedItemNum <= $diamond)
|
||||
{
|
||||
$code = 100;
|
||||
$leftDiamond = $diamond - $tempNeedItemNum;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 95;//道具不足
|
||||
for($j = 0; $j < $allItemLen; $j++)
|
||||
{
|
||||
$bagItemID = $row[$j]["id"];
|
||||
$bagItemNum = $row[$j]["num"];
|
||||
if($tempNeedItemID == $bagItemID)
|
||||
{
|
||||
error_log("技能升级======".$bagItemID."==".$bagItemNum);
|
||||
if($tempNeedItemNum <= $bagItemNum)
|
||||
{
|
||||
$code = 100;
|
||||
$deleteItem = array("item_id"=>$bagItemID,"item_num"=>$tempNeedItemNum);
|
||||
array_push($itemArr,$deleteItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SERVER_ENV != _ONLINE) {
|
||||
$code = 100;
|
||||
}
|
||||
}
|
||||
if($code != 100)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 90;
|
||||
}
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
if($skillCfg["nextid"] > 0)
|
||||
{
|
||||
$skillLv ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 98;//已经升到最大级
|
||||
}
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
$this->decItem($itemArr);
|
||||
$this->updateCurrency($leftMoney,$leftDiamond);
|
||||
$tempItemData = array("skill_type_id"=>$skill_type_id,"skill_id"=>$skill_id,"skill_lv"=>$skillLv);
|
||||
$this->updateGunSkillIntensify($tempItemData);
|
||||
$resultData = array("skill_type_id"=>$skill_type_id,"skill_id"=>$skill_id,"skill_lv"=>$skillLv);
|
||||
}
|
||||
error_log("GunTest3======".$skill_id."==".$skill_type_id);
|
||||
}
|
||||
$this->sendDataToClient($code,"gunSkillLvUp",$resultData);
|
||||
//$conn = $this->getMysql($account_id);
|
||||
}
|
||||
public function updateCurrency($_money,$_diamond)
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
$sqlStr2 = "Update user set coin_num =:coin_num,diamond_num =:diamond_num WHERE accountid=:accountid ";
|
||||
$row = $conn->execQuery($sqlStr2,array(':accountid' => $account_id,':coin_num' => $_money,':diamond_num' => $_diamond));
|
||||
|
||||
}
|
||||
public function updateGunSkillIntensify($item)
|
||||
{
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'gun_intensify',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_type_id' => $item['skill_type_id'],
|
||||
'skill_id' => $item['skill_id']
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_type_id' => $item['skill_type_id'],
|
||||
'skill_id' => $item['skill_id'],
|
||||
'skill_lv' =>$item['skill_lv'],
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'skill_lv' => $item['skill_lv'],
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
public function getGunAndSkinInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr2 = "SELECT gun_id,skin_id FROM gun WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr2,array(':accountid' => $account_id));
|
||||
$resultData = array();
|
||||
|
||||
array_push($resultData,$row);
|
||||
//获得已经购买的皮肤列表
|
||||
$sqlStr3 = "SELECT gun_id,skin_id FROM gun_skin WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr3,array(':accountid' => $account_id));
|
||||
array_push($resultData,$row);
|
||||
$this->sendDataToClient(100,"getGunAndSkinInfo",$resultData);
|
||||
}
|
||||
public function equipGunSkin()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$gunID = $_REQUEST['gun_id'];
|
||||
$skinID = $_REQUEST['skin_id'];
|
||||
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'gun',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_id' => $gunID
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_id' => $gunID,
|
||||
'skin_id' =>$skinID,
|
||||
'trytime' =>0,
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'skin_id' =>$skinID,
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
$resultData = array("gun_id"=>$gunID,"skin_id"=>$skinID);
|
||||
$this->sendDataToClient(100,"changeGunSkin",$resultData);
|
||||
}
|
||||
public function buyGunSkin()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$gunID = $_REQUEST['gun_id'];
|
||||
$skinID = $_REQUEST['skin_id'];
|
||||
$goodsID = $_REQUEST['goodsID'];
|
||||
|
||||
error_log("购买皮肤======".$goodsID);
|
||||
$shopMeta = mt\NewShop::getShopItemByID($goodsID);
|
||||
$code = 100;
|
||||
$skinData = null;
|
||||
if($shopMeta)
|
||||
{
|
||||
$priceNum = $shopMeta["priceNum"];
|
||||
$priceID = $shopMeta["priceID"];
|
||||
$code = $this->checkPriceEnough($priceNum,$priceID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;
|
||||
}
|
||||
|
||||
if($code == 100)
|
||||
{
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'gun_skin',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_id' => $gunID,
|
||||
'skin_id' => $skinID
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_id' => $gunID,
|
||||
'skin_id' =>$skinID,
|
||||
'trytime' =>0,
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'trytime' => 0,
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'gun',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_id' => $gunID
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_id' => $gunID,
|
||||
'skin_id' =>$skinID,
|
||||
'trytime' =>0,
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'skin_id' =>$skinID,
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
$resultData = array("gun_id"=>$gunID,"skin_id"=>$skinID);
|
||||
$this->sendDataToClient($code,"buyGunSkin",$resultData);
|
||||
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ class NHeroController extends BaseAuthedController {
|
||||
// 10202,10203,10204,10205,10206,10207,10208,12100,12102,12103,12104,
|
||||
// 12105,12106,12107,12119,12120,12121];
|
||||
$playerCfg = require('../res/player@player.php');
|
||||
$itemIDArr = array(1,2,3);
|
||||
$itemIDArr = array(30100,30200,30300);
|
||||
$itemArr = array();
|
||||
$len = count($itemIDArr);
|
||||
for($i = 0; $i< $len; $i++)
|
||||
@ -18,7 +18,7 @@ class NHeroController extends BaseAuthedController {
|
||||
if($playerCfg[$heroID])
|
||||
{
|
||||
$heroCfg = $playerCfg[$heroID];
|
||||
$skinListStr = $heroCfg["skinlist"];
|
||||
$skinListStr = $heroCfg["skinlist"];
|
||||
$skinIDArr = explode("|",$skinListStr);
|
||||
$skinID = $skinIDArr[0];
|
||||
$itemData = array("hero_id"=>$heroID,"skin_id"=>$skinID);
|
||||
@ -37,6 +37,71 @@ class NHeroController extends BaseAuthedController {
|
||||
$this->addAllHero($itemArr);
|
||||
$this->sendDataToClient(1,"test03",$playerCfg);
|
||||
}
|
||||
public function addHeroToDB($heroID,$_heroCfg)
|
||||
{
|
||||
$code = 100;
|
||||
$itemArr = array();
|
||||
$resultArr = array();
|
||||
$heroCfg = $_heroCfg;
|
||||
$skinListStr = $heroCfg["skinlist"];
|
||||
$skinIDArr = explode("|",$skinListStr);
|
||||
$skinID = $skinIDArr[0];
|
||||
$itemData = array("hero_id"=>$heroID,"skin_id"=>$skinID);
|
||||
array_push($itemArr,$itemData);
|
||||
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
|
||||
$this->addHeroSkin($skinData);
|
||||
|
||||
$this->addAllHero($itemArr);
|
||||
array_push($resultArr,$itemData);
|
||||
array_push($resultArr,$skinData);
|
||||
return $resultArr;
|
||||
}
|
||||
public function addHeroAndSkin($heroID,$_heroCfg,$skinID)
|
||||
{
|
||||
$code = 100;
|
||||
$itemArr = array();
|
||||
$resultArr = array();
|
||||
$heroCfg = $_heroCfg;
|
||||
|
||||
|
||||
|
||||
//添加指定皮肤
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 1,
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
$this->addHeroSkin($skinData);
|
||||
//添加默认皮肤
|
||||
$skinListStr = $heroCfg["skinlist"];
|
||||
$skinIDArr = explode("|",$skinListStr);
|
||||
$defualtSkinID = $skinIDArr[0];
|
||||
$skinData02 = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $defualtSkinID,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
$itemData = array("hero_id"=>$heroID,"default_skinID"=>$defualtSkinID,"skin_id"=>$skinID);
|
||||
array_push($itemArr,$itemData);
|
||||
$this->addHeroSkin($skinData02);
|
||||
$this->addAllHero($itemArr);
|
||||
array_push($resultArr,$itemData);
|
||||
array_push($resultArr,$skinData);
|
||||
array_push($resultArr,$skinData02);
|
||||
return $resultArr;
|
||||
}
|
||||
public function getAllHero()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
@ -51,11 +116,27 @@ class NHeroController extends BaseAuthedController {
|
||||
}
|
||||
$this->sendDataToClient(0,"getHero",$row);
|
||||
}
|
||||
public function getHeroInfoByID()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$heroID = $_REQUEST['heroID'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM hero WHERE accountid=:accountid AND id=:id;";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':id' => $heroID));
|
||||
|
||||
if($row) {
|
||||
error_log("getHero======");
|
||||
}
|
||||
else{
|
||||
error_log("getHeroFailed=======");
|
||||
}
|
||||
$this->sendDataToClient(0,"getHeroInfoByID",$row);
|
||||
}
|
||||
public function getYokeItemInfo()//获得羁绊道具信息
|
||||
{
|
||||
|
||||
}
|
||||
public function changeSkin($type)//切换英雄皮肤
|
||||
public function changeSkin()//切换英雄皮肤
|
||||
{
|
||||
$skinID = $_REQUEST['skin_id'];
|
||||
$heroID = $_REQUEST['hero_id'];
|
||||
@ -63,71 +144,161 @@ class NHeroController extends BaseAuthedController {
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
error_log("updateHeroSkinSuccess======".$heroID);
|
||||
// $ret = $conn->execScript('UPDATE bag SET num=:num, status=:status, modify_time=:modify_time ' .
|
||||
// ' WHERE accountid=:account_id AND id=:id;',
|
||||
// array(
|
||||
// ':account_id' => $accountid,
|
||||
// ':id' => $item_id,
|
||||
// ':num' => $row['num'] + $item_num,
|
||||
// ':status' => $status,
|
||||
// ':modify_time' => phpcommon\getNowTime()
|
||||
// ));
|
||||
|
||||
$sqlStr = "Update hero set skinid =:skinid WHERE accountid=:accountid AND id=:id ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':id'=>$heroID,':skinid'=>$skinID));
|
||||
$updateState = 0;
|
||||
if($row) {
|
||||
$updateState = $skinID;
|
||||
error_log("updateHeroSkinSuccess======");
|
||||
}
|
||||
else{
|
||||
error_log("updateHeroSkinFailed=======");
|
||||
}
|
||||
$this->sendDataToClient(0,"updateHeroSkin",$skinID);
|
||||
|
||||
$this->sendDataToClient(100,"updateHeroSkin",$skinID);
|
||||
}
|
||||
public function buySkin()//购买英雄皮肤
|
||||
{
|
||||
error_log("TestNewShop01====");
|
||||
$shopMeta = mt\NewShop::get(1);
|
||||
error_log("TestNewShop====".json_encode($shopMeta));
|
||||
//$this->getShopItemByID(0);
|
||||
// $account_id = $_REQUEST['account_id'];
|
||||
// $skinID = $_REQUEST['skin_id'];
|
||||
// $heroID = $_REQUEST['hero_id'];
|
||||
// $playerSkinCfg = require('../res/playerskin@playerskin.php');
|
||||
// $skinCfg = $playerSkinCfg[$skinID];
|
||||
// $skinPriceStr = $skinCfg["sell"];
|
||||
// $code = $this->checkPriceEnough($skinPriceStr);
|
||||
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$skinID = $_REQUEST['skin_id'];
|
||||
$heroID = $_REQUEST['hero_id'];
|
||||
$goodsID = $_REQUEST['goodsID'];
|
||||
|
||||
$shopMeta = mt\NewShop::getShopItemByID($goodsID);
|
||||
$code = 100;
|
||||
$skinData = null;
|
||||
if($shopMeta)
|
||||
{
|
||||
$priceNum = $shopMeta["priceNum"];
|
||||
$priceID = $shopMeta["priceID"];
|
||||
$code = $this->checkPriceEnough($priceNum,$priceID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if (SERVER_ENV != _ONLINE) {
|
||||
// $code = 100;
|
||||
// $skinData = array(
|
||||
// 'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
// 'skin_state' => 0,
|
||||
// 'get_from' => 0,
|
||||
// 'consume_num' => 0,
|
||||
// 'trytime' => 0
|
||||
// );
|
||||
// $this->addHeroSkin($skinData);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if($code == 100)
|
||||
// {
|
||||
// $skinData = array(
|
||||
// 'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
// 'skin_state' => 0,
|
||||
// 'get_from' => 0,
|
||||
// 'consume_num' => 0,
|
||||
// 'trytime' => 0
|
||||
// );
|
||||
// $this->addHeroSkin($skinData);
|
||||
// }
|
||||
// }
|
||||
if (SERVER_ENV != _ONLINE) {
|
||||
$code = 100;
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
$this->addHeroSkin($skinData);
|
||||
}
|
||||
else
|
||||
{
|
||||
if($code == 100)
|
||||
{
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
$this->addHeroSkin($skinData);
|
||||
}
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "Update hero set skinid =:skinid WHERE accountid=:accountid AND id=:id ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':id'=>$heroID,':skinid'=>$skinID));
|
||||
}
|
||||
$this->sendDataToClient($code,"buyHeroSuccess",$skinData);
|
||||
|
||||
// $this->sendDataToClient($code,"buyHeroSuccess",null);
|
||||
}
|
||||
public function buyHero()//购买英雄
|
||||
{
|
||||
|
||||
$playerCfg = require('../res/player@player.php');
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$heroID = $_REQUEST['hero_id'];
|
||||
$buyType = $_REQUEST['buyType'];
|
||||
$heroCfg = null;
|
||||
$code = 99;
|
||||
$money = 0;
|
||||
$heroData = null;
|
||||
$leftMoney = 0;
|
||||
$skinPrice = 0;
|
||||
$skinID = null;
|
||||
if($playerCfg[$heroID])
|
||||
{
|
||||
$heroCfg = $playerCfg[$heroID];
|
||||
$goodsID = $heroCfg["hero_item"];
|
||||
$goodsItem = mt\NewShop::getShopItemByID($goodsID);
|
||||
$priceNum = $goodsItem["priceNum"];//商品价格
|
||||
$priceID = $goodsItem["priceID"];//商品价格货币ID
|
||||
if($buyType == 1)
|
||||
{
|
||||
$playerSkinCfg = require('../res/playerskin@playerskin.php');
|
||||
$skinID = $_REQUEST['skin_id'];
|
||||
if($playerSkinCfg[$skinID])
|
||||
{
|
||||
$skinCfg = $playerSkinCfg[$skinID];
|
||||
$skinGoodsID = $skinCfg["itemid"];
|
||||
$skinGoodsItem = mt\NewShop::getShopItemByID($skinGoodsID);
|
||||
$skinPriceNum = $skinGoodsItem["priceNum"];//商品价格
|
||||
$skinPrice = $skinPriceNum;
|
||||
}
|
||||
|
||||
}
|
||||
$priceNum = $priceNum +$skinPrice;
|
||||
|
||||
$code = $this->checkPriceEnough($priceNum,$priceID);
|
||||
if($code == 100)
|
||||
{
|
||||
error_log("购买英雄成功=====".$priceNum);
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr3 = "SELECT coin_num,diamond_num FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr3,array(':accountid' => $account_id));
|
||||
|
||||
if($row)
|
||||
{
|
||||
$money = $row[0]["coin_num"];
|
||||
$diamond = $row[0]["diamond_num"];
|
||||
$leftMoney = $money;
|
||||
$leftDiamond = $diamond;
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 90;
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
if($priceID == "10001")
|
||||
{
|
||||
$leftMoney = $leftMoney -$priceNum;
|
||||
}
|
||||
else if($priceID == "10003")
|
||||
{
|
||||
$leftDiamond = $leftDiamond -$priceNum;
|
||||
}
|
||||
//更新货币到数据库
|
||||
$this->updateCurrency($leftMoney,$leftDiamond);
|
||||
//添加新英雄到数据库
|
||||
if($buyType == 0)
|
||||
{
|
||||
$heroData = $this->addHeroToDB($heroID,$heroCfg);
|
||||
}
|
||||
else
|
||||
{
|
||||
$heroData = $this->addHeroAndSkin($heroID,$heroCfg,$skinID);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->sendDataToClient($code,"buyHero",$heroData);
|
||||
}
|
||||
public function updateCurrency($_money,$_diamond)
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
$sqlStr2 = "Update user set coin_num =:coin_num,diamond_num =:diamond_num WHERE accountid=:accountid ";
|
||||
$row = $conn->execQuery($sqlStr2,array(':accountid' => $account_id,':coin_num' => $_money,':diamond_num' => $_diamond));
|
||||
|
||||
}
|
||||
public function getAllHeroSkinByID()//获得英雄的所有皮肤
|
||||
{
|
||||
@ -308,8 +479,10 @@ class NHeroController extends BaseAuthedController {
|
||||
if($code == 100)//更新数据库
|
||||
{
|
||||
$this->decItem($itemArr);
|
||||
$this->updateCurrency($leftMoney,$leftDiamond);
|
||||
$conn = $this->getMysql($account_id);
|
||||
$row = $conn->execQuery($sqlStr2,array(':accountid' => $account_id,':id' => $heroID,':skill1_lv' => $skillLv));
|
||||
|
||||
error_log("更新英雄数据到服务器===");
|
||||
}
|
||||
}
|
||||
|
36
webapp/controller/NPlayerController.class.php
Normal file
36
webapp/controller/NPlayerController.class.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
class NPlayerController extends BaseAuthedController {
|
||||
|
||||
public function getGunInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
// $row = $conn->execQueryOne('SELECT guildcoin_num FROM user WHERE accountid=:accountid;',
|
||||
// array(
|
||||
// ':accountid' => $account_id
|
||||
// ));
|
||||
$sqlStr = "SELECT * FROM gun_intensify WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
error_log("GunTest3======");
|
||||
}
|
||||
else{
|
||||
error_log("GunTest4=======");
|
||||
}
|
||||
$this->sendDataToClient(0,"test02",$row);
|
||||
}
|
||||
public function getPlayerLv()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
|
||||
$sqlStr = "SELECT lv,lv_exp,money_of_week FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
|
||||
}
|
||||
$this->sendDataToClient(100,"getPlayerLv",$row);
|
||||
}
|
||||
}
|
227
webapp/controller/NPlayerInfoController.class.php
Normal file
227
webapp/controller/NPlayerInfoController.class.php
Normal file
@ -0,0 +1,227 @@
|
||||
<?php
|
||||
class NPlayerInfoController extends BaseAuthedController {
|
||||
|
||||
public function getGiveMeFive()//获得玩家被点赞的次数
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$giveMeFiveCnt = 0;
|
||||
$sqlStr = "SELECT give_me_five FROM player_info WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
|
||||
$giveMeFiveCnt = $row["give_me_five"];
|
||||
}
|
||||
error_log("当前GiveMeFiveCnt===".$giveMeFiveCnt);
|
||||
return $giveMeFiveCnt;
|
||||
|
||||
}
|
||||
public function sendGMFToClient()
|
||||
{
|
||||
$tmpCnt = $this->getGiveMeFive();
|
||||
$this->sendDataToClient(100,"getGiveMeFive",$tmpCnt);
|
||||
}
|
||||
public function addGiveMeFive()//玩家被点赞一次
|
||||
{
|
||||
error_log("玩家被点赞===".$this->getAccountId());
|
||||
$tmpCnt = $this->getGiveMeFive();
|
||||
$tmpCnt ++;
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'player_info',
|
||||
array(
|
||||
'accountid' => $this->getAccountId()
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'give_me_five' => $tmpCnt,
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'give_me_five' => $tmpCnt,
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
$this->sendDataToClient(100,"getGiveMeFiveTest",null);
|
||||
}
|
||||
public function getPlayerInfo()//获得玩家个人信息
|
||||
{
|
||||
|
||||
$account_id = $_REQUEST['acctID'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$from = $_REQUEST['from'];
|
||||
|
||||
$sqlStr = "SELECT * FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
$resultArr = null;
|
||||
$code = 100;
|
||||
if($row) {
|
||||
//$resultData = $row[0];
|
||||
$userName = $row[0]["user_name"];//玩家昵称
|
||||
$teamName =$row[0]["team_name"];//战队昵称
|
||||
$sex = $row[0]["sex"];
|
||||
$lv = $row[0]["lv"];//玩家等级
|
||||
$lv_exp = $row[0]["lv_exp"];//玩家当前等级已经获得的经验
|
||||
$hiID = $row[0]["hi_id"];//玩家头像ID
|
||||
$hiFrameID = $row[0]["head_kuang_id"];//玩家头像框ID
|
||||
$heroID = $row[0]["hero_id"];//当前使用的英雄ID
|
||||
$killRank = 2;//击杀排名
|
||||
$gameTimes = $row[0]["game_times"];//游戏场次
|
||||
$winTimes = $row[0]["win_times"];//游戏胜利场次
|
||||
$maxKill = $row[0]["kill_his"];//最高击杀
|
||||
$totalKill = $row[0]["kills"];//总击杀次数
|
||||
$maxDamage = $row[0]["harm_his"];//最高伤害
|
||||
$totalDamage = $row[0]["harm"];//总伤害
|
||||
//$rankScore = $row[0][""];//当前段位分数
|
||||
|
||||
if($hiID == 0)
|
||||
{
|
||||
$hiID = 18001;
|
||||
}
|
||||
if($hiFrameID == 0)
|
||||
{
|
||||
$hiFrameID = 19001;
|
||||
}
|
||||
if($heroID == 0)
|
||||
{
|
||||
$heroID = 30100;
|
||||
}
|
||||
$resultArr = array(
|
||||
"acctID"=>$account_id,
|
||||
"userName"=>$userName,
|
||||
"teamName"=>$teamName,
|
||||
"sex"=>$sex,
|
||||
"lv"=>$lv,
|
||||
"lv_exp"=>$lv_exp,
|
||||
"hiID"=>$hiID,
|
||||
"hiFrameID"=>$hiFrameID,
|
||||
"heroID"=>$heroID,
|
||||
"killRank"=>$killRank,
|
||||
"gameTimes"=>$gameTimes,
|
||||
"winTimes"=>$winTimes,
|
||||
"maxKill"=>$maxKill,
|
||||
"totalKill"=>$totalKill,
|
||||
"maxDamage"=>$maxDamage,
|
||||
"totalDamage"=>$totalDamage,
|
||||
"from"=>$from
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
$tmpSkinID = 0;
|
||||
$tmpHeroID = $resultArr["heroID"];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
$sqlStr = "SELECT skinid FROM hero WHERE accountid=:accountid AND id=:id";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':id' => $tmpHeroID));
|
||||
if($row)
|
||||
{
|
||||
$resultArr["skinID"] = $row[0]["skinid"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;
|
||||
}
|
||||
|
||||
//array_push($resultArr,"Test"=>0);
|
||||
}
|
||||
//获得所有英雄开始-
|
||||
if($code == 100)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
$tmpHeroArr = array();
|
||||
$sqlStr = "SELECT id FROM hero WHERE accountid=:accountid;";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row)
|
||||
{
|
||||
for($i = 0 ;$i < count($row);$i++)
|
||||
{
|
||||
$tmpHeroID = $row[$i]["id"];
|
||||
array_push($tmpHeroArr,$tmpHeroID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;
|
||||
}
|
||||
$resultArr["heroArr"] = $tmpHeroArr;
|
||||
}
|
||||
//获得所有英雄结束-
|
||||
$this->sendDataToClient($code,"getPlayerInfo",$resultArr);
|
||||
}
|
||||
public function changeHIFrameHero()//修改头像 头像框 英雄
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$type = $_REQUEST['type'];
|
||||
$itemID = $_REQUEST["itemID"];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$code = 100;
|
||||
$updateInfo = null;
|
||||
$heroSkinID = 0;
|
||||
if($type == 2)//修改头像
|
||||
{
|
||||
$updateInfo = array("hi_id" => $itemID);
|
||||
}
|
||||
else if($type == 3)//修改头像框
|
||||
{
|
||||
$updateInfo = array("head_kuang_id" => $itemID);
|
||||
}
|
||||
else if($type == 4)//修改英雄
|
||||
{
|
||||
$updateInfo = array("hero_id" => $itemID);
|
||||
$sqlStr = "SELECT skinid FROM hero WHERE accountid=:accountid AND id=:id";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':id' => $itemID));
|
||||
if($row)
|
||||
{
|
||||
$heroSkinID = $row[0]["skinid"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;
|
||||
}
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
phpcommon\SqlHelper::update
|
||||
($this->getSelfMysql(),
|
||||
'user',
|
||||
array(
|
||||
'accountid' => $this->getAccountId()
|
||||
),
|
||||
$updateInfo
|
||||
);
|
||||
}
|
||||
|
||||
$resultArr = array("type"=>$type,"itemID"=>$itemID,"heroSkinID"=>$heroSkinID);
|
||||
$this->sendDataToClient($code,"changeHIFrameHero",$resultArr);
|
||||
}
|
||||
|
||||
public function changeName()//修改昵称
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$nickName = $_REQUEST['nickName'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$code = 100;
|
||||
|
||||
phpcommon\SqlHelper::update
|
||||
($this->getSelfMysql(),
|
||||
'user',
|
||||
array(
|
||||
'accountid' => $this->getAccountId()
|
||||
),
|
||||
array(
|
||||
'user_name' => $nickName
|
||||
)
|
||||
);
|
||||
|
||||
$this->sendDataToClient($code,"changeNickName",$nickName);
|
||||
|
||||
// $sqlStr = "SELECT * FROM user WHERE accountid=:accountid; ";
|
||||
// $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
}
|
||||
}
|
490
webapp/controller/NRRController.class.php
Normal file
490
webapp/controller/NRRController.class.php
Normal file
@ -0,0 +1,490 @@
|
||||
<?php
|
||||
require_once('mt/Season.php');
|
||||
require_once('mt/SeasonTaskExp.php');
|
||||
class NRRController extends BaseAuthedController {
|
||||
|
||||
public $m_testCnt = 0;
|
||||
public function getGunInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM gun_intensify WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
error_log("GunTest3======");
|
||||
}
|
||||
else{
|
||||
error_log("GunTest4=======");
|
||||
}
|
||||
$this->sendDataToClient(0,"test02",$row);
|
||||
}
|
||||
public function test()
|
||||
{
|
||||
error_log("testController====".$this->m_testCnt);
|
||||
$this->m_testCnt ++;
|
||||
}
|
||||
public function ResetRRVIP()
|
||||
{
|
||||
$code = 100;
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "UPDATE user set passcard=:passcard WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':passcard'=>0));
|
||||
|
||||
$this->sendDataToClient($code,"ResetRRVIP",null);
|
||||
}
|
||||
public function buyRRVIP()
|
||||
{
|
||||
$code = 100;
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT integral,season_point,passcard FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
$rrVipState = $row[0]["passcard"];//精英进阶手册是否购买
|
||||
if($rrVipState > 0)
|
||||
{
|
||||
$code = 99;//已经购买了精英手册
|
||||
}
|
||||
else
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "UPDATE user set passcard=:passcard WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':passcard'=>1));
|
||||
error_log("更新user==".json_encode($row));
|
||||
}
|
||||
}
|
||||
$this->sendDataToClient($code,"buyRRVIP",null);
|
||||
}
|
||||
public function getRRInfo()
|
||||
{
|
||||
$seasonCfg = mt\Season::getSeasonCfg();
|
||||
$curCfg = $this->getCurSeasonCfg();
|
||||
$curSeason = $curCfg["season_number"];//当前赛季ID
|
||||
$leftSeconds = 0;//当前赛季剩余时间
|
||||
$nowTime = phpcommon\getNowTime();
|
||||
$startTime =strtotime($curCfg["time1"]);
|
||||
$endTime = strtotime($curCfg["time2"]);
|
||||
|
||||
$leftSeconds = $endTime - $nowTime;//获得剩余时间
|
||||
$resultArr = array();
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT integral,season_point,passcard FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
$rankPoint = $row[0]["integral"];//排位积分
|
||||
$seasonPoint = $row[0]["season_point"];//赛季任务积分
|
||||
$rrVipState = $row[0]["passcard"];//精英进阶手册是否购买
|
||||
$userInfo = array("rankPoint"=>$rankPoint,"seasonPoint"=>$seasonPoint,"rrVIPState"=>$rrVipState,
|
||||
"curSeason" => $curSeason,"leftSeconds"=>$leftSeconds);
|
||||
array_push($resultArr,$userInfo);
|
||||
}
|
||||
//查询手册奖励领取状态开始--
|
||||
$passInfoArr = array();
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT passid,active_status,honor_status FROM passinfo WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
error_log("Test==".json_encode($row));
|
||||
if($row) {
|
||||
|
||||
$cnt = count($row);
|
||||
for($i = 0 ; $i < $cnt; $i ++)
|
||||
{
|
||||
array_push($passInfoArr,$row[$i]);
|
||||
}
|
||||
array_push($resultArr,$passInfoArr);
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push($resultArr,$passInfoArr);
|
||||
}
|
||||
//查询手册奖励领取状结束--
|
||||
//获得任务信息开始--
|
||||
$nowSeconds = $this->getNowTime();
|
||||
$nextDaySeconds = phpcommon\getNextDaySeconds($nowSeconds);
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM quest WHERE accountid=:accountid AND quest_type=3 || quest_type = 4 ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
$taskArr = array();
|
||||
if($row)
|
||||
{
|
||||
foreach($row as $item)
|
||||
{
|
||||
$taskID = $item["quest_id"];
|
||||
$taskNum = $item["quest_num"];
|
||||
$rewardState = $item["quest_state"];
|
||||
$taskCondition = $item["quest_type"];
|
||||
$modifyTime = $item["modify_time"];
|
||||
if($nowSeconds >= $modifyTime)
|
||||
{
|
||||
$rewardState = 0;
|
||||
$modifyTime = $nextDaySeconds;
|
||||
$taskNum = 0;
|
||||
}
|
||||
$tmpData = array("id"=>$taskId,"num"=>$taskNum,"rewardState"=>$rewardStat,"condition"=>$taskCondition,"modifyTime"=>$modifyTime);
|
||||
array_push($taskArr,$tampData);
|
||||
|
||||
}
|
||||
}
|
||||
array_push($resultArr,$taskArr);
|
||||
//获得任务信息结束--
|
||||
$this->sendDataToClient(0,"getRRInfo",$resultArr);
|
||||
}
|
||||
public function getAward()
|
||||
{
|
||||
|
||||
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$rewardType = $_REQUEST['rewardType'];
|
||||
$sqlStr = "SELECT integral,season_point,passcard FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
$rrVipState = 0;
|
||||
$activeState = 0;
|
||||
$honorState = 0;
|
||||
if($row) {
|
||||
$rankPoint = $row[0]["integral"];//排位积分
|
||||
$seasonPoint = $row[0]["season_point"];//赛季任务积分
|
||||
$rrVipState = $row[0]["passcard"];//精英进阶手册是否购买
|
||||
}
|
||||
$resultItemArr = array();
|
||||
$code = 100;
|
||||
$allRewardArr = $this->getAwardArr();
|
||||
|
||||
$rewardId = $_REQUEST['rewardId'];
|
||||
$rewardId = $rewardId + 1;
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM passinfo WHERE accountid=:accountid AND passid=:passid ;";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':passid' => $rewardId));
|
||||
error_log("准备领取奖励===".$rewardId);
|
||||
if($row) {
|
||||
$tmpState = 0;//奖励是否领取
|
||||
$activeState = $row[0]['active_status'];
|
||||
$honorState = $row[0]['honor_status'];
|
||||
if($rewardType == 1)
|
||||
{
|
||||
if($activeState >= 1)
|
||||
{
|
||||
$tmpState = 1;
|
||||
}
|
||||
|
||||
}
|
||||
else if($rewardType == 2)
|
||||
{
|
||||
if($honorState >= 1)
|
||||
{
|
||||
$tmpState = 1;
|
||||
}
|
||||
}
|
||||
if($tmpState == 1)
|
||||
{
|
||||
$code = 99;//奖励已经领取
|
||||
}
|
||||
|
||||
error_log("查询结果=======".json_encode($row));
|
||||
}
|
||||
if($code == 100)//未领取奖励
|
||||
{
|
||||
if($rewardType == 1)//领取普通的奖励
|
||||
{
|
||||
$activeState = 1;
|
||||
}
|
||||
else if($rewardType == 2)//领取精英手册奖励
|
||||
{
|
||||
$honorState = 1;
|
||||
}
|
||||
$rewardData = $allRewardArr[$rewardId-1];
|
||||
//添加道具开始--
|
||||
$item1 = $rewardData["item1"];
|
||||
$item2 = $rewardData["item2"];
|
||||
$cnt2 = count($item1);
|
||||
for($i = 0 ; $i < $cnt2 ; $i ++)
|
||||
{
|
||||
$tmpID = $item1[$i]["id"];
|
||||
if($tmpID >0)
|
||||
{
|
||||
$itemInfo = array("item_id"=>$item1[$i]["id"],"item_num"=>$item1[$i]["num"]);
|
||||
array_push($resultItemArr,$itemInfo);
|
||||
}
|
||||
}
|
||||
if($rrVipState >= 1)//购买了精英手册
|
||||
{
|
||||
$cnt2 = count($itme2);
|
||||
for($i = 0 ; $i < $cnt2 ; $i ++)
|
||||
{
|
||||
$tmpID = $item2[$i]["id"];
|
||||
if($tmpID >0)
|
||||
{
|
||||
$itemInfo = array("item_id"=>$item2[$i]["id"],"item_num"=>$item2[$i]["num"]);
|
||||
array_push($resultItemArr,$itemInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->addItem($resultItemArr);
|
||||
//添加道具结束--
|
||||
//插入数据到DB开始--
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
(
|
||||
$this->getSelfMysql(),
|
||||
'passinfo',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'passid' => $rewardId
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'passid' => $rewardId,
|
||||
'active_status' => $activeState,
|
||||
'honor_status' => $honorState,
|
||||
'create_time' => $this->getNowTime(),
|
||||
'modify_time' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'active_status' => $activeState,
|
||||
'honor_status' =>$honorState,
|
||||
'modify_time' =>$this->getNowTime()
|
||||
)
|
||||
);
|
||||
//插入数据到DB结束--
|
||||
}
|
||||
$toClientData = array();
|
||||
array_push($toClientData,$resultItemArr);
|
||||
if($code == 100)
|
||||
{
|
||||
$tmpData2 = array("passid"=>$rewardId,"active_status"=>$activeState,"honor_status"=>$honorState);
|
||||
array_push($toClientData,$tmpData2);
|
||||
}
|
||||
|
||||
// error_log("当前赛季02==".json_encode($allRewardArr));
|
||||
|
||||
$this->sendDataToClient($code,"getAward",$toClientData);
|
||||
}
|
||||
public function getAwardArr()
|
||||
{
|
||||
$seasonCfg = mt\Season::getSeasonCfg();
|
||||
$curCfg = $this->getCurSeasonCfg();
|
||||
$baseRewardStr = $curCfg["season_reward"];
|
||||
$secondRewardStr = $curCfg["season_reward2"];
|
||||
$normalRewardArr = $this->getRewardArr($baseRewardStr);
|
||||
$vipRewardArr = $this->getRewardArr($secondRewardStr);
|
||||
$resultItemArr = array();
|
||||
$cnt = count($normalRewardArr);
|
||||
$allRewardArr = array();
|
||||
for($i = 0; $i < $cnt ; $i ++)
|
||||
{
|
||||
$len1 = count($normalRewardArr[$i]);
|
||||
$len2 = count($vipRewardArr[$i]);
|
||||
$itemArr1 = array();
|
||||
$itemArr2 = array();
|
||||
for($j = 0; $j < $len1; $j++)
|
||||
{
|
||||
$tmpItemData = $this->getRewardByStr($normalRewardArr[$i][$j]);
|
||||
array_push($itemArr1,$tmpItemData);
|
||||
|
||||
}
|
||||
for($j = 0; $j < $len2; $j++)
|
||||
{
|
||||
$tmpItemData = $this->getRewardByStr($vipRewardArr[$i][$j]);
|
||||
array_push($itemArr2,$tmpItemData);
|
||||
}
|
||||
$tmpItemCfg = array("item1"=>$itemArr1,"item2"=>$itemArr2);
|
||||
array_push($allRewardArr,$tmpItemCfg);
|
||||
}
|
||||
return $allRewardArr;
|
||||
}
|
||||
public function getAllReward()//一键领取所有能领取的奖励
|
||||
{
|
||||
$code = 100;
|
||||
$allRewardArr = $this->getAwardArr();
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT season_point,passcard FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
$seasonTaskExpCfg = null;
|
||||
$curLv = 0;
|
||||
$rrVipState = 0;
|
||||
$cnt1 = count($allRewardArr);
|
||||
if($row)
|
||||
{
|
||||
$seasonPoint = $row[0]["season_point"];//赛季任务积分
|
||||
$rrVipState = $row[0]["passcard"];//精英进阶手册是否购买
|
||||
$seasonTaskExpCfg = mt\SeasonTaskExp::getSeasonTaskExpCfgByPoint($seasonPoint);
|
||||
$curLv = $seasonTaskExpCfg["itemCfg"]["lv"];
|
||||
}
|
||||
$resultArr = array();
|
||||
$resultItemArr = array();//要添加到DB的道具列表
|
||||
if($code == 100)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM passinfo WHERE accountid=:accountid ;";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
for($i = 0 ;$i < $curLv;$i++)
|
||||
{
|
||||
$active_status = 0;
|
||||
$honor_status =0;
|
||||
$isUpdate = 0;
|
||||
for($k = 0; $k <count($row); $k ++)
|
||||
{
|
||||
$passid = $row[$k]["passid"];
|
||||
if($passid == ($i+1))
|
||||
{
|
||||
$active_status = $row[$k]['active_status'];
|
||||
$honor_status = $row[$k]['honor_status'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($active_status == 0)//未领取普通奖励
|
||||
{
|
||||
$item1 = $allRewardArr[$i]["item1"];
|
||||
$cnt2 = count($item1);
|
||||
for($j = 0 ; $j < $cnt2 ; $j ++)
|
||||
{
|
||||
$tmpID = $item1[$j]["id"];
|
||||
if($tmpID >0)
|
||||
{
|
||||
$itemInfo = array("item_id"=>$item1[$j]["id"],"item_num"=>$item1[$j]["num"],"passid"=>$i);
|
||||
array_push($resultItemArr,$itemInfo);
|
||||
}
|
||||
}
|
||||
$isUpdate = 1;
|
||||
}
|
||||
if($rrVipState > 0)//购买了精英手册
|
||||
{
|
||||
if($honor_status == 0)//未领取精英奖励
|
||||
{
|
||||
$item2 = $allRewardArr[$i]["item2"];
|
||||
$cnt2 = count($item2);
|
||||
for($j = 0; $j < $cnt2; $j++)
|
||||
{
|
||||
$tmpID = $item2[$j]["id"];
|
||||
if($tmpID >0)
|
||||
{
|
||||
$itemInfo = array("item_id"=>$item2[$j]["id"],"item_num"=>$item2[$j]["num"],"passid"=>$i);
|
||||
array_push($resultItemArr,$itemInfo);
|
||||
}
|
||||
}
|
||||
$honor_status = 1;
|
||||
$isUpdate = 1;
|
||||
}
|
||||
|
||||
}
|
||||
if($isUpdate == 1)
|
||||
{
|
||||
//插入数据到DB开始--
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
(
|
||||
$this->getSelfMysql(),
|
||||
'passinfo',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'passid' => ($i+1)
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'passid' => ($i+1),
|
||||
'active_status' => 1,
|
||||
'honor_status' => $honor_status,
|
||||
'create_time' => $this->getNowTime(),
|
||||
'modify_time' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'active_status' => 1,
|
||||
'honor_status' =>$honor_status,
|
||||
'modify_time' =>$this->getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
//插入数据到DB结束--
|
||||
}
|
||||
|
||||
}
|
||||
$tmpArr = array();
|
||||
array_push($tmpArr, $allRewardArr);
|
||||
array_push($tmpArr,$resultItemArr);
|
||||
$cnt3 = count($resultItemArr);
|
||||
if(cnt3 <= 0)
|
||||
{
|
||||
$code = 99;//没有奖励可以领取
|
||||
}
|
||||
$this->sendDataToClient($code,"getAllReward",$resultItemArr);
|
||||
}
|
||||
public function lvUp()//购买升级
|
||||
{
|
||||
$code = 100;
|
||||
$resultArr = null;
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT season_point FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
$seasonTaskExpCfg = null;
|
||||
if($row) {
|
||||
$seasonPoint = $row[0]["season_point"];//赛季任务积分
|
||||
$seasonTaskExpCfg = mt\SeasonTaskExp::getSeasonTaskExpCfgByPoint($seasonPoint);
|
||||
$curLv = $seasonTaskExpCfg["itemCfg"]["lv"];
|
||||
$nextCfg = mt\SeasonTaskExp::getSeasonTaskExpCfgByLv($curLv+1);
|
||||
if($nextCfg)
|
||||
{
|
||||
$nextLv = $nextCfg['lv'];
|
||||
$nextMinPoint = $nextCfg['min_point'];
|
||||
$resultArr = array("Lv"=>$nextLv,"point"=>$nextMinPoint);
|
||||
//更新数据开始--
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "UPDATE user set season_point =:point WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':point'=>$nextMinPoint,':accountid' => $account_id));
|
||||
//更新数据结束--
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 98;//已经升到最大级
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$code =99;
|
||||
}
|
||||
$this->sendDataToClient($code,"buyLvUp",$resultArr);
|
||||
}
|
||||
public function getCurSeasonCfg()
|
||||
{
|
||||
$seasonCfg = mt\Season::getSeasonCfg();
|
||||
$tmpData = null;
|
||||
foreach($seasonCfg as $item)
|
||||
{
|
||||
$tmpCfg = $item;
|
||||
$nowTime = phpcommon\getNowTime();
|
||||
$startTime =strtotime($tmpCfg["time1"]);
|
||||
$endTime = strtotime($tmpCfg["time2"]);
|
||||
if($nowTime >= $startTime && $nowTime <= $endTime)
|
||||
{
|
||||
$tmpData = $tmpCfg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $tmpData;
|
||||
}
|
||||
public function getRewardArr($str)
|
||||
{
|
||||
$itemArr = array();
|
||||
$strArr = explode("|",$str);
|
||||
$cnt = count($strArr);
|
||||
for($i = 0 ;$i < $cnt; $i++)
|
||||
{
|
||||
$strMutiArr = explode(";",$strArr[$i]);
|
||||
array_push($itemArr,$strMutiArr);
|
||||
}
|
||||
return $itemArr;
|
||||
}
|
||||
public function getRewardByStr($str)
|
||||
{
|
||||
$strArr2 = explode(":",$str);
|
||||
$itemID = $strArr2[0];
|
||||
$itemNum = $strArr2[1];
|
||||
$tmpItem = array("id"=>$itemID,"num"=>$itemNum,"state"=>0);
|
||||
return $tmpItem;
|
||||
}
|
||||
|
||||
}
|
102
webapp/controller/NRankController.class.php
Normal file
102
webapp/controller/NRankController.class.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
class NRankController extends BaseAuthedController {
|
||||
|
||||
public $m_testCnt = 0;
|
||||
public function getGunInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM gun_intensify WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
error_log("GunTest3======");
|
||||
}
|
||||
else{
|
||||
error_log("GunTest4=======");
|
||||
}
|
||||
$this->sendDataToClient(0,"test02",$row);
|
||||
}
|
||||
public function getRankInfo()
|
||||
{
|
||||
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
|
||||
$killResultArr = array();
|
||||
$rankPointArr = array();
|
||||
//获得自己的击杀排行榜
|
||||
$sqlStr = "SELECT accountid,user_name,hi_id,head_kuang_id,kills,win_times FROM user WHERE accountid=:accountid";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row)
|
||||
{
|
||||
array_push($killResultArr,$row[0]);
|
||||
}
|
||||
//击杀排行榜
|
||||
$sqlStr = "SELECT accountid,user_name,hi_id,head_kuang_id,kills,win_times FROM user order by win_times desc limit 50";
|
||||
$row = $conn->execQuery($sqlStr);
|
||||
if($row) {
|
||||
$len = count($row);
|
||||
for($i = 0 ; $i < $len ; $i ++)
|
||||
{
|
||||
array_push($killResultArr,$row[$i]);
|
||||
}
|
||||
}
|
||||
//获得自己的排位积分
|
||||
$sqlStr = "SELECT accountid,user_name,hi_id,head_kuang_id,integral FROM user WHERE accountid=:accountid";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row)
|
||||
{
|
||||
array_push($rankPointArr,$row[0]);
|
||||
}
|
||||
//积分排行榜
|
||||
$sqlStr = "SELECT accountid,user_name,hi_id,head_kuang_id,integral FROM user order by integral desc limit 50";
|
||||
$row = $conn->execQuery($sqlStr);
|
||||
if($row) {
|
||||
$len = count($row);
|
||||
for($i = 0 ; $i < $len ; $i ++)
|
||||
{
|
||||
array_push($rankPointArr,$row[$i]);
|
||||
}
|
||||
}
|
||||
//好友排行榜
|
||||
|
||||
$resultData = array();
|
||||
array_push($resultData,$killResultArr);
|
||||
array_push($resultData,$rankPointArr);
|
||||
|
||||
|
||||
|
||||
|
||||
$this->sendDataToClient(100,"getRankInfo",$resultData);
|
||||
}
|
||||
public function mailTest()
|
||||
{
|
||||
$url = '';
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
$url = 'https://gamemail.kingsome.cn/webapp/index.php?c=MailMgr&a=sendMail&';
|
||||
} else {
|
||||
$url = 'https://gamemail-test.kingsome.cn/webapp/index.php?c=MailMgr&a=sendMail&';
|
||||
}
|
||||
$params = array(
|
||||
'gameid' => "1234",
|
||||
'to' => $account_id,
|
||||
'from' => $account_id,
|
||||
'mailsubtype'=>12,
|
||||
'content'=>"采蘑菇的小朋友",
|
||||
'subject'=>"皮卡猪",
|
||||
"attachments"=>"1001:10|1002:20",
|
||||
"ext"=>"10"
|
||||
);
|
||||
if (!phpcommon\HttpClient::get($url, $params, $response)) {
|
||||
phpcommon\sendError(ERR_RETRY, '系统繁忙');
|
||||
return;
|
||||
}
|
||||
$data = json_decode($response, true);
|
||||
error_log("邮件测试=====".json_encode($data));
|
||||
$this->sendDataToClient(100,"MailTest",$data);
|
||||
}
|
||||
|
||||
}
|
684
webapp/controller/NShopController.class.php
Normal file
684
webapp/controller/NShopController.class.php
Normal file
@ -0,0 +1,684 @@
|
||||
<?php
|
||||
require_once('mt/NewShop.php');
|
||||
require_once('mt/Player.php');
|
||||
require_once('mt/NewItem.php');
|
||||
require_once('mt/PlayerSkin.php');
|
||||
require_once('mt/GunSkin.php');
|
||||
class NShopController extends BaseAuthedController {
|
||||
|
||||
private $m_timeSeed = 0;
|
||||
public function getGunInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
// $row = $conn->execQueryOne('SELECT guildcoin_num FROM user WHERE accountid=:accountid;',
|
||||
// array(
|
||||
// ':accountid' => $account_id
|
||||
// ));
|
||||
$sqlStr = "SELECT * FROM gun_intensify WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
error_log("GunTest3======");
|
||||
}
|
||||
else{
|
||||
error_log("GunTest4=======");
|
||||
}
|
||||
$this->sendDataToClient(0,"test02",$row);
|
||||
}
|
||||
public function getShopData()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
$sqlStr = "SELECT id FROM hero WHERE accountid=:accountid; ";
|
||||
$heroData = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
|
||||
$sqlStr = "SELECT skin_id FROM hero_skin WHERE accountid=:accountid; ";
|
||||
$heroSkinData = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
|
||||
$sqlStr = "SELECT skin_id FROM gun_skin WHERE accountid=:accountid; ";
|
||||
$gunSkinData = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
$goodsID = "";
|
||||
$allItemCfg = $this->getAllItem();
|
||||
$resultArr = array("heroData"=>$heroData,"heroSkin"=>$heroSkinData,"gunSkin"=>$gunSkinData,"allItem"=>$allItemCfg);
|
||||
$this->sendDataToClient(100,"getShopData",$resultArr);
|
||||
}
|
||||
public function getAllItem()
|
||||
{
|
||||
$draw_uuid = 'game2005api_newShopAllItem_uuid:' . $_REQUEST['account_id'];
|
||||
$allItemCfg = null;
|
||||
$r = $this->getRedis($draw_uuid);
|
||||
if($r)
|
||||
{
|
||||
$tmpItemCfg = null;
|
||||
$tmpItemCfg = $r->get($draw_uuid);
|
||||
if(!empty($tmpItemCfg))
|
||||
{
|
||||
$allItemCfg = json_decode($tmpItemCfg);
|
||||
}
|
||||
else
|
||||
{
|
||||
$randN = rand(1,10000);
|
||||
$this->resetTimeSeed($randN);
|
||||
}
|
||||
if($allItemCfg)
|
||||
{
|
||||
|
||||
$allItemCfg->goodsData;//$tmpAllData["goodsData"];
|
||||
$goodsData = null;
|
||||
$len = count($allItemCfg->goodsData);
|
||||
for($i = 0 ;$i < $len; $i++)
|
||||
{
|
||||
$len2 = count($allItemCfg->goodsData[$i]);
|
||||
for($j = 0; $j < $len2; $j ++)
|
||||
{
|
||||
$limitType = $allItemCfg->goodsData[$i][$j]->limitType;
|
||||
if($limitType !=0 )
|
||||
{
|
||||
$itemID01 = $allItemCfg->goodsData[$i][$j]->goodsID;
|
||||
$tmpCnt= $this->getLimitTypeCnt($itemID01);
|
||||
$allItemCfg->goodsData[$i][$j]->buyCnt = $tmpCnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error_log("ErrorRedis====");
|
||||
}
|
||||
|
||||
if(!$allItemCfg)
|
||||
{
|
||||
$allItemCfg = $this->initAllItem();
|
||||
$r -> set($draw_uuid, json_encode($allItemCfg));
|
||||
//if (phpcommon\getMondayseconds(phpcommon\getNowTime()) - phpcommon\getMondayseconds($rowuser['update_time']) > 0)
|
||||
$nowSeconds = phpcommon\getNowTime();
|
||||
$nextDaySeconds = phpcommon\getNextDaySeconds($nowSeconds);
|
||||
$daySeconds = phpcommon\getdayseconds($nowSeconds);
|
||||
$nextWeekSeconds = phpcommon\getMondaySeconds($nowSeconds);
|
||||
//$deadline = phpcommon\getNextDaySeconds()-phpcommon\getNowTime();
|
||||
$dayDeadLine = $nextDaySeconds - $nowSeconds;
|
||||
$weekDeadLine = ($nextWeekSeconds + 86400*7)-$nowSeconds;
|
||||
$r -> pexpire($draw_uuid, 200 * 1000);
|
||||
$encodeArr = json_encode($allItemCfg);
|
||||
$allItemCfg = json_decode($encodeArr);
|
||||
error_log("已经过期重新获得====".$nextDaySeconds."==".$nowSeconds."==".$daySeconds."==".$nextWeekSeconds);
|
||||
}
|
||||
return $allItemCfg;
|
||||
}
|
||||
public function getLimitTypeCnt($_itemID)
|
||||
{
|
||||
$tmpCnt = 0;
|
||||
$draw_uuid = 'game2005api_newShopLimit'.$_itemID.'_uuid:' . $_REQUEST['account_id'];
|
||||
|
||||
$r = $this->getRedis($draw_uuid);
|
||||
$limitGoods = $r->get($draw_uuid);
|
||||
if(empty($limitGoods))
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$limitGoods = json_decode($limitGoods);
|
||||
$buyCnt = $limitGoods->buyCnt;
|
||||
$tmpCnt = $buyCnt;
|
||||
}
|
||||
return $tmpCnt;
|
||||
}
|
||||
public function rnd($_seed)
|
||||
{
|
||||
$tmpSeed = ($_seed * 9301 + 49297) % 233280; //神奇数字
|
||||
$this->m_timeSeed = $tmpSeed;
|
||||
return $tmpSeed / (233280.0);
|
||||
}
|
||||
public function resetTimeSeed($_timeSeed)
|
||||
{
|
||||
$this->m_timeSeed = $_timeSeed;
|
||||
}
|
||||
public function getRandN($_num)
|
||||
{
|
||||
$tmpN = $this->rnd($this->m_timeSeed);
|
||||
$randN = floor($tmpN*$_num);
|
||||
return $randN;
|
||||
}
|
||||
public function getItemIDByGoodsID($_goodsID)
|
||||
{
|
||||
$itemCfg = null;
|
||||
$shopMeta = mt\NewItem::getItemCfgByID($_goodsID);
|
||||
if($shopMeta)
|
||||
{
|
||||
|
||||
$itemType = $shopMeta["type"];
|
||||
//error_log("道具测试01=====".$itemType);
|
||||
if($itemType == 19)//英雄表
|
||||
{
|
||||
$itemCfg = mt\Player::getPlayerCfgByGoodsID($_goodsID);
|
||||
}
|
||||
else if($itemType == 13)//枪皮肤
|
||||
{
|
||||
$itemCfg = mt\GunSkin::getGunSkinCfgByGoodsID($_goodsID);
|
||||
}
|
||||
else if($itemType == 12)//英雄皮肤
|
||||
{
|
||||
$itemCfg = mt\PlayerSkin::getPlayerSkinCfgByGoodsID($_goodsID);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$itemCfg = $shopMeta;//道具信息
|
||||
}
|
||||
}
|
||||
|
||||
return $itemCfg;
|
||||
}
|
||||
public function buyGunSkin($gunID,$skinID)
|
||||
{
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'gun_skin',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_id' => $gunID,
|
||||
'skin_id' => $skinID
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'gun_id' => $gunID,
|
||||
'skin_id' =>$skinID,
|
||||
'trytime' =>0,
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'trytime' => 0,
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
public function buyItem()
|
||||
{
|
||||
$code = 100;
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$goodsID = $_REQUEST['goodsID'];
|
||||
$goodsType = $_REQUEST['goodsType'];
|
||||
$buyCnt = $_REQUEST['buyCnt'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT id FROM hero WHERE accountid=:accountid; ";
|
||||
|
||||
$itemCfg = null;
|
||||
|
||||
$skinData = null;
|
||||
$priceID = 0;
|
||||
$priceNum = 0;
|
||||
$leftMoney = 0;
|
||||
$leftDiamond = 0;
|
||||
$curBuyCnt = -1;
|
||||
$buyGoodsCfg = $this->calculateLimitGoods($goodsID);//当前购买的道具的配置信息
|
||||
if(!$buyGoodsCfg)
|
||||
{
|
||||
$code = 91;//道具被重新刷新,请重新打开页面
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
if($buyGoodsCfg->limitType !=0)
|
||||
{
|
||||
$tmpCnt = $buyGoodsCfg->buyCnt;
|
||||
$curBuyCnt = $tmpCnt ;
|
||||
$maxCntStrArr = explode(":",$buyGoodsCfg->limitType);
|
||||
$maxCnt = $maxCntStrArr[1];
|
||||
//error_log("购买限购商品======".$curBuyCnt."==".$maxCnt);
|
||||
if($tmpCnt+1 > $maxCnt)
|
||||
{
|
||||
$code = 92;//购买上限
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($code == 100)
|
||||
{
|
||||
|
||||
|
||||
$shopMeta = mt\NewShop::getShopItemByID($goodsID);
|
||||
if($shopMeta)
|
||||
{
|
||||
$priceNum = $shopMeta["priceNum"];
|
||||
$priceID = $shopMeta["priceID"];
|
||||
$priceNum = $priceNum * $buyCnt;
|
||||
if($buyGoodsCfg->isSpecail == 1)
|
||||
{
|
||||
$srcPrice = $priceNum;
|
||||
$zkN = (int)$buyGoodsCfg->specailPrice;
|
||||
$priceNum = $priceNum * ($zkN/100);
|
||||
error_log("购买的价格是否打折======".$srcPrice."==".$zkN."==".$priceNum);
|
||||
}
|
||||
$code = $this->checkPriceEnough($priceNum,$priceID);//检查是否现有货币是否足够购买道具
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;//商品不存在
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
$itemCfg = $this->getItemIDByGoodsID($goodsID);
|
||||
if(!$itemCfg)
|
||||
{
|
||||
error_log("商品部存在===".$goodsID);
|
||||
$code = 98;//商品对应的道具不存在
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$itemID = 0;
|
||||
|
||||
|
||||
if($code == 100)
|
||||
{
|
||||
$itemID = null;
|
||||
if(array_key_exists("itemid",$itemCfg))
|
||||
{
|
||||
$itemID = $itemCfg["itemid"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$itemID = $itemCfg["id"];
|
||||
}
|
||||
|
||||
error_log("购买道具======".$itemID);
|
||||
if($goodsType == 19)//购买英雄
|
||||
{
|
||||
|
||||
$heroCfg = mt\Player::getPlayerCfgByGoodsID($itemID);
|
||||
$this->addHeroToDB($itemID,$heroCfg);
|
||||
//error_log("准备购买英雄======".json_encode($heroCfg));
|
||||
}
|
||||
else if($goodsType == 12)//购买英雄皮肤
|
||||
{
|
||||
$tmpHeroID = $itemCfg["playerid"];
|
||||
$this->buySkin($itemID,$tmpHeroID);
|
||||
}
|
||||
else if($goodsType == 13)//购买枪皮肤
|
||||
{
|
||||
$tmpGunID = $itemCfg["gunid"];
|
||||
$this->buyGunSkin($tmpGunID,$itemID);
|
||||
}
|
||||
else //背包道具
|
||||
{
|
||||
$itemData =array("item_id"=>$itemID,"item_num"=>1);
|
||||
$item_list = array();
|
||||
array_push($item_list,$itemData);
|
||||
$this->addItem($item_list);
|
||||
}
|
||||
// if ($item['item_id'] == $this->goldID) {
|
||||
// $this->addGold($item['item_num']);
|
||||
// error_log("添加金币=====".$item['item_num']);
|
||||
// }
|
||||
// else if ($item['item_id'] == $this->lotteryID){
|
||||
// $this->addLottery($item['item_num']);
|
||||
// error_log("添加奖券=====".$item['item_num']);
|
||||
// }
|
||||
}
|
||||
if($code == 100)//更新货币
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr3 = "SELECT coin_num,diamond_num FROM user WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr3,array(':accountid' => $account_id));
|
||||
|
||||
if($row)
|
||||
{
|
||||
$money = $row[0]["coin_num"];
|
||||
$diamond = $row[0]["diamond_num"];
|
||||
$leftMoney = $money;
|
||||
$leftDiamond = $diamond;
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 90;
|
||||
}
|
||||
if($priceID == "10001")
|
||||
{
|
||||
$leftMoney = $leftMoney -$priceNum;
|
||||
}
|
||||
else if($priceID == "10003")
|
||||
{
|
||||
$leftDiamond = $leftDiamond -$priceNum;
|
||||
}
|
||||
//更新货币到数据库
|
||||
$this->updateCurrency($leftMoney,$leftDiamond);
|
||||
// error_log("限购测试=====".$itemID."==".$curBuyCnt);
|
||||
if($curBuyCnt >=0)
|
||||
{
|
||||
$curBuyCnt ++;
|
||||
$draw_uuid = 'game2005api_newShopLimit'.$itemID.'_uuid:' . $_REQUEST['account_id'];
|
||||
$r = $this->getRedis($draw_uuid);
|
||||
$limitGoods = $r->get($draw_uuid);
|
||||
$tmpData = array("goodsID"=>$itemID,"buyCnt"=>$curBuyCnt);
|
||||
$r -> set($draw_uuid, json_encode($tmpData));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$resultArr = array("goodsID"=>$goodsID,"goodsType"=>$goodsType,"buyCnt"=>$curBuyCnt);
|
||||
$this->sendDataToClient($code,"getShopData",$resultArr);
|
||||
}
|
||||
public function updateLimitGoodsCnt()
|
||||
{
|
||||
$tmpAllData = $this->getAllItem();
|
||||
$allItemCfg = $tmpAllData->goodsData;//$tmpAllData["goodsData"];
|
||||
$goodsData = null;
|
||||
$len = count($allItemCfg);
|
||||
for($i = 0 ;$i < $len; $i++)
|
||||
{
|
||||
|
||||
$len2 = count($allItemCfg[$i]);
|
||||
//error_log("当前列表======".$len2."==".$i);
|
||||
for($j = 0; $j < $len2; $j ++)
|
||||
{
|
||||
$tmpGoodsID = $allItemCfg[$i][$j]->goodsID;
|
||||
// error_log("获得道具信息========="."==".$tmpGoodsID."==".$_goodsID.json_encode($allItemCfg[$i][$j]));
|
||||
if($tmpGoodsID == $_goodsID)
|
||||
{
|
||||
$goodsData = $allItemCfg[$i][$j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function calculateLimitGoods($_goodsID)
|
||||
{
|
||||
$tmpAllData = $this->getAllItem();
|
||||
$allItemCfg = $tmpAllData->goodsData;//$tmpAllData["goodsData"];
|
||||
$goodsData = null;
|
||||
$len = count($allItemCfg);
|
||||
for($i = 0 ;$i < $len; $i++)
|
||||
{
|
||||
|
||||
$len2 = count($allItemCfg[$i]);
|
||||
//error_log("当前列表======".$len2."==".$i);
|
||||
for($j = 0; $j < $len2; $j ++)
|
||||
{
|
||||
$tmpGoodsID = $allItemCfg[$i][$j]->goodsID;
|
||||
// error_log("获得道具信息========="."==".$tmpGoodsID."==".$_goodsID.json_encode($allItemCfg[$i][$j]));
|
||||
if($tmpGoodsID == $_goodsID)
|
||||
{
|
||||
$goodsData = $allItemCfg[$i][$j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $goodsData;
|
||||
}
|
||||
public function initAllItem()
|
||||
{
|
||||
$shopCfg = mt\NewShop::getShopCfg();
|
||||
$tmpInex = 0;
|
||||
$randRnage = 1000;
|
||||
$allItemCfg = array();
|
||||
$tableNameArr = array();
|
||||
$limitGoodsArr = array();//限购商品
|
||||
$perDayArr = array();//每日刷新
|
||||
|
||||
foreach ($shopCfg as $item)
|
||||
{
|
||||
$tmpCfg = $item;
|
||||
$shopTableName = $tmpCfg["shopname"];//页签名称
|
||||
$goodsListStr = $tmpCfg["goods"];
|
||||
$goodsListStr1 = explode("|",$goodsListStr);
|
||||
$allItemIDArr = array();
|
||||
$tmpItemIDArr = array();
|
||||
$randN = 0;
|
||||
$bargainNum = $tmpCfg["bargain"];
|
||||
$shopUIIndex = $tmpCfg["shopui"];
|
||||
$len1 = count($goodsListStr1);
|
||||
for($i = 0; $i < $len1 ;$i++)
|
||||
{
|
||||
$goodsListStrArr2 = explode(":",$goodsListStr1[$i]);
|
||||
$tmpItemID = $goodsListStrArr2[0];
|
||||
array_push($tmpItemIDArr,$tmpItemID);
|
||||
}
|
||||
if($tmpCfg["random"])
|
||||
{
|
||||
$randN = $tmpCfg["random"];
|
||||
}
|
||||
if($randN > 0)
|
||||
{
|
||||
while($randN > 0)
|
||||
{
|
||||
$randN --;
|
||||
$tmpN2 = $this->getRandN($randRnage);
|
||||
$per = $tmpN2 / $randRnage;
|
||||
$index = floor($per * count($tmpItemIDArr));
|
||||
|
||||
$tmpID = $tmpItemIDArr[$index];
|
||||
array_push($allItemIDArr,$tmpID);
|
||||
array_splice($tmpItemIDArr,$index,1);
|
||||
//error_log("随机结果====".$tmpN2."==".json_encode($tmpItemIDArr));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$allItemIDArr = $tmpItemIDArr;
|
||||
}
|
||||
$itemCfg = array();
|
||||
$specialArr = array();
|
||||
//获得特价商品开始--
|
||||
if($bargainNum > 0)
|
||||
{
|
||||
$tmpSpecailArr = array();
|
||||
$len2 = count($allItemIDArr);
|
||||
for($i = 0; $i < $len2;$i++)
|
||||
{
|
||||
$tmpGoods = mt\NewShop::getShopItemByID($allItemIDArr[$i]);
|
||||
$tmpNum = $tmpGoods["specailPrice"];
|
||||
if($tmpNum > 0)
|
||||
{
|
||||
array_push($tmpSpecailArr,$tmpGoods["goodsID"]);
|
||||
}
|
||||
}
|
||||
//获得随机特价商品开始--
|
||||
|
||||
for($i = 0; $i < $bargainNum; $i++)
|
||||
{
|
||||
$specailRandN = $this->getRandN($randRnage);
|
||||
$per = $specailRandN / $randRnage;
|
||||
$len3 = count($tmpSpecailArr);
|
||||
$index02 = floor($per * $len3);
|
||||
|
||||
if($len3 > 0)
|
||||
{
|
||||
//error_log("获得随机的特价商品====".$index02."==".json_encode($tmpSpecailArr));
|
||||
array_push($specialArr,$tmpSpecailArr[$index02]);
|
||||
array_splice($tmpSpecailArr,$index02,1);
|
||||
}
|
||||
}
|
||||
//error_log("特价商品===".json_encode($specialArr));
|
||||
//获得随机特价商品结束--
|
||||
}
|
||||
//获得特价商品结束--
|
||||
//记录向客户端发送的商品列表开始--
|
||||
$len4 = count($allItemIDArr);
|
||||
for($i = 0; $i < $len4 ;$i++)
|
||||
{
|
||||
$tmpGoods = mt\NewShop::getShopItemByID($allItemIDArr[$i]);
|
||||
$isSpecail = 0;
|
||||
$len5 = count($specialArr);
|
||||
for($j =0 ; $j < $len5 ; $j++)
|
||||
{
|
||||
$tmpGoodsID = $specialArr[$j];
|
||||
if($tmpGoodsID == $tmpGoods["goodsID"])
|
||||
{
|
||||
$isSpecail = 1;
|
||||
}
|
||||
}
|
||||
$tmpGoods["isSpecail"] = $isSpecail;
|
||||
$tmpGoods["shopUIIndex"] = $shopUIIndex;
|
||||
$tmpGoods["buyCnt"] = 0;//已经购买了多少个
|
||||
array_push($itemCfg,$tmpGoods);
|
||||
}
|
||||
array_push($tableNameArr,$shopTableName);
|
||||
array_push($allItemCfg,$itemCfg);
|
||||
//记录向客户端发送的商品列表结束--
|
||||
}
|
||||
|
||||
$nowSeconds = phpcommon\getNowTime();
|
||||
$nextDaySeconds = phpcommon\getNextDaySeconds($nowSeconds);
|
||||
//$daySeconds = phpcommon\getdayseconds($nowSeconds);
|
||||
$nextWeekSeconds = phpcommon\getMondaySeconds($nowSeconds);
|
||||
//$deadline = phpcommon\getNextDaySeconds()-phpcommon\getNowTime();
|
||||
$dayDeadLine = $nextDaySeconds - $nowSeconds;
|
||||
$weekDeadLine = ($nextWeekSeconds + 86400*7)-$nowSeconds;
|
||||
//查询周限购 和 每日限购 开始
|
||||
$lenAllItem = count($allItemCfg);
|
||||
for($i = 0 ; $i < $lenAllItem; $i++)
|
||||
{
|
||||
$lenRows = count($allItemCfg[$i]);
|
||||
for($j = 0; $j < $lenRows; $j++)
|
||||
{
|
||||
$itemID = $allItemCfg[$i][$j]["goodsID"];
|
||||
$limitType = $allItemCfg[$i][$j]["limitType"];
|
||||
if($limitType != 0)//是限购商品
|
||||
{
|
||||
$limitTypeStrArr = explode(":",$limitType);
|
||||
$draw_uuid = 'game2005api_newShopLimit'.$itemID.'_uuid:' . $_REQUEST['account_id'];
|
||||
$updateTime = 0;
|
||||
if($limitTypeStrArr[0] == 1)//每日更新
|
||||
{
|
||||
$updateTime = $dayDeadLine;
|
||||
}
|
||||
else if($limitTypeStrArr[0] == 2)//每周更新
|
||||
{
|
||||
$updateTime = $weekDeadLine;
|
||||
}
|
||||
$r = $this->getRedis($draw_uuid);
|
||||
$limitGoods = $r->get($draw_uuid);
|
||||
if(empty($limitGoods))
|
||||
{
|
||||
$tmpData = array("goodsID"=>$itemID,"buyCnt"=>0);
|
||||
$r -> set($draw_uuid, json_encode($tmpData));
|
||||
$r -> pexpire($draw_uuid, $updateTime * 1000);
|
||||
error_log("过期了,不存在======".$itemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$limitGoods = json_decode($limitGoods);
|
||||
$buyCnt = $limitGoods->buyCnt;
|
||||
$allItemCfg[$i][$j]["buyCnt"] = $buyCnt;//赋值已经购买了多少个
|
||||
error_log("FromRadis======".json_encode($limitGoods));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//查询周限购 和 每日限购 结束
|
||||
|
||||
$resultArr = array("goodsData"=>$allItemCfg,"tableName"=>$tableNameArr);
|
||||
|
||||
return $resultArr;
|
||||
|
||||
//$this->sendDataToClient(100,"InitAllItem",$resultArr);
|
||||
}
|
||||
public function addHeroToDB($heroID,$_heroCfg)
|
||||
{
|
||||
$itemArr = array();
|
||||
$resultArr = array();
|
||||
$heroCfg = $_heroCfg;
|
||||
$skinListStr = $heroCfg["skinlist"];
|
||||
$skinIDArr = explode("|",$skinListStr);
|
||||
$skinID = $skinIDArr[0];
|
||||
$itemData = array("hero_id"=>$heroID,"skin_id"=>$skinID);
|
||||
array_push($itemArr,$itemData);
|
||||
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
$this->addHeroSkin($skinData);
|
||||
$this->addAllHero($itemArr);
|
||||
}
|
||||
public function addAllHero($items)
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'hero',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'id' => $item['hero_id']
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'id' => $item['hero_id'],
|
||||
'lv' => 1,
|
||||
'skinid' => $item['skin_id'],
|
||||
'skill1_lv1' =>1,
|
||||
'skill1_lv2' =>1,
|
||||
'yokeexp' => 0,
|
||||
'yoketotalexp' => 0,
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'skill_lv1' => 1,
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
public function addHeroSkin($item)
|
||||
{
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'hero_skin',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'hero_id' => $item['hero_id'],
|
||||
'skin_id' => $item['skin_id']
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'hero_id' => $item['hero_id'],
|
||||
'skin_id' => $item['skin_id'],
|
||||
'skin_state' => $item['skin_state'],
|
||||
'get_from' => $item['get_from'],
|
||||
'consume_num' => $item['consume_num'],
|
||||
'trytime' => $item['trytime'],
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'skin_state' => 3,
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
public function buySkin($_skinID,$_heroID)//购买英雄皮肤
|
||||
{
|
||||
$skinID = $_skinID;
|
||||
$heroID = $_heroID;
|
||||
$code = 100;
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
$this->addHeroSkin($skinData);
|
||||
}
|
||||
public function updateCurrency($_money,$_diamond)
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
|
||||
$sqlStr2 = "Update user set coin_num =:coin_num,diamond_num =:diamond_num WHERE accountid=:accountid ";
|
||||
$row = $conn->execQuery($sqlStr2,array(':accountid' => $account_id,':coin_num' => $_money,':diamond_num' => $_diamond));
|
||||
|
||||
}
|
||||
}
|
467
webapp/controller/NTaskController.class.php
Normal file
467
webapp/controller/NTaskController.class.php
Normal file
@ -0,0 +1,467 @@
|
||||
<?php
|
||||
require_once('mt/Task.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once 'metatable/drop.php';
|
||||
class NTaskController extends BaseAuthedController {
|
||||
|
||||
public $m_testCnt = 0;
|
||||
public function getGunInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM gun_intensify WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
error_log("GunTest3======");
|
||||
}
|
||||
else{
|
||||
error_log("GunTest4=======");
|
||||
}
|
||||
$this->sendDataToClient(0,"test02",$row);
|
||||
}
|
||||
public function test()
|
||||
{
|
||||
error_log("testController====".$this->m_testCnt);
|
||||
$this->m_testCnt ++;
|
||||
}
|
||||
public function updateLogin()//更新登录任务
|
||||
{
|
||||
|
||||
}
|
||||
public function getRewardState($_num)
|
||||
{
|
||||
$g = $_num % 10;
|
||||
$s = floor(($_num % 100)/10);
|
||||
$b = floor(($_num % 1000)/100);
|
||||
$q = floor(($_num % 10000)/1000);
|
||||
$w = floor(($_num % 100000)/10000);
|
||||
$listArr = array();
|
||||
array_push($listArr,$g);
|
||||
array_push($listArr,$s);
|
||||
array_push($listArr,$b);
|
||||
array_push($listArr,$q);
|
||||
array_push($listArr,$w);
|
||||
return $listArr;
|
||||
}
|
||||
public function getLvTastRewardByTaskID()//领取玩家等级成长任务奖励
|
||||
{
|
||||
$code = 100;
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$taskID = $_REQUEST['id'];
|
||||
$taskCfg = mt\Task::getTaskCfgByID($taskID);
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT lv FROM user WHERE accountid=:accountid;";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
$playerLv = 0;
|
||||
$itemList = array();
|
||||
$resultArr = array();
|
||||
array_push($resultArr,array("taskID"=>$taskID));
|
||||
if($row)
|
||||
{
|
||||
$playerLv = $row[0]["lv"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 99;//玩家不存在
|
||||
}
|
||||
$playerLv = 7;
|
||||
if($code == 100)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM quest WHERE accountid=:accountid AND quest_id=:quest_id; ";
|
||||
$row2 = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':quest_id' => $taskID));
|
||||
if(!$row2)
|
||||
{
|
||||
$lvLimit = $taskCfg["value"];
|
||||
if($playerLv >= $lvLimit)
|
||||
{
|
||||
$dropID = $taskCfg["reward_dropid"];
|
||||
$dropItemArr = metatable\getDropListById($dropID);
|
||||
$dropItemLen = count($dropItemArr);
|
||||
$dropList = array();
|
||||
for($j = 0; $j < $dropItemLen ; $j++)
|
||||
{
|
||||
$itemID = $dropItemArr[$j]["item_id"];
|
||||
$itemNum = $dropItemArr[$j]["item_num"];
|
||||
$item = array("item_id"=>$itemID,"item_num"=>$itemNum);
|
||||
if($itemID == Daily_AP_ID)
|
||||
{
|
||||
error_log("我是每日活跃度ID=====".$itemID."==".$itemNum);
|
||||
$this->updateActivePointTODB(999,$itemNum,0);
|
||||
}
|
||||
else if($itemID == WEEK_AP_ID)
|
||||
{
|
||||
$this->updateActivePointTODB(998,$itemNum,0);
|
||||
error_log("我是周活跃度ID=====".$itemID."==".$itemNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
array_push($itemList,$item);
|
||||
}
|
||||
array_push($resultArr,$item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 97;//等级不足
|
||||
}
|
||||
//
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 98;//奖励已经领取
|
||||
}
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
$itemLen = count($itemList);
|
||||
if($itemLen >0 )
|
||||
{
|
||||
$this->addItem($itemList);
|
||||
}
|
||||
$this->InsertTaskType($taskID,$taskCfg["type"],0);
|
||||
}
|
||||
error_log("PlayerLv=====".$playerLv);
|
||||
$this->sendDataToClient($code,"GetPlayerLvTaskReward",$resultArr);
|
||||
}
|
||||
public function getRewardByTaskID()//领取任务奖励
|
||||
{
|
||||
$code = 100;
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$taskID = $_REQUEST['id'];
|
||||
$tmpIndex = $_REQUEST["rewardIndex"];
|
||||
$taskCfg = mt\Task::getTaskCfgByID($taskID);
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM quest WHERE accountid=:accountid AND quest_id=:quest_id; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':quest_id' => $taskID));
|
||||
$itemList = array();
|
||||
$resultArr = array();
|
||||
array_push($resultArr,array("taskID"=>$taskID,"index"=>$tmpIndex));
|
||||
$rewardState = 0;//未领取奖励状态
|
||||
error_log("准备领取奖励测试======".$taskID."==".json_encode($row));
|
||||
if($row)
|
||||
{
|
||||
$rewardState = $row[0]["quest_state"];//重新赋值是否领取了奖励
|
||||
$isGet = 0;//是否领取了奖励
|
||||
$listArr = [];
|
||||
$maxNum = 0;
|
||||
$dropID = 0;
|
||||
|
||||
if($taskID >=900 && $taskID < 1000)
|
||||
{
|
||||
$targetLimitID = 0;
|
||||
$targetDropID = 0;
|
||||
$stateNum = $rewardState;
|
||||
if($taskID == 999)
|
||||
{
|
||||
$targetLimitID = 208;
|
||||
$targetDropID = 209;
|
||||
}
|
||||
else if($taskID == 998)
|
||||
{
|
||||
$targetLimitID = 210;
|
||||
$targetDropID = 211;
|
||||
}
|
||||
if($stateNum <= 0)
|
||||
{
|
||||
$stateNum = 1000000;
|
||||
}
|
||||
$listArr = $this->getRewardState($stateNum);
|
||||
$limitCfg = mt\Parameter::getParameterCfgByID($targetLimitID);
|
||||
$dropIDCfg = mt\Parameter::getParameterCfgByID($targetDropID);
|
||||
$limitStr = $limitCfg["param_value"];
|
||||
$limitStrArr = explode("|",$limitStr);
|
||||
$dropIDStr = $dropIDCfg["param_value"];
|
||||
$dropIDStrArr = explode("|",$dropIDStr);
|
||||
$dropID = $dropIDStrArr[$tmpIndex - 1];
|
||||
$maxNum = $limitStrArr[$tmpIndex - 1];
|
||||
$tmpState = $listArr[$tmpIndex - 1];
|
||||
if($tmpState >= 1)
|
||||
{
|
||||
$isGet = 1;//奖励已经领取
|
||||
}
|
||||
else
|
||||
{
|
||||
$listArr[$tmpIndex - 1] = 1;
|
||||
}
|
||||
$listLen = count($listArr);
|
||||
$newState = "10";
|
||||
for($i = $listLen -1;$i >=0;$i--)
|
||||
{
|
||||
$newState = $newState."".$listArr[$i];
|
||||
}
|
||||
$rewardState = $newState;
|
||||
error_log("配置信息======".$maxNum."==".$dropID."==".json_encode($listArr)."==".$newState);
|
||||
}
|
||||
else
|
||||
{
|
||||
$maxNum = $taskCfg["value"];
|
||||
$dropID = $taskCfg["reward_dropid"];
|
||||
$isGet = $rewardState;
|
||||
$rewardState = 1;
|
||||
}
|
||||
if($isGet == 0)//未领取奖励
|
||||
{
|
||||
$curNum = $row[0]["quest_num"];
|
||||
if($curNum >= $maxNum)
|
||||
{
|
||||
$dropItemArr = metatable\getDropListById($dropID);
|
||||
$dropItemLen = count($dropItemArr);
|
||||
$dropList = array();
|
||||
for($j = 0; $j < $dropItemLen ; $j++)
|
||||
{
|
||||
$itemID = $dropItemArr[$j]["item_id"];
|
||||
$itemNum = $dropItemArr[$j]["item_num"];
|
||||
$item = array("item_id"=>$itemID,"item_num"=>$itemNum);
|
||||
if($itemID == Daily_AP_ID)
|
||||
{
|
||||
error_log("我是每日活跃度ID=====".$itemID."==".$itemNum);
|
||||
$this->updateActivePointTODB(999,$itemNum,0);
|
||||
}
|
||||
else if($itemID == WEEK_AP_ID)
|
||||
{
|
||||
$this->updateActivePointTODB(998,$itemNum,0);
|
||||
error_log("我是周活跃度ID=====".$itemID."==".$itemNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
array_push($itemList,$item);
|
||||
}
|
||||
array_push($resultArr,$item);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 92;//条件不足领取奖励
|
||||
}
|
||||
}
|
||||
else//已经领取了奖励
|
||||
{
|
||||
$code = 91;//j奖励已经领取
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = 90;//任务不存在
|
||||
}
|
||||
if($code == 100)
|
||||
{
|
||||
$itemLen = count($itemList);
|
||||
if($itemLen >0 )
|
||||
{
|
||||
$this->addItem($itemList);
|
||||
}
|
||||
$this->updateActivePointTODB($taskID,0,$rewardState);
|
||||
|
||||
}
|
||||
$this->sendDataToClient($code,"GetRewardFromTask",$resultArr);
|
||||
//error_log("准备领取奖励=====".json_encode($_REQUEST)."==".$taskID);
|
||||
}
|
||||
//更新日活跃和周活跃分数
|
||||
public function updateActivePointTODB($_questID,$_questNum,$_rewardState)
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM quest WHERE accountid=:accountid AND quest_id=:quest_id; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':quest_id' => $_questID));
|
||||
$nowSeconds = $this->getNowTime();
|
||||
$nextDaySeconds = phpcommon\getNextDaySeconds($nowSeconds);
|
||||
$nextWeekSeconds = phpcommon\getMondaySeconds($nowSeconds);
|
||||
$weekDeadLine = ($nextWeekSeconds + 86400*7);
|
||||
$rewardState = 0;
|
||||
$modifyTime = 0;
|
||||
$taskNum = 0 ;
|
||||
if($row) {
|
||||
$item = $row[0];
|
||||
$taskNum = $item["quest_num"];
|
||||
$taskCondition = $item["quest_type"];
|
||||
$rewardState = $item["quest_state"];
|
||||
$modifyTime = $item["modify_time"];
|
||||
|
||||
if($taskCondition == 1 || $taskCondition == 99)//每日任务 周活跃奖励
|
||||
|
||||
{
|
||||
if($nowSeconds >= $modifyTime)//是否过期
|
||||
{
|
||||
$rewardState = 0;
|
||||
$modifyTime = $nextDaySeconds;
|
||||
if($taskCondition == 99)
|
||||
{
|
||||
$modifyTime = $weekDeadLine;
|
||||
}
|
||||
$taskNum = $_questNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
$taskNum = $taskNum + $_questNum;
|
||||
$rewardState = $_rewardState;
|
||||
|
||||
}
|
||||
}
|
||||
phpcommon\SqlHelper::update
|
||||
($this->getSelfMysql(),
|
||||
'quest',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'quest_id' => $_questID
|
||||
),
|
||||
array(
|
||||
'quest_num' =>$taskNum,
|
||||
"quest_state" =>$rewardState,
|
||||
'modify_time' => $modifyTime
|
||||
)
|
||||
);
|
||||
}
|
||||
else{
|
||||
error_log("questInfo2=======");
|
||||
}
|
||||
}
|
||||
public function updateTaskToDB($_questID,$_questNum)
|
||||
{
|
||||
|
||||
$taskCfg = mt\Task::getTaskCfgByID($_questID);
|
||||
$taskType = $taskCfg["type"];
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM quest WHERE accountid=:accountid AND quest_id=:quest_id; ";
|
||||
//$sqlStr = "SELECT * FROM quest WHERE quest_id=:quest_id; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':quest_id' => $_questID));
|
||||
//$row = $conn->execQuery($sqlStr,array(':quest_id' => $_questID));
|
||||
$questNum = 0;
|
||||
$nowSeconds = phpcommon\getNowTime();
|
||||
$nextDaySeconds = phpcommon\getNextDaySeconds($nowSeconds);
|
||||
$nowTime = $this->getNowTime();
|
||||
$modifyTime = 0;
|
||||
$getReward = 0 ;
|
||||
if($row) {
|
||||
$modifyTime = $row[0]["modify_time"];
|
||||
$getReward = $row[0]["quest_state"];
|
||||
if($nowTime >= $modifyTime)
|
||||
{
|
||||
$getReward = 0;//第二天 数据恢复
|
||||
$questNum = $_questNum;
|
||||
$modifyTime = $nextDaySeconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
$questNum = $row[0]["quest_num"] + $_questNum;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$modifyTime = $nextDaySeconds;
|
||||
$questNum = $_questNum;
|
||||
}
|
||||
//quest_state = 奖励是否领取
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'quest',
|
||||
array(
|
||||
'accountid' => $account_id,
|
||||
'quest_id' => $_questID
|
||||
),
|
||||
array(
|
||||
'accountid' => $account_id,
|
||||
'quest_id' => $_questID,
|
||||
'quest_num' =>$questNum,
|
||||
'quest_type' =>$taskType,
|
||||
'quest_state' =>0,
|
||||
'create_time' => $this->getNowTime(),
|
||||
'modify_time' => $modifyTime
|
||||
),
|
||||
array(
|
||||
'quest_num' => $questNum,
|
||||
'quest_state' =>$getReward,
|
||||
'modify_time' => $modifyTime
|
||||
)
|
||||
);
|
||||
}
|
||||
public function getAllTaskInfo()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$nowSeconds = $this->getNowTime();
|
||||
$nextDaySeconds = phpcommon\getNextDaySeconds($nowSeconds);
|
||||
|
||||
$nextWeekSeconds = phpcommon\getMondaySeconds($nowSeconds);
|
||||
$weekDeadLine = ($nextWeekSeconds + 86400*7);
|
||||
|
||||
|
||||
//插入今日活跃度任务开始--
|
||||
$this->InsertTaskType(999,1,$nextDaySeconds);
|
||||
//插入今日活跃度任务结束--
|
||||
//插入每周活跃度任务开始--
|
||||
$this->InsertTaskType(998,99,$weekDeadLine);
|
||||
//插入每周活跃度任务结束--
|
||||
|
||||
|
||||
$resultArr = array();
|
||||
$sqlStr = "SELECT * FROM quest WHERE accountid=:accountid; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
|
||||
if($row) {
|
||||
|
||||
foreach($row as $item)
|
||||
{
|
||||
$taskID = $item["quest_id"];
|
||||
$taskNum = $item["quest_num"];
|
||||
$rewardState = $item["quest_state"];
|
||||
$taskCondition = $item["quest_type"];
|
||||
$modifyTime = $item["modify_time"];
|
||||
if($taskCondition == 1 || $taskCondition == 99)//每日任务 周活跃奖励
|
||||
{
|
||||
if($nowSeconds >= $modifyTime)
|
||||
{
|
||||
$rewardState = 0;
|
||||
$modifyTime = $nextDaySeconds;
|
||||
if($taskCondition == 99)
|
||||
{
|
||||
$modifyTime = $weekDeadLine;
|
||||
}
|
||||
$taskNum = 0;
|
||||
error_log("重置======".$nowSeconds."==".$modifyTime);
|
||||
}
|
||||
}
|
||||
$tmpData = array("id"=>$taskID,"num"=>$taskNum,"rewardState"=>$rewardState,"condition"=>$taskCondition,"modifyTime"=>$modifyTime);
|
||||
array_push($resultArr,$tmpData);
|
||||
}
|
||||
}
|
||||
else{
|
||||
error_log("questInfo2=======");
|
||||
}
|
||||
|
||||
$this->sendDataToClient(100,"getAllTaskInfo",$resultArr);
|
||||
}
|
||||
public function InsertTaskType($questID,$dailyType,$deadline)
|
||||
{
|
||||
$nowSeconds = $this->getNowTime();
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$sqlStr = "SELECT * FROM quest WHERE accountid=:accountid AND quest_id=:quest_id; ";
|
||||
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':quest_id' => $questID));
|
||||
if($row)
|
||||
{
|
||||
|
||||
}
|
||||
else//不存在插入
|
||||
{
|
||||
$sqlStr ='INSERT INTO quest(accountid, quest_id, quest_num, quest_type, quest_state, create_time, modify_time) ' .
|
||||
' VALUES(:accountid, :quest_id, :quest_num, :quest_type, :quest_state, :create_time, :modify_time) ';
|
||||
$params = array(
|
||||
':accountid' => $account_id,
|
||||
':quest_id' => $questID,
|
||||
':quest_num' => 0,
|
||||
':quest_type' => $dailyType,
|
||||
':quest_state'=> 1000000,
|
||||
':create_time' => $nowSeconds,
|
||||
':modify_time' => $deadline
|
||||
);
|
||||
$ret = $conn->execScript($sqlStr,$params);
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,8 @@
|
||||
|
||||
require 'classes/Quest.php';
|
||||
require 'classes/AddReward.php';
|
||||
|
||||
require 'NTaskController.class.php';
|
||||
require_once('mt/Parameter.php');
|
||||
class RoleController extends BaseAuthedController {
|
||||
|
||||
|
||||
@ -83,7 +84,7 @@ class RoleController extends BaseAuthedController {
|
||||
'open_time' => $season_meta['time1'],
|
||||
'end_time' => $season_meta['time2'],
|
||||
'reward' => $season_meta['season_reward'],
|
||||
'weekreward' => $season_meta['week_reward'],
|
||||
'weekreward' => $season_meta['season_reward2'],
|
||||
);
|
||||
return $season;
|
||||
}
|
||||
@ -137,6 +138,7 @@ class RoleController extends BaseAuthedController {
|
||||
|
||||
public function roleInfo()
|
||||
{
|
||||
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
//$user_name = $_REQUEST['name'];
|
||||
//$avatar_url = $_REQUEST['avatar_url'];
|
||||
@ -144,6 +146,13 @@ class RoleController extends BaseAuthedController {
|
||||
$avatar_url = '18201';
|
||||
$switch_id = 1;
|
||||
$switch_id = isset($_REQUEST['switch_id']);
|
||||
//new classes\Quest();
|
||||
//创建任务对象开始--
|
||||
$testTask = new NTaskController();
|
||||
$testTask->updateTaskToDB(QUEST_DAY_LOGIN,1);
|
||||
//创建任务对象结束--
|
||||
|
||||
error_log("玩家登录=====".$account_id);
|
||||
//登录校验
|
||||
$login = loginVerify($account_id, $_REQUEST['session_id']);
|
||||
if (!$login) {
|
||||
@ -178,9 +187,9 @@ class RoleController extends BaseAuthedController {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times, shop_view_times, new_first_equip, newhand2,game_times2, view_times2, guildcoin_num, new_second_equip, rmb_num, max_single_recharge, passcard, rmb_lot_ticket, daily_max_single, head_kuang_id, daily_score, daily_offline, create_user, sex, sumlot_coin, max_integral) ' .
|
||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, 0, 0, 0, 0, 0, 0, 2, 0, 0) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0, shop_view_times=0, new_first_equip=0, newhand2=0, game_times2=0,view_times2=0, guildcoin_num=0, new_second_equip=2, rmb_num=0, max_single_recharge=0, passcard=0, rmb_lot_ticket=0, daily_max_single=0, head_kuang_id=0, daily_score=0, daily_offline=0, create_user=0, sex=2, sumlot_coin=0, max_integral=0;',
|
||||
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times, shop_view_times, new_first_equip, newhand2,game_times2, view_times2, guildcoin_num, new_second_equip, rmb_num, max_single_recharge, passcard, rmb_lot_ticket, daily_max_single, head_kuang_id, daily_score, daily_offline, create_user, sex, sumlot_coin, max_integral,lv,lv_exp,money_of_week,team_name,hi_id,hero_id) ' .
|
||||
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, 0, 0, 19003, 0, 0, 0, 2, 0, 0,0,0,0,"",18003,30100) ' .
|
||||
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0, shop_view_times=0, new_first_equip=0, newhand2=0, game_times2=0,view_times2=0, guildcoin_num=0, new_second_equip=2, rmb_num=0, max_single_recharge=0, passcard=0, rmb_lot_ticket=0, daily_max_single=0, head_kuang_id=0, daily_score=0, daily_offline=0, create_user=0, sex=2, sumlot_coin=0, max_integral=0,lv_exp = 0,money_of_week = 0 ,team_name = "",hi_id = 18003,hero_id = 30100;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':user_name' => $user_name,
|
||||
@ -196,6 +205,9 @@ class RoleController extends BaseAuthedController {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
//赠送玩家英雄开始--
|
||||
$this->addHeroToDB();
|
||||
//赠送玩家英雄结束--
|
||||
//新玩家赠送材料,表情
|
||||
$this->newPlayerReward($account_id);
|
||||
echo json_encode(array(
|
||||
@ -403,10 +415,109 @@ class RoleController extends BaseAuthedController {
|
||||
'avatar_url' => $row['avatar_url'],
|
||||
'create_user' => $row['create_user'],
|
||||
'sex' => $row['sex'],
|
||||
'lv' => $row['lv'],
|
||||
'lv_exp'=> $row['lv_exp'],
|
||||
'hiid' => $row['hi_id'],
|
||||
'hero_id' => $row['hero_id'],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function addHeroToDB()
|
||||
{
|
||||
// $itemArr = [10101,10102,10103,10104,10105,10106,10200,10201,
|
||||
// 10202,10203,10204,10205,10206,10207,10208,12100,12102,12103,12104,
|
||||
// 12105,12106,12107,12119,12120,12121];
|
||||
$globleCfg = mt\Parameter::getParameterCfgByID(212);
|
||||
$paramValue = $globleCfg["param_value"];
|
||||
$paramStrArr = explode("|",$paramValue);
|
||||
$itemIDArr = array();
|
||||
for($i = 0 ; $i < count($paramStrArr); $i++)
|
||||
{
|
||||
array_push($itemIDArr,$paramStrArr[$i]);
|
||||
}
|
||||
$playerCfg = require('../res/player@player.php');
|
||||
|
||||
$itemArr = array();
|
||||
$len = count($itemIDArr);
|
||||
for($i = 0; $i< $len; $i++)
|
||||
{
|
||||
$heroID = $itemIDArr[$i];
|
||||
if($playerCfg[$heroID])
|
||||
{
|
||||
$heroCfg = $playerCfg[$heroID];
|
||||
$skinListStr = $heroCfg["skinlist"];
|
||||
$skinIDArr = explode("|",$skinListStr);
|
||||
$skinID = $skinIDArr[0];
|
||||
$itemData = array("hero_id"=>$heroID,"skin_id"=>$skinID);
|
||||
array_push($itemArr,$itemData);
|
||||
$skinData = array(
|
||||
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
|
||||
'skin_state' => 0,
|
||||
'get_from' => 0,
|
||||
'consume_num' => 0,
|
||||
'trytime' => 0
|
||||
);
|
||||
$this->addHeroSkin($skinData);
|
||||
}
|
||||
}
|
||||
$this->addAllHero($itemArr);
|
||||
}
|
||||
public function addAllHero($items)
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'hero',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'id' => $item['hero_id']
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'id' => $item['hero_id'],
|
||||
'lv' => 1,
|
||||
'skinid' => $item['skin_id'],
|
||||
'skill1_lv1' =>1,
|
||||
'skill1_lv2' =>1,
|
||||
'yokeexp' => 0,
|
||||
'yoketotalexp' => 0,
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'skill_lv1' => 1,
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
public function addHeroSkin($item)
|
||||
{
|
||||
phpcommon\SqlHelper::insertOrUpdate
|
||||
($this->getSelfMysql(),
|
||||
'hero_skin',
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'hero_id' => $item['hero_id'],
|
||||
'skin_id' => $item['skin_id']
|
||||
),
|
||||
array(
|
||||
'accountid' => $this->getAccountId(),
|
||||
'hero_id' => $item['hero_id'],
|
||||
'skin_id' => $item['skin_id'],
|
||||
'skin_state' => $item['skin_state'],
|
||||
'get_from' => $item['get_from'],
|
||||
'consume_num' => $item['consume_num'],
|
||||
'trytime' => $item['trytime'],
|
||||
'createtime' => $this->getNowTime(),
|
||||
'modifytime' => $this->getNowTime()
|
||||
),
|
||||
array(
|
||||
'skin_state' => 3,
|
||||
'modifytime' => $this->getNowTime()
|
||||
)
|
||||
);
|
||||
}
|
||||
protected function newPlayerReward($account_id)
|
||||
{
|
||||
$conn = $this->getMysql($account_id);
|
||||
@ -687,40 +798,8 @@ class RoleController extends BaseAuthedController {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
//刷新任务
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_FIGHT, 1, 1, $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_ALIVE, 1, (int)($alive_time / 1000 / 60), $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_HARM, 1, $harm, $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_KILL, 1, $kills, $account_id);
|
||||
|
||||
$quest->submitSeaQuest(74006, 1, $account_id);
|
||||
$quest->submitSeaQuest(74002, (int)($alive_time / 1000 / 60), $account_id);
|
||||
$quest->submitSeaQuest(74003, $harm, $account_id);
|
||||
$quest->submitSeaQuest(74004, $kills, $account_id);
|
||||
|
||||
$addreward = new classes\Addreward();
|
||||
$vip_level = $addreward->getVipLevel($account_id);
|
||||
for ($i = 1; $i < 8; $i++) {
|
||||
if ($i <= $vip_level) {
|
||||
$quest->triggerQuest(73000 + $i, 4, 1, $account_id);
|
||||
}
|
||||
}
|
||||
if ($row['passcard'] == 1) {
|
||||
$quest->submitSeaQuest(75003, 1, $account_id);
|
||||
$quest->submitSeaQuest(75004, 1, $account_id);
|
||||
$quest->submitSeaQuest(75005, 1, $account_id);
|
||||
//$quest->submitSeaQuest(74001, $kills, $account_id);
|
||||
$quest->submitSeaQuest(75002, 1, $account_id);
|
||||
}
|
||||
if ($team_status == 1 && $rank <= 5) {
|
||||
$quest->triggerQuest(QUEST_DAY_RANK, 1, 1, $account_id);
|
||||
$quest->submitSeaQuest(74001, 1, $account_id);
|
||||
}
|
||||
if ($team_status == 1) {
|
||||
$quest->triggerQuest(QUEST_DAY_TEAM, 1, 1, $account_id);
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
@ -730,6 +809,30 @@ class RoleController extends BaseAuthedController {
|
||||
|
||||
public function battleReport()
|
||||
{
|
||||
error_log("游戏结束====".json_encode($_REQUEST));
|
||||
//任务参与 N场比赛开始--
|
||||
$taskObj = new NTaskController();
|
||||
$taskObj->updateTaskToDB(PLAY_GAME,1);
|
||||
//任务参与 N场比赛结束--
|
||||
//累计生存时间多少分钟开始--
|
||||
$alive_time = $_REQUEST["alive_time"];
|
||||
$tmpAlive_time = floor($alive_time/1000);
|
||||
$taskObj->updateTaskToDB(ALIVE_TIME,$tmpAlive_time);
|
||||
error_log("玩家存活时间======".$alive_time."==".$tmpAlive_time);
|
||||
//累计生存时间多少分钟结束--
|
||||
//累计击杀10个敌人开始--
|
||||
$killNum = $_REQUEST['kills'];
|
||||
$taskObj->updateTaskToDB(KILL_NUM,$killNum);
|
||||
//累计击杀10个敌人结束--
|
||||
//造成800伤害70006开始--
|
||||
$damageNum = $_REQUEST['harm'];
|
||||
$taskObj->updateTaskToDB(DAMAGE_NUM70006,$damageNum);
|
||||
//造成800伤害70006结束--
|
||||
//---------
|
||||
//救起2个队友开始--
|
||||
$helpOtherPlayer = $_REQUEST['rescue_member'];
|
||||
$taskObj->updateTaskToDB(HELP_OP70008,$helpOtherPlayer);
|
||||
//救起2个队友结束--
|
||||
if (!isset($_REQUEST['room_mode']) || $_REQUEST['room_mode'] == 0) {
|
||||
$this->oldBattleReport();
|
||||
} else {
|
||||
@ -786,10 +889,6 @@ class RoleController extends BaseAuthedController {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
//刷新任务
|
||||
//$quest = new classes\Quest();
|
||||
//$quest->triggerQuest(QUEST_DAY_FIGHT, 1, 1, $account_id);
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
@ -828,6 +927,7 @@ class RoleController extends BaseAuthedController {
|
||||
$coin_num = $_REQUEST['coin_num']; //金币
|
||||
$integral = $_REQUEST['rank_score']; //排位积分
|
||||
$score = $_REQUEST['pass_score']; //通行证积分
|
||||
|
||||
|
||||
if ($_REQUEST['items'] != '') {
|
||||
$item_list = $this->getExplode($_REQUEST['items']);
|
||||
@ -1008,42 +1108,10 @@ class RoleController extends BaseAuthedController {
|
||||
return;
|
||||
}
|
||||
|
||||
//刷新任务
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_FIGHT, 1, 1, $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_ALIVE, 1, (int)($alive_time / 1000 / 60), $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_HARM, 1, $harm, $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_KILL, 1, $kills, $account_id);
|
||||
$quest->triggerQuest(QUEST_DAY_HELP, 1, $rescue_member, $account_id);
|
||||
|
||||
$quest->submitSeaQuest(74006, 1, $account_id);
|
||||
$quest->submitSeaQuest(74002, (int)($alive_time / 1000 / 60), $account_id);
|
||||
$quest->submitSeaQuest(74003, $harm, $account_id);
|
||||
$quest->submitSeaQuest(74004, $kills, $account_id);
|
||||
$quest->submitSeaQuest(74005, $rescue_member, $account_id);
|
||||
|
||||
|
||||
$addreward = new classes\Addreward();
|
||||
$vip_level = $addreward->getVipLevel($account_id);
|
||||
for ($i = 1; $i < 8; $i++) {
|
||||
if ($i <= $vip_level) {
|
||||
$quest->triggerQuest(73000 + $i, 4, 1, $account_id);
|
||||
}
|
||||
}
|
||||
if ($row['passcard'] == 1) {
|
||||
$quest->submitSeaQuest(75003, 1, $account_id);
|
||||
$quest->submitSeaQuest(75004, 1, $account_id);
|
||||
$quest->submitSeaQuest(75005, 1, $account_id);
|
||||
$quest->submitSeaQuest(75001, $rescue_member, $account_id);
|
||||
$quest->submitSeaQuest(75002, 1, $account_id);
|
||||
}
|
||||
if ($team_status == 1 && $rank <= 5) {
|
||||
$quest->triggerQuest(QUEST_DAY_RANK, 1, $rank, $account_id);
|
||||
$quest->submitSeaQuest(74001, 1, $account_id);
|
||||
}
|
||||
if ($team_status == 1) {
|
||||
$quest->triggerQuest(QUEST_DAY_TEAM, 1, 1, $account_id);
|
||||
}
|
||||
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
@ -1111,8 +1179,8 @@ class RoleController extends BaseAuthedController {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_SHARE, 1, 1, $account_id);
|
||||
// $quest = new classes\Quest();
|
||||
// $quest->triggerQuest(QUEST_DAY_SHARE, 1, 1, $account_id);
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
|
@ -150,8 +150,8 @@ class SignController extends BaseAuthedController {
|
||||
//更新签到总天数
|
||||
$this->updateSignSum($account_id, $last_sign_id);
|
||||
//完成签到任务
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
||||
// $quest = new classes\Quest();
|
||||
// $quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
||||
} else {
|
||||
$last_sign_time = $rows[0]['sign_time'];
|
||||
$flag = 0;
|
||||
@ -214,8 +214,8 @@ class SignController extends BaseAuthedController {
|
||||
$this->updateSignSum($account_id, $passed_days);
|
||||
}
|
||||
//完成签到任务
|
||||
$quest = new classes\Quest();
|
||||
$quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
||||
// $quest = new classes\Quest();
|
||||
// $quest->triggerQuest(QUEST_DAY_LOGIN, 1, 1, $account_id);
|
||||
//$quest->triggerQuest(QUEST_SUM_LOGIN, 2, 1, $account_id);
|
||||
}
|
||||
}
|
||||
|
40
webapp/mt/GunSkin.php
Normal file
40
webapp/mt/GunSkin.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class GunSkin {
|
||||
|
||||
|
||||
public static function get($equipId)
|
||||
{
|
||||
return self::getMeta()[$equipId];
|
||||
}
|
||||
|
||||
protected static function getMeta()
|
||||
{
|
||||
if (!self::$meta) {
|
||||
self::$meta = getMetaTable('gunskin@gunskin.php');
|
||||
}
|
||||
return self::$meta;
|
||||
}
|
||||
public static function getGunSkinCfgByGoodsID($_itemID)
|
||||
{
|
||||
$gunSkinCfg = self::getMeta();
|
||||
$itemData = null;
|
||||
foreach($gunSkinCfg as $item)
|
||||
{
|
||||
$tmpItemID = $item["itemid"];
|
||||
if($tmpItemID == $_itemID)
|
||||
{
|
||||
$itemData = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $itemData;
|
||||
}
|
||||
protected static $itemArr;
|
||||
protected static $meta;
|
||||
|
||||
}
|
36
webapp/mt/NewItem.php
Normal file
36
webapp/mt/NewItem.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class NewItem {
|
||||
|
||||
|
||||
public static function get($equipId)
|
||||
{
|
||||
return self::getMeta()[$equipId];
|
||||
}
|
||||
|
||||
protected static function getMeta()
|
||||
{
|
||||
if (!self::$meta) {
|
||||
self::$meta = getMetaTable('newitem@newitem.php');
|
||||
}
|
||||
return self::$meta;
|
||||
}
|
||||
|
||||
public static function getItemCfgByID($itemID)
|
||||
{
|
||||
$itemCfgArr = self::getMeta();
|
||||
$itemData = null;
|
||||
if($itemCfgArr[$itemID])
|
||||
{
|
||||
$itemData = $itemCfgArr[$itemID];
|
||||
}
|
||||
return $itemData;
|
||||
}
|
||||
protected static $itemArr;
|
||||
protected static $meta;
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ use phpcommon;
|
||||
|
||||
class NewShop {
|
||||
|
||||
|
||||
public static function get($equipId)
|
||||
{
|
||||
return self::getMeta()[$equipId];
|
||||
@ -18,7 +19,106 @@ class NewShop {
|
||||
}
|
||||
return self::$meta;
|
||||
}
|
||||
public static function getShopCfg()
|
||||
{
|
||||
$shopCfgArr = self::getMeta();
|
||||
|
||||
return $shopCfgArr;
|
||||
}
|
||||
public static function getShopItemByID($itemID)
|
||||
{
|
||||
$shopCfgArr = self::getMeta();
|
||||
if(!self::$itemArr)
|
||||
{ self::$itemArr = array();
|
||||
foreach ($shopCfgArr as $item)
|
||||
{
|
||||
$goodsIDStr = $item["goods"];
|
||||
$tmpPriceStr = $item["price"];
|
||||
$goodsIDArrStr = explode("|",$goodsIDStr);
|
||||
$goodsPriceArrStr = explode("|",$tmpPriceStr);
|
||||
$discountStr = null;
|
||||
$limitStr = null;
|
||||
if($item["discount"] && $item["discount"] != "")
|
||||
{
|
||||
$discountStr = $item["discount"];
|
||||
}
|
||||
if($item["limit"] && $item["limit"] != "")
|
||||
{
|
||||
$limitStr = $item["limit"];
|
||||
}
|
||||
$discountStrArr = null;
|
||||
$limitStrArr = null;
|
||||
if($discountStr)
|
||||
{
|
||||
$discountStrArr = explode("|",$discountStr);
|
||||
}
|
||||
if($limitStr)
|
||||
{
|
||||
$limitStrArr = explode("|",$limitStr);
|
||||
}
|
||||
$len = count($goodsIDArrStr);
|
||||
$len2 = count($goodsIDArrStr);
|
||||
for($i = 0 ; $i < $len ;$i++)
|
||||
{
|
||||
$goodsIDArr = explode(":",$goodsIDArrStr[$i]);
|
||||
$goodsPriceStr2 = $goodsPriceArrStr[$i];
|
||||
if($goodsPriceStr2 == "")
|
||||
{
|
||||
$goodsPriceStr2 = "10001:99999";
|
||||
}
|
||||
$priceArr = explode(":",$goodsPriceStr2);
|
||||
$goodsID = $goodsIDArr[0];
|
||||
$goodsNum = 1;
|
||||
$tmpLen = count($goodsIDArr);
|
||||
if($tmpLen >= 2)
|
||||
{
|
||||
$goodsNum = $goodsIDArr[1];
|
||||
}
|
||||
$priceID = $priceArr[0];
|
||||
$priceNum = $priceArr[1];
|
||||
$specailPrice = 0;
|
||||
$limitType = 0;
|
||||
|
||||
if($discountStrArr)
|
||||
{
|
||||
$len1 = count($discountStrArr);
|
||||
if($len1 > 0)
|
||||
{
|
||||
$specailPrice = $discountStrArr[$i];
|
||||
}
|
||||
}
|
||||
if($limitStrArr)
|
||||
{
|
||||
$len1 = count($limitStrArr);
|
||||
if($len1 > 0)
|
||||
{
|
||||
if($len1 > $i)
|
||||
{
|
||||
$limitType = $limitStrArr[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$itemInfo = array("goodsID"=>$goodsID,"goodsNum"=>$goodsNum,
|
||||
"priceID"=>$priceID,"priceNum"=>$priceNum,
|
||||
"specailPrice"=>$specailPrice,"limitType"=>$limitType);
|
||||
self::$itemArr[$itemInfo['goodsID']] = $itemInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$itemData = null;
|
||||
if(self::$itemArr[$itemID])
|
||||
{
|
||||
$itemData = self::$itemArr[$itemID];
|
||||
}
|
||||
|
||||
return $itemData;
|
||||
|
||||
|
||||
}
|
||||
protected static $itemArr;
|
||||
protected static $meta;
|
||||
|
||||
}
|
||||
|
41
webapp/mt/Parameter.php
Normal file
41
webapp/mt/Parameter.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class Parameter {
|
||||
|
||||
|
||||
public static function get($equipId)
|
||||
{
|
||||
return self::getMeta()[$equipId];
|
||||
}
|
||||
|
||||
protected static function getMeta()
|
||||
{
|
||||
if (!self::$meta) {
|
||||
self::$meta = getMetaTable('parameter@parameter.php');
|
||||
}
|
||||
return self::$meta;
|
||||
}
|
||||
|
||||
public static function getParameterCfgByID($_itemID)
|
||||
{
|
||||
$parameterCfg = self::getMeta();
|
||||
$itemData = null;
|
||||
foreach($parameterCfg as $item)
|
||||
{
|
||||
$tmpItemID = $item["id"];
|
||||
if($tmpItemID == $_itemID)
|
||||
{
|
||||
$itemData = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $itemData;
|
||||
}
|
||||
protected static $itemArr;
|
||||
protected static $meta;
|
||||
|
||||
}
|
59
webapp/mt/Player.php
Normal file
59
webapp/mt/Player.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class Player {
|
||||
|
||||
|
||||
public static function get($equipId)
|
||||
{
|
||||
return self::getMeta()[$equipId];
|
||||
}
|
||||
|
||||
protected static function getMeta()
|
||||
{
|
||||
if (!self::$meta) {
|
||||
self::$meta = getMetaTable('player@player.php');
|
||||
}
|
||||
return self::$meta;
|
||||
}
|
||||
public static function getShopCfg()
|
||||
{
|
||||
$shopCfgArr = self::getMeta();
|
||||
|
||||
return $shopCfgArr;
|
||||
}
|
||||
public static function getPlayerCfgByID($itemID)
|
||||
{
|
||||
$playerCfg = self::getMeta();
|
||||
$itemData = null;
|
||||
if($playerCfg[$itemID])
|
||||
{
|
||||
$itemData = $playerCfg[$itemID];
|
||||
}
|
||||
|
||||
return $itemData;
|
||||
|
||||
|
||||
}
|
||||
public static function getPlayerCfgByGoodsID($_itemID)
|
||||
{
|
||||
$playerCfg = self::getMeta();
|
||||
$itemData = null;
|
||||
foreach($playerCfg as $item)
|
||||
{
|
||||
$tmpItemID = $item["itemid"];
|
||||
if($tmpItemID == $_itemID)
|
||||
{
|
||||
$itemData = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $itemData;
|
||||
}
|
||||
protected static $itemArr;
|
||||
protected static $meta;
|
||||
|
||||
}
|
41
webapp/mt/PlayerSkin.php
Normal file
41
webapp/mt/PlayerSkin.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class PlayerSkin {
|
||||
|
||||
|
||||
public static function get($equipId)
|
||||
{
|
||||
return self::getMeta()[$equipId];
|
||||
}
|
||||
|
||||
protected static function getMeta()
|
||||
{
|
||||
if (!self::$meta) {
|
||||
self::$meta = getMetaTable('playerskin@playerskin.php');
|
||||
}
|
||||
return self::$meta;
|
||||
}
|
||||
|
||||
public static function getPlayerSkinCfgByGoodsID($_itemID)
|
||||
{
|
||||
$playerSkinCfg = self::getMeta();
|
||||
$itemData = null;
|
||||
foreach($playerSkinCfg as $item)
|
||||
{
|
||||
$tmpItemID = $item["itemid"];
|
||||
if($tmpItemID == $_itemID)
|
||||
{
|
||||
$itemData = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $itemData;
|
||||
}
|
||||
protected static $itemArr;
|
||||
protected static $meta;
|
||||
|
||||
}
|
47
webapp/mt/Season.php
Normal file
47
webapp/mt/Season.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class Season {
|
||||
|
||||
protected static function getMeta()
|
||||
{
|
||||
if (!self::$meta) {
|
||||
self::$meta = getMetaTable('season@season.php');
|
||||
}
|
||||
return self::$meta;
|
||||
}
|
||||
public static function getSeasonRewardByLv($lv)
|
||||
{
|
||||
$seasonCfg = self::getMeta();
|
||||
|
||||
return $seasonCfg;
|
||||
|
||||
}
|
||||
public static function getSeasonCfg()
|
||||
{
|
||||
$seasonCfg = self::getMeta();
|
||||
|
||||
return $seasonCfg;
|
||||
}
|
||||
public static function getTaskCfgByID($_itemID)
|
||||
{
|
||||
$playerSkinCfg = self::getMeta();
|
||||
$itemData = null;
|
||||
foreach($playerSkinCfg as $item)
|
||||
{
|
||||
$tmpItemID = $item["id"];
|
||||
if($tmpItemID == $_itemID)
|
||||
{
|
||||
$itemData = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $itemData;
|
||||
}
|
||||
protected static $itemArr;
|
||||
protected static $meta;
|
||||
|
||||
}
|
63
webapp/mt/SeasonTaskExp.php
Normal file
63
webapp/mt/SeasonTaskExp.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class SeasonTaskExp {
|
||||
|
||||
protected static function getMeta()
|
||||
{
|
||||
if (!self::$meta) {
|
||||
self::$meta = getMetaTable('nseasoncard@nseasoncard.php');
|
||||
}
|
||||
return self::$meta;
|
||||
}
|
||||
|
||||
public static function getSeasonTaskExpCfg()
|
||||
{
|
||||
$seasonCfg = self::getMeta();
|
||||
|
||||
return $seasonCfg;
|
||||
}
|
||||
public static function getSeasonTaskExpCfgByLv($_lv)
|
||||
{
|
||||
$tmpData = null;
|
||||
$seasonTaskExpCfg = self::getMeta();
|
||||
foreach($seasonTaskExpCfg as $item)
|
||||
{
|
||||
$lv = $item['lv'];
|
||||
if($lv == $_lv)
|
||||
{
|
||||
$tmpData = $item;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $tmpData;
|
||||
|
||||
}
|
||||
public static function getSeasonTaskExpCfgByPoint($point)
|
||||
{
|
||||
$tmpData = null;
|
||||
$seasonTaskExpCfg = self::getMeta();
|
||||
$maxLv = count($seasonTaskExpCfg);
|
||||
foreach($seasonTaskExpCfg as $item)
|
||||
{
|
||||
$minScore = $item['min_point'];
|
||||
$maxScore = $item['max_exp'];
|
||||
if($point >= $minScore && $point <= $maxScore)
|
||||
{
|
||||
$tmpData = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$resultArr = array("itemCfg"=>$tmpData,"maxLv"=>$maxLv);
|
||||
return $resultArr;
|
||||
}
|
||||
protected static $itemArr;
|
||||
protected static $meta;
|
||||
|
||||
}
|
41
webapp/mt/Task.php
Normal file
41
webapp/mt/Task.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class Task {
|
||||
|
||||
|
||||
public static function get($equipId)
|
||||
{
|
||||
return self::getMeta()[$equipId];
|
||||
}
|
||||
|
||||
protected static function getMeta()
|
||||
{
|
||||
if (!self::$meta) {
|
||||
self::$meta = getMetaTable('newtask@newtask.php');
|
||||
}
|
||||
return self::$meta;
|
||||
}
|
||||
|
||||
public static function getTaskCfgByID($_itemID)
|
||||
{
|
||||
$playerSkinCfg = self::getMeta();
|
||||
$itemData = null;
|
||||
foreach($playerSkinCfg as $item)
|
||||
{
|
||||
$tmpItemID = $item["id"];
|
||||
if($tmpItemID == $_itemID)
|
||||
{
|
||||
$itemData = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $itemData;
|
||||
}
|
||||
protected static $itemArr;
|
||||
protected static $meta;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user