From 910fbcffec3df0ee0c3d688a989756f7a778d5c8 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Mon, 13 Feb 2023 14:22:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=83=85=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Emoji.py | 44 ++++++++++++ doc/User.py | 1 + doc/_common.py | 8 +++ sql/gamedb.sql | 36 ++++++++++ webapp/controller/EmojiController.class.php | 76 +++++++++++++++++++++ webapp/models/Emoji.php | 52 ++++++++++++++ webapp/mt/LevelUp.php | 27 ++++++++ webapp/services/BattleDataService.php | 30 +++++++- 8 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 doc/Emoji.py create mode 100644 webapp/controller/EmojiController.class.php create mode 100644 webapp/models/Emoji.php diff --git a/doc/Emoji.py b/doc/Emoji.py new file mode 100644 index 00000000..ff0bd6c6 --- /dev/null +++ b/doc/Emoji.py @@ -0,0 +1,44 @@ +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()], '表情列表'] + ] + },{ + '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/User.py b/doc/User.py index e28a1f54..ac77f4cc 100644 --- a/doc/User.py +++ b/doc/User.py @@ -78,6 +78,7 @@ class User(object): ['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 fba7acb7..3184d52a 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1017,4 +1017,12 @@ 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:未使用'], ] \ No newline at end of file diff --git a/sql/gamedb.sql b/sql/gamedb.sql index cb3071fc..40781bac 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -920,4 +920,40 @@ 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 */; \ 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..611a6d0e --- /dev/null +++ b/webapp/controller/EmojiController.class.php @@ -0,0 +1,76 @@ +$val, + 'state'=>1, + ) + ); + }else{ + array_push($data, + array( + 'item_id'=>$val, + 'state'=>0, + ) + ); + } + } + $this->_rspData(array( + 'data' => $data + )); + } + + 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) >= 6){ + $this->_rspErr(1, 'To maximize'); + return; + } + array_push($uses,$itemId); + Emoji::updateEmoji(array( + 'value' => 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(array( + 'value' => implode('|',$uses) + )); + $this->_rspOk(); + } +} \ No newline at end of file diff --git a/webapp/models/Emoji.php b/webapp/models/Emoji.php new file mode 100644 index 00000000..68c06fe5 --- /dev/null +++ b/webapp/models/Emoji.php @@ -0,0 +1,52 @@ +_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($fieldsKv){ + SqlHelper::update + (myself()->_getSelfMysql(), + 't_user_use_emoji', + array( + 'account_id' => myself()->_getAccountId(), + ), + $fieldsKv + ); + } + +} \ No newline at end of file diff --git a/webapp/mt/LevelUp.php b/webapp/mt/LevelUp.php index 684d8b1a..2092597a 100644 --- a/webapp/mt/LevelUp.php +++ b/webapp/mt/LevelUp.php @@ -6,5 +6,32 @@ namespace mt; class LevelUp { + public static function getExpByLv(&$lv,&$exp){ + $meta = self::getMetaList(); + if ($exp > 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/services/BattleDataService.php b/webapp/services/BattleDataService.php index 4f9019af..38f77b75 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'); @@ -90,7 +91,8 @@ class BattleDataService extends BaseService { 'curr_ceg' => 0, ), 'total_ceg' => 0, - 'items' => array() + 'items' => array(), + 'lvInfo' => array() ); private $rankActivityService = null; private $pveGeminiMeta = null; @@ -191,6 +193,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'];