1
This commit is contained in:
parent
8092eb93a4
commit
6fdbebd2fd
@ -95,14 +95,19 @@ class Role(object):
|
||||
]
|
||||
},
|
||||
{
|
||||
'desc': 'getNewHandReward',
|
||||
'desc': '获取新手奖励getNewHandReward',
|
||||
'group': 'Role',
|
||||
'url': 'webapp/index.php?c=Role&a=getNewHandReward',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['type', 0, '类型1或2'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!item_list', _common.DropItemInfo, '掉落道具列表'],
|
||||
['coin_num', 0, '当前金币数'],
|
||||
['rmb_num', 0, '当前点券数量'],
|
||||
['!all_item_list', _common.RewardItemInfo, '实际奖励的道具列表'],
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -124,3 +124,21 @@ class RobotMetaInfo(object):
|
||||
['name', 0, '机器人名字'],
|
||||
['avatar_url', 0, '机器人头像'],
|
||||
]
|
||||
|
||||
class DropItemInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['item_id', 0, '道具id'],
|
||||
['item_num', 0, '道具数量'],
|
||||
['time', 0, '时间'],
|
||||
]
|
||||
|
||||
class RewardItemInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['item_id', 0, '道具id'],
|
||||
['item_num', 0, '道具数量'],
|
||||
['time', 0, '时间'],
|
||||
]
|
||||
|
@ -241,5 +241,19 @@ function getMetaTable($tblName)
|
||||
return $g_metatables[$tblName];
|
||||
}
|
||||
|
||||
function splitStr1($string)
|
||||
{
|
||||
return explode('|', $string);
|
||||
}
|
||||
|
||||
function splitStr2($string)
|
||||
{
|
||||
$result = array();
|
||||
foreach (explode('|', $string) as $tmpStr) {
|
||||
array_push($result, explode(':', $tmpStr));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
checkMysqlConfig();
|
||||
checkRedisConfig();
|
||||
|
@ -215,7 +215,7 @@ class RoleController extends BaseAuthedController {
|
||||
|
||||
$nowDaySeconds = $this->getNowDaySeconds();
|
||||
if ($_REQUEST['items'] != '') {
|
||||
$item_list = $this->getExplode($_REQUEST['items']);
|
||||
$item_list = splitStr1($_REQUEST['items']);
|
||||
$addreward = new classes\AddReward();
|
||||
$addreward->addReward((int)$item_list[0][0], (int)$item_list[0][1], $account_id, 0, 0);
|
||||
}
|
||||
@ -378,73 +378,52 @@ class RoleController extends BaseAuthedController {
|
||||
|
||||
public function getNewHandReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$row = $conn->execQueryOne('SELECT newhand, newhand2 FROM user WHERE accountid=:account_id;',
|
||||
array(
|
||||
':account_id' => $account_id
|
||||
));
|
||||
$type = 1;
|
||||
if (isset($_REQUEST['type'])) {
|
||||
$type = $_REQUEST['type'];
|
||||
$userInfo = $this->getUserInfo(array(
|
||||
'newhand',
|
||||
'newhand2'
|
||||
));
|
||||
if (!isset($_REQUEST['type']) || !in_array($_REQUEST['type'], array(1, 2))) {
|
||||
$this->rspErr(1, '参数错误');
|
||||
return;
|
||||
}
|
||||
$type = $_REQUEST['type'];
|
||||
$reward_id = 29001;
|
||||
if ($type == 1) {
|
||||
$reward_id = 29001;
|
||||
if (!$row || $row['newhand'] != 1) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '未达到领取条件');
|
||||
return;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE user SET newhand=2, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':modify_time' => phpcommon\getNowTime(),
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
if ($userInfo['newhand'] != 1) {
|
||||
$this->rspErr(ERR_USER_BASE + 2, '未达到领取条件');
|
||||
return;
|
||||
}
|
||||
$this->updateUserInfo(array(
|
||||
'newhand' => 2,
|
||||
'modify_time' => $this->getNowTime()
|
||||
));
|
||||
} else if ($type == 2) {
|
||||
$reward_id = 29002;
|
||||
if (!$row || $row['newhand2'] != 1) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '未达到领取条件');
|
||||
if ($userInfo['newhand2'] != 1) {
|
||||
$this->rspErr(ERR_USER_BASE + 2, '未达到领取条件');
|
||||
return;
|
||||
}
|
||||
$ret = $conn->execScript('UPDATE user SET newhand2=2, modify_time=:modify_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':modify_time' => phpcommon\getNowTime(),
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$d = mt\Drop::getOldDrop($reward_id);
|
||||
if (!$d) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
|
||||
return;
|
||||
}
|
||||
$item_list = array();
|
||||
$all_item_list = array();
|
||||
$item_id_array = $this->getExplode($d['item_id']);
|
||||
$item_num_array = $this->getExplode($d['num']);
|
||||
for ($i = 0; $i < count($item_id_array); $i++) {
|
||||
$item_id = $item_id_array[$i][0];
|
||||
$item_num = $item_num_array[$i][0];
|
||||
array_push($item_list, array(
|
||||
'item_id' => $item_id,
|
||||
'item_num' => $item_num,
|
||||
'time' => 0
|
||||
$this->updateUserInfo(array(
|
||||
'newhand2' => 2,
|
||||
'modify_time' => $this->getNowTime()
|
||||
));
|
||||
}
|
||||
|
||||
$dropMeta = mt\Drop::get($reward_id);
|
||||
if (!$dropMeta) {
|
||||
$this->rspErr(ERR_USER_BASE + 3, '没有这个奖励');
|
||||
return;
|
||||
}
|
||||
$item_list = mt\Drop::getDropData();
|
||||
$all_item_list = array();
|
||||
$addreward = new classes\AddReward();
|
||||
foreach ($item_list as $item) {
|
||||
$items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time'], 0);
|
||||
$items = $addreward->addReward($item['item_id'],
|
||||
$item['item_num'],
|
||||
$this->getAccountId(),
|
||||
$item['time'],
|
||||
0);
|
||||
foreach($items as $i) {
|
||||
array_push($all_item_list, array(
|
||||
'item_id' => $i['item_id'],
|
||||
@ -453,14 +432,16 @@ class RoleController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
}
|
||||
$coin_num = $addreward->getCoinNum($account_id);
|
||||
$num = $addreward->getRmbNum($account_id);
|
||||
$newUserInfo = $this->getUserInfo(array(
|
||||
'coin_num',
|
||||
'rmb_num'
|
||||
));
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg'=> '',
|
||||
'item_list' => $item_list,
|
||||
'coin_num' => $coin_num,
|
||||
'rmb_nums' => $num,
|
||||
'coin_num' => $newUserInfo['coin_num'],
|
||||
'rmb_nums' => $newUserInfo['rmb_num'],
|
||||
'all_item_list' => $all_item_list
|
||||
));
|
||||
}
|
||||
@ -854,7 +835,6 @@ class RoleController extends BaseAuthedController {
|
||||
$updateInfo
|
||||
);
|
||||
}
|
||||
|
||||
$resultArr = array("type"=>$type,"itemID"=>$itemID,"heroSkinID"=>$heroSkinID);
|
||||
$this->sendDataToClient($code,"changeHIFrameHero",$resultArr);
|
||||
}
|
||||
@ -875,7 +855,6 @@ class RoleController extends BaseAuthedController {
|
||||
if($code == 100)
|
||||
{
|
||||
$this->decItem($itemArr);
|
||||
|
||||
//error_log("改名测试======".$code);
|
||||
phpcommon\SqlHelper::update
|
||||
($this->getSelfMysql(),
|
||||
|
@ -2,21 +2,19 @@
|
||||
|
||||
class VoiceController extends BaseAuthedController {
|
||||
|
||||
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$raw_data = file_get_contents('php://input');
|
||||
$data = base64_encode($raw_data);
|
||||
$md5 = md5($data);
|
||||
$r = $this->getRedis($md5);
|
||||
$r->set('game2004:voice:' . $md5, $data);
|
||||
$r -> pexpire('game2004:voice:' . $md5, 1000 * 600);
|
||||
$r->set('game2005:voice:' . $md5, $data);
|
||||
$r -> pexpire('game2005:voice:' . $md5, 1000 * 600);
|
||||
$url = '';
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
$url = "https://game2004api.kingsome.cn/webapp/index.php?c=Voice&a=download&res_id=" . $md5;
|
||||
$url = "https://game2005api.kingsome.cn/webapp/index.php?c=Voice&a=download&res_id=" . $md5;
|
||||
} else {
|
||||
$url = "https://game2004api-test.kingsome.cn/webapp/index.php?c=Voice&a=download&res_id=" . $md5;
|
||||
$url = "https://game2005api-test.kingsome.cn/webapp/index.php?c=Voice&a=download&res_id=" . $md5;
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
@ -28,10 +26,8 @@ class VoiceController extends BaseAuthedController {
|
||||
public function download()
|
||||
{
|
||||
$r = $this->getRedis($_REQUEST['res_id']);
|
||||
$data = $r->get('game2004:voice:' . $_REQUEST['res_id']);
|
||||
$data = $r->get('game2005:voice:' . $_REQUEST['res_id']);
|
||||
echo base64_decode($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,6 +24,23 @@ class Drop {
|
||||
);
|
||||
}
|
||||
|
||||
public static function getDropData($meta)
|
||||
{
|
||||
$itemIds = splitStr1($meta['item_id']);
|
||||
$itemNums = splitStr1($meta['num']);
|
||||
$result = array();
|
||||
if (count($itemIds) == count($itemNums)) {
|
||||
for ($i = 0; $i < count($itemIds); ++$i) {
|
||||
array_push($result, array(
|
||||
'item_id' => $itemIds[$i],
|
||||
'item_num' => $itemNus[$i],
|
||||
'time' => 0
|
||||
));
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
|
46
webapp/mt/Robot.php
Normal file
46
webapp/mt/Robot.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class Robot {
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return array_key_exists($id, self::getMetaList()) ? self::getMetaList()[$id] : null;
|
||||
}
|
||||
|
||||
public static function getRandMember()
|
||||
{
|
||||
$meta = self::get(1000 + rand(1, 100));
|
||||
return array(
|
||||
'account_id' => $meta['id'],
|
||||
'name' => $meta['name'],
|
||||
'avatar_url' => $meta['avatar_url'],
|
||||
);
|
||||
}
|
||||
|
||||
public static function getSinMembers()
|
||||
{
|
||||
$members = array();
|
||||
foreach (self::getMetaList() as $meta) {
|
||||
array_push($members, array(
|
||||
'name' => $meta['name'],
|
||||
'avatar_url' => $meta['avatar_url'],
|
||||
));
|
||||
}
|
||||
return $members;
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('robot@robot1.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user