diff --git a/doc/Bag.py b/doc/Bag.py index d99cc38b..2b4c24bf 100644 --- a/doc/Bag.py +++ b/doc/Bag.py @@ -26,7 +26,7 @@ class Bag(object): 'url': 'webapp/index.php?c=Bag&a=useItem', 'params': [ _common.ReqHead(), - ['item_id', 0, '道具id'], + ['item_uniid', 0, '道具唯一id'], ['item_num', 0, '道具数量'], ['param1', '', '参数1(当使用的是改名卡时param1=新的角色名)'], ['param2', '', '参数2(当使用的是改名卡时param2=签名)'], diff --git a/doc/Chip.py b/doc/Chip.py deleted file mode 100644 index 9afc63be..00000000 --- a/doc/Chip.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- - -import _common - -class Chip(object): - - def __init__(self): - self.apis = [ - { - 'name': 'chipList', - 'desc': '获取芯片列表', - 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=chipList', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ['!chip_list', [_common.Gun()], '芯片列表'] - ] - }, - ] diff --git a/doc/Gun.py b/doc/Gun.py index 05a2ff51..dffce062 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -59,4 +59,34 @@ class Gun(object): ['!gun_list', [_common.Gun()], '枪械列表'] ] }, + { + 'name': 'upgradeLevel', + 'desc': '升等级', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=upgradeLevel', + 'params': [ + _common.ReqHead(), + ['gun_uniid', 0, '枪械唯一id'], + ['cost_item_id', 0, '支付方式'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + }, + { + 'name': 'upgradeQuality', + 'desc': '升阶', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=upgradeQuality', + 'params': [ + _common.ReqHead(), + ['gun_uniid', 0, '枪械唯一id'], + ['cost_item_id', 0, '支付方式'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + }, ] diff --git a/doc/_common.py b/doc/_common.py index 25cfa1dd..e04b6ab6 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -155,8 +155,10 @@ class Item(object): def __init__(self): self.fields = [ + ['item_uniid', 0, '道具唯一id'], ['item_id', 0, '道具id'], ['item_num', 0, '道具数量'], + ['!attr', [Attr()], '属性'], ] class AwardItem(object): @@ -179,7 +181,7 @@ class PropertyChg(object): def __init__(self): self.fields = [ ['user_info', UserInfo(), '用户信息变更(用来更新本地客户端字段(有则更新无则不变))'], - ['!container_chg', [''], '容器类数据变更(bag、hero、heroSkin、gunSkin)'] + ['!container_chg', [''], '容器类数据变更(bag、hero、heroSkin、gunSkin, gun)'] ] class CostInfoItem(object): @@ -366,19 +368,3 @@ class TeamInfo(object): ['state', 0, '0:未开始 1:准备就绪(这时客户端进入长链接走组队逻辑)'], ['!member_list', [TeamMember()], '队伍成员列表(包含自己)'], ] - -class Chip(object): - - def __init__(self): - self.fields = [ - ['chip_uniid', 0, '芯片唯一id'], - ['chip_id', 0, '芯片id'], - ['state', 0, '0:已购买 1:体验中'], - ['gun_lv', 0, '枪等级'], - ['quality', 0, '品阶'], - ['!attr', [Attr()], '属性'], - ['try_count', 0, '剩余体验次数 当state=1时才有意义'], - ['lock_type', 0, '0:无锁 1:升级 2:升阶'], - ['lock_time', 0, '使用锁定时间(升级或者升阶触发),单位秒,锁定期间不可战斗和做其他操作'], - ['trade_locktime', 0, '出售锁定时间(升级或者升阶完成后触发),单位秒,只锁交易,其他的操作仍可进行'], - ] diff --git a/sql/gamedb.sql b/sql/gamedb.sql index cf29fae2..86acefb5 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -122,6 +122,7 @@ CREATE TABLE `t_bag` ( `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `item_num` int(11) NOT NULL DEFAULT '0' COMMENT '数量', + `rand_attr` mediumblob COMMENT '随机属性', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/mt/AttrHelper.php b/webapp/mt/AttrHelper.php index e0c90e93..58cee428 100644 --- a/webapp/mt/AttrHelper.php +++ b/webapp/mt/AttrHelper.php @@ -6,11 +6,17 @@ use phpcommon; class AttrHelper { - public static function parseAttr($attrStr) + public static function parseAttrCfg($attrStr) { $attrs = array(); $strs = explode('|', $attrStr); foreach ($strs as $str) { + $strs1 = explode('|', $attrStr); + array_push($attrs, + array( + 'attr_id' => $strs1[0], + 'type' => $strs1[1], + )); } return $attrs; } @@ -20,7 +26,23 @@ class AttrHelper { } - public static function canMerge($aAttr, $bAttr) + public static function canMergeCfg($aAttr, $bAttr) + { + foreach ($bAttr as $attr){ + if (!array_find($aAttr, function($val) use($attr) { + if ($val['attr_id'] == $attr['attr_id'] && + $val['type'] == $attr['type']) { + return true; + } + return false; + })) { + return false; + } + } + return true; + } + + public static function randAttr($attr, $outAttr) { } diff --git a/webapp/mt/HeroLevel.php b/webapp/mt/HeroLevel.php index e52935d4..cee33a91 100644 --- a/webapp/mt/HeroLevel.php +++ b/webapp/mt/HeroLevel.php @@ -21,11 +21,12 @@ class HeroLevel { public static function getRandAttr($initMeta, $nextMeta, $oldAttr, &$newAttr) { - $initAttr = mt\AttrHelper::parseAttr($initMeta['rand_attrs']); - $nextAttr = mt\AttrHelper::parseAttr($next['rand_attrs']); - if (!mt\AttrHelper::canMerge($initAttr, $nextAttr)) { + $initAttr = mt\AttrHelper::parseAttrCfg($initMeta['rand_attrs']); + $nextAttr = mt\AttrHelper::parseAttrCfg($next['rand_attrs']); + if (!mt\AttrHelper::canMergeCfg($initAttr, $nextAttr)) { return false; } + mt\AttrHelper::randAttr($newMeta, $newAttr); mt\AttrHelper::mergeAttr($oldAttr, $newAttr); return true; }