diff --git a/doc/Chip.py b/doc/Chip.py
index 06f14617..73582c88 100644
--- a/doc/Chip.py
+++ b/doc/Chip.py
@@ -18,20 +18,6 @@ class Chip(object):
_common.RspHead(),
['!data', [_common.Chip()], '芯片列表']
]
- },{
- 'name': 'chipOrder',
- 'desc': '芯片列表排序',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=chipOrder',
- 'params': [
- _common.ReqHead(),
- ['type', '', '芯片类型:1 英雄;2 枪械'],
- ['order', '', 'asc 升序;desc 降序'],
- ],
- 'response': [
- _common.RspHead(),
- ['!data', [_common.Chip()], '芯片列表']
- ]
},{
'name': 'chipDetails',
'desc': '芯片详情',
@@ -39,200 +25,39 @@ class Chip(object):
'url': 'webapp/index.php?c=Chip&a=chipDetails',
'params': [
_common.ReqHead(),
- ['token_id', '', '芯片token id'],
+ ['unique_id', '', 'unique_id'],
],
'response': [
_common.RspHead(),
['!data', [_common.Chip()], '芯片信息']
]
},{
- 'name': 'beforeInlay',
- 'desc': '芯片镶嵌前置,获取可镶嵌的芯片',
+ 'name': 'upgradeLevelPreview',
+ 'desc': '芯片升级前置操作',
'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=beforeInlay',
+ 'url': 'webapp/index.php?c=Chip&a=upgradeLevelPreview',
'params': [
_common.ReqHead(),
- ['type', '', '芯片类型:1 英雄;2 枪械'],
+ ['unique_id', '', 'unique_id'],
],
'response': [
_common.RspHead(),
- ['!data', [_common.Chip()], '芯片列表']
+ ['!data', [_common.ChipPro()], '芯片信息']
]
},{
- 'name': 'inlayChip',
- 'desc': '芯片镶嵌',
+ 'name': 'upgradeLevel',
+ 'desc': '芯片升级',
'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=inlayChip',
+ 'url': 'webapp/index.php?c=Chip&a=upgradeLevel',
'params': [
_common.ReqHead(),
- ['type', '', '1 英雄;2 枪械'],
- ['unique_id', '', '英雄或枪械的唯一id'],
- ['token_id', '', '芯片token id'],
- ],
- 'response': [
- _common.RspHead(),
- ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'],
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },{
- 'name': 'demountChip',
- 'desc': '芯片卸下',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=demountChip',
- 'params': [
- _common.ReqHead(),
- ['type', '', '1 英雄;2 枪械'],
- ['unique_id', '', '英雄或枪械的唯一id'],
- ['token_id', '', '芯片token id'],
- ],
- 'response': [
- _common.RspHead(),
- ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'],
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },{
- 'name': 'replaceChip',
- 'desc': '芯片替换',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=replaceChip',
- 'params': [
- _common.ReqHead(),
- ['type', '', '1 英雄;2 枪械'],
- ['unique_id', '', '英雄或枪械的唯一id'],
- ['token_id_new', '', '新芯片token id'],
- ['token_id_old', '', '被替换的芯片token id'],
- ],
- 'response': [
- _common.RspHead(),
- ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例'],
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },{
- 'name': 'aKeyInlayChip',
- 'desc': '芯片一键镶嵌',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=aKeyInlayChip',
- 'params': [
- _common.ReqHead(),
- ['type', '', '1 英雄;2 枪械'],
- ['unique_id', '', '英雄或枪械的唯一id'],
- ],
- 'response': [
- _common.RspHead(),
- ['!data', [_common.Hero()], '英雄或枪械加成信息,用英雄举例']
- ]
- },{
- 'name': 'beforeSynthetic',
- 'desc': '芯片合成前置操作',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=beforeSynthetic',
- 'params': [
- _common.ReqHead(),
- ['token_id', '', '新芯片token id'],
- ],
- 'response': [
- _common.RspHead(),
- ['!data', [_common.ChipPro()], '芯片信息']
- ]
- },{
- 'name': 'selectChip',
- 'desc': '选择合成材料',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=selectChip',
- 'params': [
- _common.ReqHead(),
- ['token_id', '', '芯片token id参数 例:参数1源芯片 参数2材料芯片'],
- ],
- 'response': [
- _common.RspHead(),
- ['data', '', '材料芯片的累计价值']
- ]
- },{
- 'name': 'syntheticChip',
- 'desc': '芯片合成',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=syntheticChip',
- 'params': [
- _common.ReqHead(),
- ['token_id_main', '', '源芯片token id'],
- ['token_id_param', '', '材料芯片token id 例:参数1 参数2 参数3'],
+ ['unique_id_main', '', '源芯片token id'],
+ ['unique_id_param', '', '材料芯片token id 例:参数1 参数2 参数3'],
],
'response': [
_common.RspHead(),
['!data', [_common.Chip()], '芯片信息'],
- ['state', 0, '1 成功,0 失败'],
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },{
- 'name': 'isNeedLucky',
- 'desc': '选择需要幸运值',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=isNeedLucky',
- 'params': [
- _common.ReqHead(),
- ['token_id', '', '源芯片token id'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },{
- 'name': 'isNotNeedLucky',
- 'desc': '放弃幸运值',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=isNotNeedLucky',
- 'params': [
- _common.ReqHead(),
- ['token_id', '', '源芯片token id'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },{
- 'name': 'waitingLucky',
- 'desc': '幸运值未做选择-待定阶段',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=waitingLucky',
- 'params': [
- _common.ReqHead(),
- ['token_id', '', '源芯片token id'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },{
- 'name': 'aKeySynthetic',
- 'desc': '芯片合成一键添加',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=aKeySynthetic',
- 'params': [
- _common.ReqHead(),
- ['token_id', '', '源芯片token id'],
- ],
- 'response': [
- _common.RspHead(),
- ['data', [
- ['cost', '', '所添加芯片的总累计价值'],
- ['token_ids', '', '芯片token id 例如:token_id1 token_id2 token_id3'],
- ], '芯片信息']
- ]
- },{
- 'name': 'lockChip',
- 'desc': '芯片加锁',
- 'group': 'Chip',
- 'url': 'webapp/index.php?c=Chip&a=lockChip',
- 'params': [
- _common.ReqHead(),
- ['token_id', '', '芯片token id'],
- ['state', '', '1 加锁 ;0 释放锁'],
- ],
- 'response': [
- _common.RspHead(),
['property_chg', _common.PropertyChg(), '属性变更'],
]
},
-
-
]
diff --git a/doc/ChipPage.py b/doc/ChipPage.py
new file mode 100644
index 00000000..6871c4e8
--- /dev/null
+++ b/doc/ChipPage.py
@@ -0,0 +1,101 @@
+# -*- coding: utf-8 -*-
+
+import _common
+
+class ChipPage(object):
+
+ def __init__(self):
+ self.apis = [
+ {
+ 'name': 'chipPageList',
+ 'desc': '铭文页列表',
+ 'group': 'ChipPage',
+ 'url': 'webapp/index.php?c=ChipPage&a=chipPageList',
+ 'params': [
+ _common.ReqHead(),
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['!data', [_common.ChipPageList()], '页列表']
+ ]
+ },{
+ 'name': 'showPageInfo',
+ 'desc': '铭文页信息',
+ 'group': 'ChipPage',
+ 'url': 'webapp/index.php?c=ChipPage&a=showPageInfo',
+ 'params': [
+ _common.ReqHead(),
+ ['page', '', '页id'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['!data', [_common.ChipPage()], '页信息']
+ ]
+ },{
+ 'name': 'addChipPage',
+ 'desc': '添加铭文页',
+ 'group': 'ChipPage',
+ 'url': 'webapp/index.php?c=ChipPage&a=addChipPage',
+ 'params': [
+ _common.ReqHead(),
+ ],
+ 'response': [
+ _common.RspHead(),
+ ]
+ },{
+ 'name': 'rename',
+ 'desc': '修改页名',
+ 'group': 'ChipPage',
+ 'url': 'webapp/index.php?c=ChipPage&a=rename',
+ 'params': [
+ _common.ReqHead(),
+ ['page', '', '页id'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['!data', [_common.ChipPage()], '页信息']
+ ]
+ },{
+ 'name': 'useChip',
+ 'desc': '使用芯片(镶嵌)',
+ 'group': 'ChipPage',
+ 'url': 'webapp/index.php?c=ChipPage&a=useChip',
+ 'params': [
+ _common.ReqHead(),
+ ['page', '', '页id'],
+ ['slot_id', '', '卡槽id'],
+ ['unique_id', '', '芯片idx'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['!data', [_common.ChipPage()], '页信息']
+ ]
+ },{
+ 'name': 'removeChipOne',
+ 'desc': '芯片移除',
+ 'group': 'ChipPage',
+ 'url': 'webapp/index.php?c=ChipPage&a=removeChipOne',
+ 'params': [
+ _common.ReqHead(),
+ ['page', '', '页id'],
+ ['slot_id', '', '卡槽id'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['!data', [_common.ChipPage()], '页信息']
+ ]
+ },{
+ 'name': 'removeChipAll',
+ 'desc': '芯片移除(一键移除)',
+ 'group': 'ChipPage',
+ 'url': 'webapp/index.php?c=ChipPage&a=removeChipAll',
+ 'params': [
+ _common.ReqHead(),
+ ['page', '', '页id'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['!data', [_common.ChipPage()], '页信息']
+ ]
+ },
+ ]
diff --git a/doc/Emoji.py b/doc/Emoji.py
new file mode 100644
index 00000000..e18caec1
--- /dev/null
+++ b/doc/Emoji.py
@@ -0,0 +1,45 @@
+import _common
+
+class Emoji(object):
+
+ def __init__(self):
+ self.apis = [
+ {
+ 'name': 'getEmojiList',
+ 'desc': '表情列表',
+ 'group': 'Emoji',
+ 'url': 'webapp/index.php?c=Emoji&a=getEmojiList',
+ 'params': [
+ _common.ReqHead(),
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['!data', [_common.Emoji()], '表情列表'],
+ ['use_emoji', [], '已选择的表情列表'],
+ ]
+ },{
+ 'name': 'setEmoji',
+ 'desc': '设置表情',
+ 'group': 'Emoji',
+ 'url': 'webapp/index.php?c=Emoji&a=setEmoji',
+ 'params': [
+ _common.ReqHead(),
+ ['item_id', '0', 'item_id'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ]
+ },{
+ 'name': 'cancel',
+ 'desc': '取消设置',
+ 'group': 'Emoji',
+ 'url': 'webapp/index.php?c=Emoji&a=cancel',
+ 'params': [
+ _common.ReqHead(),
+ ['item_id', '0', 'item_id'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ]
+ },
+ ]
\ No newline at end of file
diff --git a/doc/Gun.py b/doc/Gun.py
index 1bd057d5..68413646 100644
--- a/doc/Gun.py
+++ b/doc/Gun.py
@@ -59,21 +59,7 @@ 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'],
- ['slot_id', 0, '槽id(0-1)'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },
+
{
'name': 'upgradeLevelPreview',
'desc': '升等级',
@@ -87,87 +73,7 @@ class Gun(object):
_common.RspHead(),
['old_gun', _common.Gun(), '枪械-老'],
['new_gun', _common.Gun(), '枪械-新'],
- ['cost', _common.Cost(), '所需费用'],
- ]
- },
- {
- 'name': 'upgradeQualityOld',
- 'desc': '升阶',
- 'group': 'Gun',
- 'url': 'webapp/index.php?c=Gun&a=upgradeQualityOld',
- 'params': [
- _common.ReqHead(),
- ['gun_uniid', 0, '枪械唯一id'],
- ['cost_hero_uniid', 0, '耗材英雄唯一id'],
- ['slot_id', 0, '槽id(0-1)'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },
- {
- 'name': 'upgradeQuality',
- 'desc': '升阶',
- 'group': 'Gun',
- 'url': 'webapp/index.php?c=Gun&a=upgradeQuality',
- 'params': [
- _common.ReqHead(),
- ['trans_id', 0, 'transId'],
- ['token_id1', 0, '枪械token'],
- ['token_id2', 0, '耗材枪械token'],
- ],
- 'response': [
- _common.RspHead(),
- ]
- },
- {
- 'name': 'upgradeQualityPreview',
- 'desc': '升阶',
- 'group': 'Gun',
- 'url': 'webapp/index.php?c=Gun&a=upgradeQualityPreview',
- 'params': [
- _common.ReqHead(),
- ['gun_uniid', 0, '枪械唯一id'],
- ['cost_gun_uniid', 0, '耗材枪械唯一id'],
- ],
- 'response': [
- _common.RspHead(),
- ['old_gun', _common.Gun(), '枪械-老'],
- ['new_gun', _common.Gun(), '枪械-新'],
- ['cost', _common.Cost(), '所需费用'],
- ]
- },
- {
- 'name': 'receiveUpgradeQuality',
- 'desc': '获取升阶后的武器',
- 'group': 'Gun',
- 'url': 'webapp/index.php?c=Gun&a=receiveUpgradeQuality',
- 'params': [
- _common.ReqHead(),
- ['trans_id', 0, 'transId'],
- ['token_id', 0, '枪械token'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },
- {
- 'name': 'receive',
- 'desc': '获取升级、升阶后的武器',
- 'group': 'Gun',
- 'url': 'webapp/index.php?c=Gun&a=receive',
- 'params': [
- _common.ReqHead(),
- ['type', 0, '1:领取升级 2:领取升阶'],
- ['gun_uniid', 0, '枪械唯一id'],
- ],
- 'response': [
- _common.RspHead(),
- ['state', 0, '0:失败 1:成功'],
- ['old_hero', _common.Gun(), '枪械-老'],
- ['new_hero', _common.Gun(), '枪械-新'],
+ ['!cost', [_common.AwardItem()], '所需费用'],
]
},
{
@@ -185,16 +91,20 @@ class Gun(object):
]
},
{
- 'name': 'getUpgradeQualityList',
- 'desc': '获取升阶中的枪械列表',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=getUpgradeQualityList',
+ 'name': 'upgradeLv',
+ 'desc': '升等级',
+ 'group': 'Gun',
+ 'url': 'webapp/index.php?c=Gun&a=upgradeLv',
'params': [
_common.ReqHead(),
+ ['gun_uniid', 0, '枪械唯一id'],
+ ['cost_gun_uniid', 0, '材料武器id'],
],
'response': [
_common.RspHead(),
- ['!infos', [_common.QualityingGun()], '升阶中的枪械列表'],
+ ['property_chg', _common.PropertyChg(), '属性变更'],
+ ['old_gun', _common.Gun(), '枪械-老'],
+ ['new_gun', _common.Gun(), '枪械-新'],
]
},
]
diff --git a/doc/Hero.py b/doc/Hero.py
index 05d6cc02..3223aa2f 100644
--- a/doc/Hero.py
+++ b/doc/Hero.py
@@ -26,6 +26,7 @@ class Hero(object):
'url': 'webapp/index.php?c=Hero&a=skinList',
'params': [
_common.ReqHead(),
+ ['hero_id', 0, '英雄itemId'],
],
'response': [
_common.RspHead(),
@@ -46,37 +47,6 @@ class Hero(object):
_common.RspHead(),
]
},
- {
- 'name': 'upgradeSkill',
- 'desc': '升技能',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=upgradeSkill',
- 'params': [
- _common.ReqHead(),
- ['hero_uniid', 0, '英雄唯一id'],
- ['skill_uniid', 0, '技能唯一id'],
- ['skill_idx', 0, '技能idx 0:主动技能;1:被动技能'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },
- {
- 'name': 'upgradeLevel',
- 'desc': '升等级',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=upgradeLevel',
- 'params': [
- _common.ReqHead(),
- ['hero_uniid', 0, '英雄唯一id'],
- ['slot_id', 0, '槽id(0-1)'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },
{
'name': 'upgradeLevelPreview',
'desc': '升等级',
@@ -93,112 +63,6 @@ class Hero(object):
['cost', _common.Cost(), '所需费用'],
]
},
- {
- 'name': 'getUpgradeLevelList',
- 'desc': '获取升级中的英雄列表',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=getUpgradeLevelList',
- 'params': [
- _common.ReqHead(),
- ],
- 'response': [
- _common.RspHead(),
- ['!infos', [_common.LevelingHero()], '升级中的英雄列表'],
- ]
- },
- {
- 'name': 'upgradeQuality',
- 'desc': '升阶',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=upgradeQuality',
- 'params': [
- _common.ReqHead(),
- ['trans_id', 0, 'transId'],
- ['token_id1', 0, '英雄token'],
- ['token_id2', 0, '耗材英雄token'],
- ],
- 'response': [
- _common.RspHead(),
- ]
- },
- {
- 'name': 'receiveUpgradeQuality',
- 'desc': '领取升阶',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=receiveUpgradeQuality',
- 'params': [
- _common.ReqHead(),
- ['trans_id', 0, 'transId'],
- ['token_id', 0, '英雄token'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },
- {
- 'name': 'upgradeQualityOld',
- 'desc': '升阶',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=upgradeQualityOld',
- 'params': [
- _common.ReqHead(),
- ['hero_uniid', 0, '英雄唯一id'],
- ['slot_id', 0, '槽id(0-1)'],
- ['cost_hero_uniid', 0, '耗材英雄唯一id'],
- ],
- 'response': [
- _common.RspHead(),
- ['property_chg', _common.PropertyChg(), '属性变更'],
- ]
- },
- {
- 'name': 'upgradeQualityPreview',
- 'desc': '升阶',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=upgradeQualityPreview',
- 'params': [
- _common.ReqHead(),
- ['hero_uniid', 0, '英雄唯一id'],
- ['cost_hero_uniid', 0, '耗材英雄唯一id'],
- ],
- 'response': [
- _common.RspHead(),
- ['old_hero', _common.Hero(), '英雄-老'],
- ['new_hero', _common.Hero(), '英雄-新'],
- ['cost', _common.Cost(), '所需费用'],
- ]
- },
- {
- 'name': 'getUpgradeQualityList',
- 'desc': '获取升阶中的英雄列表',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=getUpgradeQualityList',
- 'params': [
- _common.ReqHead(),
- ],
- 'response': [
- _common.RspHead(),
- ['!infos', [_common.QualityingHero()], '升阶中的英雄列表'],
- ]
- },
- {
- 'name': 'receive',
- 'desc': '领取升级/升阶英雄',
- 'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=receive',
- 'params': [
- _common.ReqHead(),
- ['type', 0, '1:领取升级 2:领取升阶'],
- ['hero_uniid', 0, '英雄唯一id'],
- ],
- 'response': [
- _common.RspHead(),
- ['state', 0, '0:失败 1:成功'],
- ['old_hero', _common.Hero(), '英雄-老'],
- ['new_hero', _common.Hero(), '英雄-新'],
- ]
- },
{
'name': 'heroDetails',
'desc': '英雄详情',
@@ -214,18 +78,49 @@ class Hero(object):
]
},
{
- 'name': 'upgradeSkillCommon',
- 'desc': '通用技能升级',
+ 'name': 'upgradeLv',
+ 'desc': '升级',
'group': 'Hero',
- 'url': 'webapp/index.php?c=Hero&a=upgradeSkillCommon',
+ 'url': 'webapp/index.php?c=Hero&a=upgradeLv',
'params': [
_common.ReqHead(),
['hero_uniid', 0, '英雄唯一id'],
- ['skill_index', 0, '通用技能下标'],
+ ['cost_hero_uniid', 0, '材料英雄id(非必选参数--4|9|14等级必选)'],
],
'response': [
_common.RspHead(),
['property_chg', _common.PropertyChg(), '属性变更'],
+ ['old_hero', _common.Hero(), '英雄-老'],
+ ['new_hero', _common.Hero(), '英雄-新'],
+ ]
+ },{
+ 'name': 'presetHero',
+ 'desc': '英雄预设',
+ 'group': 'Hero',
+ 'url': 'webapp/index.php?c=Hero&a=presetHero',
+ 'params': [
+ _common.ReqHead(),
+ ['hero_uid', 0, '英雄唯一id'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['data', _common.HeroPreset(), '预设信息']
+ ]
+ },{
+ 'name': 'applyHero',
+ 'desc': '应用',
+ 'group': 'Hero',
+ 'url': 'webapp/index.php?c=Hero&a=applyHero',
+ 'params': [
+ _common.ReqHead(),
+ ['hero_uid', 0, '英雄唯一id'],
+ ['skill_id', 0, '技能itemId'],
+ ['weapon_uid1', 0, '武器1唯一id'],
+ ['weapon_uid2', 0, '武器2唯一id'],
+ ['chip_page', 0, '芯片页id'],
+ ],
+ 'response': [
+ _common.RspHead(),
]
},
diff --git a/doc/HeroSkill.py b/doc/HeroSkill.py
new file mode 100644
index 00000000..add8505b
--- /dev/null
+++ b/doc/HeroSkill.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+
+import _common
+
+class HeroSkill(object):
+
+ def __init__(self):
+ self.apis = [
+ {
+ 'name': 'getSkillList',
+ 'desc': '技能列表',
+ 'group': 'HeroSkill',
+ 'url': 'webapp/index.php?c=HeroSkill&a=getSkillList',
+ 'params': [
+ _common.ReqHead(),
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['data', [], '技能itemId']
+ ]
+ }
+ ]
diff --git a/doc/Market.py b/doc/Market.py
index 0747c547..c634f3d3 100644
--- a/doc/Market.py
+++ b/doc/Market.py
@@ -9,6 +9,7 @@ class NftIntro(object):
['idx', 0, 'idx'],
['token_id', '', 'token_id'],
['token_type', 0, 'nft类型 1:英雄 2:枪支 3:芯片'],
+ ['amount', 0, '堆叠数量'],
['createtime', 0, '创建时间(上架时间)'],
['modifytime', 0, '修改时间(更新价格等)'],
['s_price', 0, '出售价格-暂定'],
@@ -16,8 +17,32 @@ class NftIntro(object):
['c_job', 0, '缓存-职业'],
['c_lv', 0, '缓存-级别'],
['c_id', 0, '缓存-idx'],
+ ['selling', 0, '正在售卖的个数'],
+ ['o_link', '', '关联的售卖单号'],
['details', _common.NftDetail(), 'nft列表'],
]
+
+class CurrencyType(object):
+ def __init__(self):
+ self.fields = [
+ ['name', '', '货币名称'],
+ ['address', '', '货币地址'],
+ ]
+
+class TransactionRecord(object):
+ def __init__(self):
+ self.fields = [
+ ['idx', '', 'idx'],
+ ['createtime', 0, '交易成功时间'],
+ ['orderid', 0, 'market订单id'],
+ ['o_link', '', '合约订单id'],
+ ['seller', '', '卖家'],
+ ['buyer', '', '买家'],
+ ['tokenid', '', 'tokenid'],
+ ['amount', 0, '商品数量'],
+ ['name', '', '商品名称'],
+ ['type', 0, '商品类型'],
+ ]
class Market(object):
def __init__(self):
@@ -368,6 +393,7 @@ class Market(object):
['token', '', 'token'],
['nft_token', '', 'nft_token'],
['s_price', '', '出售价格USDT'],
+ ['amount', 0, '出售数量'],
['payment_token_address', '', 'payment_token_address'],
['nonce', '', 'nonce'],
['signature', '', '签名soliditySha3(type, payment_token_address, price, nonce), 签名的replace客户端做处理'],
@@ -395,4 +421,37 @@ class Market(object):
_common.RspHead()
]
},
+ {
+ 'name': 'getSupportedCurrencyTypes',
+ 'desc': '获取支持的货币类型',
+ 'group': 'Market',
+ 'url': 'webapp/index.php?c=Market&a=getSupportedCurrencyTypes',
+ 'params': [
+ ['account', '', '账号id'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['!list', [CurrencyType()], '货币类型列表'],
+ ]
+ },
+ {
+ 'name': 'getTransactionRecord',
+ 'desc': '获取交易记录',
+ 'group': 'Market',
+ 'url': 'webapp/index.php?c=Market&a=getTransactionRecord',
+ 'params': [
+ ['account', '', '账号id'],
+ ['type', 0, '物品类型 0:所有 1:英雄 2:武器 3:芯片 5:碎片'],
+ ['start', 0, '分页开始偏移'],
+ ['page_size', 0, '分页大小'],
+ ],
+ 'response': [
+ _common.RspHead(),
+ ['total', 0, '交易记录总数'],
+ ['start', 0, '有效的分页偏移'],
+ ['page_size', 0, '有效的分页大小'],
+ ['!list', [TransactionRecord()], '交易记录列表'],
+ ]
+ }
+
]
diff --git a/doc/User.py b/doc/User.py
index d257da97..ac77f4cc 100644
--- a/doc/User.py
+++ b/doc/User.py
@@ -77,6 +77,8 @@ class User(object):
['guild_id', 0, '跟新工会id(可选参数,不传就不更新)'],
['guild_job', 0, '跟新工会职位(可选参数,不传就不更新)'],
['guild_name', 0, '跟新工会名称(可选参数,不传就不更新)'],
+ ['parachute', 0, '跟新降落伞(可选参数,不传就不更新)'],
+ ['ring_id', 0, '跟新戒指(可选参数,不传就不更新)'],
],
'response': [
_common.RspHead(),
diff --git a/doc/_common.py b/doc/_common.py
index e38c0f55..8cdef054 100644
--- a/doc/_common.py
+++ b/doc/_common.py
@@ -78,15 +78,13 @@ class Gun(object):
['token_id', '', 'token id'],
['gun_uniid', 0, '枪唯一id'],
['gun_id', 0, '枪id'],
- ['state', 0, '0:已购买 1:体验中'],
+ ['state', 0, '0:已购买 1:免费(GIFT标签)'],
['gun_lv', 0, '枪等级'],
['quality', 0, '品阶'],
['durability', 0, '耐久'],
- ['durability_max', 0, '最大耐久'],
['ceg_uplimit', 0, 'ceg今天获取上限'],
['!attr_base', [Attr()], '枪械基础属性'],
['!attr_pro', [Attr()], '枪械升级升阶加成属性'],
- ['!attr_chip', [Attr()], '枪械芯片加成属性'],
['try_count', 0, '剩余体验次数 当state=1时才有意义'],
['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'],
['unlock_time', 0, '使用解锁utc时间(升级或者升阶触发),锁定期间不可战斗和做其他操作,配合lock_type使用'],
@@ -96,11 +94,8 @@ class Gun(object):
['current_pve_get_ceg', 0, '当前pve获取的ceg数量'],
['last_pvp_get_ceg_time', 0, '最后一次获取pvp获取ceg时间'],
['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'],
- ['chip_ids', '', '镶嵌的芯片主键id组'],
- ['!chip_core', [ChipCore()], '芯片核心加成'],
- ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'],
- ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'],
['offer_reward_state', 0, '是否悬赏中'],
+ ['tags', '', '1:Gen状态'],
]
class GunSkin(object):
@@ -149,6 +144,10 @@ class UserInfo(object):
['guild_id', '', '工会id'],
['guild_job', 0, '工会职位'],
['guild_name', '', '工会名称'],
+ ['parachute', '', '当前使用的降落伞id'],
+ ['!parachute_list', [0], '拥有的降落伞列表'],
+ ['ring_id', 0, '勋章(戒指)ID'],
+ ['!ring_list', [0], '勋章(戒指)列表'],
]
class UserSimple(object):
@@ -235,34 +234,24 @@ class Hero(object):
['hero_id', 0, '英雄id'],
['hero_lv', 0, '英雄等级'],
['hero_tili', 0, '英雄体力'],
- ['hero_tili_max', 0, '英雄最大体力'],
- ['state', 0, '0:已购买 1:体验中'],
+ ['state', 0, '0:已购买 1:免费(GIFT标签)'],
['skin_id', 0, '英雄皮肤id'],
['quality', 0, '品阶'],
['skill_lv1', 0, '主动技能等级'],
['skill_lv2', 0, '被动技能等级'],
['!attr_base', [Attr()], '英雄基础属性'],
['!attr_pro', [Attr()], '英雄升级升阶提升属性'],
- ['!attr_skill', [Attr()], '英雄技能提升属性'],
- ['!attr_chip', [Attr()], '英雄芯片提升属性'],
['try_count', 0, '剩余体验次数 当state=1时才有意义'],
['lock_type', 0, '0:无锁 1:升级 2:升阶 3:派遣中'],
['unlock_lefttime', 0, '解锁剩余时间(单位秒)'],
['unlock_time', 0, '使用解锁utc时间(升级或者升阶触发),锁定期间不可战斗和做其他操作,配合lock_type使用'],
- ['current_pvp_get_ceg', 0, '当前pvp获取的ceg数量'],
- ['current_pve_get_ceg', 0, '当前pve获取的ceg数量'],
- ['last_pvp_get_ceg_time', 0, '最后一次获取pvp获取ceg时间'],
- ['last_pve_get_ceg_time', 0, '最后一次获取pve获取ceg时间'],
+ ['current_get_gold', 0, '当前获取的gold数量'],
+ ['last_get_gold_time', 0, '最后一次获取gold时间'],
+ ['gold_uplimit', 0, '每天gold上限'],
['unlock_trade_time', 0, '出售解锁utc时间(升级或者升阶完成后触发),只锁交易,其他的操作仍可进行,和lock_type无关是独立的锁!!!'],
['advanced_count', 0, '进阶次数'],
- ['lukcy', 0, '幸运'],
- ['chip_ids', '', '镶嵌的芯片主键id组'],
- ['skill_points', '', '技能点'],
- ['!chip_core', [ChipCore()], '芯片核心加成'],
- ['!skill_common', [], '通用属性'],
- ['pvp_ceg_uplimit', 0, 'pvp获取的ceg的上限'],
- ['pve_ceg_uplimit', 0, 'pve获取的ceg的上限'],
['offer_reward_state', 0, '是否悬赏中'],
+ ['tags', '', '1:Gen状态'],
]
@@ -299,8 +288,8 @@ class HeroSkin(object):
def __init__(self):
self.fields = [
['skin_id', 0, '英雄皮肤id'],
- ['skin_state', 0, '英雄皮肤状态 0=已经购,1 = 试用状态'],
- ['try_expire_at', 0, '试用到期时间(utc时间)'],
+ ['is_have', 0, '是否拥有 1:拥有 0:未拥有'],
+ ['use_state', 0, '选中状态 1:选中 0:未选中'],
]
class Item(object):
@@ -782,23 +771,7 @@ class ChipAttr(object):
def __init__(self):
self.fields = [
['attr_id', 0, '属性id'],
- ['type', 0, '1: 绝对值 2:百分比 ---弃用字段'],
['val', 0, '综合属性值'],
- ['chip_type', 0, '1:英雄芯片 2:枪械芯片'],
- ['attr_num', 0, '成长属性值'],
- ['attr_pool_num', 0, '固定属性值'],
- ]
-
-class ChipCore(object):
-
- def __init__(self):
- self.fields = [
- ['chip_core_id', 0, '核心id'],
- ['chip_core_type', 0, '1:英雄芯片核心 2:枪械芯片核心'],
- ['chip_core_lv', 0, '核心等级'],
- ['attr_id', 0, '芯片属性id'],
- ['attr_number', 0, '属性加成'],
- ['attr_add_type', 0, '加成类型:1 绝对值;2 百分比 ---弃用字段'],
]
class Chip(object):
@@ -811,41 +784,31 @@ class Chip(object):
['item_id', 0, '道具id'],
['item_num', 0, '道具数量'],
['chip_grade', 0, '芯片等级'],
- ['chip_type', 0, '芯片类型:1 英雄;2 枪械'],
- ['state', 0, '芯片添加状态:0 正常;1 选择;-1 锁定'],
- ['supper_state', 0, '是否锁定:0 正常;1 锁住'],
- ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了'],
+ ['chip_type', 0, '芯片类型:1 攻击;2 防御;3 辅助'],
+ ['state', 0, '0:已购买 1:免费(GIFT标签)'],
+ ['supper_state', 0, '是否锁定:0 正常;1 锁住 ---弃用字段'],
+ ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'],
['!rand_attr', [ChipAttr()], '属性'],
- ['lucky_temporary', '', '升级成功后的幸运值'],
- ['lucky_final', '', '最终幸运值'],
- ['strength_max', '', '最大体力值'],
- ['strength', '', '前一天体力值'],
- ['strength_temporary', '', '升级成功所得出的总体力值'],
- ['mint', '', '所需mint费'],
- ['belong_to_item_id', '', '所镶嵌的英雄或枪械的item id'],
-
+ ['tags', '', '1:Gen状态'],
]
class ChipPro(object):
def __init__(self):
self.fields = [
- ['idx', 0, '主键id'],
+ ['idx', 0, '主键id'],
['token_id', '', 'token id'],
['account_id', '', '账号id'],
['item_id', 0, '道具id'],
['item_num', 0, '道具数量'],
['chip_grade', 0, '芯片等级'],
- ['chip_type', 0, '芯片类型:1 英雄;2 枪械'],
- ['state', 0, '芯片添加状态:0 正常;1 选择;-1 锁定'],
- ['supper_state', 0, '是否锁定:0 正常;1 锁住'],
- ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了'],
+ ['chip_type', 0, '芯片类型:1 攻击;2 防御;3 辅助'],
+ ['state', 0, '状态:0 免费;1 常规'],
+ ['supper_state', 0, '是否锁定:0 正常;1 锁住 ---弃用字段'],
+ ['inlay_state', 0, '镶嵌状态:0 未镶嵌;1 镶嵌了 ---弃用字段'],
['!rand_attr', [ChipAttr()], '属性'],
- ['lucky_temporary', '', '临时幸运值'],
- ['lucky_final', '', '最终幸运值'],
- ['strength', '', '体力值'],
['!rand_attr_after', [ChipAttr()], '芯片升级后的属性'],
- ['upgrade_cost', '', '芯片升级所需价值'],
+ ['cost',[],'升级所需gold消耗']
]
class BattleMember(object):
@@ -938,6 +901,7 @@ class BattleReward(object):
['weapon1', BattleCegReward(), '武器1奖励'],
['weapon2', BattleCegReward(), '武器2奖励'],
['!items', [BattleItemReward()], '碎片奖励'],
+ ['lvInfo', [['oldLv',0,'老等级'],['newLv',0,'新等级']], '等级信息'],
]
class BattleRankScore(object):
@@ -1012,4 +976,55 @@ class Currency(object):
['symbol', '', '符号'],
['precision', 0, '精度'],
['type', 0, '1:ERC721 2:ERC1155 3:ERC20'],
+ ]
+
+class Emoji(object):
+
+ def __init__(self):
+ self.fields = [
+ ['item_id', 0, 'item_id'],
+ ['state', 0, '1:使用 0:未使用'],
+ ]
+
+class ChipPageList(object):
+
+ def __init__(self):
+ self.fields = [
+ ['idx', 0, 'idx'],
+ ['account_id', 0, 'account_id'],
+ ['page_id', 0, '页id'],
+ ['page_name', '', '页名'],
+ ['createtime', 0, '创建时间'],
+ ]
+
+class ChipPage(object):
+
+ def __init__(self):
+ self.fields = [
+ ['idx', 0, 'idx'],
+ ['page_id', 0, '页id'],
+ ['page_name', '', '页名'],
+ ['!data', [ChipPageSlot()], '卡槽信息'],
+ ['!attr', [Attr()], '属性信息'],
+ ]
+
+class ChipPageSlot(object):
+
+ def __init__(self):
+ self.fields = [
+ ['slot_id', 0, '卡槽id'],
+ ['state', 0, '0:未解锁 1:已解锁'],
+ ['chip_id', '', '芯片idx'],
+ ]
+
+class HeroPreset(object):
+
+ def __init__(self):
+ self.fields = [
+ ['skill_id', 0, '技能item id'],
+ ['weapon_uid1', 0, '武器1唯一id'],
+ ['weapon_uid2', 0, '武器2唯一id'],
+ ['gun_id1', 0, '武器1 item id'],
+ ['gun_id2', 0, '武器2 item id'],
+ ['chip_page', 0, '芯片页id'],
]
\ No newline at end of file
diff --git a/sql/gamedb.sql b/sql/gamedb.sql
index fd809c41..9f657746 100644
--- a/sql/gamedb.sql
+++ b/sql/gamedb.sql
@@ -65,6 +65,8 @@ CREATE TABLE `t_user` (
`guild_id` varchar(60) NOT NULL DEFAULT '' COMMENT '工会id',
`guild_job` int(11) NOT NULL DEFAULT '0' COMMENT '工会职位',
`guild_name` varchar(255) NOT NULL DEFAULT '' COMMENT '工会名称',
+ `parachute` int(11) NOT NULL DEFAULT '0' COMMENT '降落伞ID',
+ `ring_id` int(11) NOT NULL DEFAULT '0' COMMENT '戒指id',
PRIMARY KEY (`idx`),
UNIQUE KEY `account_id` (`account_id`),
KEY `channel` (`channel`)
@@ -162,10 +164,6 @@ CREATE TABLE `t_hero` (
`last_mission_get_ceg_time` bigint NOT NULL DEFAULT '0' COMMENT '最后悬赏任务获取金币的时间',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
- `chip_ids` varchar(100) NOT NULL DEFAULT '' COMMENT '已镶嵌的芯片idx组',
- `skill_common` varchar(255) NOT NULL DEFAULT '100100|100120|100140|100160|100180|100200|100220|100240|100260|100280' COMMENT '通用技能',
- `skill_points` int(11) NOT NULL DEFAULT '0' COMMENT '技能点',
- `labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值',
`active_token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'active_token_id',
`active_count` int(11) NOT NULL DEFAULT '0' COMMENT 'active_count',
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1:已初始激活',
@@ -186,6 +184,7 @@ CREATE TABLE `t_hero_skin` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
`skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤id',
+ `hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄id',
`skin_state` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤状态 0=已经购,1 = 试用状态',
`get_from` int(11) NOT NULL DEFAULT '0' COMMENT '获得方式 0 = 系统赠送 1 = 金币购买',
`consume_num` int(11) NOT NULL DEFAULT '0' COMMENT '消耗货币的具体数量',
@@ -240,22 +239,13 @@ CREATE TABLE `t_chip` (
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
`item_num` int(11) NOT NULL DEFAULT '1' COMMENT '数量',
`chip_grade` int(11) NOT NULL DEFAULT '1' COMMENT '芯片等级',
- `chip_type` int(11) NOT NULL DEFAULT '1' COMMENT '1:角色芯片 2:武器芯片',
- `state` int(11) NOT NULL DEFAULT '0' COMMENT '芯片添加状态:0 正常;1 选择;-1 锁定',
- `supper_state` int(11) NOT NULL DEFAULT '0' COMMENT '是否锁定:0 正常;1 锁住',
- `inlay_state` int(11) NOT NULL DEFAULT '0' COMMENT '镶嵌状态:0 未镶嵌;1 镶嵌了',
+ `chip_type` int(11) NOT NULL DEFAULT '1' COMMENT '1 攻击;2 防御;3 辅助',
+ `state` int(11) NOT NULL DEFAULT '0' COMMENT '0:已购买 1:免费(GIFT标签)',
+ `inlay_state` varchar(60) COMMENT '所镶嵌的芯片页id:1|2|3',
`rand_attr` mediumblob COMMENT '随机属性',
- `today_get_gold` bigint NOT NULL DEFAULT '0' COMMENT '金币',
- `last_get_gold_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后获取金币的时间',
- `lucky_temporary` varchar(10) NOT NULL DEFAULT '0' COMMENT '临时幸运值',
- `lucky_final` varchar(10) NOT NULL DEFAULT '0' COMMENT '最终幸运值',
- `strength_max` varchar(10) NOT NULL DEFAULT '0' COMMENT '最大体力值',
- `strength` varchar(10) NOT NULL DEFAULT '0' COMMENT '前一天体力值',
- `upgrade_mint` double NOT NULL DEFAULT '0' COMMENT 'mint费用',
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1:已初始激活',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
- `labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值',
PRIMARY KEY (`idx`),
UNIQUE KEY `token_id` (`token_id`),
KEY `item_id` (`item_id`),
@@ -292,8 +282,6 @@ CREATE TABLE `t_gun` (
`last_mission_get_ceg_time` bigint NOT NULL DEFAULT '0' COMMENT '最后悬赏任务获取金币的时间',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
- `chip_ids` varchar(100) NOT NULL DEFAULT '' COMMENT '已镶嵌的芯片idx组',
- `labour` int(11) NOT NULL DEFAULT '0' COMMENT '劳力值',
`active_token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'active_token_id',
`active_count` int(11) NOT NULL DEFAULT '0' COMMENT 'active_count',
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1:已初始激活',
@@ -634,6 +622,25 @@ CREATE TABLE `t_fragment_pool` (
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
+--
+-- Table structure for table `t_fragment_record`
+--
+
+DROP TABLE IF EXISTS `t_fragment_record`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t_fragment_record` (
+ `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
+ `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
+ `param` int(11) NOT NULL DEFAULT '0' COMMENT 'param',
+ `value` int(11) NOT NULL DEFAULT '0' COMMENT '有效场次',
+ `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
+ `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
+ PRIMARY KEY (`idx`),
+ KEY `account_param` (`account_id`, `param`)
+) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
--
-- Table structure for table `t_realtime_data`
--
@@ -918,4 +925,81 @@ CREATE TABLE `t_user_currency` (
PRIMARY KEY (`idx`),
UNIQUE KEY `account_net_address` (`account_id`, `net_id`, `address`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+
+--
+-- Table structure for table `t_emoji`
+--
+
+DROP TABLE IF EXISTS `t_emoji`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t_emoji` (
+ `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
+ `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
+ `item_id` int(11) NOT NULL DEFAULT '0' COMMENT 'itemID',
+ `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
+ `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
+ PRIMARY KEY (`idx`),
+ UNIQUE KEY `account_item_id` (`account_id`, `item_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `t_user_use_emoji`
+--
+
+DROP TABLE IF EXISTS `t_user_use_emoji`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t_user_use_emoji` (
+ `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
+ `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
+ `value` varchar(255) NOT NULL DEFAULT '' COMMENT '选中表情itemID',
+ `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
+ `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
+ PRIMARY KEY (`idx`)
+) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `t_chip_page`
+--
+
+DROP TABLE IF EXISTS `t_chip_page`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t_chip_page` (
+ `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
+ `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
+ `page_name` varchar(50) NOT NULL DEFAULT '' COMMENT '页名',
+ `page_id` int(11) NOT NULL DEFAULT '0' COMMENT '页id',
+ `data` mediumblob COMMENT 'data',
+ `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
+ `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
+ PRIMARY KEY (`idx`),
+ UNIQUE KEY `account_page_id` (`account_id`, `page_id`)
+) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `t_hero_preset`
+--
+
+DROP TABLE IF EXISTS `t_hero_preset`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t_hero_preset` (
+ `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
+ `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
+ `hero_uid` int(11) NOT NULL DEFAULT 0 COMMENT 'hero uniid',
+ `skill_id` int(11) NOT NULL DEFAULT 0 COMMENT '技能 item_id',
+ `weapon_uid1` int(11) NOT NULL DEFAULT 0 COMMENT 'gun uniid1',
+ `weapon_uid2` int(11) NOT NULL DEFAULT 0 COMMENT 'gun uniid2',
+ `chip_page` int(11) NOT NULL DEFAULT 0 COMMENT '芯片页id',
+ `createtime` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
+ `modifytime` int(11) NOT NULL DEFAULT 0 COMMENT '修改时间',
+ PRIMARY KEY (`idx`)
+) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = @saved_cs_client */;
\ No newline at end of file
diff --git a/uml/market.drawio b/uml/market.drawio
new file mode 100644
index 00000000..e8009160
--- /dev/null
+++ b/uml/market.drawio
@@ -0,0 +1,149 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php
index 3bdbd521..26cf74e5 100644
--- a/webapp/bootstrap/constant.php
+++ b/webapp/bootstrap/constant.php
@@ -41,6 +41,8 @@ define('TN_DAILY_PVP_GET_FRAGMENT_NUM', 9009);
define('TN_DAILY_PVE_LAST_GET_FRAGMENT_BATTLE', 9010);
define('TN_DAILY_RANK_BATTLE_TIMES', 9011);
define('TN_DAILY_END', 9011);
+define('TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM', 9012);
+define('TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM', 9013);
define('TN_WEEKLY_BEGIN', 10001);
define('TN_WEEKLY_ACTIVE', 10002);
@@ -95,3 +97,4 @@ const kWantedLockType = 3;
const kMaxHeroUpLevelNum = 2;
const kMaxHeroUpQualityNum = 2;
+const kMaxEmojiNum = 6;
diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php
index 69dfe18e..76d206c5 100644
--- a/webapp/controller/BaseAuthedController.class.php
+++ b/webapp/controller/BaseAuthedController.class.php
@@ -12,6 +12,7 @@ require_once('models/User.php');
require_once('models/Nft.php');
require_once('models/UserSeasonRing.php');
require_once('models/Parachute.php');
+require_once('models/Chip.php');
require_once('mt/Parameter.php');
require_once('mt/RankSeason.php');
@@ -26,6 +27,7 @@ use models\User;
use models\Nft;
use models\Parachute;
use models\UserSeasonRing;
+use models\Chip;
class BaseAuthedController extends BaseController {
@@ -252,6 +254,15 @@ class BaseAuthedController extends BaseController {
));
}
break;
+ case V_ITEM_EXP:
+ {
+ $this->_updateUserInfo(array(
+ 'exp' => function () use($itemNum) {
+ return "exp + ${itemNum}";
+ }
+ ));
+ }
+ break;
case V_ITEM_ACTIVE:
{
return;
@@ -375,6 +386,12 @@ class BaseAuthedController extends BaseController {
$propertyService->addUserChg();
}
break;
+ case mt\Item::CHIP_TYPE:
+ {
+ Chip::addChip($itemMeta);
+ $propertyService->addChip();
+ }
+ break;
default:
{
$this->_addLog('additems', 'invalid_item', array(
diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php
index bd4ba3ec..ea38c468 100644
--- a/webapp/controller/BattleController.class.php
+++ b/webapp/controller/BattleController.class.php
@@ -1,23 +1,29 @@
$member['account_id'],
'session_id' => $member['session_id'],
@@ -140,6 +147,7 @@ class BattleController extends BaseAuthedController {
'hero_dto' => '',
'weapon_dto1' => '',
'weapon_dto2' => '',
+ 'level' =>$user['level'],
'is_valid_battle' => 0,
'payload' => json_encode($member['cmjoin']),
@@ -156,6 +164,12 @@ class BattleController extends BaseAuthedController {
if ($heroDb) {
$info['is_valid_battle'] = 1;
$info['hero_dto'] = Hero::toDto($heroDb);
+ {//选用皮肤id
+ $skinDb = HeroSkin::findBx($heroDb['hero_id']);
+ if ($skinDb){
+ $info['hero_dto']['skin_id'] = $skinDb['skin_id'];
+ }
+ }
} else {
$info['errcode'] = 51;
$info['errmsg'] = 'paramater error';
@@ -186,6 +200,7 @@ class BattleController extends BaseAuthedController {
);
$currSeason = mt\RankSeason::getCurrentSeason();
foreach ($members as $member) {
+ $userDb = User::find($member['account_id']);
$info = array(
'account_id' => $member['account_id'],
'session_id' => $member['session_id'],
@@ -193,6 +208,7 @@ class BattleController extends BaseAuthedController {
'weapon_uuid1' => $member['weapon_uuid1'],
'weapon_uuid2' => $member['weapon_uuid2'],
'battle_uuid' => $member['battle_uuid'],
+ 'parachute' => $userDb['parachute']?$userDb['parachute']:Parachute::$parachute,
'hero_dto' => '',
'weapon_dto1' => '',
'weapon_dto2' => '',
diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php
index cf39f53e..25cbfcc0 100644
--- a/webapp/controller/CallbackController.class.php
+++ b/webapp/controller/CallbackController.class.php
@@ -335,7 +335,7 @@ class CallbackController extends BaseController {
myself()->_rspOk();
}
- public function chipUpgradeGrade(){
+ public function chipUpgradeGrade(){return;
$transId = getReqVal('trans_id', '0');
$tokenId = getReqVal('token_id', '0');
if (!$transId || !$tokenId){
diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php
index ab05a5fa..feef0d66 100644
--- a/webapp/controller/ChipController.class.php
+++ b/webapp/controller/ChipController.class.php
@@ -14,6 +14,7 @@ require_once('services/LogService.php');
+
use models\Chip;
use models\Hero;
use models\Gun;
@@ -26,838 +27,198 @@ class ChipController extends BaseAuthedController
{
public function chipList()
{
-// $type = getReqVal('type','');
-// if (! $type){
-// $this->_rspErr(1,'Please enter instructions');
-// return ;
-// }
-// $chipList = Chip::all($type);
-// $chipDtoList = array();
-// foreach ($chipList as $item) {
-// array_push($chipDtoList, Chip::toDto($item));
-// }
$chipList = array();
Chip::getChipList(function ($row) use(&$chipList){
- array_push($chipList, Chip::toDto($row));
+// if ($row['inlay_state'] != 1){
+ array_push($chipList, Chip::toDto($row));
+// }
});
$this->_rspData(array(
'data' => $chipList,
));
}
- public function chipOrder(){
- $type = getReqVal('type','');
- if (! $type){
- $this->_rspErr(1,'Please enter instructions');
- return ;
- }
- $order = getReqVal('order','asc');
- $chipList = Chip::all($type);
- $chipDtoList = array();
- foreach ($chipList as $item) {
- array_push($chipDtoList, Chip::toDto($item));
- }
- $data = $this->_orderByChip($chipDtoList,$order);
- $this->_rspData(array(
- 'data' => $data,
- ));
- }
-
public function chipDetails(){
- $token_id = getReqVal('token_id','');
- if (! $token_id){
- $this->_rspErr(1,'Please enter instructions');
+ $unique_id = trim(getReqVal('unique_id', 0));
+ if (! $unique_id){
+ $this->_rspErr(1, 'Please enter parameter unique_id');
return ;
}
- $chip = Chip::getChipByTokenId($token_id);
- if ($chip['supper_state'] == 1){
- $chip['strength_temporary'] = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$chip['lucky_temporary']);
- $chip['mint'] = strval(\services\FormulaService::Chip_Need_Mint_Cost($chip['chip_grade'])-$chip['upgrade_mint']);
+ $chipDb = Chip::find($unique_id);
+ if (! $chipDb){
+ $this->_rspErr(1, "You don't have the chip yet");
+ return;
}
-// if ($chip['inlay_state'] == 1){
- $tili = $chip['strength_max']-$chip['strength'];
- $chip['mint'] = \services\FormulaService::Chip_Demount_Mint($tili);
-// }
- $chip = Chip::toDto($chip);
+ $chip = Chip::toDto($chipDb);
$this->_rspData(array(
'data' => $chip,
));
}
- public function beforeInlay(){
- $type = getReqVal('type','');
- if (! $type){
- $this->_rspErr(1,'Please enter instructions');
- return ;
+ public function upgradeLevelPreview(){
+ $unique_id = trim(getReqVal('unique_id', 0));
+ if (! $unique_id) {
+ $this->_rspErr(1, 'Please enter parameter unique_id');
+ return;
}
- $chipList = Chip::all($type);
- $chipDtoList = array();
- foreach ($chipList as $item) {
- if ($item['supper_state']==0 && $item['inlay_state']==0){
- array_push($chipDtoList, Chip::toDto($item));
+ $chipDb = Chip::find($unique_id);
+ if (!$chipDb){
+ $this->_rspErr(1,'unique_id parameter error');
+ return;
+ }
+ if ($chipDb['chip_grade'] == Chip::CHIP_LV_MAX){
+ $this->_rspErr(1,' Level upper limit');
+ return;
+ }
+ $chip = Chip::toDto($chipDb);
+ $rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array());
+ $chipMeta = mt\ChipAttr::getAttrByItemId($chipDb['item_id']);
+ if ($chipMeta){
+ array_unshift($rand_attr,array(
+ 'attr_id'=>$chipMeta['attr_id'],
+ 'val' => $chipMeta['lv'.($chipDb['chip_grade']+1)]
+ ));
+ }
+ $chip['rand_attr_after'] = $rand_attr;
+ $paramMeta = mt\Parameter::getByName('chip_upgrade_cost');
+ $gold = 0;
+ if ($paramMeta){
+ $paramValue = explode('|',$paramMeta['param_value']);
+ switch ($chipDb['chip_grade']){
+ case 1: {
+ $gold = $paramValue[0];
+ };break;
+ case 2: {
+ $gold = $paramValue[1];
+ };break;
}
}
+ $chip['cost'] = array(
+ 'item_id' => V_ITEM_GOLD,
+ 'item_num' => $gold
+ );
$this->_rspData(array(
- 'data' => $chipDtoList,
+ 'data' => $chip
));
}
- public function inlayChip(){
- $type = trim(getReqVal('type', 0));
- $unique_id = trim(getReqVal('unique_id', 0));
- $token_id = trim(getReqVal('token_id', 0));
- if (!$type || ! $token_id || ! $unique_id) {
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addChip();
- if ($type == 1){
- if (! $this->_doInlayHero($unique_id,$token_id)){
- return;
- }
- $hero = Hero::toDto(Hero::find($unique_id));
- $propertyChgService->addHeroChg();
- $this->_rspData([
- 'data'=>$hero,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }else{
- if (! $this->_doInlayGun($unique_id,$token_id)){
- return;
- }
- $gun = Gun::toDto(Gun::find($unique_id));
- $propertyChgService->addGunChg();
- $this->_rspData([
- 'data'=>$gun,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }
-
- }
-
- public function demountChip(){
- $type = trim(getReqVal('type', 0));
- $unique_id = trim(getReqVal('unique_id', 0));
- $token_id = trim(getReqVal('token_id', 0));
- if (!$type || ! $token_id || ! $unique_id) {
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addChip();
- if ($type == 1){
- if (!$this->_doDemount($unique_id,$token_id)){
- return;
- }
- $hero = Hero::toDto(Hero::find($unique_id));
- $propertyChgService->addHeroChg();
- $this->_rspData([
- 'data'=>$hero,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }else{
- if (! $this->_doDemountGun($unique_id,$token_id)){
- return;
- }
- $gun = Gun::toDto(Gun::find($unique_id));
- $propertyChgService->addGunChg();
- $this->_rspData([
- 'data'=>$gun,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }
-
- }
-
- public function replaceChip(){
- $type = trim(getReqVal('type', 0));
- $unique_id = trim(getReqVal('unique_id', 0));
- $token_id_new = trim(getReqVal('token_id_new', 0));
- $token_id_old = trim(getReqVal('token_id_old', 0));
- if (! $token_id_new ||! $token_id_old || ! $unique_id || !$type) {
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addChip();
- if ($type == 1){
- if (! $this->_doDemount($unique_id,$token_id_old)){
- return;
- }
- if (! $this->_doInlayHero($unique_id,$token_id_new)){
- return;
- }
- $hero = Hero::toDto(Hero::find($unique_id));
- $propertyChgService->addHeroChg();
- $this->_rspData([
- 'data'=>$hero,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }else{
- if (! $this->_doDemountGun($unique_id,$token_id_old)){
- return;
- }
- if (! $this->_doInlayGun($unique_id,$token_id_new)){
- return;
- }
- $gun = Gun::toDto(Gun::find($unique_id));
- $propertyChgService->addGunChg();
- $this->_rspData([
- 'data'=>$gun,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }
-
- }
-
- public function aKeyInlayChip(){
- $type = trim(getReqVal('type', 0));
- $unique_id = trim(getReqVal('unique_id', 0));
- if ( ! $type || ! $unique_id) {
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- if ($type == 1){
- $hero_or_gun = Hero::find($unique_id);
- }else{
- $hero_or_gun = Gun::find($unique_id);
- }
-
- if (! $hero_or_gun){
- $this->_rspErr(1, 'Not enough hero or gun');
- return;
- }
- $limit = 0;
- if (! $hero_or_gun['chip_ids'] ){
- $limit = 4;
- }
- if ($hero_or_gun['chip_ids'] && !strpos($hero_or_gun['chip_ids'], '|')){
- $limit = 3;
- }
- if ($hero_or_gun['chip_ids'] && strpos($hero_or_gun['chip_ids'], '|')){
- $chipIdsArr = explode('|',$hero_or_gun['chip_ids']);
- $limit = 4-count($chipIdsArr);
- }
-
- $chipList = Chip::all($type);
- if (! $chipList){
- $this->_rspErr(1, 'Not enough chip');
- return;
- }
- $usable = array();
- foreach ($chipList as $item) {
- if ($item['supper_state']==0 && $item['inlay_state']==0){
- array_push($usable, $item);
- }
- }
-
- $res = $this->_getHignGradeLimit($usable,$limit);
- if (! $res){
- $this->_rspErr(1, 'The chip slot is full');
- return;
- }
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addChip();
- if ($type == 1){
- foreach ($res as $val){
- $this->_doInlayHero($unique_id,$val['token_id']);
- }
- $hero_new = Hero::toDto(Hero::find($unique_id));
- $propertyChgService->addHeroChg();
- $this->_rspData([
- 'data'=>$hero_new,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }else{
- foreach ($res as $val){
- $this->_doInlayGun($unique_id,$val['token_id']);
- }
- $gun_new = Gun::toDto(Gun::find($unique_id));
- $propertyChgService->addGunChg();
- $this->_rspData([
- 'data'=>$gun_new,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }
- }
-
- public function beforeSynthetic(){
- $token_id = trim(getReqVal('token_id', 0));
- if (! $token_id) {
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- $chip = Chip::getChipByTokenId($token_id);
- if ($chip['supper_state'] == 1 || $chip['inlay_state'] == 1 || $chip['state'] == -1){
- $this->_rspErr(1, "The chip can't synthetic");
- return;
- }
- if ($chip['chip_grade'] == 15){
- $this->_rspErr(1, "Chip Lv upper limit");
- return;
- }
- $chip = Chip::toDto($chip);
- foreach ($chip['rand_attr'] as $k=>$val){
- $attr = \mt\ChipAttr::getAttrById($val['attr_id'],$val['chip_type']);
- $chip['rand_attr_after'][$k] =[
- 'attr_id'=>$val['attr_id'],
- 'type'=>$val['type'],
- 'val'=>$attr['lv'.($chip['chip_grade']+1)]*$val['attr_pool_num'],
- 'chip_type'=>$val['chip_type']
- ];
- }
- $chip['upgrade_cost']=\services\FormulaService::getChipUpgradeCost($chip['chip_grade']+1);
- $this->_rspData(['data'=>$chip]);
- }
-
public function selectChip(){
- $token_id = trim(getReqVal('token_id', 0));
- $token_ids = explode(' ',$token_id);
- if (count($token_ids)<0){
+ $unique_id = trim(getReqVal('unique_id', 0));
+ $idxArr = explode(' ',$unique_id);
+ if (count($idxArr)<0){
$this->_rspErr(1, 'Please enter instructions');
return;
}
- $chip_main = Chip::getChipByTokenId($token_ids[0]);
- $chip_param = Chip::getChipByTokenId($token_ids[1]);
- if ($chip_param['supper_state'] == 1 || $chip_param['inlay_state'] == 1 || $chip_param['state'] == -1){
- $this->_rspErr(1, "The chip can't select");
+ $chipDbMain = Chip::find($idxArr[0]);
+ $chipDbParam = Chip::find($idxArr[1]);
+ if (!$chipDbMain || !$chipDbParam){
+ $this->_rspErr(1,'unique_id parameter error');
return;
}
- if ($chip_param['chip_grade']>$chip_main['chip_grade']){
+ if ($chipDbParam['token_id']) {
+ $this->_rspErr(1, "Unable to use nft chip");
+ return;
+ }
+ if (!$chipDbParam['state']) {
+ $this->_rspErr(1, "Unable to use free chip");
+ return;
+ }
+ if ($chipDbParam['chip_grade']>$chipDbMain['chip_grade']){
$this->_rspErr(1, "The selected material is too high grade");
return;
}
- $cost = \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']);
- $this->_rspData(['data'=>$cost]);
+ $cost = \services\FormulaService::getChipCumulativeCost($chipDbParam['chip_grade']);
+ $this->_rspData(['cost'=>$cost]);
}
- public function syntheticChip(){
- $this->_rspOk();return;
- $token_id_main = trim(getReqVal('token_id_main', 0));
- $token_id_param = array_filter(explode(' ',getReqVal('token_id_param', 0)));
- if (! $token_id_main || count($token_id_param)<=0 ) {
- $this->_rspErr(1, 'Please enter instructions token_id_param');
+ public function upgradeLevel(){
+ $idxMain = trim(getReqVal('unique_id_main', 0));
+ $idxParam = trim(getReqVal('unique_id_param', 0));
+ if (!$idxMain || !$idxParam) {
+ $this->_rspErr(1, 'Please enter parameter');
return;
}
- $chip_main = Chip::getChipByTokenId($token_id_main);
- $upgrade_cost = \services\FormulaService::getChipUpgradeCost($chip_main['chip_grade']+1);
- if ($upgrade_cost==0){
- $this->_rspErr(1, 'Error in calculation formula');
+ $chipDbMain = Chip::find($idxMain);
+ if (!$chipDbMain){
+ $this->_rspErr(1,'unique_id_main parameter error');
return;
}
- $cumulative_cost = 0;
- $params = array();
- foreach ($token_id_param as $val){
- $chip_param = Chip::getChipByTokenId($val);
- array_push($params,array(
- 'unique_id'=>$chip_param['idx'],
- 'token_id'=>$chip_param['token_id'],
- ));
- $cumulative_cost += \services\FormulaService::getChipCumulativeCost($chip_param['chip_grade']);
-// Chip::deleteChip(['token_id'=>$val]);
+ if ($chipDbMain['chip_grade'] == Chip::CHIP_LV_MAX){
+ $this->_rspErr(1,' Level upper limit');
+ return;
}
- {
- //埋点
- $event = [
- 'name' => LogService::CHIP_SYNTH_MATERIAL,
- ];
- LogService::ConsumableMaterial($event,$params);
+ $chipDbParam = Chip::find($idxParam);
+ if (!$chipDbParam){
+ $this->_rspErr(1,"unique_id_param parameter error");
+ return;
}
- $num = round(round(($cumulative_cost/$upgrade_cost),5)*10000);
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addChip();
- if ($num_rspData([
- 'state' => 0,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }else{
- //合成成功
- $this->_upgraded($chip_main);
- $chip_new = Chip::toDto(Chip::getChipByTokenId($token_id_main));
- $chip_new['strength_temporary'] = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip_new['chip_grade'],$chip_new['lucky_temporary']);
- $chip_new['mint'] = \services\FormulaService::Chip_Need_Mint_Cost($chip_new['chip_grade'])-$chip_new['upgrade_mint'];
- $this->_rspData([
- 'data'=>$chip_new,
- 'state' => 1,
- 'property_chg' => $propertyChgService->toDto(),
- ]);
+ if ($chipDbParam['token_id']) {
+ $this->_rspErr(1, "Unable to use nft chip");
+ return;
+ }
+ if ($chipDbParam['state'] == Chip::FREE_STATE) {
+ $this->_rspErr(1, "Unable to use free chip");
+ return;
+ }
+ if (count(array_filter(explode("|",$chipDbParam['inlay_state']))) > 0){
+ $this->_rspErr(1, "The used chip");
+ return;
+ }
+ if ($chipDbParam['chip_grade'] != $chipDbMain['chip_grade']){
+ $this->_rspErr(1, "Material chip grade does not meet");
+ return;
+ }
+ $paramMeta = mt\Parameter::getByName('chip_upgrade_cost');
+ $gold = 0;
+ if ($paramMeta){
+ $paramValue = explode('|',$paramMeta['param_value']);
+ switch ($chipDbMain['chip_grade']){
+ case 1: {
+ $gold = $paramValue[0];
+ };break;
+ case 2: {
+ $gold = $paramValue[1];
+ };break;
+ }
+ }
+ $costItems = array(
+ array(
+ 'item_id' => V_ITEM_GOLD,
+ 'item_num' => $gold
+ ),
+ );
+ $lackItem = null;
+ if (!$this->_hasEnoughItems($costItems, $lackItem)) {
+ $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
+ return;
}
- }
- public function isNeedLucky(){
- $token_id = trim(getReqVal('token_id', 0));
- if (! $token_id) {
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- $chip = Chip::getChipByTokenId($token_id);
- $strength_max = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$chip['lucky_temporary']);
- $mint_cost = \services\FormulaService::Chip_Need_Mint_Cost($chip['chip_grade'])-$chip['upgrade_mint'];
- $fieldsKv = [
- 'supper_state' => 0,
- 'lucky_final'=>$chip['lucky_temporary'],
- 'lucky_temporary'=>0,
- 'strength_max' => $strength_max,
- 'strength' => $strength_max,
- 'upgrade_mint' => $mint_cost,
- 'labour' => 0
- ];
- $userObj = new User();
- $user=$userObj->find(myself()->_getAccountId());
- if ($mint_cost>$user['gold']){
- $this->_rspErr(2, 'Be short of gold coins');
- return;
- }
- User::update(['gold'=>$user['gold']-$mint_cost]);
- Chip::update($chip['token_id'],$fieldsKv);
- $old_chip = Chip::toDto($chip);
- $new_chip = Chip::toDto(Chip::getChipByTokenId($token_id));
- {
- //埋点
- $event = [
- 'name' => LogService::CHIP_LUCKY,
- 'val' => $mint_cost
- ];
- $old_chip['level'] = $old_chip['chip_grade'];
- $new_chip['level'] = $new_chip['chip_grade'];
- LogService::consumeCEG($event,$old_chip,$new_chip);
- }
+ $this->_decItems($costItems);
+ Chip::update2($idxParam,
+ array(
+ 'account_id' => myself()->_getAccountId() . '!!!',
+ )
+ );
$propertyChgService = new services\PropertyChgService();
- $propertyChgService->addUserChg();
$propertyChgService->addChip();
- $this->_rspData(array(
- 'property_chg' => $propertyChgService->toDto(),
+ $rand_attr = emptyReplace(json_decode($chipDbMain['rand_attr'], true), array());
+ $attrProMeta = \mt\ChipAttr::getAttrPool($chipDbMain);
+ array_push($rand_attr,array(
+ 'attr_id'=>$attrProMeta['attr_id'],
+ 'val'=>$attrProMeta['val'],
));
- }
-
- public function isNotNeedLucky(){
- $token_id = trim(getReqVal('token_id', 0));
- if (! $token_id) {
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- $chip = Chip::getChipByTokenId($token_id);
- $fieldsKv = [
- 'supper_state' => 0,
- 'lucky_temporary'=>0,
- ];
- Chip::update($chip['token_id'],$fieldsKv);
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addChip();
- $this->_rspData(array(
- 'property_chg' => $propertyChgService->toDto(),
- ));
- }
-
- public function waitingLucky(){
- $token_id = trim(getReqVal('token_id', 0));
- if (! $token_id) {
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- $chip = Chip::getChipByTokenId($token_id);
- $fieldsKv = [
- 'supper_state'=>1,
- ];
- Chip::update($chip['token_id'],$fieldsKv);
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addChip();
+ Chip::update2($idxMain,
+ array(
+ 'chip_grade' => $chipDbMain['chip_grade']+1,
+ 'state' => Chip::GETED_STATE,
+ 'rand_attr' => json_encode($rand_attr),
+ )
+ );
+ $chipDbNew = Chip::toDto(Chip::find($idxMain));
$this->_rspData([
+ 'data'=>$chipDbNew,
'property_chg' => $propertyChgService->toDto(),
]);
}
- public function aKeySynthetic(){
- $token_id = trim(getReqVal('token_id', 0));
- if (! $token_id) {
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- $chip = Chip::getChipByTokenId($token_id);
- $upgrade_cost =\services\FormulaService::getChipUpgradeCost($chip['chip_grade']+1); //芯片升星价值
-
- $chipList = Chip::all($chip['chip_type']);
- $chipDtoList = array();
- foreach ($chipList as $item) {
- if ($item['supper_state']==0 && $item['inlay_state']==0 && $item['state']!=-1 && $item['token_id'] != $token_id && $item['chip_grade'] <= $chip['chip_grade']){
- array_push($chipDtoList, $item);
- }
- };
- $data = $this->_orderByChip($chipDtoList,'asc');
- $chip_param = [];
- $chip_param_out = [];
- if (count($data) > 20) {
- $cost = 0;
- for ($i=0;$i$upgrade_cost){
- $diff_cost = $cost - $upgrade_cost;
- foreach ($chip_param as $k=>$value){
- if ($diff_cost>$value['cost']){
- $diff_cost -= $value['cost'];
- unset($chip_param[$k]);
- }
- }
- }else{
- $chip_param = $this->_bestFun($upgrade_cost,$chip_param,$chip_param_out);
- }
-
- }else{
- $cost = 0;
- foreach ($data as $k=>$val){
- $data[$k]['cost'] = \services\FormulaService::getChipCumulativeCost($data[$k]['chip_grade']);
- $cost += $data[$k]['cost'];
- }
- if ($cost > $upgrade_cost){
- $diff_cost = $cost - $upgrade_cost;
- foreach ($data as $k=>$value){
- if ($diff_cost>$value['cost']){
- $diff_cost -= $value['cost'];
- unset($data[$k]);
- }
- }
- }
- $chip_param = $data;
- }
- $cumulative_cost = [];
- $token_id_arr = [];
- foreach ($chip_param as $value){
- array_push($cumulative_cost,$value['cost']);
- array_push($token_id_arr,$value['token_id']);
- }
- $this->_rspData(['data'=>['cost'=>$cumulative_cost,'token_ids'=>$token_id_arr]]);
- }
-
- public function lockChip(){
- $token_id = trim(getReqVal('token_id', 0));
- $state = trim(getReqVal('state', 0));
- if (! $token_id){
- $this->_rspErr(1, 'Please enter instructions');
- return;
- }
- if ($state == 1){
- Chip::update($token_id,['state'=>-1]);
- }else{
- Chip::update($token_id,['state'=>0]);
- }
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addChip();
- $this->_rspData([
- 'property_chg' => $propertyChgService->toDto(),
- ]);
- }
-
- private function _doInlayHero($hero_id,$token_id){
- $chip = Chip::getChipByTokenId($token_id);
- $hero = Hero::find($hero_id);
- if (! $chip || ! $hero){
- $this->_rspErr(1, 'Not enough chip or hero');
- return false;
- }
- if (! $hero['chip_ids']){
- $fieldsKv = ['chip_ids'=>$chip['idx']];
- }
- if ($hero['chip_ids'] && !strpos($hero['chip_ids'], '|')){
- $chipIdsArr = [$hero['chip_ids']];
- array_push($chipIdsArr,$chip['idx']);
- $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
- }
- if ($hero['chip_ids'] && strpos($hero['chip_ids'], '|')){
- $chipIdsArr = explode('|',$hero['chip_ids']);
- array_push($chipIdsArr,$chip['idx']);
- $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
- }
- Hero::update($hero_id,$fieldsKv);
- Chip::updateChipInlayState($token_id,1);
- return true;
- }
-
- private function _doInlayGun($gun_id,$token_id){
- $chip = Chip::getChipByTokenId($token_id);
- $gun = Gun::find($gun_id);
- if (! $chip || ! $gun){
- $this->_rspErr(1, 'Not enough chip or gun');
- return false;
- }
- if (! $gun['chip_ids']){
- $fieldsKv = ['chip_ids'=>$chip['idx']];
- }
- if ($gun['chip_ids'] && !strpos($gun['chip_ids'], '|')){
- $chipIdsArr = [$gun['chip_ids']];
- array_push($chipIdsArr,$chip['idx']);
- $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
- }
- if ($gun['chip_ids'] && strpos($gun['chip_ids'], '|')){
- $chipIdsArr = explode('|',$gun['chip_ids']);
- array_push($chipIdsArr,$chip['idx']);
- $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
- }
- Gun::update($gun_id,$fieldsKv);
- Chip::updateChipInlayState($token_id,1);
- return true;
- }
-
- private function _doDemount($unique_id,$token_id){
- $chip = Chip::getChipByTokenId($token_id);
- $hero = Hero::find($unique_id);
- if (! $chip || ! $hero){
- $this->_rspErr(1, 'Not enough chip or hero');
- return false;
- }
- $chipIdsArr = explode('|',$hero['chip_ids']);
- $k = array_search($chip['idx'],$chipIdsArr);
- unset($chipIdsArr[$k]);
- $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
- $tili = $chip['strength_max']-$chip['strength'];
- if ($tili){
- $mint = \services\FormulaService::Chip_Demount_Mint($tili);
- $userObj = new User();
- $user=$userObj->find(myself()->_getAccountId());
- if ($mint>$user['gold']){
- $this->_rspErr(2, 'Be short of gold coins');
- return false;
- }
- User::update(['gold'=>$user['gold']-$mint]);
- $chipDto = Chip::toDto($chip);
- {
- //埋点
- $event = [
- 'name' => LogService::CHIP_DEMOUNT,
- 'val' => $mint
- ];
- $chipDto['level'] = $chipDto['chip_grade'];
- LogService::consumeCEG($event,$chipDto,$chipDto);
- }
- }
- $where = ['inlay_state'=>0,'strength'=>$chip['strength_max']];
- Hero::update($unique_id,$fieldsKv);
- Chip::update($token_id,$where);
- return true;
- }
-
- private function _doDemountGun($unique_id,$token_id){
- $chip = Chip::getChipByTokenId($token_id);
- $gun = Gun::find($unique_id);
- if (! $chip || ! $gun){
- $this->_rspErr(1, 'Not enough chip or gun');
- return false;
- }
- $chipIdsArr = explode('|',$gun['chip_ids']);
- $k = array_search($chip['idx'],$chipIdsArr);
- unset($chipIdsArr[$k]);
- $fieldsKv = ['chip_ids'=>implode('|',$chipIdsArr)];
-
- $tili = $chip['strength_max']-$chip['strength'];
- if ($tili){
- $mint = \services\FormulaService::Chip_Demount_Mint($tili);
- $userObj = new User();
- $user=$userObj->find(myself()->_getAccountId());
- if ($mint>$user['gold']){
- $this->_rspErr(2, 'Be short of gold coins');
- return false;
- }
- User::update(['gold'=>$user['gold']-$mint]);
- $chipDto = Chip::toDto($chip);
- {
- //埋点
- $event = [
- 'name' => LogService::CHIP_DEMOUNT,
- 'val' => $mint
- ];
- $chipDto['level'] = $chipDto['chip_grade'];
- LogService::consumeCEG($event,$chipDto,$chipDto);
- }
- }
- $where = ['inlay_state'=>0,'strength'=>$chip['strength_max']];
- Gun::update($unique_id,$fieldsKv);
- Chip::update($token_id,$where);
- return true;
- }
-
- private function _inLayNewAttr($hero_id){
- $heroDb = Hero::find($hero_id);
- $hero = Hero::toDto($heroDb);
- $chipAttr = [];
- if (! $hero['chip_ids'] ){
- return $hero;
- }
- if ($hero['chip_ids'] && !strpos($hero['chip_ids'], '|')){
- $chip =Chip::toDto(Chip::getChipByIdx($hero['chip_ids']));
- foreach ($chip['rand_attr'] as $val){
- array_push($chipAttr,$val);
- }
- }
- if ($hero['chip_ids'] && strpos($hero['chip_ids'], '|')){
- $chipIdsArr = explode('|',$hero['chip_ids']);
- foreach ($chipIdsArr as $val){
- $chip = Chip::toDto(Chip::getChipByIdx($val));
- foreach ($chip['rand_attr'] as $v){
- array_push($chipAttr,$v);
- }
- }
- }
- $item = [];
- foreach ($chipAttr as $k=>$v){
- if (!isset($item[$v['attr_id']])){
- $item[$v['attr_id']] = $v;
- }else{
- $item[$v['attr_id']]['val']+= $v['val'];
- }
- }
- $hero['attr_chip'] = $item;//芯片属性
- return $hero;
- }
-
- private function _inLayNewAttrGun($gun_id){
- $gunDb = Gun::find($gun_id);
- $gun = Gun::toDto($gunDb);
- $chipAttr = [];
- if (! $gun['chip_ids'] ){
- return $gun;
- }
- if ($gun['chip_ids'] && !strpos($gun['chip_ids'], '|')){
- $chip =Chip::toDto(Chip::getChipByIdx($gun['chip_ids']));
- foreach ($chip['rand_attr'] as $val){
- array_push($chipAttr,$val);
- }
- }
- if ($gun['chip_ids'] && strpos($gun['chip_ids'], '|')){
- $chipIdsArr = explode('|',$gun['chip_ids']);
- foreach ($chipIdsArr as $val){
- $chip = Chip::toDto(Chip::getChipByIdx($val));
- foreach ($chip['rand_attr'] as $v){
- array_push($chipAttr,$v);
- }
- }
- }
- $item = [];
- foreach ($chipAttr as $k=>$v){
- if (!isset($item[$v['attr_id']])){
- $item[$v['attr_id']] = $v;
- }else{
- $item[$v['attr_id']]['val']+= $v['val'];
- }
- }
- $gun['attr_chip'] = $item;//芯片属性
- return $gun;
- }
-
- private function _chipCore($unique_id,$type){
- $chipCore = [];
- if ($type==1){
- $hero = Hero::find($unique_id);
- }else{
- $hero = Gun::find($unique_id);
- }
-
- if ($hero['chip_ids'] && strpos($hero['chip_ids'], '|')){
- $chipIdsArr = explode('|',$hero['chip_ids']);
- if (count($chipIdsArr) == 4){
- $min = 15;
- foreach ($chipIdsArr as $val){
- $chip = Chip::getChipByIdx($val);
- if ($chip['chip_grade']<$min){
- $min = $chip['chip_grade'];
- }
- }
- $chipCoreList = getMetaTable('chipCore@chipCore.php');
- foreach ($chipCoreList as $val){
- if ($val['chip_core_type']==$type && $val['chip_core_lv']<=$min){
- array_push($chipCore,$val);
- }
- }
- return $chipCore;
- }else{
- return [];
- }
- }else{
- return [];
- }
- }
-
- private function _getHignGradeLimit($data,$limit){
- $len = count($data);
- if ($len<=1 || $len<=$limit){
- return $data;
- }
- for ($i = 0; $i < $len - 1; $i++) {
- for ($j = $i + 1; $j < $len; $j++) {
- if ($data[$i]['chip_grade'] < $data[$j]['chip_grade']) {
- $tmp = $data[$i];
- $data[$i] = $data[$j];
- $data[$j] = $tmp;
- }
- }
- }
- return array_slice($data,0,$limit);
- }
-
- private function _orderByChip($data,$order){
- $len = count($data);
- if ($len<=1){
- return $data;
- }
- if ($order == 'desc'){
- for ($i = 0; $i < $len - 1; $i++) {
- for ($j = $i + 1; $j < $len; $j++) {
- if ($data[$i]['chip_grade'] < $data[$j]['chip_grade']) {
- $tmp = $data[$i];
- $data[$i] = $data[$j];
- $data[$j] = $tmp;
- }
- }
- }
- }else{
- for ($i = 0; $i < $len - 1; $i++) {
- for ($j = $i + 1; $j < $len; $j++) {
- if ($data[$i]['chip_grade'] > $data[$j]['chip_grade']) {
- $tmp = $data[$i];
- $data[$i] = $data[$j];
- $data[$j] = $tmp;
- }
- }
- }
- }
- return $data;
- }
-
- private function _upgraded($chip){
- $new_grade = $chip['chip_grade']+1;
- if ($new_grade == 3 || $new_grade == 5){
- Chip::updateRandAttr(myself()->_getAccountId(),$chip);
- }
-
- $lucky = ltrim(\services\FormulaService::getChipLuckyValue($new_grade),'-') ;
- if ($new_grade>=5){
- $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade,'supper_state'=>1,'modifytime' => $this->_getNowTime()];
- }else{
- $where = ['lucky_temporary'=>$lucky, 'chip_grade'=>$new_grade,'modifytime' => $this->_getNowTime()];
- }
- Chip::update($chip['token_id'],$where);
- }
-
- private function _bestFun($upgrade_cost,$chip_param,$chip_param_out){
- $cost = 0;
- foreach ($chip_param as $v){
- $cost += $v['cost'];
- };
- if ($cost>$upgrade_cost){
- return $chip_param;
- }else{
- array_shift($chip_param);
- array_push($chip_param,array_shift($chip_param_out));
- return $this->_bestFun($upgrade_cost,$chip_param,$chip_param_out);
- }
- }
-
}
\ No newline at end of file
diff --git a/webapp/controller/ChipPageController.class.php b/webapp/controller/ChipPageController.class.php
new file mode 100644
index 00000000..f070b215
--- /dev/null
+++ b/webapp/controller/ChipPageController.class.php
@@ -0,0 +1,183 @@
+initChipPage();
+
+ $list =array();
+ ChipPage::getList(function ($row) use(&$list){
+ array_push($list, ChipPage::toDto($row));
+ });
+ $this->_rspData(array(
+ 'data' => $list,
+ ));
+ }
+
+ public function showPageInfo(){
+ $page = getReqVal('page',1);
+ $chipPageDb = ChipPage::find($page);
+ if (!$chipPageDb){
+ $this->_rspErr(1,'page parameter error');
+ return ;
+ }
+ $chipPageDto = ChipPage::toDtoInfo($chipPageDb);
+ $this->_rspData(array(
+ 'data' => $chipPageDto,
+ ));
+ }
+
+ public function addChipPage(){
+ ChipPage::addChipPage();
+ $this->_rspOk();
+ }
+
+ public function rename(){
+ $page = getReqVal('page',0);
+ $chipPageDb = ChipPage::find($page);
+ if (! $chipPageDb ){
+ $this->_rspErr(1,'page parameter error');
+ return ;
+ }
+ $name = getReqVal('name','');
+ if (mb_strlen($name) < 3) {
+ $this->_rspErr(1,'Parameter error name length must not be less than 3');
+ return;
+ }
+ if (mb_strlen($name, 'utf8') > 12) {
+ $this->_rspErr(1,'Parameter error name length must not be greater than 12');
+ return;
+ }
+ ChipPage::update($page,array(
+ 'page_name' => $name
+ ));
+ $chipPageDto = ChipPage::toDtoInfo($chipPageDb);
+ $this->_rspData(array(
+ 'data' => $chipPageDto,
+ ));
+ }
+
+ public function useChip(){
+ $page = getReqVal('page',0);
+ $slotId = getReqVal('slot_id',0);
+ $uniqueId = getReqVal('unique_id',0);
+ if (!$page || !$slotId || !$uniqueId){
+ $this->_rspErr(1, 'Missing parameter');
+ return ;
+ }
+ $chipPageDb = ChipPage::find($page);
+ if (!$chipPageDb){
+ $this->_rspErr(1,'page parameter error');
+ return ;
+ }
+ if ($slotId > ChipPageService::MAX_CHIP_SLOT_NUM || $slotId < 0 ){
+ $this->_rspErr(1,'No card slot exists');
+ return ;
+ }
+ $data = emptyReplace(json_decode($chipPageDb['data'], true), array());
+ if ( $data[$slotId-1]['state'] != 1){
+ $this->_rspErr(1,'Unlocked state');
+ return ;
+ }
+ $chipDb = Chip::find($uniqueId);
+ if (! $chipDb){
+ $this->_rspErr(1, "You don't have the chip yet");
+ return;
+ }
+
+ if (in_array($page,array_filter(explode("|",$chipDb['inlay_state'])))){
+ $this->_rspErr(1, "The used chip");
+ return;
+ }
+ switch ($slotId%3){
+ case 1 : $type = 1;break;
+ case 2 : $type = 2;break;
+ case 0 : $type = 3;break;
+ default:$type = 0;
+ }
+
+ if ($chipDb['chip_type'] != $type){
+ $this->_rspErr(1, "Type mismatch");
+ return;
+ }
+ if ( $data[$slotId-1]['chip_id'] ){
+
+ Chip::updateInlayState($data[$slotId-1]['chip_id'],$page);
+ }
+ $data[$slotId-1]['chip_id'] = $uniqueId;
+
+ Chip::updateInlayState($uniqueId,$page);
+ ChipPage::update($page,array(
+ 'data' => json_encode($data)
+ ));
+ $newChipPageDb = ChipPage::find($page);
+ $chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
+ $this->_rspData(array(
+ 'data' => $chipPageDto,
+ ));
+ }
+
+ public function removeChipOne(){
+ $page = getReqVal('page',0);
+ $slotId = getReqVal('slot_id',0);
+ if (!$page || !$slotId){
+ $this->_rspErr(1, 'Missing parameter');
+ return ;
+ }
+ $chipPageDb = ChipPage::find($page);
+ if (!$chipPageDb){
+ $this->_rspErr(1,'page parameter error');
+ return ;
+ }
+ $data = emptyReplace(json_decode($chipPageDb['data'], true), array());
+ foreach ($data as &$value){
+ if ($value['slot_id'] == $slotId){
+ Chip::updateInlayState($value['chip_id'],$page);
+ $value['chip_id'] = 0;
+ }
+ }
+ ChipPage::update($page,array(
+ 'data' => json_encode($data)
+ ));
+ $newChipPageDb = ChipPage::find($page);
+ $chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
+ $this->_rspData(array(
+ 'data' => $chipPageDto,
+ ));
+ }
+
+ public function removeChipAll(){
+ $page = getReqVal('page',0);
+ $chipPageDb = ChipPage::find($page);
+ if (!$chipPageDb){
+ $this->_rspErr(1,'page parameter error');
+ return ;
+ }
+ $data = emptyReplace(json_decode($chipPageDb['data'], true), array());
+ foreach ($data as &$value){
+ if ($value['chip_id']){
+ Chip::updateInlayState($value['chip_id'],$page);
+ $value['chip_id'] = 0;
+ }
+ }
+ ChipPage::update($page,array(
+ 'data' => json_encode($data)
+ ));
+ $newChipPageDb = ChipPage::find($page);
+ $chipPageDto = ChipPage::toDtoInfo($newChipPageDb);
+ $this->_rspData(array(
+ 'data' => $chipPageDto,
+ ));
+ }
+
+
+}
\ No newline at end of file
diff --git a/webapp/controller/EmojiController.class.php b/webapp/controller/EmojiController.class.php
new file mode 100644
index 00000000..9c333543
--- /dev/null
+++ b/webapp/controller/EmojiController.class.php
@@ -0,0 +1,73 @@
+$val,
+ 'state'=>1,
+ )
+ );
+ }else{
+ array_push($data,
+ array(
+ 'item_id'=>$val,
+ 'state'=>0,
+ )
+ );
+ }
+ }
+ $this->_rspData(array(
+ 'data' => $data,
+ 'use_emoji' => $uses
+ ));
+ }
+
+ public function setEmoji(){
+ $itemId = getReqVal('item_id', '');
+ if(! in_array($itemId,Emoji::emojiList())){
+ $this->_rspErr(1, 'item_id parameter error');
+ return;
+ }
+ $uses = Emoji::getUseEmoji();
+ if(in_array($itemId,$uses)){
+ $this->_rspErr(1, 'The emoji has been used');
+ return;
+ }
+ if(count($uses) >= kMaxEmojiNum){
+ $this->_rspErr(1, 'To maximize');
+ return;
+ }
+ array_push($uses,$itemId);
+ Emoji::updateEmoji( implode('|',$uses) );
+ $this->_rspOk();
+ }
+
+ public function cancel(){
+ $itemId = getReqVal('item_id', '');
+ if(! in_array($itemId,Emoji::emojiList())){
+ $this->_rspErr(1, 'item_id parameter error');
+ return;
+ }
+ $uses = Emoji::getUseEmoji();
+ if(! in_array($itemId,$uses)){
+ $this->_rspErr(1, 'The emoji is not used');
+ return;
+ }
+ foreach ($uses as $k=>$v){
+ if ($itemId == $v){
+ unset($uses[$k]);
+ }
+ }
+ Emoji::updateEmoji(implode('|',$uses));
+ $this->_rspOk();
+ }
+}
\ No newline at end of file
diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php
index a1b93908..03544e25 100644
--- a/webapp/controller/GunController.class.php
+++ b/webapp/controller/GunController.class.php
@@ -11,6 +11,7 @@ require_once('models/User.php');
require_once('models/Gun.php');
require_once('models/Bag.php');
require_once('models/Chip.php');
+require_once('models/Nft.php');
require_once('models/NftUpReceive.php');
require_once('models/Transaction.php');
@@ -26,6 +27,7 @@ use models\User;
use models\Gun;
use models\Bag;
use models\Chip;
+use models\Nft;
use models\NftUpReceive;
use models\Transaction;
use services\LogService;
@@ -61,6 +63,11 @@ class GunController extends BaseAuthedController {
$this->_rspErr(1, "You don't have the gun yet");
return;
}
+ $gunDb['tags'] = '';
+ if ($gunDb['token_id']){
+ $nftDb = Nft::getNft($gunDb['token_id']);
+ $gunDb['tags'] = $nftDb['tags'];
+ }
$gun = Gun::toDto($gunDb);
$this->_rspData(array(
@@ -255,19 +262,29 @@ class GunController extends BaseAuthedController {
return;
}
+ $costItems = array(
+ array(
+ 'item_id' => V_ITEM_GOLD,
+ 'item_num' => $nextLevelMeta['gold']
+ ),
+ array(
+ 'item_id' => V_ITEM_DIAMOND,
+ 'item_num' => $nextLevelMeta['diamond']
+ ),
+ );
+
$newGunDb = $gunDb;
$newGunDb['gun_lv'] += 1;
$attrs = mt\GunLevel::addRandAttrNew($gunDb,0);
$newGunDb['rand_attr'] = json_encode($attrs);
- $cost['CEG'] = \services\FormulaService::Weapon_Upgrade_CEG_Expend( $newGunDb['gun_lv']);
- $cost['CEC'] = \services\FormulaService::Weapon_Upgrade_CEC_Expend( $newGunDb['gun_lv']);
+
$gunDto = Gun::toDto($gunDb);
$newGunDto = Gun::toDto($newGunDb);
$this->_rspData(array(
'old_gun' => $gunDto,
'new_gun' => $newGunDto,
- 'cost' => $cost
+ 'cost' => $costItems
));
}
@@ -816,4 +833,79 @@ class GunController extends BaseAuthedController {
));
}
+ public function upgradeLv(){
+ $gunUniId = getReqVal('gun_uniid', 0);
+ $costGunUniId = getReqVal('cost_gun_uniid', 0);
+ $gunDb = Gun::find($gunUniId);
+ $oldGun = Gun::toDto($gunDb);
+ $costGunDb = Gun::findEx($costGunUniId);
+ if (!$gunDb || !$costGunDb) {
+ $this->_rspErr(100, 'param error or null');
+ return;
+ }
+ if ($costGunDb['token_id']){
+ $this->_rspErr(100, 'NFT cannot be a material');
+ return;
+ }
+ if ($costGunDb['state'] == Gun::FREE_STATE){
+ $this->_rspErr(100, 'Unable to use free gun');
+ return;
+ }
+ if ($gunDb['gun_lv'] != $costGunDb['gun_lv']){
+ $this->_rspErr(100, 'You need the same level to do it');
+ return;
+ }
+ $itemMeta = mt\Item::get($gunDb['gun_id']);
+ if (!$itemMeta) {
+ $this->_rspErr(100, 'server internal error');
+ return;
+ }
+
+ $nextLevelMeta = mt\GunLevel::getByLevel($gunDb['gun_lv'] +1);
+ if (!$nextLevelMeta) {
+ $this->_rspErr(5, "It's already the highest level");
+ return;
+ }
+
+ //升级所需消耗
+ $costItems = array(
+ array(
+ 'item_id' => V_ITEM_GOLD,
+ 'item_num' => $nextLevelMeta['gold']
+ ),
+ array(
+ 'item_id' => V_ITEM_DIAMOND,
+ 'item_num' => $nextLevelMeta['diamond']
+ ),
+ );
+ $lackItem = null;
+ if (!$this->_hasEnoughItems($costItems, $lackItem)) {
+ $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
+ return;
+ }
+ $this->_decItems($costItems);
+
+ $attrs = mt\GunLevel::addRandAttrNew($gunDb,1);
+ Gun::update($gunUniId,
+ array(
+ 'gun_lv' => $gunDb['gun_lv'] + 1,
+ 'state' => Gun::GETED_STATE,
+ 'rand_attr' => json_encode($attrs),
+ ));
+ Gun::update($costGunUniId,
+ array(
+ 'account_id' => myself()->_getAccountId() . '!!!',
+ )
+ );
+ $newGun = Gun::toDto(Gun::find($gunUniId));
+ $propertyChgService = new services\PropertyChgService();
+ $propertyChgService->addGunChg();
+ $propertyChgService->addUserChg();
+ $this->_rspData(array(
+ 'property_chg' => $propertyChgService->toDto(),
+ 'old_gun' => $oldGun,
+ 'new_gun' => $newGun,
+ ));
+ }
+
}
diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php
index 3d27d598..f28a17c7 100644
--- a/webapp/controller/HeroController.class.php
+++ b/webapp/controller/HeroController.class.php
@@ -14,9 +14,11 @@ require_once('mt/Skill.php');
require_once('models/Hero.php');
require_once('models/Bag.php');
require_once('models/HeroSkin.php');
-require_once('models/Chip.php');
+require_once('models/Nft.php');
require_once('models/NftUpReceive.php');
require_once('models/Transaction.php');
+require_once('models/ChipPage.php');
+require_once('models/Gun.php');
require_once('services/AwardService.php');
require_once('services/PropertyChgService.php');
@@ -29,7 +31,9 @@ use phpcommon\SqlHelper;
use models\Hero;
use models\Bag;
use models\HeroSkin;
-use models\Chip;
+use models\ChipPage;
+use models\Gun;
+use models\Nft;
use models\NftUpReceive;
use models\Transaction;
use services\LogService;
@@ -59,6 +63,11 @@ class HeroController extends BaseAuthedController {
$this->_rspErr(1, "You don't have the hero yet");
return;
}
+ $heroDb['tags'] = '';
+ if ($heroDb['token_id']){
+ $nftDb = Nft::getNft($heroDb['token_id']);
+ $heroDb['tags'] = $nftDb['tags'];
+ }
$hero = Hero::toDto($heroDb);
$this->_rspData(array(
@@ -66,6 +75,312 @@ class HeroController extends BaseAuthedController {
));
}
+ public function skinList()
+ {
+ $heroId = getReqVal('hero_id',0);
+ if (!$heroId){
+ $this->_rspErr(1, "param null");
+ return;
+ }
+ $itemMeta = \mt\Item::get($heroId);
+ if (!$itemMeta || $itemMeta['type']!=\mt\Item::HERO_TYPE){
+ $this->_rspErr(1, "param error");
+ return;
+ }
+ $skinList = array();
+ $skinMeta = \mt\Item::getMetaListByType(\mt\Item::HERO_SKIN_TYPE);
+ if ($skinMeta){
+ foreach ($skinMeta as $value){
+ if ($value['playerid'] == $heroId){
+ array_push($skinList,HeroSkin::toDto($value));
+ }
+ }
+ }
+ $this->_rspData(array(
+ 'skin_list' => $skinList
+ ));
+ }
+
+ public function takeonSkin()
+ {
+ $heroUniId = getReqVal('hero_uniid', 0);
+ $skinId = getReqVal('skin_id', 0);
+ $heroDb = Hero::find($heroUniId);
+ $heroSkinDb = HeroSkin::find($skinId);
+ if (!$heroDb) {
+ $this->_rspErr(1, "You don't have the hero yet");
+ return;
+ }
+ if (!$heroSkinDb) {
+ $this->_rspErr(2, "You don't have the skin yet");
+ return;
+ }
+ HeroSkin::takeonSkin( $skinId,$heroDb['hero_id']);
+ $this->_rspOk();
+ }
+
+ public function upgradeLevelPreview(){
+ $heroUniId = getReqVal('hero_uniid', 0);
+ $heroDb = Hero::find($heroUniId);
+ if (!$heroDb) {
+ $this->_rspErr(1, 'hero does not exist');
+ return;
+ }
+ $heroMeta = mt\Hero::get($heroDb['hero_id']);
+ if (!$heroMeta) {
+ $this->_rspErr(100, 'server internal error');
+ return;
+ }
+ $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1);
+ if (!$nextLevelMeta) {
+ $this->_rspErr(5, "It's already the highest level");
+ return;
+ }
+
+ $meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1);
+ $costItems = array(
+ array(
+ 'item_id' => V_ITEM_GOLD,
+ 'item_num' => $meta['gold']
+ ),
+ array(
+ 'item_id' => V_ITEM_DIAMOND,
+ 'item_num' => $meta['diamond']
+ )
+ );
+
+ $newHeroDb = $heroDb;
+ $newHeroDb['hero_lv'] += 1;
+ $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,0);
+ $newHeroDb['rand_attr'] = json_encode($attrs);
+
+ $heroDto = Hero::toDto($heroDb);
+ $newHeroDto = Hero::toDto($newHeroDb);
+ $this->_rspData(array(
+
+ 'old_hero' => $heroDto,
+ 'new_hero' => $newHeroDto,
+ 'cost' => $costItems
+ ));
+ }
+
+ public function upgradeLv()
+ {
+ $heroUniId = getReqVal('hero_uniid', 0);
+ $costHeroUniId = getReqVal('cost_hero_uniid', 0);
+ $heroDb = Hero::find($heroUniId);
+ $oldHero = Hero::toDto($heroDb);
+ $costHeroDb = Hero::findEx($costHeroUniId);
+ if (!$heroDb) {
+ $this->_rspErr(100, 'param error or null');
+ return;
+ }
+ if ($heroDb['hero_lv'] == Hero::LV_1 ||
+ $heroDb['hero_lv'] == Hero::LV_2 ||
+ $heroDb['hero_lv'] == Hero::LV_3 ){
+ if (! $costHeroDb){
+ $this->_rspErr(100, 'material param error or null');
+ return;
+ }
+ if ($costHeroDb['token_id']){
+ $this->_rspErr(100, 'NFT cannot be a material');
+ return;
+ }
+ if ($costHeroDb['state'] == Hero::FREE_STATE){
+ $this->_rspErr(100, 'Unable to use free hero');
+ return;
+ }
+ switch ($heroDb['hero_lv']){
+ case Hero::LV_1:{
+ if ($heroDb['hero_lv'] < $costHeroDb['hero_lv']){
+ $this->_rspErr(100, 'Grade discrepancy');
+ return;
+ }
+ };break;
+ case Hero::LV_2:{
+ if ($heroDb['hero_lv'] < $costHeroDb['hero_lv'] && $costHeroDb['hero_lv'] <= Hero::LV_1){
+ $this->_rspErr(100, 'Grade discrepancy');
+ return;
+ }
+ };break;
+ case Hero::LV_3:{
+ if ($heroDb['hero_lv'] < $costHeroDb['hero_lv'] && $costHeroDb['hero_lv'] <= Hero::LV_2){
+ $this->_rspErr(100, 'Grade discrepancy');
+ return;
+ }
+ }
+ }
+ }
+ $heroMeta = mt\Hero::get($heroDb['hero_id']);
+ if (!$heroMeta) {
+ $this->_rspErr(100, 'server internal error');
+ return;
+ }
+ $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1);
+ if (!$nextLevelMeta) {
+ $this->_rspErr(5, "It's already the highest level");
+ return;
+ }
+
+ //升级所需消耗
+ $meta = mt\HeroLevel::get($heroDb['hero_lv'] + 1);
+ $costItems = array(
+ array(
+ 'item_id' => V_ITEM_GOLD,
+ 'item_num' => $meta['gold']
+ ),
+ array(
+ 'item_id' => V_ITEM_DIAMOND,
+ 'item_num' => $meta['diamond']
+ )
+ );
+ $lackItem = null;
+ if (!$this->_hasEnoughItems($costItems, $lackItem)) {
+ $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
+ return;
+ }
+ $this->_decItems($costItems);
+
+ $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1);
+ Hero::update($heroUniId, array(
+ 'hero_lv' => $heroDb['hero_lv'] + 1,
+ 'rand_attr' => json_encode($attrs),
+ 'state' => Hero::GETED_STATE,
+ ));
+ if ($costHeroDb){
+ Hero::update($costHeroUniId, array(
+ 'account_id' => myself()->_getAccountId() . '!!!',
+ ));
+ }
+ if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) {
+ myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1);
+ }
+ $newHero = Hero::toDto(Hero::find($heroUniId));
+ $propertyChgService = new services\PropertyChgService();
+ $propertyChgService->addHeroChg();
+ $propertyChgService->addUserChg();
+ $this->_rspData(array(
+ 'property_chg' => $propertyChgService->toDto(),
+ 'old_hero' => $oldHero,
+ 'new_hero' => $newHero,
+ ));
+ }
+
+ public function presetHero(){
+ $heroId = getReqVal('hero_uid',0);
+ $heroDb = Hero::find($heroId);
+ if (! $heroDb){
+ $this->_rspErr(1, "You don't have the hero yet");
+ return;
+ }
+ $row = SqlHelper::ormSelectOne(
+ $this->_getSelfMysql(),
+ 't_hero_preset',
+ array(
+ 'account_id' => $this->_getAccountId(),
+ 'hero_uid' => $heroId,
+ )
+ );
+ if ($row){
+
+ $data = array(
+ 'skill_id' => $row['skill_id'],
+ 'weapon_uid1' => $row['weapon_uid1'],
+ 'weapon_uid2' => $row['weapon_uid2'],
+ 'chip_page' => $row['chip_page'],
+ 'gun_id1'=>0,
+ 'gun_id2'=>0,
+ );
+ $gunDb1 = Gun::find($row['weapon_uid1']);
+ $gunDb2 = Gun::find($row['weapon_uid2']);
+ if ($gunDb1){
+ $data['gun_id1'] = $gunDb1['gun_id'];
+ }
+ if ($gunDb1){
+ $data['gun_id2'] = $gunDb2['gun_id'];
+ }
+ }else{
+ $data = array(
+ 'skill_id' => \mt\Skill::DEFAULT_SKILL,
+ 'weapon_uid1' => 0,
+ 'weapon_uid2' => 0,
+ 'gun_id1'=>0,
+ 'gun_id2'=>0,
+ 'chip_page' => 1,
+ );
+ }
+ $this->_rspData(array(
+ 'data' => $data,
+ ));
+ }
+
+ public function applyHero(){
+ $heroId = getReqVal('hero_uid',0);
+ $chipPageId = getReqVal('chip_page',0);
+ $weaponUid1 = getReqVal('weapon_uid1',0);
+ $weaponUid2 = getReqVal('weapon_uid2',0);
+ $skillId = getReqVal('skill_id',0);
+ $heroDb = Hero::find($heroId);
+ if (! $heroDb){
+ $this->_rspErr(1, "You don't have the hero yet");
+ return;
+ }
+ $chipPageDb = ChipPage::find($chipPageId);
+ if (! $chipPageDb){
+ $this->_rspErr(1, "You don't have the chip page");
+ return;
+ }
+ if ($weaponUid1){
+ $gunDb1 = Gun::find($weaponUid1);
+ if (!$gunDb1){
+ $this->_rspErr(1, "You don't have the gun1 yet");
+ return;
+ }
+ }
+ if ($weaponUid2){
+ $gunDb2 = Gun::find($weaponUid2);
+ if (!$gunDb2){
+ $this->_rspErr(1, "You don't have the gun2 yet");
+ return;
+ }
+ }
+ $skillMeta = \mt\Skill::get($skillId);
+ if (! $skillMeta){
+ $this->_rspErr(1,'skill_id parameter error');
+ return ;
+ }
+ SqlHelper::upsert
+ ($this->_getSelfMysql(),
+ 't_hero_preset',
+ array(
+ 'account_id' => $this->_getAccountId(),
+ 'hero_uid' => $heroId,
+ ),
+ array(
+ 'skill_id' => $skillId,
+ 'weapon_uid1' => $weaponUid1,
+ 'weapon_uid2' => $weaponUid2,
+ 'chip_page' => $chipPageId,
+ 'modifytime' => $this->_getNowTime(),
+ ),
+ array(
+ 'account_id' => $this->_getAccountId(),
+ 'hero_uid' => $heroId,
+ 'skill_id' => $skillId,
+ 'weapon_uid1' => $weaponUid1,
+ 'weapon_uid2' => $weaponUid2,
+ 'chip_page' => $chipPageId,
+ 'createtime' => $this->_getNowTime(),
+ 'modifytime' => $this->_getNowTime(),
+
+ )
+ );
+ $this->_rspOk();
+ }
+
+
+
+
public function upgradeSkillCommon(){
$heroUniId = getReqVal('hero_uniid', 0);
$skillIndex = getReqVal('skill_index', 0);
@@ -148,42 +463,6 @@ class HeroController extends BaseAuthedController {
));
}
- public function skinList()
- {
- $skinList = array();
- SqlHelper::ormSelect(
- $this->_getSelfMysql(),
- 't_hero_skin',
- array(
- 'account_id' => $this->_getAccountId()
- ),
- function ($row) use(&$skinList) {
- array_push($skinList, HeroSkin::toDto($row));
- }
- );
- $this->_rspData(array(
- 'skin_list' => $skinList
- ));
- }
-
- public function takeonSkin()
- {
- $heroUniId = getReqVal('hero_uniid', 0);
- $skinId = getReqVal('skin_id', 0);
- $heroDb = Hero::find($heroUniId);
- $heroSkinDb = HeroSkin::find($skinId);
- if (!$heroDb) {
- $this->_rspErr(1, "You don't have the hero yet");
- return;
- }
- if (!$heroSkinDb) {
- $this->_rspErr(2, "You don't have the skin yet");
- return;
- }
- Hero::takeonSkin($heroUniId, $skinId);
- $this->_rspOk();
- }
-
public function getUpgradeLevelList()
{
$infos = array();
@@ -228,9 +507,9 @@ class HeroController extends BaseAuthedController {
// $this->_rspData(array(
// 'infos' => $infos
// ));
- $list = NftUpReceive::all(myself()->_getAccountId(),1);
- $infos = array();
- foreach ($list as $value){
+ $list = NftUpReceive::all(myself()->_getAccountId(),1);
+ $infos = array();
+ foreach ($list as $value){
if ($this->_getNowTime() - $value['createtime'] < 24*3600 && !$value['from_data'] || $value['from_data'] ){
$hero = Hero::findByTokenId2($value['token_id1']);
$costHero = Hero::findByTokenId2($value['token_id2']);
@@ -254,7 +533,7 @@ class HeroController extends BaseAuthedController {
);
array_push($infos,$info);
}
- }
+ }
$this->_rspData(array(
'infos' => $infos
));
@@ -279,40 +558,40 @@ class HeroController extends BaseAuthedController {
$oldHero = $heroDto;
$newHero = $heroDto;
switch ($type) {
- case 1:
- {
- $idx = 0;
- $found = false;
- for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) {
- $upHeroUniId = $this->_getV(TN_HERO_LEVEL_UP, $i);
- if ($upHeroUniId == $heroUniId) {
- $idx = $i;
- $found = true;
- break;
- }
- }
+ case 1:
+ {
+ $idx = 0;
+ $found = false;
+ for ($i = 0; $i < kMaxHeroUpLevelNum; ++$i) {
+ $upHeroUniId = $this->_getV(TN_HERO_LEVEL_UP, $i);
+ if ($upHeroUniId == $heroUniId) {
+ $idx = $i;
+ $found = true;
+ break;
+ }
+ }
- if (!$found) {
- $this->_rspErr(1, 'hero does not exist2');
- return;
- }
- $this->_setV(TN_HERO_LEVEL_UP, $idx, 0);
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addHeroChg();
- $propertyChgService->addBagChg();
- $propertyChgService->addUserChg();
- $nextLevelMeta = null;
- $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1);
- if ($nextLevelMeta) {
- $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1);
- $where = array(
- 'hero_lv' => $heroDb['hero_lv'] + 1,
- 'rand_attr' => json_encode($attrs),
- 'lock_type' => 0,
- 'unlock_time' => 0,
- 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point']
- );
- //免费英雄到底15级后生成NFT
+ if (!$found) {
+ $this->_rspErr(1, 'hero does not exist2');
+ return;
+ }
+ $this->_setV(TN_HERO_LEVEL_UP, $idx, 0);
+ $propertyChgService = new services\PropertyChgService();
+ $propertyChgService->addHeroChg();
+ $propertyChgService->addBagChg();
+ $propertyChgService->addUserChg();
+ $nextLevelMeta = null;
+ $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1);
+ if ($nextLevelMeta) {
+ $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,1);
+ $where = array(
+ 'hero_lv' => $heroDb['hero_lv'] + 1,
+ 'rand_attr' => json_encode($attrs),
+ 'lock_type' => 0,
+ 'unlock_time' => 0,
+ 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point']
+ );
+ //免费英雄到底15级后生成NFT
// if ($heroDb['hero_lv'] + 1 == 15 && !$heroDb['token_id']){
// $token_id = myself()->_getNowTime();
// if(!\services\NftService::addNft($heroDb['hero_id'],$token_id)){
@@ -327,181 +606,181 @@ class HeroController extends BaseAuthedController {
// 'skill_points' => $heroDb['skill_points']+$nextLevelMeta['skill_point']
// );
// }
- Hero::update($heroUniId, $where);
- if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) {
- myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1);
+ Hero::update($heroUniId, $where);
+ if ($heroDb['hero_lv'] + 1 > myself()->_getV(TN_HERO_MAX_LEVEL, 0)) {
+ myself()->_setV(TN_HERO_MAX_LEVEL, 0, $heroDb['hero_lv'] + 1);
+ }
+ $newHeroDb = Hero::find($heroUniId);
+ $newHero = Hero::toDto($newHeroDb);
}
- $newHeroDb = Hero::find($heroUniId);
- $newHero = Hero::toDto($newHeroDb);
+ {
+ //埋点
+ $event = [
+ 'name' => LogService::HERO_LEVEL_UP,
+ ];
+ $oldHero['level'] = $oldHero['hero_lv'];
+ $oldHero['item_id'] = $oldHero['hero_id'];
+ $newHero['level'] = $newHero['hero_lv'];
+ $newHero['item_id'] = $newHero['hero_id'];
+ LogService::LevelUpOrQualityUp($event,$oldHero,$newHero);
+ }
+ $this->_rspData(array(
+ 'property_chg' => $propertyChgService->toDto(),
+ 'old_hero' => $oldHero,
+ 'new_hero' => $newHero,
+ ));
}
- {
- //埋点
- $event = [
- 'name' => LogService::HERO_LEVEL_UP,
- ];
- $oldHero['level'] = $oldHero['hero_lv'];
- $oldHero['item_id'] = $oldHero['hero_id'];
- $newHero['level'] = $newHero['hero_lv'];
- $newHero['item_id'] = $newHero['hero_id'];
- LogService::LevelUpOrQualityUp($event,$oldHero,$newHero);
- }
- $this->_rspData(array(
- 'property_chg' => $propertyChgService->toDto(),
- 'old_hero' => $oldHero,
- 'new_hero' => $newHero,
- ));
- }
- break;
- case 2:
- {
- $this->_rspOk();return;
- $idx = 0;
- $found = false;
- for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {
- $upHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i);
- if ($upHeroUniId == $heroUniId) {
- $idx = $i;
- $found = true;
- break;
- }
- }
- if (!$found) {
- $this->_rspErr(1, 'hero does not exist');
- return;
- }
- $costHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, (int)$idx + 1000);
- $this->_setV(TN_HERO_QUALITY_UP, $idx, 0);
- $this->_setV(TN_HERO_QUALITY_UP, (int)$idx + 1000, 0);
- $propertyChgService = new services\PropertyChgService();
- $propertyChgService->addHeroChg();
- $propertyChgService->addBagChg();
- $propertyChgService->addUserChg();
- $nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality'] + 1);
- if ($nextQualityMeta) {
- $costHeroDb = Hero::find($costHeroUniId);
- if ($costHeroDb['token_id']){
+ break;
+ case 2:
+ {
+ $this->_rspOk();return;
+ $idx = 0;
+ $found = false;
+ for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) {
+ $upHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i);
+ if ($upHeroUniId == $heroUniId) {
+ $idx = $i;
+ $found = true;
+ break;
+ }
+ }
+ if (!$found) {
+ $this->_rspErr(1, 'hero does not exist');
+ return;
+ }
+ $costHeroUniId = $this->_getV(TN_HERO_QUALITY_UP, (int)$idx + 1000);
+ $this->_setV(TN_HERO_QUALITY_UP, $idx, 0);
+ $this->_setV(TN_HERO_QUALITY_UP, (int)$idx + 1000, 0);
+ $propertyChgService = new services\PropertyChgService();
+ $propertyChgService->addHeroChg();
+ $propertyChgService->addBagChg();
+ $propertyChgService->addUserChg();
+ $nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality'] + 1);
+ if ($nextQualityMeta) {
+ $costHeroDb = Hero::find($costHeroUniId);
+ if ($costHeroDb['token_id']){
// SqlHelper::update(
// myself()->_getMarketMysql(),
// 't_nft',
// ['token_id'=>$costHeroDb['token_id']],
// ['deleted'=>1]
// );
- }else{
+ }else{
+ Hero::update($costHeroUniId,
+ array(
+ 'account_id' => myself()->_getAccountId() . '!!!',
+ )
+ );
+ }
Hero::update($costHeroUniId,
array(
- 'account_id' => myself()->_getAccountId() . '!!!',
+ 'lock_type' => 0,
+ 'unlock_time' => 0,
)
);
- }
- Hero::update($costHeroUniId,
- array(
- 'lock_type' => 0,
- 'unlock_time' => 0,
- )
- );
- {
- //埋点
- $event = [
- 'name' => LogService::HERO_QUALITY_UP_MATERIAL,
- ];
- $params = array(
- array(
- 'unique_id'=>$costHeroDb['idx'],
- 'token_id'=>$costHeroDb['token_id'],
- )
- );
- LogService::ConsumableMaterial($event,$params);
- }
- $rnd = rand(1, 100);
- $probability = \services\FormulaService::Hero_Advanced_Probability($heroDb['quality'] + 1)*100;
- if ($rnd > $probability) {
- Hero::update($heroUniId,
- array(
- 'advanced_count' => $heroDb['advanced_count'] + 1,
- 'lock_type' => 0,
- 'unlock_time' => 0,
- )
- );
- $oldHero['advanced_count'] += 1;
- $newHero['advanced_count'] += 1;
{
//埋点
$event = [
- 'name' => LogService::HERO_QUALITY_UP,
+ 'name' => LogService::HERO_QUALITY_UP_MATERIAL,
];
- $oldHero['level'] = $oldHero['hero_lv'];
- $oldHero['item_id'] = $oldHero['hero_id'];
- $newHero['level'] = $newHero['hero_lv'];
- $newHero['item_id'] = $newHero['hero_id'];
- LogService::LevelUpOrQualityUp($event,$oldHero,$newHero);
+ $params = array(
+ array(
+ 'unique_id'=>$costHeroDb['idx'],
+ 'token_id'=>$costHeroDb['token_id'],
+ )
+ );
+ LogService::ConsumableMaterial($event,$params);
}
- $this->_rspRawData(array(
- 'errcode' => 0,
- 'errmsg' => '',
- 'state' => 0,
- 'old_hero' => $oldHero,
- 'new_hero' => $newHero,
- //'errmsg' => 'advance failed',
- 'property_chg' => $propertyChgService->toDto(),
- ));
+ $rnd = rand(1, 100);
+ $probability = \services\FormulaService::Hero_Advanced_Probability($heroDb['quality'] + 1)*100;
+ if ($rnd > $probability) {
+ Hero::update($heroUniId,
+ array(
+ 'advanced_count' => $heroDb['advanced_count'] + 1,
+ 'lock_type' => 0,
+ 'unlock_time' => 0,
+ )
+ );
+ $oldHero['advanced_count'] += 1;
+ $newHero['advanced_count'] += 1;
+ {
+ //埋点
+ $event = [
+ 'name' => LogService::HERO_QUALITY_UP,
+ ];
+ $oldHero['level'] = $oldHero['hero_lv'];
+ $oldHero['item_id'] = $oldHero['hero_id'];
+ $newHero['level'] = $newHero['hero_lv'];
+ $newHero['item_id'] = $newHero['hero_id'];
+ LogService::LevelUpOrQualityUp($event,$oldHero,$newHero);
+ }
+ $this->_rspRawData(array(
+ 'errcode' => 0,
+ 'errmsg' => '',
+ 'state' => 0,
+ 'old_hero' => $oldHero,
+ 'new_hero' => $newHero,
+ //'errmsg' => 'advance failed',
+ 'property_chg' => $propertyChgService->toDto(),
+ ));
+ return;
+ }
+ $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality']);
+ $nextHeroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality'] + 1);
+ $heroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroLucky);
+ $nextHeroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'] + 1,$nextHeroLucky);
+ Hero::update($heroUniId,
+ array(
+ 'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili),
+ 'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'],
+ 'quality' => $heroDb['quality'] + 1,
+ 'advanced_count' => $heroDb['advanced_count'] + 1,
+ 'lock_type' => 0,
+ 'unlock_time' => 0,
+ 'labour' => 0,
+ )
+ );
+ if ($heroDb['quality'] + 1 > myself()->_getV(TN_HERO_MAX_QUALITY, 0)) {
+ myself()->_setV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1);
+ }
+ $newHeroDb = Hero::find($heroUniId);
+ $newHero = Hero::toDto($newHeroDb);
+ error_log(json_encode(array(
+ 'costHeroUniId' => $costHeroUniId,
+ 'heroUniId' => $heroUniId
+ )));
+ $rankActivityService = new services\RankActivityService();
+ $rankActivityService->heroUpgradeQuality($heroDb['quality'] + 1);
+ }
+ if (!$nextQualityMeta) {
+ $this->_rspErr(1, 'quality is full');
return;
}
- $heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality']);
- $nextHeroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($heroDb['quality'] + 1);
- $heroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'],$heroLucky);
- $nextHeroTili = \services\FormulaService::Hero_NFT_Maximum_Physical_Strength($heroDb['quality'] + 1,$nextHeroLucky);
- Hero::update($heroUniId,
- array(
- 'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili),
- 'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'],
- 'quality' => $heroDb['quality'] + 1,
- 'advanced_count' => $heroDb['advanced_count'] + 1,
- 'lock_type' => 0,
- 'unlock_time' => 0,
- 'labour' => 0,
- )
- );
- if ($heroDb['quality'] + 1 > myself()->_getV(TN_HERO_MAX_QUALITY, 0)) {
- myself()->_setV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1);
+ {
+ //埋点
+ $event = [
+ 'name' => LogService::HERO_QUALITY_UP,
+ ];
+ $oldHero['level'] = $oldHero['hero_lv'];
+ $oldHero['item_id'] = $oldHero['hero_id'];
+ $newHero['level'] = $newHero['hero_lv'];
+ $newHero['item_id'] = $newHero['hero_id'];
+ LogService::LevelUpOrQualityUp($event,$oldHero,$newHero);
}
- $newHeroDb = Hero::find($heroUniId);
- $newHero = Hero::toDto($newHeroDb);
- error_log(json_encode(array(
- 'costHeroUniId' => $costHeroUniId,
- 'heroUniId' => $heroUniId
- )));
- $rankActivityService = new services\RankActivityService();
- $rankActivityService->heroUpgradeQuality($heroDb['quality'] + 1);
+ $this->_rspData(array(
+ 'state' => 1,
+ 'property_chg' => $propertyChgService->toDto(),
+ 'old_hero' => $oldHero,
+ 'new_hero' => $newHero,
+ ));
}
- if (!$nextQualityMeta) {
- $this->_rspErr(1, 'quality is full');
- return;
- }
- {
- //埋点
- $event = [
- 'name' => LogService::HERO_QUALITY_UP,
- ];
- $oldHero['level'] = $oldHero['hero_lv'];
- $oldHero['item_id'] = $oldHero['hero_id'];
- $newHero['level'] = $newHero['hero_lv'];
- $newHero['item_id'] = $newHero['hero_id'];
- LogService::LevelUpOrQualityUp($event,$oldHero,$newHero);
- }
- $this->_rspData(array(
- 'state' => 1,
- 'property_chg' => $propertyChgService->toDto(),
- 'old_hero' => $oldHero,
- 'new_hero' => $newHero,
- ));
- }
- break;
- default:
- {
- $this->_rspErr(1, 'type parameter error');
- return;
- }
- break;
+ break;
+ default:
+ {
+ $this->_rspErr(1, 'type parameter error');
+ return;
+ }
+ break;
}
}
@@ -616,39 +895,6 @@ class HeroController extends BaseAuthedController {
));
}
- public function upgradeLevelPreview(){
- $heroUniId = getReqVal('hero_uniid', 0);
- $heroDb = Hero::find($heroUniId);
- if (!$heroDb) {
- $this->_rspErr(1, 'hero does not exist');
- return;
- }
- $heroMeta = mt\Hero::get($heroDb['hero_id']);
- if (!$heroMeta) {
- $this->_rspErr(100, 'server internal error');
- return;
- }
- $nextLevelMeta = mt\HeroLevelAttr::getByLevel($heroDb['hero_lv'] + 1);
- if (!$nextLevelMeta) {
- $this->_rspErr(5, "It's already the highest level");
- return;
- }
- $newHeroDb = $heroDb;
- $newHeroDb['hero_lv'] += 1;
- $attrs = mt\HeroLevelAttr::addRandAttrNew($heroDb,0);
- $newHeroDb['rand_attr'] = json_encode($attrs);
- $cost['CEG'] = \services\FormulaService::Hero_Upgrade_CEG_Expend($newHeroDb['hero_lv']);
- $cost['CEC'] = \services\FormulaService::Hero_Upgrade_CEC_Expend($newHeroDb['hero_lv']);
- $heroDto = Hero::toDto($heroDb);
- $newHeroDto = Hero::toDto($newHeroDb);
- $this->_rspData(array(
-
- 'old_hero' => $heroDto,
- 'new_hero' => $newHeroDto,
- 'cost' => $cost
- ));
- }
-
public function upgradeQualityOld()
{
$costHeroUniId = getReqVal('cost_hero_uniid', 0);
@@ -758,16 +1004,16 @@ class HeroController extends BaseAuthedController {
$this->_decItems($costItems);
Hero::update($heroUniId,
- array(
- 'lock_type' => Hero::QUALITY_LOCK,
- 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'],
- )
+ array(
+ 'lock_type' => Hero::QUALITY_LOCK,
+ 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'],
+ )
);
Hero::update($costHeroUniId,
- array(
- 'lock_type' => Hero::COST_LOCK,
- 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'],
- )
+ array(
+ 'lock_type' => Hero::COST_LOCK,
+ 'unlock_time' => $this->_getNowTime() + $nextQualityMeta['time'],
+ )
);
$this->_setV(TN_HERO_QUALITY_UP, (int)$slotId, (int)$heroDb['idx']);
$this->_setV(TN_HERO_QUALITY_UP, (int)$slotId + 1000, (int)$costHeroDb['idx']);
diff --git a/webapp/controller/HeroSkillController.class.php b/webapp/controller/HeroSkillController.class.php
new file mode 100644
index 00000000..c9cee0b5
--- /dev/null
+++ b/webapp/controller/HeroSkillController.class.php
@@ -0,0 +1,114 @@
+_rspData(array(
+ 'data' => $list,
+ ));
+ }
+
+ public function presetHero(){
+ $skillId = getReqVal('skill_id',0);
+ $skillMeta = \mt\Skill::get($skillId);
+ if (! $skillMeta){
+ $this->_rspErr(1,'skill_id parameter error');
+ return ;
+ }
+ $heroList = array();
+ Hero::getHeroList(function ($row) use(&$heroList) {
+ array_push($heroList, $row);
+ });
+ $list = array_unique(array_column($heroList,'hero_id'));
+ $data = array();
+ if (count($list) > 0){
+ foreach ($list as $value){
+ $data[$value] = array(
+ 'item_id' => $value,
+ 'state' => 0
+ );
+ }
+ }
+
+ $rows = SqlHelper::ormSelect(
+ $this->_getSelfMysql(),
+ 't_hero_skill',
+ array(
+ 'account_id' => $this->_getAccountId(),
+ 'skill_id' => $skillId,
+ )
+ );
+ if ($rows){
+ foreach ($rows as $row){
+ $heroDb = Hero::find($row['hero_uid']);
+ $data[$heroDb['hero_id']]['state'] = 1;
+ }
+ }
+ $this->_rspData(array(
+ 'data' => $data,
+ ));
+ }
+
+ public function applyHero(){
+ $skillId = getReqVal('skill_id',0);
+ $heroIds = getReqVal('hero_ids','');
+ $heroIdArr = explode('|',$heroIds);
+ if (!$skillId || count($heroIdArr)<0){
+ $this->_rspErr(1,' parameter error');
+ return ;
+ }
+ $skillMeta = \mt\Skill::get($skillId);
+ if (! $skillMeta){
+ $this->_rspErr(1,'skill_id parameter error');
+ return ;
+ }
+ foreach ($heroIdArr as $heroId){
+ $heroMeta = \mt\Hero::get($heroId);
+ if (! $heroMeta){
+ $this->_rspErr(1,'hero_id parameter error');
+ return ;
+ }
+ }
+ foreach ($heroIdArr as $heroId){
+ $heroList = Hero::getHeroByItemId($heroId);
+ if ($heroList){
+ foreach ($heroList as $hero){
+ SqlHelper::upsert
+ ($this->_getSelfMysql(),
+ 't_hero_skill',
+ array(
+ 'account_id' => $this->_getAccountId(),
+ 'hero_uid' => $hero['idx'],
+ ),
+ array(
+ 'skill_id' => $skillId,
+ 'modifytime' => $this->_getNowTime(),
+ ),
+ array(
+ 'account_id' => $this->_getAccountId(),
+ 'hero_uid' => $hero['idx'],
+ 'skill_id' => $skillId,
+ 'createtime' => $this->_getNowTime(),
+ 'modifytime' => $this->_getNowTime(),
+
+ )
+ );
+ }
+ }
+ }
+ $this->_rspOk();
+ }
+}
\ No newline at end of file
diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php
index a5585ea6..31d2a2db 100644
--- a/webapp/controller/MarketController.class.php
+++ b/webapp/controller/MarketController.class.php
@@ -22,6 +22,7 @@ require_once('services/ActivateNftService.php');
require_once('phpcommon/bchelper.php');
+// use phpcommon as phpcommon;
use phpcommon\SqlHelper;
use models\BoxOrder;
use models\Nft;
@@ -571,8 +572,12 @@ class MarketController extends BaseController {
switch ($type) {
case Nft::HERO_TYPE: {
$rows = Nft::getNftListByType($account, $type);
+ $rows = array_merge($rows, $this->listMySelledNfts($account, $type));
foreach ($rows as &$row) {
$nftDb = Nft::findNftByOwner($account, $row['token_id']);
+ if (empty($nftDb)) {
+ $nftDb = Nft::getNft($row['token_id']);
+ }
$row['info'] = Nft::toDto($nftDb);
$row['detail'] = Hero::toDtoInfo(Hero::findByTokenId2($row['token_id']));
if (in_array($row['info']['info']['job'], $job)==false) continue;
@@ -601,8 +606,12 @@ class MarketController extends BaseController {
break;
case Nft::EQUIP_TYPE: {
$rows = Nft::getNftListByType($account, $type);
+ $rows = array_merge($rows, $this->listMySelledNfts($account, $type));
foreach ($rows as &$row) {
$nftDb = Nft::findNftByOwner($account, $row['token_id']);
+ if (empty($nftDb)) {
+ $nftDb = Nft::getNft($row['token_id']);
+ }
$row['info'] = Nft::toDto($nftDb);
$row['detail'] = Gun::toDtoInfo(Gun::findByTokenId2($row['token_id']));
if ($row['detail']['gun_lv']<$lv) continue;
@@ -630,6 +639,7 @@ class MarketController extends BaseController {
break;
case Nft::CHIP_TYPE: {
$rows = Nft::getNft1155List($account, $type);
+ $rows = array_merge($rows, $this->listMySelledNfts($account, $type));
foreach ($rows as &$row) {
$row['detail'] = Chip::toDto(Chip::getChipByTokenId($row['token_id']));
if (!in_array($row['detail']['chip_type'], $job))
@@ -653,8 +663,12 @@ class MarketController extends BaseController {
break;
case Nft::FRAGMENT_TYPE: {
$rows = Nft::getNft1155List($account, $type);
+ $rows = array_merge($rows, $this->listMySelledNfts($account, $type));
foreach ($rows as &$row) {
$nftDb = Nft::findNftByOwner($account, $row['token_id']);
+ if (empty($nftDb)) {
+ $nftDb = Nft::getNft($row['token_id']);
+ }
$row['detail'] = $this->getNftGameData($nftDb);
if (!in_array($row['detail']['type'], $job))
continue;
@@ -676,7 +690,7 @@ class MarketController extends BaseController {
public function listSellNfts()
{
- $account = getReqVal('account', '');
+ $account = strtolower(getReqVal('account', ''));
$token = getReqVal('token', '');
$start = getReqVal('start', 0);
$page_size = getReqVal('page_size', 10);
@@ -770,7 +784,7 @@ class MarketController extends BaseController {
$counts = $conn->execQuery(
'SELECT count(*) as count FROM t_market_store '.
- 'WHERE token_type=:token_type '.
+ 'WHERE token_type=:token_type AND status=0 '.
$job_filter_fn($job_filter_array).
$lv_filter_fn($lv_filter).
$quality_filter_fn($quality_filter).
@@ -794,7 +808,7 @@ class MarketController extends BaseController {
$rows = $conn->execQuery(
'SELECT * FROM t_market_store '.
- 'WHERE token_type=:token_type '.
+ 'WHERE token_type=:token_type AND status=0 '.
$job_filter_fn($job_filter_array).
$lv_filter_fn($lv_filter).
$quality_filter_fn($quality_filter).
@@ -812,10 +826,17 @@ class MarketController extends BaseController {
for ($x = $start; $x < $page_end; $x++) {
$row = $rows[$x%$page_size];
- $nftDb = Nft::findNftByOwner($row['owner_address'], $row['token_id']);
+ $nftDb = Nft::getNft($row['token_id']);
if (!$nftDb) {
- myself()->_rspErr(1, 'nft not exists');
- return;
+ $nftDb = Nft::findNftByOwner($account, $row['token_id']);
+ // 0x768b5faed6dc69816f33377d214ffaf00dcdd0cf
+ if (!$nftDb) {
+ $nftDb = Nft::findNftByOwner('0xfc628dd79137395f3c9744e33b1c5de554d94882', $row['token_id']);
+ if (!$nftDb) {
+ myself()->_rspErr(1, 'nft not exists');
+ return;
+ }
+ }
}
$nft = Nft::toDto($nftDb);
$row['info'] = $nft;
@@ -867,6 +888,7 @@ class MarketController extends BaseController {
$nfts = array();
for ($x = $start; $x < $page_end; $x++) {
$row = $rows[$x];
+ // $this->attach_market_selling($row);
array_push($nfts, $row);
}
@@ -884,6 +906,7 @@ class MarketController extends BaseController {
$token = getReqVal('token', '');
$nft_token = getReqVal('nft_token', '');
$s_price = getReqVal('s_price', '');
+ $amount = getReqVal('amount', 1);
$payment_token_address = getReqVal('payment_token_address', '');
$nonce = getReqVal('nonce', '');
$signature = getReqVal('signature', '');
@@ -901,6 +924,7 @@ class MarketController extends BaseController {
'token_id' => $nft_token,
'owner_address' => $nftDetail['owner_address'],
'token_type' => $nftDetail['type'],
+ 'amount' => $amount,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
's_price' => $s_price,
@@ -934,6 +958,317 @@ class MarketController extends BaseController {
$this->_rspOk();
}
+ public function getSupportedCurrencyTypes() {
+ $types = array();
+ if (SERVER_ENV == _ONLINE) {
+ array_push($types, array(
+ 'name' => 'USDT',
+ 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093',
+ ));
+ } else {
+ array_push($types, array(
+ 'name' => 'USDT',
+ 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093',
+ ));
+ }
+ $this->_rspData(array(
+ 'list' => $types,
+ ));
+ }
+
+ public function getTransactionRecord() {
+ $account = strtolower(getReqVal('account', ''));
+ $type = getReqVal('type', 0);
+ $start = getReqVal('start', 0);
+ $page_size = getReqVal('page_size', 10);
+
+ $conn = myself()->_getMysql('');
+
+ $type_filter_fn = function ($f) {
+ if ($f==0) {
+ return '';
+ }
+ else {
+ return 'AND type=' . $f;
+ }
+ };
+
+ $counts = $conn->execQuery(
+ 'SELECT count(*) as count FROM t_market_transaction_record '.
+ 'WHERE (seller=:account OR buyer=:account) '.
+ $type_filter_fn($type).
+ ' ORDER BY createtime DESC',
+ array(
+ ':account' => $account,
+ )
+ );
+
+ $total = $counts[0]['count'];
+ $page_end = $start + $page_size;
+ if ($page_end > $total) {
+ $page_end = $total;
+ $start = $total-1;
+ $start = intval($start / $page_size) * $page_size;
+ if ($start<0) $start = 0;
+ }
+
+ $rows = $conn->execQuery(
+ 'SELECT * FROM t_market_transaction_record '.
+ 'WHERE (seller=:account OR buyer=:account) '.
+ $type_filter_fn($type).
+ ' ORDER BY createtime DESC '.
+ 'LIMIT '.$start.','.$page_size,
+ array(
+ ':account' => $account,
+ )
+ );
+
+ $this->_rspData(array(
+ "total" => $total,
+ "start" => $start,
+ "page_size" => $page_size,
+ 'nfts' => $rows,
+ ));
+ }
+
+ private function addTransactionRecord($record) {
+ $conn = myself()->_getMysql('');
+
+ $r = SqlHelper::insert(
+ $conn,
+ 't_market_transaction_record',
+ $record
+ );
+ if (!$r) {
+ $this->_rspErr(2, 'unknown error, orderId='.$record['orderid']);
+ }
+ }
+
+ public function eventSellOrder() {
+ $tokenId = getReqVal('tokenId', '');
+ $owner = strtolower(getReqVal('owner', ''));
+ $nftToken = getReqVal('nftToken', '');
+ $amount = getReqVal('amount', 0);
+ $orderId = getReqVal('orderId', '');
+ $currency = getReqVal('currency', '');
+ $price = getReqVal('price', '');
+
+ error_log("eventSellOrder:" . json_encode(
+ array(
+ 'tokenId' => $tokenId,
+ 'owner' => $owner,
+ 'nftToken' => $nftToken,
+ 'amount' => $amount,
+ 'orderId' => $orderId,
+ 'currency' => $currency,
+ 'price' => $price,
+ ),
+ JSON_PRETTY_PRINT
+ )
+ );
+
+ $conn = myself()->_getMysql('');
+
+ // 1. check order status
+ $chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId));
+ if (!empty($chk)) {
+ $this->_rspErr(1, 'repeat sell order, orderId='.$orderId);
+ return;
+ }
+
+ // 2. insert sell order to t_market_store
+ $nftDb = Nft::findNftByOwner($owner, $tokenId);
+ if (empty($nftDb)) {
+ $nftDb = Nft::getNft($tokenId);
+ }
+ $nftDetail = Nft::toDto($nftDb);
+ $detail = $this->getNftGameData($nftDb);
+ $r = SqlHelper::insert(
+ $conn,
+ 't_market_store',
+ array(
+ 'token_id' => $tokenId,
+ 'o_link' => $orderId,
+ 'nft_token' => $nftToken,
+ 'status' => 0,
+ 'owner_address' => $owner,
+ 'token_type' => $nftDetail['type'],
+ 'amount' => $amount,
+ 'createtime' => myself()->_getNowTime(),
+ 'modifytime' => myself()->_getNowTime(),
+ 's_currency' => $currency,
+ 's_price' => $price,
+ 'c_name' => $nftDetail['info']['name'],
+ 'c_job' => isset($nftDetail['info']['job']) ? $nftDetail['info']['job']
+ : (isset($detail['chip_type']) ? $detail['chip_type']
+ : (isset($detail['type'])?$detail['type']
+ :0)),
+ 'c_lv' => @$detail['gun_lv'] | @$detail['hero_lv'] | @$detail['chip_grade'],
+ 'c_quality' => isset($nftDetail['info']['quality']) ? $nftDetail['info']['quality'] : 0,
+ 'c_durability' => isset($nftDetail['info']['durability']) ? $nftDetail['info']['durability'] : (isset($detail['hero_tili']) ? $detail['hero_tili'] : 0),
+ 'c_type' => isset($detail['type']) ? $detail['type'] : 0,
+ 'c_id' => $nftDetail['item_id'],
+ )
+ );
+ if (!$r) {
+ $this->_rspErr(2, 'unknown error, orderId='.$orderId);
+ }
+
+ $this->_rspOk();
+ }
+
+ public function eventBuyOrder() {
+ $tokenId = getReqVal('tokenId', '');
+ $orderId = getReqVal('orderId', '');
+ $nftToken = getReqVal('nftToken', '');
+ $amount = getReqVal('amount', 0);
+ $seller = strtolower(getReqVal('seller', ''));
+ $buyer = strtolower(getReqVal('buyer', ''));
+ $erc20 = getReqVal('erc20', '');
+ $price = getReqVal('price', '');
+
+ error_log("eventBuyOrder:" . json_encode(
+ array(
+ 'tokenId' => $tokenId,
+ 'orderId' => $orderId,
+ 'nftToken' => $nftToken,
+ 'amount' => $amount,
+ 'seller' => $seller,
+ 'buyer' => $buyer,
+ 'erc20' => $erc20,
+ 'price' => $price,
+ ),
+ JSON_PRETTY_PRINT
+ )
+ );
+
+ $conn = myself()->_getMysql('');
+
+ // 1. check order status
+ $chk = SqlHelper::selectOne($conn, 't_market_store', array('status','idx', 'c_name', 'token_type'), array('o_link' => $orderId));
+ if (empty($chk)) {
+ $this->_rspErr(1, 'not found order, orderId='.$orderId);
+ return;
+ }
+ if ($chk['status']== '0') {
+ $r = SqlHelper::update(
+ $conn,
+ 't_market_store',
+ array(
+ 'o_link' => $orderId,
+ ),
+ array(
+ 'status' => 2,
+ )
+ );
+ if ($r) {
+ // 增加交易记录
+ $record = array(
+ 'createtime' => myself()->_getNowTime(),
+ 'orderid' => $chk['idx'],
+ 'o_link' => $orderId,
+ 'seller' => $seller,
+ 'buyer' => $buyer,
+ 'tokenid' => $tokenId,
+ 'amount' => $amount,
+ 'name' => $chk['c_name'],
+ 'type' => $chk['token_type'],
+ );
+ $this->addTransactionRecord($record);
+ $this->_rspOk();
+ return;
+ }
+ }
+ $this->_rspErr(1, 'order status error, order='.$orderId);
+ }
+
+ public function eventCancelOrder() {
+ $orderId = getReqVal('orderId', '');
+ $nftToken = getReqVal('nftToken', '');
+ $tokenId = getReqVal('tokenId', '');
+ error_log("eventCancelOrder:" . json_encode(
+ array(
+ 'orderId' => $orderId,
+ 'nftToken' => $nftToken,
+ 'tokenId' => $tokenId,
+ ),
+ JSON_PRETTY_PRINT
+ )
+ );
+
+ $conn = myself()->_getMysql('');
+
+ // 1. check order status
+ $chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId));
+ if (empty($chk)) {
+ $this->_rspErr(1, 'not found order, orderId='.$orderId);
+ return;
+ }
+ if ($chk['status']== '0') {
+ $r = SqlHelper::update(
+ $conn,
+ 't_market_store',
+ array(
+ 'o_link' => $orderId,
+ ),
+ array(
+ 'status' => 1,
+ )
+ );
+ if ($r) {
+ $this->_rspOk();
+ return;
+ }
+ }
+ $this->_rspErr(1, 'order status error, order='.$orderId);
+ }
+
+ public function eventPriceUpdateOrder() {
+ $orderId = getReqVal('orderId', '');;
+ $nftToken = getReqVal('nftToken', '');
+ $tokenId = getReqVal('tokenId', '');
+ $priceOld = getReqVal('priceOld', '');
+ $price = getReqVal('price', '');
+ error_log("eventPriceUpdateOrder:" . json_encode(
+ array(
+ 'orderId' => $orderId,
+ 'nftToken' => $nftToken,
+ 'tokenId' => $tokenId,
+ 'priceOld' => $priceOld,
+ 'price' => $price,
+ ),
+ JSON_PRETTY_PRINT
+ )
+ );
+
+ $conn = myself()->_getMysql('');
+
+ // 1. check order status
+ $chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId));
+ if (empty($chk)) {
+ $this->_rspErr(1, 'not found order, orderId='.$orderId);
+ return;
+ }
+
+ if ($chk['status']== '0') {
+ $r = SqlHelper::update(
+ $conn,
+ 't_market_store',
+ array(
+ 'o_link' => $orderId,
+ ),
+ array(
+ 's_price' => $price,
+ )
+ );
+ if ($r) {
+ $this->_rspOk();
+ return;
+ }
+ }
+
+ $this->_rspErr(1, 'price update failed, orderId='.$orderId);
+ }
private function getNftGameData($nftRowInfo) {
$t = $nftRowInfo['token_type'];
@@ -957,7 +1292,6 @@ class MarketController extends BaseController {
return array('unknown' => 'unknown game data type, cannot find data');
}
-
private function appendChipsInfo($detail) {
$detail['chips_info'] = array();
if (!empty($detail['chip_ids'])) {
@@ -972,4 +1306,44 @@ class MarketController extends BaseController {
}
return $detail;
}
+
+ private function attach_market_selling(&$row) {
+ $conn = myself()->_getMysql('');
+
+ $rows = $conn->execQuery(
+ 'SELECT * FROM t_market_store '.
+ 'WHERE token_id=:token_id AND owner_address=:owner_address AND status=:status',
+ array(
+ ':token_id' => $row['token_id'],
+ ':owner_address' => $row['owner_address'],
+ ':status' => 0,
+ )
+ );
+
+ $count = 0;
+ $link_array = array();
+ foreach ($rows as $r) {
+ $count += $r['amount'];
+ array_push($link_array, $r['o_link']);
+ }
+
+ $row['o_link'] = implode('|', $link_array);
+ $row['selling'] = $count;
+ }
+
+ private function listMySelledNfts($account, $type)
+ {
+ $conn = myself()->_getMysql('');
+
+ $rows = $conn->execQuery(
+ 'SELECT * FROM t_market_store '.
+ 'WHERE owner_address=:account AND token_type=:token_type AND status=0 ',
+ array(
+ ':account' => $account,
+ ':token_type' => $type,
+ )
+ );
+
+ return $rows;
+ }
}
diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php
index f876b9d2..e6e2ea1e 100644
--- a/webapp/controller/UserController.class.php
+++ b/webapp/controller/UserController.class.php
@@ -125,24 +125,24 @@ class UserController extends BaseAuthedController {
}
private function _addFreeItem(){
-// foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) {
-// $heroMeta = mt\Item::get($heroId);
-// if ($heroMeta) {
-// Hero::addHero($heroMeta);
-// User::upsertHeadList($heroMeta);
-// }
-// }
-// $addItems =array();
-// foreach (mt\Parameter::getListValue('creator_present_items') as $itemsStr) {
-// list($itemId, $itemNum) = explode(':', $itemsStr);
-// if ($itemNum > 0) {
-// array_push($addItems,
-// array(
-// 'item_id' => $itemId,
-// 'item_num' => $itemNum
-// ));
-// }
-// }
+ foreach (mt\Parameter::getListValue('creator_hero_id') as $heroId) {
+ $heroMeta = mt\Item::get($heroId);
+ if ($heroMeta) {
+ Hero::addHero($heroMeta);
+ User::upsertHeadList($heroMeta);
+ }
+ }
+ $addItems =array();
+ foreach (mt\Parameter::getListValue('creator_present_items') as $itemsStr) {
+ list($itemId, $itemNum) = explode(':', $itemsStr);
+ if ($itemNum > 0) {
+ array_push($addItems,
+ array(
+ 'item_id' => $itemId,
+ 'item_num' => $itemNum
+ ));
+ }
+ }
$items = array(
array(
'item_id' => V_ITEM_GOLD,
@@ -486,6 +486,36 @@ class UserController extends BaseAuthedController {
'valid_func' => function ($val, &$errCode, &$errMsg) {
return true;
}
+ ),
+ 'parachute' => array(
+ 'field_name' => 'parachute',
+ 'val_func' => function ($val) {
+ return $val;
+ },
+ 'valid_func' => function ($val, &$errCode, &$errMsg) {
+ if (User::isValidParachute($val)) {
+ return true;
+ } else {
+ $errCode = 1;
+ $errMsg = 'parachute parameter error';
+ return false;
+ }
+ }
+ ),
+ 'ring_id' => array(
+ 'field_name' => 'ring_id',
+ 'val_func' => function ($val) {
+ return $val;
+ },
+ 'valid_func' => function ($val, &$errCode, &$errMsg) {
+ if (User::isValidRing($val)) {
+ return true;
+ } else {
+ $errCode = 1;
+ $errMsg = 'ring_id parameter error';
+ return false;
+ }
+ }
)
);
$fieldsKv = array();
@@ -699,8 +729,8 @@ class UserController extends BaseAuthedController {
if ($heroMeta['normal_gift'] && !in_array($heroMeta['normal_gift'],$headList)){
array_push($headList,$heroMeta['normal_gift']);
}
- Hero::addHero($heroMeta);
- Gun::addGun($gunMeta);
+ Hero::addFreeHero($heroMeta);
+ Gun::addFreeGun($gunMeta);
$fields = array(
'hero_id' => $temp ? $temp[1] : 0,
'head_id' => $temp ? $temp[0] : 0,
diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php
index 2374b3f4..d691c8c6 100644
--- a/webapp/models/Chip.php
+++ b/webapp/models/Chip.php
@@ -11,21 +11,49 @@ require_once('mt/ChipAttr.php');
use mt;
+use mt\ChipAttr;
use phpcommon\SqlHelper;
use services\NftService;
use services\FormulaService;
class Chip extends BaseModel
{
- public static function all($type)
+ const GETED_STATE = 0;
+ const FREE_STATE = 1;
+
+ const CHIP_LV_MAX = 3;
+
+ public static function find($chipUniId)
{
- $chipList = array();
- self::getChipList(function ($row) use(&$chipList,$type) {
- if ($row['item_num'] > 0 && $row['chip_type'] == $type) {
- array_push($chipList, $row);
+ $row = SqlHelper::ormSelectOne(
+ myself()->_getSelfMysql(),
+ 't_chip',
+ array(
+ 'idx' => $chipUniId,
+ )
+ );
+ if ($row) {
+ if ($row['account_id'] != myself()->_getAccountId()) {
+ if (NftService::getChipBlance(myself()->_getOpenId(), $row['token_id']) <= 0) {
+ $row = null;
+ }
}
- });
- return $chipList;
+ }
+ return $row;
+ }
+
+ public static function update2($chipUniId, $fieldsKv){
+ if (self::find($chipUniId)) {
+ SqlHelper::update
+ (myself()->_getSelfMysql(),
+ 't_chip',
+ array(
+ 'idx' => $chipUniId,
+ ),
+ $fieldsKv
+ );
+ }
+
}
public static function findByTokenId($tokenId)
@@ -48,6 +76,16 @@ class Chip extends BaseModel
public static function getChipList($cb)
{
+ SqlHelper::ormSelect(
+ myself()->_getSelfMysql(),
+ 't_chip',
+ array(
+ 'account_id' => myself()->_getAccountId()
+ ),
+ function ($row) use($cb) {
+ $cb($row);
+ }
+ );
$sql = "select * from t_nft1155 where owner_address=:owner_address and token_id>10000000 and balance>0";
$whereKv =array(
'owner_address' => myself()->_getOpenId(),
@@ -60,6 +98,19 @@ class Chip extends BaseModel
'token_id' => $nftDb['token_id'],
)
);
+ if (!$row) {
+ $itemMeta = mt\Item::get($nftDb['item_id']);
+ if ($itemMeta) {
+ self::addNftChip($itemMeta, $nftDb['token_id']);
+ $row = SqlHelper::ormSelectOne(
+ myself()->_getSelfMysql(),
+ 't_chip',
+ array(
+ 'token_id' => $nftDb['token_id'],
+ )
+ );
+ }
+ }
if ($row){
if (! $row['activate']){
self::activateChip($row);
@@ -78,201 +129,135 @@ class Chip extends BaseModel
}
private static function activateChip($row){
- if ($row['item_num'] <= 0) {
- return;
- }
$itemMeta = mt\Item::get($row['item_id']);
if (!$itemMeta) {
return;
}
$randAttr = array();
- if (mt\Item::isRoleChipItem($itemMeta)) {
- $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$row['chip_grade']);
- }
- if (mt\Item::isGunChipItem($itemMeta)) {
- $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$row['chip_grade']);
- }
- if ($row['chip_grade'] >= 5){
- $lucky = ltrim(\services\FormulaService::getChipLuckyValue($row['chip_grade']),'-') ;
- $fieldsKv = array(
- 'supper_state'=>1,
- 'lucky_temporary'=>$lucky,
- 'chip_type' => $itemMeta['sub_type'],
- 'rand_attr' => json_encode($randAttr),
- 'activate' => 1,
- 'modifytime' => myself()->_getNowTime()
- );
- }else{
- $fieldsKv = array(
- 'chip_type' => $itemMeta['sub_type'],
- 'rand_attr' => json_encode($randAttr),
- 'activate' => 1,
- 'modifytime' => myself()->_getNowTime()
- );
- }
+ $fieldsKv = array(
+ 'item_id' => $itemMeta['id'],
+ 'item_num' => 1,
+ 'state' => self::GETED_STATE,
+ 'rand_attr' => json_encode($randAttr),
+ 'chip_grade' => 1,
+ 'chip_type' => $itemMeta['sub_type'],
+ 'activate' => 1,
+ 'modifytime' => myself()->_getNowTime()
+ );
self::update($row['token_id'],$fieldsKv);
}
public static function toDto($row)
{
- $todayGetGold = $row['today_get_gold'];
- $lastGetGoldTime = $row['last_get_gold_time'];
- if (myself()->_getDaySeconds($lastGetGoldTime) > myself()->_getNowDaySeconds()) {
- $todayGetGold = 0;
+// $todayGetGold = $row['today_get_gold'];
+// $lastGetGoldTime = $row['last_get_gold_time'];
+// if (myself()->_getDaySeconds($lastGetGoldTime) > myself()->_getNowDaySeconds()) {
+// $todayGetGold = 0;
+// }
+ $rand_attr = emptyReplace(json_decode($row['rand_attr'], true), array());
+ $chipMeta = mt\ChipAttr::getAttrByItemId($row['item_id']);
+ if ($chipMeta){
+ array_unshift($rand_attr,array(
+ 'attr_id'=>$chipMeta['attr_id'],
+ 'val' => $chipMeta['lv'.$row['chip_grade']]
+ ));
}
- $attr_pool = emptyReplace(json_decode($row['rand_attr'], true), array());
- $attrs = array();
- foreach ($attr_pool as $key=>$val){
- if ($val){
- $attr = mt\ChipAttr::getAttrById($val['attr_id'],$val['attr_type']);
- $newAttr = [
-
- 'attr_id' => $attr['attr_id'],
- 'type' => 2,
- 'val' => strval($attr['lv'.$row['chip_grade']]*$val['attr_pool_number']),
-// 'chip_name' => $attr['chip_name'],
- 'chip_type' => $attr['chip_type'],
- 'attr_num' => $attr['lv'.$row['chip_grade']],
- 'attr_pool_num' => $val['attr_pool_number'],
- ];
- array_push($attrs,$newAttr);
- }
- }
- $row['rand_attr'] = $attrs;
- $row['today_get_gold'] = $todayGetGold;
- $row['last_get_gold_time'] = $lastGetGoldTime;
- $row['chip_name'] = mt\Item::get($row['item_id'])?mt\Item::get($row['item_id'])['name']:'XXX';
-// $row['belong_to_item_id'] = self::belongsToWhereOld($row);
+ $dto = array(
+ 'idx'=> $row['idx'],
+ 'token_id'=> $row['token_id'],
+ 'item_id'=> $row['item_id'],
+ 'chip_grade'=> $row['chip_grade'],
+ 'chip_type'=> $row['chip_type'],
+ 'state'=> $row['state'],
+ 'inlay_state'=> $row['inlay_state'],
+ 'rand_attr'=> $rand_attr,
+ );
+ $dto['chip_name'] = mt\Item::get($row['item_id'])?mt\Item::get($row['item_id'])['name']:'XXX';
$nft_address = '';
- if ($row['token_id']){
+ if ($dto['token_id']){
$nft_address = SERVER_ENV == _ONLINE ? '0x73482411443E87CAC124C12A10B34e9Aaa2De168' : '0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec';
}
- $row['nft_address'] = $nft_address;
- return $row;
+ $dto['nft_address'] = $nft_address;
+ $dto['tags'] = '';
+ return $dto;
}
- public static function belongsToWhere($row){
- $tokenId = $row['token_id'];
- $sql = "select * from t_chip_plugin where chip1=:tokenId or chip2=:tokenId or chip3=:tokenId or chip4=:tokenId limit 1";
- $whereKv =array(
- 'tokenId' => $tokenId
- );
- $ChipPluginDb = myself()->_getMarketMysql()->execQuery($sql,$whereKv);
- if (!$ChipPluginDb){
- return 0;
- }
- switch ($row['chip_type']){
- case 1:{
- $heroDb = Hero::findByTokenId2($ChipPluginDb['token_id']);
- if($heroDb){
- return $heroDb['hero_id'];
- }else{
- return 0;
- }
- }
- break;
- case 2:{
- $gunDb = Gun::findByTokenId2($ChipPluginDb['token_id']);
- if($gunDb){
- return $gunDb['gun_id'];
- }else{
- return 0;
- }
- }
- break;
- default:{
- return 0;
- }
- }
- }
- public static function belongsToWhereOld($row){
- switch ($row['chip_type']){
- case 1:{
- $heroDb = array();
- Hero::getHeroList(function ($hero) use ($row,&$heroDb) {
- if ($hero['chip_ids'] && strstr($hero['chip_ids']."|",strval($row['idx']."|")) ){
- $heroDb = $hero;
- }
- });
- if($heroDb){
- return $heroDb['hero_id'];
- }else{
- return 0;
- }
- }
- break;
- case 2:{
- $gunDb = array();
- Gun::getGunList(function ($gun) use($row,&$gunDb) {
- if ($gun['chip_ids'] && strstr($gun['chip_ids']."|",strval($row['idx']."|")) ){
- $gunDb = $gun;
- }
- });
- if($gunDb){
- return $gunDb['gun_id'];
- }else{
- return 0;
- }
- }
- break;
- default:{
- return 0;
- }
- }
- }
-
- public static function addChip($itemId, $tokenId)
+ public static function addFreeChip($itemMeta)
{
+
+ return self::internalAddItem(
+ myself()->_getSelfMysql(),
+ $itemMeta,
+ myself()->_getAccountId(),
+ null,
+ self::FREE_STATE);
+ }
+
+ public static function addChip($itemMeta)
+ {
+
+ return self::internalAddItem(
+ myself()->_getSelfMysql(),
+ $itemMeta,
+ myself()->_getAccountId(),
+ null,
+ self::GETED_STATE);
+ }
+
+ public static function addNftChip($itemMeta,$tokenId)
+ {
+
return self::internalAddItem(
myself()->_getMysql($tokenId),
- $itemId,
- 1,
+ $itemMeta,
null,
- $tokenId);
+ $tokenId,
+ self::GETED_STATE);
}
- public static function internalAddItem($conn, $itemId, $itemNum, $accountId, $tokenId)
+ public static function internalAddItem($conn, $itemMeta, $accountId, $tokenId,$state)
{
- $grade = rand(1,4);//随机一个等级
- if (myself()->_isVirtualItem($itemId)) {
- return;
- }
- if ($itemNum <= 0) {
- return;
- }
- $itemMeta = mt\Item::get($itemId);
if (!$itemMeta) {
return;
}
- $randAttr = array();
- if (mt\Item::isRoleChipItem($itemMeta)) {
- $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade);
- }
- if (mt\Item::isGunChipItem($itemMeta)) {
- $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade);
- }
- $fieldsKv = array(
- 'item_id' => $itemId,
- 'item_num' => 1,
- 'rand_attr' => json_encode($randAttr),
- 'chip_grade' => $grade,
- 'chip_type' => $itemMeta['sub_type'],
- 'labour' => 0,
- 'createtime' => myself()->_getNowTime(),
- 'modifytime' => myself()->_getNowTime()
- );
- if ($accountId) {
- $fieldsKv['account_id'] = $accountId;
- }
- if ($tokenId) {
- $fieldsKv['token_id'] = $tokenId;
- }
+ if (myself()->_isVirtualItem($itemMeta['id'])) {
+ return;
+ }
+ $chipMeta = ChipAttr::getAttrByItemId($itemMeta['id']);
+ if (!$chipMeta){
+ return;
+ }
+// $randAttr = array();
+// if (mt\Item::isRoleChipItem($itemMeta)) {
+// $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade);
+// }
+// if (mt\Item::isGunChipItem($itemMeta)) {
+// $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade);
+// }
+ $randAttr = array();
+ $fieldsKv = array(
+ 'item_id' => $itemMeta['id'],
+ 'item_num' => 1,
+ 'state' => $state,
+ 'rand_attr' => json_encode($randAttr),
+ 'chip_grade' => 1,
+ 'chip_type' => $itemMeta['sub_type'],
+ 'activate' => 1,
+ 'createtime' => myself()->_getNowTime(),
+ 'modifytime' => myself()->_getNowTime()
+ );
+ if ($accountId) {
+ $fieldsKv['account_id'] = $accountId;
+ }
+ if ($tokenId) {
+ $fieldsKv['token_id'] = $tokenId;
+ }
- SqlHelper::insert
- ($conn,
- 't_chip',
- $fieldsKv
- );
+ SqlHelper::insert
+ ($conn,
+ 't_chip',
+ $fieldsKv
+ );
}
public static function getChipByTokenId($token_ids){
@@ -308,53 +293,40 @@ class Chip extends BaseModel
);
}
- public static function updateChipInlayState($token_id,$state){
- return SqlHelper::update(
- myself()->_getSelfMysql(),
- 't_chip',
- ['token_id' => $token_id],
- ['inlay_state'=>$state]
- );
+ public static function updateInlayState($idx,$page){
+ $row = self::find($idx);
+ if ($row){
+ $inlayState = array_filter (explode("|",$row['inlay_state']) );
+ if (in_array($page,$inlayState)){
+ unset($inlayState[array_search($page,$inlayState)]);
+ }else{
+ array_push($inlayState,$page);
+ }
+ self::update2($idx,array(
+ 'inlay_state' => implode('|',$inlayState)
+ ));
+ }
+
}
- public static function getChipInlay($type){
- return SqlHelper::ormSelect(
- myself()->_getSelfMysql(),
- 't_chip',
- array(
- 'chip_type' => $type,
- 'supper_state' => 0,
- 'inlay_state' => 0,
- )
- );
- }
-// public static function deleteChip($whereKv){
+// public static function updateRandAttr($accountId,$chip){
+// $attr_pool = mt\ChipAttr::generateOneAttr($chip['chip_type']);
+// $rand_attr = emptyReplace(json_decode($chip['rand_attr'], true), array());
+// array_push($rand_attr,$attr_pool);
+// $fieldsKv = [
+// 'rand_attr'=>json_encode($rand_attr)
+// ];
// SqlHelper::update(
-// myself()->_getMarketMysql(),
-// 't_nft',
-// $whereKv,
-// ['deleted'=>1]
+// myself()->_getMysql($accountId),
+// 't_chip',
+// array(
+// 'token_id' => $chip['token_id'],
+// ),
+// $fieldsKv
// );
// }
- public static function updateRandAttr($accountId,$chip){
- $attr_pool = mt\ChipAttr::generateOneAttr($chip['chip_type']);
- $rand_attr = emptyReplace(json_decode($chip['rand_attr'], true), array());
- array_push($rand_attr,$attr_pool);
- $fieldsKv = [
- 'rand_attr'=>json_encode($rand_attr)
- ];
- SqlHelper::update(
- myself()->_getMysql($accountId),
- 't_chip',
- array(
- 'token_id' => $chip['token_id'],
- ),
- $fieldsKv
- );
- }
-
public static function getChipAttr($chip_ids){
$data = ['attr_chip'=>[],'chip_core'=>[]];
if (! $chip_ids) {
diff --git a/webapp/models/ChipPage.php b/webapp/models/ChipPage.php
new file mode 100644
index 00000000..c053fa2c
--- /dev/null
+++ b/webapp/models/ChipPage.php
@@ -0,0 +1,184 @@
+_getSelfMysql(),
+ 't_chip_page',
+ array(
+ 'account_id'=> myself()->_getAccountId(),
+ 'page_id' => $page
+ )
+ );
+ if (!$row){
+ return null;
+ }
+ return $row;
+ }
+
+ public static function getList($cb){
+ SqlHelper::ormSelect(
+ myself()->_getSelfMysql(),
+ 't_chip_page',
+ array(
+ 'account_id'=> myself()->_getAccountId(),
+ ),
+ function ($row) use($cb) {
+ $cb($row);
+ }
+ );
+ }
+
+ public static function toDto($row){
+ return array(
+ 'idx' => $row['idx'],
+ 'account_id' => $row['account_id'],
+ 'page_name' => $row['page_name'],
+ 'page_id' => $row['page_id'],
+ 'createtime' => $row['createtime'],
+ );
+ }
+
+ public static function toDtoInfo($row){
+ $data = emptyReplace(json_decode($row['data'], true), array());
+ foreach ($data as &$value){
+ $chipDb = Chip::find($value['chip_id']);
+ if ( !$chipDb ) {
+ $value['chip_id'] = 0;
+ }
+ }
+ self::update($row['page_id'],array(
+ 'data' => json_encode($data)
+ ));
+ $newRow = self::find($row['page_id']);
+ $newData = emptyReplace(json_decode($newRow['data'], true), array());
+ $attrs = array();
+ foreach ($newData as $key=>$value){
+ $newData[$key]['item_id'] = 0;
+ if ($value['chip_id']){
+ $chipDb = Chip::find($value['chip_id']);
+ $newData[$key]['item_id'] = $chipDb['item_id'];
+ $chipAttrMeta = ChipAttr::getAttrByItemId($chipDb['item_id']);
+ $rand_attr = emptyReplace(json_decode($chipDb['rand_attr'], true), array());
+ array_push($attrs,array(
+ 'attr_id'=>$chipAttrMeta['attr_id'],
+ 'val'=>$chipAttrMeta['lv'.$chipDb['chip_grade']],
+ ));
+ foreach ($rand_attr as $val){
+ array_push($attrs,$val);
+ }
+ }
+ }
+ $item = [];
+ foreach ($attrs as $k=>$v){
+ if (!isset($item[$v['attr_id']])){
+ $item[$v['attr_id']] = $v;
+ }else{
+ $item[$v['attr_id']]['val']+= $v['val'];
+ }
+ }
+ $info = array(
+ 'idx' => $newRow['idx'],
+ 'page_id' => $newRow['page_id'],
+ 'page_name' => $newRow['page_name'],
+ 'data' => $newData,
+ 'attr' => $item
+ );
+ return $info;
+ }
+
+ public static function updatePage($page,$slot_id,$chip_id){
+ $row = self::find($page);
+ $data = emptyReplace(json_decode($row['data'], true), array());
+ foreach ($data as &$value){
+ if ($value['slot_id'] == $slot_id){
+ $value['chip_id'] = $chip_id;
+ }
+ }
+ SqlHelper::update
+ (myself()->_getSelfMysql(),
+ 't_chip_page',
+ array(
+ 'account_id'=> myself()->_getAccountId(),
+ 'page_id' => $page
+ ),
+ array(
+ 'data'=> json_encode($data)
+ )
+ );
+ }
+
+ public static function update($page,$fieldsKv){
+ SqlHelper::update
+ (myself()->_getSelfMysql(),
+ 't_chip_page',
+ array(
+ 'account_id'=> myself()->_getAccountId(),
+ 'page_id' => $page
+ ),
+ $fieldsKv
+ );
+ }
+
+ public static function addChipPage(){
+ $data = array();
+ $userInfo = myself()->_getOrmUserInfo();
+ for ($i=1;$i <= ChipPageService::MAX_CHIP_SLOT_NUM;$i++){
+ if ($i <= $userInfo['level']){
+ array_push(
+ $data,
+ array(
+ 'slot_id'=>$i,
+ 'state'=>1,
+ 'chip_id'=>0,
+ )
+ );
+ }else{
+ array_push(
+ $data,
+ array(
+ 'slot_id'=>$i,
+ 'state'=>0,
+ 'chip_id'=>0,
+ )
+ );
+ }
+ }
+ $rows = SqlHelper::ormSelect(
+ myself()->_getSelfMysql(),
+ 't_chip_page',
+ array(
+ 'account_id'=> myself()->_getAccountId()
+ )
+ );
+ $page_id = 1;
+ if ($rows){
+ $page_id = count($rows)+1;
+ }
+ $info = array(
+ 'account_id' => myself()->_getAccountId(),
+ 'page_name' => 'page'.$page_id,
+ 'page_id' => $page_id,
+ 'data' => json_encode($data),
+ 'createtime' => myself()->_getNowTime(),
+ 'modifytime' => myself()->_getNowTime(),
+ );
+ SqlHelper::insert(
+ myself()->_getSelfMysql(),
+ 't_chip_page',
+ $info
+ );
+ }
+}
\ No newline at end of file
diff --git a/webapp/models/Emoji.php b/webapp/models/Emoji.php
new file mode 100644
index 00000000..4313f226
--- /dev/null
+++ b/webapp/models/Emoji.php
@@ -0,0 +1,61 @@
+_getSelfMysql(),
+ 't_user_use_emoji',
+ array(
+ 'account_id'=> myself()->_getAccountId()
+ )
+ );
+ $value = array();
+ if ($row && $row['value']){
+ $value = explode('|',$row['value']) ;
+ }
+ return $value;
+ }
+
+ public static function updateEmoji($fields){
+ SqlHelper::upsert
+ (myself()->_getSelfMysql(),
+ 't_user_use_emoji',
+ array(
+ 'account_id' => myself()->_getAccountId(),
+ ),
+ array(
+ 'value' => $fields,
+ 'modifytime' => myself()->_getNowTime(),
+ ),
+ array(
+ 'account_id' => myself()->_getAccountId(),
+ 'value' => $fields,
+ 'createtime' => myself()->_getNowTime(),
+ 'modifytime' => myself()->_getNowTime(),
+ )
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/webapp/models/FragmentRecord.php b/webapp/models/FragmentRecord.php
new file mode 100644
index 00000000..6875a4a9
--- /dev/null
+++ b/webapp/models/FragmentRecord.php
@@ -0,0 +1,53 @@
+_getSelfMysql(),
+ 't_fragment_record',
+ array(
+ 'account_id' => myself()->_getAccountId(),
+ 'param' => $param,
+ )
+ );
+ $num = 0;
+ if ($row) {
+ $num = $row['value'];
+ }
+ return $num;
+ }
+
+ public static function upsertGamesNum($param,$value){
+ SqlHelper::upsert
+ (myself()->_getSelfMysql(),
+ 't_fragment_record',
+ array(
+ 'account_id' => myself()->_getAccountId(),
+ 'param' => $param
+ ),
+ array(
+ 'value' => $value,
+ 'modifytime' => myself()->_getNowDaySeconds()
+ ),
+ array(
+ 'account_id' => myself()->_getAccountId(),
+ 'param' => $param,
+ 'value' => 1,
+ 'createtime' => myself()->_getNowTime(),
+ 'modifytime' => myself()->_getNowDaySeconds()
+ )
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php
index 0290146a..eba64702 100644
--- a/webapp/models/Gun.php
+++ b/webapp/models/Gun.php
@@ -20,7 +20,7 @@ use models\ChipPlugin;
class Gun extends BaseModel {
const GETED_STATE = 0;
- const TRY_STATE = 1;
+ const FREE_STATE = 1;
const NO_LOCK = 0;
const LEVEL_LOCK = 1;
@@ -57,6 +57,11 @@ class Gun extends BaseModel {
'idx' => $gunUniId,
)
);
+ if ($row) {
+ if ($row['account_id'] != myself()->_getAccountId()) {
+ $row = null;
+ }
+ }
return $row;
}
@@ -151,6 +156,7 @@ class Gun extends BaseModel {
'account_id' => myself()->_getAccountId()
),
function ($row) use($cb) {
+ $row['tags'] = '';
$cb($row);
}
);
@@ -163,6 +169,22 @@ class Gun extends BaseModel {
'token_id' => $nftDb['token_id'],
)
);
+
+ //将NFT表的数据同步到中心化英雄表 (以后可能删除)
+ if (!$row) {
+ $itemMeta = mt\Item::get($nftDb['item_id']);
+ if ($itemMeta) {
+ self::addNftGun($itemMeta, $nftDb['token_id']);
+ $row = SqlHelper::ormSelectOne(
+ myself()->_getSelfMysql(),
+ 't_gun',
+ array(
+ 'token_id' => $nftDb['token_id'],
+ )
+ );
+ }
+ }
+
if ($row){
if ( ! $row['activate']){
self::activateGun($row);
@@ -174,6 +196,7 @@ class Gun extends BaseModel {
)
);
}
+ $row['tags'] = $nftDb['tags'];
$cb($row);
}
}
@@ -201,7 +224,6 @@ class Gun extends BaseModel {
'lock_type' => self::NO_LOCK,
'unlock_time' => 0,
'unlock_trade_time' => 0,
- 'labour' => 0,
'activate' => 1,
'modifytime' => myself()->_getNowTime()
);
@@ -250,7 +272,6 @@ class Gun extends BaseModel {
$todayMissionGetCeg = 0;
}
$gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']);
- $chipIds = ChipPlugin::getInlayChip($row['token_id']);
$dto = array(
'idx' => $row['idx'],
'token_id' => $row['token_id'],
@@ -259,15 +280,12 @@ class Gun extends BaseModel {
'gun_lv' => $row['gun_lv'],
'state' => $row['state'],
'quality' => $row['quality'],
- 'lucky' => strval($gunLucky),
'durability' => $row['durability'],
'ceg_uplimit' => 0,
'pve_ceg_uplimit' => 0,
'raw_pve_ceg_uplimit' => 0,
'attr_base' => $baseAttr,
'attr_pro' => $attrPro,
- 'attr_chip' => Chip::getChipAttr($chipIds)['attr_chip'],
- 'chip_core' => Chip::getChipAttr($chipIds)['chip_core'],
'try_count' => $row['try_count'],
'current_pvp_get_ceg' => $todayGetGold / 100,
'last_pvp_get_ceg_time' => $lastGetGoldTime,
@@ -280,10 +298,12 @@ class Gun extends BaseModel {
'unlock_lefttime' => max(0,
$unlockTime - myself()->_getNowTime()),
'unlock_trade_time' => $row['unlock_trade_time'],
- 'chip_ids' => $chipIds,
- 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],2)), //计算ceg上限所需参数
'offer_reward_state' => 0,
- 'labour' => $row['labour'],
+ 'tags' => isset($row['tags'])?$row['tags']:'',
+
+ 'lucky' => strval($gunLucky),
+ 'chip_strength_sum' => 0,
+ 'labour' => 0,
);
$dto['durability_max'] = strval(round(FormulaService::Weapon_NFT_Maximum_Durability($dto['quality'],$dto['lucky']),3));
$dto['pvp_ceg_uplimit'] = strval( round(FormulaService::getWeaponPvpDailyCegUpLimit($dto),2) );
@@ -298,25 +318,37 @@ class Gun extends BaseModel {
return $dto;
}
+ public static function addFreeGun($gunMeta)
+ {
+ return self::internalAddGun(
+ myself()->_getSelfMysql(),
+ $gunMeta,
+ myself()->_getAccountId(),
+ null,
+ self::FREE_STATE);
+ }
+
public static function addGun($gunMeta)
{
return self::internalAddGun(
myself()->_getSelfMysql(),
$gunMeta,
myself()->_getAccountId(),
- null);
+ null,
+ self::GETED_STATE);
}
-// public static function addNftGun($gunMeta, $tokenId)
-// {
-// return self::internalAddGun(
-// myself()->_getMysql($tokenId),
-// $gunMeta,
-// null,
-// $tokenId);
-// }
+ public static function addNftGun($gunMeta, $tokenId)
+ {
+ return self::internalAddGun(
+ myself()->_getMysql($tokenId),
+ $gunMeta,
+ null,
+ $tokenId,
+ self::GETED_STATE);
+ }
- private static function internalAddGun($conn, $gunMeta, $accountId, $tokenId)
+ private static function internalAddGun($conn, $gunMeta, $accountId, $tokenId,$state)
{
$randAttr = array();
{
@@ -329,13 +361,12 @@ class Gun extends BaseModel {
'gun_id' => $gunMeta['id'],
'gun_lv' => 1,
'quality' => 1,
- 'state' => self::GETED_STATE,
+ 'state' => $state,
'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)),
'rand_attr' => json_encode($randAttr),
'lock_type' => self::NO_LOCK,
'unlock_time' => 0,
'unlock_trade_time' => 0,
- 'labour' => 0,
'activate' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
@@ -377,7 +408,7 @@ class Gun extends BaseModel {
'gun_id' => $gunMeta['id'],
'gun_lv' => 1,
'quality' => 1,
- 'state' => self::TRY_STATE,
+ 'state' => self::FREE_STATE,
'try_count' => $tryCount,
'durability' => $gunMeta['init_durability'],
'rand_attr' => json_encode($randAttr),
@@ -667,9 +698,7 @@ class Gun extends BaseModel {
$todayPveGetCeg = 0;
}
$gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($row['quality']);
- $chipIds = ChipPlugin::getInlayChip($row['token_id']);
- $attr_chip= Chip::getChipAttr($chipIds)['attr_chip'];
- $chip_core= Chip::getChipAttr($chipIds)['chip_core'];
+
$rand_attr = $baseAttr;
if ($attrPro){
@@ -681,20 +710,7 @@ class Gun extends BaseModel {
}
}
}
- if ($attr_chip){
- $rand_attr = self::_mergeArr(array_merge($rand_attr,$attr_chip));
- }
- if ($chip_core){
- $coreAttr = array();
- foreach ($chip_core as $value){
- array_push($coreAttr,array(
- 'attr_id'=>$value['attr_id'],
- 'type'=>$value['attr_add_type'],
- 'val'=>$value['attr_number'],
- ));
- }
- $rand_attr = self::_mergeArr(array_merge($rand_attr,$coreAttr));
- }
+
$info = array(
'idx' => $row['idx'],
'token_id' => $row['token_id'],
@@ -707,10 +723,9 @@ class Gun extends BaseModel {
'lucky' => strval($gunLucky),
'durability' => $row['durability'],
'rand_attr' => array_values($rand_attr),
- 'chip_core' => $chip_core ? $coreAttr : $chip_core,
'current_pvp_get_ceg' => $todayGetGold / 100,
'current_pve_get_ceg' => $todayPveGetCeg / 100,
- 'chip_ids' => $chipIds,
+ 'chip_ids' => $row['chip_ids'],
'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],2)), //计算ceg上限所需参数
'labour' => $row['labour'],
);
diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php
index f0d2a24c..fefcf3c5 100644
--- a/webapp/models/Hero.php
+++ b/webapp/models/Hero.php
@@ -5,6 +5,7 @@ namespace models;
require_once('mt/Hero.php');
require_once('mt/HeroLevelAttr.php');
require_once('mt/HeroQuality.php');
+require_once('mt/HeroLevel.php');
require_once('mt/AttrHelper.php');
require_once('mt/Item.php');
require_once('mt/SkillCommon.php');
@@ -27,13 +28,17 @@ use models\ChipPlugin;
class Hero extends BaseModel {
const GETED_STATE = 0;
- const TRY_STATE = 1;
+ const FREE_STATE = 1;
const NO_LOCK = 0;
const LEVEL_LOCK = 1;
const QUALITY_LOCK = 2;
const SEND_LOCK = 3;
const COST_LOCK = 4;
+ //需要材料所需等级
+ const LV_1 = 4;
+ const LV_2 = 9;
+ const LV_3 = 14;
public static function find($heroUniId)
{
@@ -48,6 +53,11 @@ class Hero extends BaseModel {
'idx' => $heroUniId,
)
);
+ if ($row) {
+ if ($row['account_id'] != myself()->_getAccountId()) {
+ $row = null;
+ }
+ }
return $row;
}
@@ -137,6 +147,7 @@ class Hero extends BaseModel {
'account_id' => myself()->_getAccountId()
),
function ($row) use($cb) {
+ $row['tags'] = '';
$cb($row);
}
);
@@ -149,6 +160,22 @@ class Hero extends BaseModel {
'token_id' => $nftDb['token_id'],
)
);
+
+ //将NFT表的数据同步到中心化英雄表 (以后可能删除)
+ if (!$row) {
+ $itemMeta = mt\Item::get($nftDb['item_id']);
+ if ($itemMeta) {
+ self::addNftHero($itemMeta, $nftDb['token_id']);
+ $row = SqlHelper::ormSelectOne(
+ myself()->_getSelfMysql(),
+ 't_hero',
+ array(
+ 'token_id' => $nftDb['token_id'],
+ )
+ );
+ }
+ }
+
if ($row) {
if (!$row['activate']) {
self::activateHero($row);
@@ -160,6 +187,7 @@ class Hero extends BaseModel {
)
);
}
+ $row['tags'] = $nftDb['tags'];
$cb($row);
}
}
@@ -183,8 +211,6 @@ class Hero extends BaseModel {
'lock_type' => self::NO_LOCK,
'unlock_time' => 0,
'unlock_trade_time' => 0,
- 'skill_points' => 0,
- 'labour' => 0,
'activate' => 1,
'modifytime' => myself()->_getNowTime()
);
@@ -206,24 +232,30 @@ class Hero extends BaseModel {
$unlockTime = $row['unlock_time'];
}
- $qualityMeta = mt\HeroQuality::getByQuality($row['quality']);
+ $levelMeta = mt\HeroLevel::getByLevel($row['hero_lv']);
$todayGetGold = $row['today_get_gold'];
$lastGetGoldTime = $row['last_get_gold_time'];
if (myself()->_getDaySeconds($lastGetGoldTime) <
myself()->_getNowDaySeconds()) {
$todayGetGold = 0;
}
- $todayPveGetCeg = $row['today_pve_get_ceg'];
- $lastPveGetCegTime = $row['last_pve_get_ceg_time'];
- if (myself()->_getDaySeconds($lastPveGetCegTime) <
- myself()->_getNowDaySeconds()) {
- $todayPveGetCeg = 0;
- }
- $todayMissionGetCeg = $row['today_mission_get_ceg'];
- $lastMissionGetCegTime = $row['last_mission_get_ceg_time'];
- if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) {
- $todayMissionGetCeg = 0;
+
+ {
+ $todayPveGetCeg = $row['today_pve_get_ceg'];
+ $lastPveGetCegTime = $row['last_pve_get_ceg_time'];
+ if (myself()->_getDaySeconds($lastPveGetCegTime) <
+ myself()->_getNowDaySeconds()) {
+ $todayPveGetCeg = 0;
+ }
+ $todayMissionGetCeg = $row['today_mission_get_ceg'];
+ $lastMissionGetCegTime = $row['last_mission_get_ceg_time'];
+ if (myself()->_getDaySeconds($lastMissionGetCegTime) < myself()->_getNowDaySeconds()) {
+ $todayMissionGetCeg = 0;
+ }
}
+
+
+
$baseAttr=[];
$attrPro=[];
$heroMeta = mt\Hero::get($row['hero_id']);
@@ -239,15 +271,6 @@ class Hero extends BaseModel {
}
$attrPro = self::mergeAttrPro($baseAttr,$attrPro1,$attrPro2);
}
- $skill_common = explode("|",$row['skill_common']);
- $attr_skill = [];
- foreach ($skill_common as $val){
- $item = mt\SkillCommon::getAttrBySkillCommon($val);
- if ($item){
- array_push($attr_skill,$item);
- }
- }
- $chipIds = ChipPlugin::getInlayChip($row['token_id']);
$heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']);
$dto = array(
'idx' => $row['idx'],
@@ -263,29 +286,30 @@ class Hero extends BaseModel {
'skill_lv2' => $row['skill_lv2'],
'attr_base' => $baseAttr,
'attr_pro' => $attrPro,
- 'attr_skill' => $attr_skill,
- 'attr_chip' => Chip::getChipAttr($chipIds)['attr_chip'],
- 'chip_core' => Chip::getChipAttr($chipIds)['chip_core'],
'try_count' => $row['try_count'],
'lock_type' => $lockType,
'unlock_time' => $unlockTime,
'unlock_lefttime' => max(0,
$unlockTime - myself()->_getNowTime()),
+ 'current_get_gold' => $todayGetGold / 100,
+ 'last_get_gold_time' => $lastGetGoldTime,
+ 'gold_uplimit' => $levelMeta['gold_limit'],
+ 'unlock_trade_time' => $row['unlock_trade_time'],
+ 'advanced_count' => $row['advanced_count'],
+ 'offer_reward_state' => 0,
+ 'tags' => isset($row['tags'])?$row['tags']:'',
+
+ //暂留(以下弃用字段)
'current_pvp_get_ceg' => $todayGetGold / 100,
'last_pvp_get_ceg_time' => $lastGetGoldTime,
'current_pve_get_ceg' => $todayPveGetCeg / 100,
'last_pve_get_ceg_time' => $lastPveGetCegTime,
'current_mission_get_ceg' => $todayMissionGetCeg / 100,
'last_mission_get_ceg_time' => $lastMissionGetCegTime,
- 'unlock_trade_time' => $row['unlock_trade_time'],
- 'advanced_count' => $row['advanced_count'],
'lucky' => $heroLucky,
- 'chip_ids' => $chipIds,
- 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],1)), //计算ceg上限所需参数
- 'skill_common' => $skill_common,
- 'skill_points' => $row['skill_points'],
- 'offer_reward_state' => 0,
- 'labour' => $row['labour'],
+ 'chip_strength_sum' => 0,
+ 'labour' => 0,
+
);
$dto['hero_tili_max'] = strval(round(FormulaService::Hero_NFT_Maximum_Physical_Strength($dto['quality'],$dto['lucky']),3));
$dto['pvp_ceg_uplimit'] =strval( round(FormulaService::getHeroPvpDailyCegUpLimit($dto),2) );
@@ -300,26 +324,46 @@ class Hero extends BaseModel {
return $dto;
}
+ public static function addFreeHero($heroMeta)
+ {
+ return self::internalAddHero(
+ myself()->_getSelfMysql(),
+ $heroMeta,
+ myself()->_getAccountId(),
+ null,
+ self::FREE_STATE);
+ }
+
public static function addHero($heroMeta)
{
return self::internalAddHero(
myself()->_getSelfMysql(),
$heroMeta,
myself()->_getAccountId(),
- null);
+ null,
+ self::GETED_STATE);
}
-// public static function addNftHero($heroMeta, $tokenId)
-// {
-// return self::internalAddHero(
-// myself()->_getMysql($tokenId),
-// $heroMeta,
-// null,
-// $tokenId);
-// }
-
- public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId)
+ public static function addNftHero($heroMeta, $tokenId)
{
+ return self::internalAddHero(
+ myself()->_getMysql($tokenId),
+ $heroMeta,
+ null,
+ $tokenId,
+ self::GETED_STATE);
+ }
+
+ public static function internalAddHero($conn, $heroMeta, $accountId, $tokenId,$state)
+ {
+ $skinItemMeta = \mt\Item::getMetaListByType(\mt\Item::HERO_SKIN_TYPE);
+ if ($skinItemMeta){
+ foreach ($skinItemMeta as $value){
+ if ($value['playerid'] == $heroMeta['id'] && $value['isdefaultskin'] ==1){
+ HeroSkin::addSkin($value);
+ }
+ }
+ }
$realHeroMeta = mt\Hero::get($heroMeta['id']);
$randAttr = array();
$fieldsKv = array(
@@ -327,15 +371,13 @@ class Hero extends BaseModel {
'hero_lv' => 1,
'quality' => 1,
'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)),
- 'state' => self::GETED_STATE,
+ 'state' => $state,
'skill_lv1' => 1,
'skill_lv2' => 1,
'rand_attr' => json_encode($randAttr),
'lock_type' => self::NO_LOCK,
'unlock_time' => 0,
'unlock_trade_time' => 0,
- 'skill_points' => 0,
- 'labour' => 0,
'activate' => 1,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
@@ -354,69 +396,6 @@ class Hero extends BaseModel {
);
}
- public static function addTryHero($heroMeta, $tryCount)
- {
- $realHeroMeta = mt\Hero::get($heroMeta['id']);
- $randAttr = array();
- {
- $initQualityMeta = mt\HeroQuality::getByQuality(1);
- if ($initQualityMeta) {
- $randAttr = mt\HeroQuality::getRandAttr($initQualityMeta);
- }
- }
- SqlHelper::upsert(
- myself()->_getSelfMysql(),
- 't_hero',
- array(
- 'account_id' => myself()->_getAccountId(),
- 'hero_id' => $heroMeta['id']
- ),
- array(
- ),
- array(
- 'account_id' => myself()->_getAccountId(),
- 'hero_id' => $heroMeta['id'],
- 'hero_lv' => 1,
- 'quality' => 1,
- 'hero_tili' => $realHeroMeta ? $realHeroMeta['tili'] : 0,
- 'state' => self::TRY_STATE,
- 'try_count' => $tryCount,
- 'skill_lv1' => 1,
- 'skill_lv2' => 1,
- 'rand_attr' => json_encode($randAttr),
- 'lock_type' => self::NO_LOCK,
- 'unlock_time' => 0,
- 'unlock_trade_time' => 0,
- 'createtime' => myself()->_getNowTime(),
- 'modifytime' => myself()->_getNowTime()
- )
- );
- }
-
- public static function takeonSkin($heroUniId, $skinId)
- {
- self::update($heroUniId, array(
- 'skin_id' => $skinId,
- 'modifytime' => myself()->_getNowTime()
- ));
- }
-
- public static function upgradeSkill($heroUniId, $skillIdx,$skill_points)
- {
- if (!in_array($skillIdx, array(0, 1))) {
- return;
- }
- $fieldName = 'skill_lv' . ($skillIdx + 1);
- self::update($heroUniId, array(
- $fieldName => function () use($fieldName) {
- return "${fieldName} + 1";
- },
- 'skill_points' => function() use ($skill_points){
- return "GREATEST(0, skill_points - ${skill_points})";
- },
- 'modifytime' => myself()->_getNowTime()
- ));
- }
public static function update($heroUniId, $fieldsKv)
{
@@ -611,13 +590,6 @@ class Hero extends BaseModel {
foreach ($baseAttr as $val){
foreach ($attr as $v){
$coef_level = mt\HeroLevelAttr::getByCoefficient($coefficient_level,$val['attr_id']);
-// if ($val['attr_id'] == $v['attr_id'] && $val['attr_id'] == kHAT_Atk){ //18 //18.941564456287 //20.847692307692
-// array_push($attrPro1,[
-// 'attr_id' => $val['attr_id'],
-// 'type'=> $val['type'],
-// 'val' => strval($val['val']*$v['val']+$v['val']/$coef_level['val']*100-100/$coef_level['val']),
-// ]);
-// }
//&& $val['attr_id'] != kHAT_Atk
if ( $val['attr_id'] == $v['attr_id'] ){
array_push($attrPro1,[
@@ -638,20 +610,6 @@ class Hero extends BaseModel {
foreach ($baseAttr as $val){
$coef_quality = mt\HeroQuality::getByCoefficient($coefficient_quality,$val['attr_id']);
if ($coef_quality){
-// if ($val['attr_id'] == kHAT_Atk){
-// array_push($attrPro2,[
-// 'attr_id' => $val['attr_id'],
-// 'type'=> $val['type'],
-// 'val' => strval($val['val']*$qualityMeta['promote_val']+$qualityMeta['promote_val']/$coef_quality['val']*100-100/$coef_quality['val']),
-// ]);
-// }
-// if ($val['attr_id'] != kHAT_Atk) {
-// array_push($attrPro2, [
-// 'attr_id' => $val['attr_id'],
-// 'type' => $val['type'],
-// 'val' => strval($val['val'] * pow($qualityMeta['promote_val'], $coef_quality['val'])),
-// ]);
-// }
array_push($attrPro2, [
'attr_id' => $val['attr_id'],
'type' => $val['type'],
@@ -711,9 +669,6 @@ class Hero extends BaseModel {
array_push($attr_skill,$item);
}
}
- $chipIds = ChipPlugin::getInlayChip($row['token_id']);
- $attr_chip= Chip::getChipAttr($chipIds)['attr_chip'];
- $chip_core= Chip::getChipAttr($chipIds)['chip_core'];
$rand_attr = $baseAttr;
if ($attrPro){
@@ -728,20 +683,7 @@ class Hero extends BaseModel {
if ($attr_skill){
$rand_attr = self::_mergeArr(array_merge($rand_attr,$attr_skill));
}
- if ($attr_chip){
- $rand_attr = self::_mergeArr(array_merge($rand_attr,$attr_chip));
- }
- if ($chip_core){
- $coreAttr = array();
- foreach ($chip_core as $value){
- array_push($coreAttr,array(
- 'attr_id'=>$value['attr_id'],
- 'type'=>$value['attr_add_type'],
- 'val'=>$value['attr_number'],
- ));
- }
- $rand_attr = self::_mergeArr(array_merge($rand_attr,$coreAttr));
- }
+
$heroLucky = \services\FormulaService::Hero_Advanced_Lucky_Value($row['quality']);
$info = array(
'idx' => $row['idx'],
@@ -753,18 +695,15 @@ class Hero extends BaseModel {
'hero_tili' => $row['hero_tili'],
'quality' => $row['quality'],
'rand_attr' => array_values($rand_attr),
- 'chip_core' => $chip_core ? $coreAttr : $chip_core,
// 'attr_base' => $baseAttr,
// 'attr_pro' => $attrPro,
// 'attr_skill' => $attr_skill,
-// 'attr_chip' => Chip::getChipAttr($chipIds)['attr_chip'],
-// 'chip_core' => Chip::getChipAttr($chipIds)['chip_core'],
'current_pvp_get_ceg' => $todayGetGold / 100,
'current_pve_get_ceg' => $todayPveGetCeg / 100,
'advanced_count' => $row['advanced_count'],
'lucky' => strval($heroLucky),
- 'chip_ids' => $chipIds,
- 'chip_strength_sum' => strval(Chip::getChipMaxStrength($chipIds,1)), //计算ceg上限所需参数
+ 'chip_ids' => $row['chip_ids'],
+ 'chip_strength_sum' => strval(Chip::getChipMaxStrength($row['chip_ids'],1)), //计算ceg上限所需参数
'skill_points' => $row['skill_points'],
'labour' => $row['labour'],
);
@@ -793,4 +732,14 @@ class Hero extends BaseModel {
}
}
+ public static function getHeroByItemId($itemId){
+ $hero = array();
+ self::getHeroList(function ($row) use (&$hero,$itemId) {
+ if ($row['hero_id'] == $itemId) {
+ array_push($hero,$row);
+ }
+ });
+ return $hero;
+ }
+
}
diff --git a/webapp/models/HeroSkin.php b/webapp/models/HeroSkin.php
index b6db2bd9..dedd5be6 100644
--- a/webapp/models/HeroSkin.php
+++ b/webapp/models/HeroSkin.php
@@ -25,13 +25,69 @@ class HeroSkin extends BaseModel {
return $row;
}
- public static function toDto($row)
+ public static function findBx($heroId)
{
- return array(
- 'skin_id' => $row['skin_id'],
- 'skin_state' => $row['skin_state'],
- 'try_expire_at' => $row['try_expire_at'],
+ $row = SqlHelper::ormSelectOne(
+ myself()->_getSelfMysql(),
+ 't_hero_skin',
+ array(
+ 'account_id' => myself()->_getAccountId(),
+ 'hero_id' => $heroId
+ )
);
+ return $row;
+ }
+
+ public static function takeonSkin($skinId,$heroId){
+ $row = self::findBx($heroId);
+ SqlHelper::update(
+ myself()->_getSelfMysql(),
+ 't_hero_skin',
+ array(
+ 'account_id' => myself()->_getAccountId(),
+ 'skin_id' => $row['skin_id']
+ ),
+ array(
+ 'hero_id'=>0
+ )
+ );
+ SqlHelper::update(
+ myself()->_getSelfMysql(),
+ 't_hero_skin',
+ array(
+ 'account_id' => myself()->_getAccountId(),
+ 'skin_id' => $skinId
+ ),
+ array(
+ 'hero_id'=>$heroId
+ )
+ );
+ }
+
+
+ public static function getSkinList($cb){
+ SqlHelper::ormSelect(
+ myself()->_getSelfMysql(),
+ 't_hero_skin',
+ array(
+ 'account_id' => myself()->_getAccountId()
+ ),
+ function ($row) use($cb) {
+ $cb($row);
+ }
+ );
+ }
+
+
+ public static function toDto($meta)
+ {
+ $row = self::find($meta['id']);
+ $array = array(
+ 'skin_id'=>$meta['id'],
+ 'is_have' => $row?1:0,
+ 'use_state' => $row['hero_id']?1:0,
+ );
+ return $array;
}
public static function addSkin($itemMeta)
@@ -43,10 +99,7 @@ class HeroSkin extends BaseModel {
'account_id' => myself()->_getAccountId(),
'skin_id' => $itemMeta['id']
),
- array(
- 'skin_state' => 3,
- 'modifytime' => myself()->_getNowTime()
- ),
+ array(),
array(
'account_id' => myself()->_getAccountId(),
'skin_id' => $itemMeta['id'],
@@ -54,6 +107,7 @@ class HeroSkin extends BaseModel {
'get_from' => 0,
'consume_num' => 0,
'try_expire_at' => 0,
+ 'hero_id' => 0,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime()
)
diff --git a/webapp/models/Parachute.php b/webapp/models/Parachute.php
index 5c7a97fc..286dbfa2 100644
--- a/webapp/models/Parachute.php
+++ b/webapp/models/Parachute.php
@@ -8,14 +8,25 @@ use mt;
use phpcommon\SqlHelper;
class Parachute extends BaseModel
{
+ public static $parachute = '170001'; //默认降落伞
+
public static function getMyParachute(){
- return SqlHelper::ormSelect(
+ $list = array(
+ self::$parachute
+ );
+ $rows = SqlHelper::ormSelect(
myself()->_getSelfMysql(),
't_parachute',
array(
'account_id' => myself()->_getAccountId(),
)
);
+ if ($rows){
+ foreach ($rows as $row){
+ array_push($list, $row['item_id']);
+ }
+ }
+ return $list;
}
public static function addParachute($itemMeta){
if ($itemMeta){
diff --git a/webapp/models/User.php b/webapp/models/User.php
index 5b0c3729..03607a56 100644
--- a/webapp/models/User.php
+++ b/webapp/models/User.php
@@ -3,12 +3,15 @@
namespace models;
require_once('mt/Item.php');
+require_once('mt/LevelUp.php');
require_once('models/UserSeasonRing.php');
+require_once('models/Parachute.php');
use mt;
use phpcommon;
use phpcommon\SqlHelper;
use models\UserSeasonRing;
+use models\Parachute;
class User extends BaseModel {
@@ -38,6 +41,7 @@ class User extends BaseModel {
public static function show($row)
{
+ mt\LevelUp::getExpByLv($row['level'],$row['exp']);
return array(
'activated' => $row['activated'],
'rename_count' => $row['rename_count'],
@@ -48,7 +52,6 @@ class User extends BaseModel {
'head_frame' => $row['head_frame'],
'level' => $row['level'],
'exp' => $row['exp'],
- 'max_exp' => $row['exp'] + 1000,
'rank' => $row['rank'],
'history_best_rank' => $row['history_best_rank'],
'score' => $row['score'],
@@ -69,11 +72,16 @@ class User extends BaseModel {
'guild_id' => $row['guild_id'],
'guild_job' => $row['guild_job'],
'guild_name' => $row['guild_name'],
+ 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute,
+ 'parachute_list' => Parachute::getMyParachute(),
+ 'ring_id' => $row['ring_id'],
+ 'ring_list' => UserSeasonRing::ringList($row['account_id']),
);
}
public static function info($row)
{
+ mt\LevelUp::getExpByLv($row['level'],$row['exp']);
return array(
'activated' => $row['activated'],
'rename_count' => $row['rename_count'],
@@ -84,7 +92,6 @@ class User extends BaseModel {
'head_frame' => $row['head_frame'],
'level' => $row['level'],
'exp' => $row['exp'],
- 'max_exp' => $row['exp'] + 1000,
'rank' => $row['rank'],
'history_best_rank' => $row['history_best_rank'],
'score' => $row['score'],
@@ -106,7 +113,10 @@ class User extends BaseModel {
'guild_id' => $row['guild_id'],
'guild_job' => $row['guild_job'],
'guild_name' => $row['guild_name'],
- 'ring_list' => UserSeasonRing::ringList($row['account_id'])
+ 'ring_id' => $row['ring_id'],
+ 'ring_list' => UserSeasonRing::ringList($row['account_id']),
+ 'parachute' => $row['parachute'] ? $row['parachute'] : Parachute::$parachute,
+ 'parachute_list' => Parachute::getMyParachute(),
);
}
@@ -150,6 +160,16 @@ class User extends BaseModel {
return in_array($headFrame, $headFrameList);
}
+ public static function isValidParachute($parachute){
+ $parachuteList = Parachute::getMyParachute();
+ return in_array($parachute, $parachuteList);
+ }
+
+ public static function isValidRing($parachute){
+ $ringList = UserSeasonRing::ringList(myself()->_getAccountId());
+ return in_array($parachute, $ringList);
+ }
+
private static function getHeadList($userInfo)
{
$headList = emptyReplace(json_decode($userInfo['head_list'], true), array());
diff --git a/webapp/mt/ChipAttr.php b/webapp/mt/ChipAttr.php
index 7674b4c1..fcef3d37 100644
--- a/webapp/mt/ChipAttr.php
+++ b/webapp/mt/ChipAttr.php
@@ -30,120 +30,85 @@ class ChipAttr {
return self::$attrPoolList;
}
- public static function getAttrPool($attr){
- $attr_pool = array();
+ public static function getAttrPool($chip){
+ $temp = array();
+ $attrWeight = 0;
foreach (self::getAttrPoolList() as $item){
- if ($item['attr_id'] == $attr['attr_id'] && $item['attr_type'] == $attr['chip_type'] ){
- $attr_pool = $item;
+ if ($item['chip_type'] == $chip['chip_type']){
+ $attrWeight += $item['attr_weight'];
+ for ($i = 0; $i < $item['attr_weight']; $i++) {
+ $temp[] = $item;
+ }
}
}
+ $attr_pool = $temp[rand(0, $attrWeight -1)];
if ($attr_pool){
- $attr_pool['weight'] = explode('|',$attr_pool['weight']);
- foreach ($attr_pool['weight'] as $key =>$item){
- $attr_pool['weight'][$key] = explode(':',$item);
+ $attr_pool['num_weight'] = explode('|',$attr_pool['num_weight']);
+ foreach ($attr_pool['num_weight'] as $key =>$item){
+ $attr_pool['num_weight'][$key] = explode(':',$item);
}
-
$weight = 0;
$tempData = array ();
- foreach ($attr_pool['weight'] as $one) {
+ foreach ($attr_pool['num_weight'] as $one) {
$weight += $one[1];
for ($i = 0; $i < $one[1]; $i++) {
$tempData[] = $one;
+
}
}
$k = rand(0, $weight -1);
- $attr_pool['attr_pool_number'] = $tempData[$k][0];
- unset($attr_pool['weight']);
+ $attr_pool['val'] = $tempData[$k][0];
+ unset($attr_pool['num_weight']);
}
return $attr_pool;
}
- public static function generateAttrRandom($itemMeta,$chip_grade){
- if ($itemMeta['sub_type'] == self::ROLE_CHIP_SUBTYPE){
- $chip = self::getNodeChip();
- return self::_randomNum($itemMeta,$chip_grade,$chip);
- }
- if ($itemMeta['sub_type'] == self::GUN_CHIP_SUBTYPE){
- $chip = self::getGunChip();
- return self::_randomNum($itemMeta,$chip_grade,$chip);
- }
- return array();
- }
- public static function getAttrById($attr_id,$attr_type){
- if($attr_type == self::ROLE_CHIP_SUBTYPE){
- $chip = self::getNodeChip();
- }
- if($attr_type == self::GUN_CHIP_SUBTYPE){
- $chip = self::getGunChip();
- }
- foreach ($chip as $item) {
- if ($item['attr_id'] == $attr_id && $item['chip_type'] == $attr_type){
- return $item;
- }
- }
- }
- public static function generateOneAttr($type){
-// $itemMeta = Item::get($item_id);
-// return self::getAttrPool(self::getAttrByItemId($itemMeta['id']));
+// public static function generateOneAttr($type){
+//// $itemMeta = Item::get($item_id);
+//// return self::getAttrPool(self::getAttrByItemId($itemMeta['id']));
+//
+//// $attr_pool = self::getAttrPool(self::getAttrByItemId($itemMeta['id']));
+//// $attr = emptyReplace(json_decode($chip['rand_attr'], true), array());
+//// array_push($attr,$attr_pool);
+//// return $attr;
+// if ($type == self::ROLE_CHIP_SUBTYPE){
+// $chip = self::getNodeChip();
+// $attr = $chip[ array_rand($chip)];
+// return self::getAttrPool($attr);
+// }
+// if ($type == self::GUN_CHIP_SUBTYPE){
+// $chip = self::getGunChip();
+// $attr = $chip[ array_rand($chip)];
+// return self::getAttrPool($attr);
+// }
+// return array();
+// }
+//
+//
+//
+// private static function getNodeChip(){
+// $node_chip = array();
+// foreach (self::getMetaList() as $item){
+// if ($item['chip_type'] == self::ROLE_CHIP_SUBTYPE){
+// array_push($node_chip,$item);
+// }
+// }
+// return $node_chip;
+// }
+//
+// private static function getGunChip(){
+// $gun_chip = array();
+// foreach (self::getMetaList() as $item){
+// if ($item['chip_type'] == self::GUN_CHIP_SUBTYPE){
+// array_push($gun_chip,$item);
+// }
+// }
+// return $gun_chip;
+// }
-// $attr_pool = self::getAttrPool(self::getAttrByItemId($itemMeta['id']));
-// $attr = emptyReplace(json_decode($chip['rand_attr'], true), array());
-// array_push($attr,$attr_pool);
-// return $attr;
- if ($type == self::ROLE_CHIP_SUBTYPE){
- $chip = self::getNodeChip();
- $attr = $chip[ array_rand($chip)];
- return self::getAttrPool($attr);
- }
- if ($type == self::GUN_CHIP_SUBTYPE){
- $chip = self::getGunChip();
- $attr = $chip[ array_rand($chip)];
- return self::getAttrPool($attr);
- }
- return array();
- }
-
- private static function _randomNum($itemMeta,$chip_grade,$chipList){
- $attr_pool = array();
- array_push($attr_pool,self::getAttrPool(self::getAttrByItemId($itemMeta['id'])));
- if ($chip_grade>=3){
- if ($chip_grade<5){
- $num = 1;
- }
- if ($chip_grade>=5){
- $num = 2;
- }
- for ($i=1;$i<=$num;$i++){
- $attr = $chipList[ array_rand($chipList)];
- array_push($attr_pool,self::getAttrPool($attr));
- }
- }
- return $attr_pool ;
- }
-
- private static function getNodeChip(){
- $node_chip = array();
- foreach (self::getMetaList() as $item){
- if ($item['chip_type'] == self::ROLE_CHIP_SUBTYPE){
- array_push($node_chip,$item);
- }
- }
- return $node_chip;
- }
-
- private static function getGunChip(){
- $gun_chip = array();
- foreach (self::getMetaList() as $item){
- if ($item['chip_type'] == self::GUN_CHIP_SUBTYPE){
- array_push($gun_chip,$item);
- }
- }
- return $gun_chip;
- }
-
- private static function getAttrByItemId($item_id){
+ public static function getAttrByItemId($item_id){
foreach (self::getMetaList() as $item){
if ($item['item_id'] == $item_id){
return $item;
diff --git a/webapp/mt/LevelUp.php b/webapp/mt/LevelUp.php
new file mode 100644
index 00000000..2092597a
--- /dev/null
+++ b/webapp/mt/LevelUp.php
@@ -0,0 +1,37 @@
+ 0){
+ for ($i=1;$i<=count($meta);$i++){
+ if ($exp > $meta[count($meta)]['total_exp']){
+ $exp = min($exp, $meta[count($meta)]['total_exp']);
+ $lv = $meta[count($meta)]['id'];
+ }else{
+ if ($exp >= $meta[$i]['total_exp'] &&
+ $exp < $meta[$i+1]['total_exp'])
+ {
+ $lv = $meta[$i]['id'];
+ }
+ }
+ }
+ }
+ }
+
+ protected static function getMetaList()
+ {
+ if (!self::$metaList) {
+ self::$metaList = getMetaTable('levelup@levelup.php');
+ }
+ return self::$metaList;
+ }
+
+ protected static $metaList;
+
+}
\ No newline at end of file
diff --git a/webapp/mt/Skill.php b/webapp/mt/Skill.php
index 30fe2a37..e047f198 100644
--- a/webapp/mt/Skill.php
+++ b/webapp/mt/Skill.php
@@ -6,11 +6,23 @@ use phpcommon;
class Skill {
+ const DEFAULT_SKILL = 10101;
public static function get($id)
{
return getXVal(self::getMetaList(), $id);
}
+ public static function getPresetSkill()
+ {
+ $list = array();
+ foreach (self::getMetaList() as $value){
+ if ($value['skill_id'] < 20000){
+ array_push($list,$value);
+ }
+ }
+ return $list;
+ }
+
protected static function getMetaList()
{
if (!self::$metaList) {
diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php
index 4f9019af..2e358814 100644
--- a/webapp/services/BattleDataService.php
+++ b/webapp/services/BattleDataService.php
@@ -15,6 +15,7 @@ require_once('mt/AttrHelper.php');
require_once('mt/PveGemini.php');
require_once('mt/PveGeminiMode.php');
require_once('mt/RankSeason.php');
+require_once('mt/LevelUp.php');
require_once('models/Season.php');
require_once('models/Battle.php');
@@ -27,6 +28,7 @@ require_once('models/FragmentPool.php');
require_once('models/RealtimeData.php');
require_once('models/BattleHistory.php');
require_once('models/NftActive.php');
+require_once('models/FragmentRecord.php');
require_once('services/RankActivityService.php');
require_once('services/FormulaService.php');
@@ -36,6 +38,7 @@ require_once('services/LogService.php');
use models\Chip;
+use models\FragmentRecord;
use models\Nft;
use models\NftActive;
use models\User;
@@ -78,19 +81,9 @@ class BattleDataService extends BaseService {
'obtain_ceg' => 0,
'curr_ceg' => 0,
),
- 'weapon1' => array(
- 'gun_uniid' => '',
- 'ceg_uplimit' => 0,
- 'obtain_ceg' => 0,
- ),
- 'weapon2' => array(
- 'gun_uniid' => '',
- 'ceg_uplimit' => 0,
- 'obtain_ceg' => 0,
- 'curr_ceg' => 0,
- ),
'total_ceg' => 0,
- 'items' => array()
+ 'items' => array(),
+ 'lvInfo' => array()
);
private $rankActivityService = null;
private $pveGeminiMeta = null;
@@ -124,32 +117,7 @@ class BattleDataService extends BaseService {
$this->reward['hero']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ?
$this->heroDto['pve_ceg_uplimit'] : $this->heroDto['pvp_ceg_uplimit'];
}
- {
- $weaponUuid1 = getReqVal('weapon_uuid1', '');
- if ($weaponUuid1) {
- $weaponDb = Gun::find($weaponUuid1);
- if (!$weaponDb) {
- return false;
- }
- $this->weapon1Dto = Gun::toDto($weaponDb);
- $this->reward['weapon1']['gun_uniid'] = $this->weapon1Dto['gun_uniid'];
- $this->reward['weapon1']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ?
- $this->weapon1Dto['pve_ceg_uplimit'] : $this->weapon1Dto['pvp_ceg_uplimit'];
- }
- }
- {
- $weaponUuid2 = getReqVal('weapon_uuid2', '');
- if ($weaponUuid2) {
- $weaponDb = Gun::find($weaponUuid2);
- if (!$weaponDb) {
- return false;
- }
- $this->weapon2Dto = Gun::toDto($weaponDb);
- $this->reward['weapon2']['gun_uniid'] = $this->weapon2Dto['gun_uniid'];
- $this->reward['weapon2']['ceg_uplimit'] = $matchMode == self::MATCH_MODE_PVE ?
- $this->weapon2Dto['pve_ceg_uplimit'] : $this->weapon2Dto['pvp_ceg_uplimit'];
- }
- }
+
//录入战斗记录
$this->saveBattleHistory();
@@ -160,7 +128,6 @@ class BattleDataService extends BaseService {
//匹配赛模式
$this->updatePvpData();
$this->rewardCegPvp();
- $this->rewardFragmentPvp();
myself()->_incDailyV(TN_DAILY_PVP_BATTLE_TIMES, 0, 1);
}
break;
@@ -177,7 +144,6 @@ class BattleDataService extends BaseService {
$this->updatePveData();
if ($this->pveGeminiMeta &&
$this->pveGeminiModeMeta) {
- $this->rewardCegPve();
$this->rewardFragmentPve();
}
myself()->_incDailyV(TN_DAILY_PVE_BATTLE_TIMES, 0, 1);
@@ -191,6 +157,32 @@ class BattleDataService extends BaseService {
}
+ public function rewardExpPvp(){
+ $expNum = 222;
+ if ($expNum>0){
+ array_push($this->reward['items'],
+ array(
+ 'item_id' => V_ITEM_EXP,
+ 'item_num' => $expNum
+ ));
+ $userInfo = myself()->_getOrmUserInfo();
+ $newExp = $userInfo['exp']+$expNum;
+ $newLv = $userInfo['level'];
+ mt\LevelUp::getExpByLv($newLv,$newExp);
+ $this->reward['lvInfo'] = array(
+ 'oldLv' => $userInfo['level'],
+ 'newLv' => $newLv
+ );
+ if ( $newExp != $userInfo['exp'] ) {
+ myself()->_updateUserInfo(array(
+ 'level' => $newLv,
+ 'exp' => $newExp,
+ ));
+ }
+ }
+
+ }
+
private function saveBattleHistory(){
$user = myself()->_getOrmUserInfo();
$newRank = $user['rank'];
@@ -781,54 +773,151 @@ class BattleDataService extends BaseService {
private function rewardFragmentPve()
{
- if ($this->instanceRank < 1) {
+ $bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0;
+ if ($this->instanceRank < 1 || !$bossReward) {
return;
}
- $todayPveBattleTimes = myself()->_getDailyV(TN_DAILY_PVE_BATTLE_TIMES, 0);
- $todayPveLastGetFragmentBattle = myself()->_getDailyV(TN_DAILY_PVE_LAST_GET_FRAGMENT_BATTLE, 0);
- $todayPveGetFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_FRAGMENT_NUM, 0);
- $todayPvpGetFragmentNum = myself()->_getDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 0);
+ $dropRate = $this->pveGeminiMeta['drop_rate'];
+ $todayPveGetHeroFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM, 0);
+ $todayPveGetGunFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM, 0);
+ if ($todayPveGetHeroFragmentNum < self::MAX_DROP_NUM) {
+ $gamesNum = FragmentRecord::getGamesNum(FragmentRecord::HERO_FRAGMENT);
+ $rate = $dropRate*($gamesNum+1);
+ if (rand(1,100) < $rate*100){
+ $dropHeroFragmentId = $this->randWeight2(1);
+ $this->drop($dropHeroFragmentId,1);
+ FragmentRecord::upsertGamesNum(FragmentRecord::HERO_FRAGMENT,0);
+ }else{
+ FragmentRecord::upsertGamesNum(FragmentRecord::HERO_FRAGMENT,$gamesNum+1);
+ }
- if ($todayPveGetFragmentNum + $todayPvpGetFragmentNum < self::MAX_DROP_NUM) {
- $onlineNum = RealtimeData::getOnline();
- $heroFragmentNum = FragmentPool::getHeroNum(1);
- $gunFragmentNum = FragmentPool::getGunNum(1);
-
- $instanceLevel = $this->pveGeminiMeta['gemini_lv'];
- $instanceRank = $this->instanceRank;
- $instanceRankRate = $this->getInstanceRankRate();
- $bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0;
- $heroQuality = $this->heroDto['quality'];
-
- $heroProbability = FormulaService::calcHeroFragmentProbabilityPve
- (
- $heroQuality,
- $onlineNum,
- $heroFragmentNum,
- $todayPveBattleTimes,
- $instanceLevel,
- $instanceRank,
- $instanceRankRate,
- $bossReward,
- $todayPveLastGetFragmentBattle
- );
- $gunProbability = FormulaService::calcWeaponFragmentProbabilityPve
- (
- $heroQuality,
- $onlineNum,
- $gunFragmentNum,
- $todayPveBattleTimes,
- $instanceLevel,
- $instanceRank,
- $instanceRankRate,
- $bossReward,
- $todayPveLastGetFragmentBattle
- );
- $emptyProbability = max(1 - $heroProbability - $gunProbability, 0);
-
- $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability));
- $this->procDrop($dropIdx);
}
+ if ($todayPveGetGunFragmentNum < self::MAX_DROP_NUM) {
+ $gamesNum = FragmentRecord::getGamesNum(FragmentRecord::GUN_FRAGMENT);
+ $rate = $dropRate*($gamesNum+1);
+ if (rand(1,100) < $rate*100){
+ $dropGunFragmentId = $this->randWeight2(2);
+ $this->drop($dropGunFragmentId,2);
+ FragmentRecord::upsertGamesNum(FragmentRecord::GUN_FRAGMENT,0);
+ }else{
+ FragmentRecord::upsertGamesNum(FragmentRecord::GUN_FRAGMENT,$gamesNum+1);
+ }
+
+ }
+
+// $todayPveBattleTimes = myself()->_getDailyV(TN_DAILY_PVE_BATTLE_TIMES, 0);
+// $todayPveLastGetFragmentBattle = myself()->_getDailyV(TN_DAILY_PVE_LAST_GET_FRAGMENT_BATTLE, 0);
+// $todayPveGetFragmentNum = myself()->_getDailyV(TN_DAILY_PVE_GET_FRAGMENT_NUM, 0);
+// $todayPvpGetFragmentNum = myself()->_getDailyV(TN_DAILY_PVP_GET_FRAGMENT_NUM, 0);
+//
+// if ($todayPveGetFragmentNum + $todayPvpGetFragmentNum < self::MAX_DROP_NUM) {
+// $onlineNum = RealtimeData::getOnline();
+// $heroFragmentNum = FragmentPool::getHeroNum(1);
+// $gunFragmentNum = FragmentPool::getGunNum(1);
+//
+// $instanceLevel = $this->pveGeminiMeta['gemini_lv'];
+// $instanceRank = $this->instanceRank;
+// $instanceRankRate = $this->getInstanceRankRate();
+// $bossReward = getReqVal('pve_kill_boss', 0) ? 1 : 0;
+// $heroQuality = $this->heroDto['quality'];
+//
+// $heroProbability = FormulaService::calcHeroFragmentProbabilityPve
+// (
+// $heroQuality,
+// $onlineNum,
+// $heroFragmentNum,
+// $todayPveBattleTimes,
+// $instanceLevel,
+// $instanceRank,
+// $instanceRankRate,
+// $bossReward,
+// $todayPveLastGetFragmentBattle
+// );
+// $gunProbability = FormulaService::calcWeaponFragmentProbabilityPve
+// (
+// $heroQuality,
+// $onlineNum,
+// $gunFragmentNum,
+// $todayPveBattleTimes,
+// $instanceLevel,
+// $instanceRank,
+// $instanceRankRate,
+// $bossReward,
+// $todayPveLastGetFragmentBattle
+// );
+// $emptyProbability = max(1 - $heroProbability - $gunProbability, 0);
+//
+// $dropIdx = $this->randWeight(array($heroProbability, $gunProbability, $emptyProbability));
+// $this->procDrop($dropIdx);
+// }
+ }
+
+ private function randWeight2($type){
+ $itemMeta = mt\Item::getMetaListByType(mt\Item::FRAGMENT_TYPE);
+ $heroFragment = array();
+ $gunFragment = array();
+ foreach ($itemMeta as $meta){
+ if ($meta['sub_type'] == 3 || $meta['sub_type'] == 1){
+ array_push($heroFragment,$meta['id']);
+ }
+ if ($meta['sub_type'] == 4 || $meta['sub_type'] == 2){
+ array_push($gunFragment,$meta['id']);
+ }
+ }
+ $weightRate = array(
+ array(0,4),
+ array(1,12),
+ array(2,12),
+ array(3,12),
+ array(4,12),
+ array(5,12),
+ array(6,12),
+ array(7,12),
+ array(8,12),
+ );
+ $weight = 0;
+ $tempData = array ();
+ foreach ($weightRate as $one) {
+ $weight += $one[1];
+ for ($i = 0; $i < $one[1]; $i++) {
+ $tempData[] = $one;
+
+ }
+ }
+ $key = $tempData[rand(0, $weight -1)][0];
+ switch ($type){
+ case 1:return $heroFragment[$key];
+ case 2:return $gunFragment[$key];
+ default:return null;
+ }
+ }
+
+ private function drop($itemId,$type){
+ $itemMeta = mt\Item::get($itemId);
+ if ($itemMeta){
+ $propertyChgService = new services\PropertyChgService();
+ $awardService = new services\AwardService();
+ array_push($this->reward['items'],
+ array(
+ 'item_id' => $itemId,
+ 'item_num' => 1
+ ));
+ myself()->_addItems(
+ array(
+ array(
+ 'item_id' => $itemId,
+ 'item_num' => 1
+ )),
+ $awardService,
+ $propertyChgService
+ );
+ switch ($type){
+ case 1:myself()->_incDailyV(TN_DAILY_PVE_GET_HERO_FRAGMENT_NUM, 0, 1);break;
+ case 2:myself()->_incDailyV(TN_DAILY_PVE_GET_GUN_FRAGMENT_NUM, 0, 1);break;
+ }
+
+ }
+
}
private function rewardCegPvp()
@@ -850,22 +939,11 @@ class BattleDataService extends BaseService {
}
}
$heroPvpCeg = FormulaService::calcHeroPvpCeg($this->heroDto, $_REQUEST);
- $weaponPvpCeg1 = 0;
- $weaponPvpCeg2 = 0;
- if ($this->weapon1Dto) {
- $weaponPvpCeg1 = FormulaService::calcWeaponPvpCeg($this->weapon1Dto, $_REQUEST);
- }
- if ($this->weapon2Dto) {
- $weaponPvpCeg2 = FormulaService::calcWeaponPvpCeg($this->weapon2Dto, $_REQUEST);
- }
error_log(json_encode(array(
'heroPvpCeg' => $heroPvpCeg,
- 'weaponPvpCeg1' => $weaponPvpCeg1,
- 'weaponPvpCeg2' => $weaponPvpCeg2,
)));
if ($heroPvpCeg > 0) {
$heroPvpCeg = Hero::gainGoldPvp($this->heroDto, $heroPvpCeg);
-
{
//埋点
$event = [
@@ -879,56 +957,14 @@ class BattleDataService extends BaseService {
$this->reward['hero']['obtain_ceg'] = '' . ($this->heroDto['current_pvp_get_ceg'] + $heroPvpCeg);
$this->reward['total_ceg'] += $heroPvpCeg;
}
- if ($weaponPvpCeg1 > 0) {
- $weaponPvpCeg1 = Gun::gainGoldPvp($this->weapon1Dto, $weaponPvpCeg1);
- {
- //埋点
- $event = [
- 'name' => LogService::BATTLE_AWARD_PVP,
- 'val' => $weaponPvpCeg1
- ];
- LogService::productCEG($event,$this->weapon1Dto,$log_param);
- }
-
- $this->reward['weapon1']['curr_ceg'] = '' . ($this->weapon1Dto['current_pvp_get_ceg'] + $weaponPvpCeg1);
- $this->reward['weapon1']['obtain_ceg'] = '' . ($this->weapon1Dto['current_pvp_get_ceg'] + $weaponPvpCeg1);
- $this->reward['total_ceg'] += $weaponPvpCeg1;
- }
- if ($weaponPvpCeg2 > 0) {
- $weaponPvpCeg2 = Gun::gainGoldPvp($this->weapon2Dto, $weaponPvpCeg2);
-
- {
- //埋点
- $event = [
- 'name' => LogService::BATTLE_AWARD_PVP,
- 'val' => $weaponPvpCeg2
- ];
- LogService::productCEG($event,$this->weapon2Dto,$log_param);
- }
-
- $this->reward['weapon2']['curr_ceg'] = '' . ($this->weapon2Dto['current_pvp_get_ceg'] + $weaponPvpCeg2);
- $this->reward['weapon2']['obtain_ceg'] = '' . ($this->weapon2Dto['current_pvp_get_ceg'] + $weaponPvpCeg2);
- $this->reward['total_ceg'] += $weaponPvpCeg2;
- }
$this->reward['total_ceg'] .= '';
error_log(json_encode(array(
'new_heroPvpCeg' => $heroPvpCeg,
- 'new_weaponPvpCeg1' => $weaponPvpCeg1,
- 'new_weaponPvpCeg2' => $weaponPvpCeg2,
)));
- $gold = $heroPvpCeg + $weaponPvpCeg1 + $weaponPvpCeg2;
+ $gold = $heroPvpCeg;
error_log('updateBattleData1');
$this->rankActivityService->updateBattleData($gold);
- if ($heroPvpCeg>0){
- NftService::addNftActive($this->heroDto,1);
- }
- if ($weaponPvpCeg1>0){
- NftService::addNftActive($this->weapon1Dto,2);
- }
- if ($weaponPvpCeg2>0){
- NftService::addNftActive($this->weapon2Dto,2);
- }
if ($gold > 0) {
myself()->_addVirtualItem(V_ITEM_GOLD, $gold);
}
diff --git a/webapp/services/ChipPageService.php b/webapp/services/ChipPageService.php
new file mode 100644
index 00000000..b308b82b
--- /dev/null
+++ b/webapp/services/ChipPageService.php
@@ -0,0 +1,57 @@
+_getSelfMysql(),
+ 't_chip_page',
+ array(
+ 'account_id'=> myself()->_getAccountId()
+ )
+ );
+ if (!$rows){
+ for ($i=0;$irefreshSlotState($row);
+ }
+ }
+ }
+
+ private function refreshSlotState($row){
+ $data = emptyReplace(json_decode($row['data'], true), array());
+ $userInfo = myself()->_getOrmUserInfo();
+ foreach ($data as &$val){
+ if ($userInfo['level'] < $val['slot_id'] && $val['state'] == 0){
+ $val['state'] = 0;
+ }else{
+ $val['state'] = 1;
+ }
+ }
+
+ SqlHelper::update(
+ myself()->_getSelfMysql(),
+ 't_chip_page',
+ array(
+ 'idx' => $row['idx']
+ ),
+ array(
+ 'data' => json_encode($data),
+ )
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/webapp/services/FormulaService.php b/webapp/services/FormulaService.php
index 0dbfb5d4..fc25f7d3 100644
--- a/webapp/services/FormulaService.php
+++ b/webapp/services/FormulaService.php
@@ -17,10 +17,17 @@ use mt;
class FormulaService extends BaseService {
+ public static function calcHeroPvpGold($heroDto, $params)
+ {
+// GOLD = Min(英雄每天gold上限*10%,标准值) * (f(队伍排名) + g(队伍击杀数))
+// f(队伍排名) = round(1-(队伍排名-1)/10 ,1)
+// g(队伍击杀数)= Min(队伍击杀数*0.1 ,2)
+ }
+
public static function calcHeroPvpCeg($heroDto, $params)
{
//每局实际收益=10%PVP收益*5*(50%*[每局排名TopX%对应比例]+25%*[每局PK人数排名TopX%对应比例]+15%*[每局英雄属性排名TopX%对应比例]+5%*[每局武器属性排名TopX%对应比例]+5%*[每局存活时间排名TopX%对应比例])
- $upLimit = $heroDto['pvp_ceg_uplimit'];
+ $upLimit = $heroDto['gold_uplimit'];
$ranked = getXVal($params, 'ranked');
$kills = getXVal($params, 'kills');
$aliveTime = getXVal($params, 'alive_time');