From 66c5417af20be75bdb074ef3ef3e35dba441bb9c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 19 Nov 2021 19:23:59 +0800 Subject: [PATCH] mv NPlayerInfo->Role --- doc/NPlayerInfo.py | 53 ---- doc/Role.py | 44 ++++ .../NPlayerInfoController.class.php | 229 ------------------ webapp/controller/RoleController.class.php | 225 +++++++++++++++++ webapp/index.php | 3 +- 5 files changed, 271 insertions(+), 283 deletions(-) delete mode 100644 doc/NPlayerInfo.py delete mode 100644 webapp/controller/NPlayerInfoController.class.php diff --git a/doc/NPlayerInfo.py b/doc/NPlayerInfo.py deleted file mode 100644 index 46bbad91..00000000 --- a/doc/NPlayerInfo.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- coding: utf-8 -*- - -import _common - -class NPlayerInfo(object): - - def __init__(self): - self.apis = [ - { - 'desc': 'addGiveMeFive', - 'group': 'NPlayerInfo', - 'url': 'webapp/index.php?c=NPlayerInfo&a=addGiveMeFive', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'getPlayerInfo', - 'group': 'NPlayerInfo', - 'url': 'webapp/index.php?c=NPlayerInfo&a=getPlayerInfo', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'changeHIFrameHero', - 'group': 'NPlayerInfo', - 'url': 'webapp/index.php?c=NPlayerInfo&a=changeHIFrameHero', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - { - 'desc': 'changeName', - 'group': 'NPlayerInfo', - 'url': 'webapp/index.php?c=NPlayerInfo&a=changeName', - 'params': [ - _common.ReqHead(), - ], - 'response': [ - _common.RspHead(), - ] - }, - ] diff --git a/doc/Role.py b/doc/Role.py index c91c01f3..968c89ac 100644 --- a/doc/Role.py +++ b/doc/Role.py @@ -303,4 +303,48 @@ class Role(object): _common.RspHead(), ] }, + { + 'desc': 'addGiveMeFive', + 'group': 'NPlayerInfo', + 'url': 'webapp/index.php?c=NPlayerInfo&a=addGiveMeFive', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ] + }, + { + 'desc': 'getPlayerInfo', + 'group': 'NPlayerInfo', + 'url': 'webapp/index.php?c=NPlayerInfo&a=getPlayerInfo', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ] + }, + { + 'desc': 'changeHIFrameHero', + 'group': 'NPlayerInfo', + 'url': 'webapp/index.php?c=NPlayerInfo&a=changeHIFrameHero', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ] + }, + { + 'desc': 'changeName', + 'group': 'NPlayerInfo', + 'url': 'webapp/index.php?c=NPlayerInfo&a=changeName', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ] + }, ] diff --git a/webapp/controller/NPlayerInfoController.class.php b/webapp/controller/NPlayerInfoController.class.php deleted file mode 100644 index 6628f0bf..00000000 --- a/webapp/controller/NPlayerInfoController.class.php +++ /dev/null @@ -1,229 +0,0 @@ -getMysql($account_id); - $giveMeFiveCnt = 0; - $sqlStr = "SELECT give_me_five FROM player_info WHERE accountid=:accountid; "; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - if($row) { - - $giveMeFiveCnt = $row["give_me_five"]; - } - //error_log("当前GiveMeFiveCnt===".$giveMeFiveCnt); - return $giveMeFiveCnt; - - } - - public function addGiveMeFive()//玩家被点赞一次 - { - //error_log("玩家被点赞===".$this->getAccountId()); - $tmpCnt = $this->getGiveMeFive(); - $tmpCnt ++; - phpcommon\SqlHelper::insertOrUpdate - ($this->getSelfMysql(), - 'player_info', - array( - 'accountid' => $this->getAccountId() - ), - array( - 'accountid' => $this->getAccountId(), - 'give_me_five' => $tmpCnt, - 'createtime' => $this->getNowTime(), - 'modifytime' => $this->getNowTime() - ), - array( - 'give_me_five' => $tmpCnt, - 'modifytime' => $this->getNowTime() - ) - ); - $this->sendDataToClient(100,"getGiveMeFiveTest",null); - } - public function getPlayerInfo()//获得玩家个人信息 - { - - $account_id = $_REQUEST['acctID']; - $conn = $this->getMysql($account_id); - $from = $_REQUEST['from']; - - $sqlStr = "SELECT * FROM user WHERE accountid=:accountid; "; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - $resultArr = null; - $code = 100; - if($row) { - //$resultData = $row[0]; - $userName = $row[0]["user_name"];//玩家昵称 - $teamName =$row[0]["team_name"];//战队昵称 - $sex = $row[0]["sex"]; - $lv = $row[0]["lv"];//玩家等级 - $lv_exp = $row[0]["lv_exp"];//玩家当前等级已经获得的经验 - $hiID = $row[0]["hi_id"];//玩家头像ID - $hiFrameID = $row[0]["head_kuang_id"];//玩家头像框ID - $heroID = $row[0]["hero_id"];//当前使用的英雄ID - $killRank = 2;//击杀排名 - $gameTimes = $row[0]["game_times"];//游戏场次 - $winTimes = $row[0]["win_times"];//游戏胜利场次 - $maxKill = $row[0]["kill_his"];//最高击杀 - $totalKill = $row[0]["kills"];//总击杀次数 - $maxDamage = $row[0]["harm_his"];//最高伤害 - $totalDamage = $row[0]["harm"];//总伤害 - $cureN = $row[0]['add_HP'];//治疗 - $aliveTimes = $row[0]['alive_time'];//生存总时间 - //$rankScore = $row[0][""];//当前段位分数 - - if($hiID == 0) - { - $hiID = 18001; - } - if($hiFrameID == 0) - { - $hiFrameID = 19001; - } - if($heroID == 0) - { - $heroID = 30100; - } - $resultArr = array( - "acctID"=>$account_id, - "userName"=>$userName, - "teamName"=>$teamName, - "sex"=>$sex, - "lv"=>$lv, - "lv_exp"=>$lv_exp, - "hiID"=>$hiID, - "hiFrameID"=>$hiFrameID, - "heroID"=>$heroID, - "killRank"=>$killRank, - "gameTimes"=>$gameTimes, - "winTimes"=>$winTimes, - "maxKill"=>$maxKill, - "totalKill"=>$totalKill, - "maxDamage"=>$maxDamage, - "totalDamage"=>$totalDamage, - "from"=>$from, - 'cureN' =>$cureN, - 'aliveTime' =>$aliveTimes - ); - } - else - { - $code = 99; - } - //获得所有英雄开始- - if($code == 100) - { - $conn = $this->getMysql($account_id); - $tmpHeroArr = array(); - $sqlStr = "SELECT id FROM hero WHERE accountid=:accountid;"; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - if($row) - { - for($i = 0 ;$i < count($row);$i++) - { - $tmpHeroID = $row[$i]["id"]; - array_push($tmpHeroArr,$tmpHeroID); - } - } - else - { - $code = 99; - } - $resultArr["heroArr"] = $tmpHeroArr; - } - //获得所有英雄结束- - //获得改名卡道具数量开始-- - if($code == 100) - { - $conn = $this->getMysql($account_id); - $tmpHeroArr = array(); - $itemID = 10106; - $sqlStr = "SELECT * FROM bag WHERE accountid=:accountid AND id=:id;"; - $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':id'=>$itemID)); - if($row) - { - $itemNum = $row[0]["num"]; - } - else - { - $itemNum = 0; - } - $resultArr["bagItem"] = $itemNum; - } - //获得改名卡道具数量结束-- - $this->sendDataToClient($code,"getPlayerInfo",$resultArr); - } - public function changeHIFrameHero()//修改头像 头像框 英雄 - { - $account_id = $_REQUEST['account_id']; - $type = $_REQUEST['type']; - $itemID = $_REQUEST["itemID"]; - $conn = $this->getMysql($account_id); - $code = 100; - $updateInfo = null; - $heroSkinID = 0; - if($type == 2)//修改头像 - { - $updateInfo = array("hi_id" => $itemID); - } - else if($type == 3)//修改头像框 - { - $updateInfo = array("head_kuang_id" => $itemID); - } - else if($type == 4)//修改英雄 - { - $updateInfo = array('hero_id' => $itemID); - } - if($code == 100) - { - phpcommon\SqlHelper::update - ($this->getSelfMysql(), - 'user', - array( - 'accountid' => $this->getAccountId() - ), - $updateInfo - ); - } - - $resultArr = array("type"=>$type,"itemID"=>$itemID,"heroSkinID"=>$heroSkinID); - $this->sendDataToClient($code,"changeHIFrameHero",$resultArr); - } - - public function changeName()//修改昵称 - { - $account_id = $_REQUEST['account_id']; - $nickName = $_REQUEST['nickName']; - $conn = $this->getMysql($account_id); - $code = 100; - $itemID = 10106; - $itemNum = 1; - - $itemArr = array(); - $deleteItem = array("item_id"=>$itemID,"item_num"=>$itemNum); - array_push($itemArr,$deleteItem); - $code = $this->deleteItem($deleteItem); - if($code == 100) - { - $this->decItem($itemArr); - - //error_log("改名测试======".$code); - phpcommon\SqlHelper::update - ($this->getSelfMysql(), - 'user', - array( - 'accountid' => $this->getAccountId() - ), - array( - 'user_name' => $nickName - ) - ); - } - $this->sendDataToClient($code,"changeNickName",$nickName); - - // $sqlStr = "SELECT * FROM user WHERE accountid=:accountid; "; - // $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); - } - -} diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index c84658fd..288f5e9b 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -2196,5 +2196,230 @@ class RoleController extends BaseAuthedController { $this->sendDataToClient(3,"ok",$row[0]); } + private function getGiveMeFive()//获得玩家被点赞的次数 + { + $account_id = $_REQUEST['account_id']; + $conn = $this->getMysql($account_id); + $giveMeFiveCnt = 0; + $sqlStr = "SELECT give_me_five FROM player_info WHERE accountid=:accountid; "; + $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); + if($row) { + + $giveMeFiveCnt = $row["give_me_five"]; + } + //error_log("当前GiveMeFiveCnt===".$giveMeFiveCnt); + return $giveMeFiveCnt; + + } + + public function addGiveMeFive()//玩家被点赞一次 + { + //error_log("玩家被点赞===".$this->getAccountId()); + $tmpCnt = $this->getGiveMeFive(); + $tmpCnt ++; + phpcommon\SqlHelper::insertOrUpdate + ($this->getSelfMysql(), + 'player_info', + array( + 'accountid' => $this->getAccountId() + ), + array( + 'accountid' => $this->getAccountId(), + 'give_me_five' => $tmpCnt, + 'createtime' => $this->getNowTime(), + 'modifytime' => $this->getNowTime() + ), + array( + 'give_me_five' => $tmpCnt, + 'modifytime' => $this->getNowTime() + ) + ); + $this->sendDataToClient(100,"getGiveMeFiveTest",null); + } + public function getPlayerInfo()//获得玩家个人信息 + { + + $account_id = $_REQUEST['acctID']; + $conn = $this->getMysql($account_id); + $from = $_REQUEST['from']; + + $sqlStr = "SELECT * FROM user WHERE accountid=:accountid; "; + $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); + $resultArr = null; + $code = 100; + if($row) { + //$resultData = $row[0]; + $userName = $row[0]["user_name"];//玩家昵称 + $teamName =$row[0]["team_name"];//战队昵称 + $sex = $row[0]["sex"]; + $lv = $row[0]["lv"];//玩家等级 + $lv_exp = $row[0]["lv_exp"];//玩家当前等级已经获得的经验 + $hiID = $row[0]["hi_id"];//玩家头像ID + $hiFrameID = $row[0]["head_kuang_id"];//玩家头像框ID + $heroID = $row[0]["hero_id"];//当前使用的英雄ID + $killRank = 2;//击杀排名 + $gameTimes = $row[0]["game_times"];//游戏场次 + $winTimes = $row[0]["win_times"];//游戏胜利场次 + $maxKill = $row[0]["kill_his"];//最高击杀 + $totalKill = $row[0]["kills"];//总击杀次数 + $maxDamage = $row[0]["harm_his"];//最高伤害 + $totalDamage = $row[0]["harm"];//总伤害 + $cureN = $row[0]['add_HP'];//治疗 + $aliveTimes = $row[0]['alive_time'];//生存总时间 + //$rankScore = $row[0][""];//当前段位分数 + + if($hiID == 0) + { + $hiID = 18001; + } + if($hiFrameID == 0) + { + $hiFrameID = 19001; + } + if($heroID == 0) + { + $heroID = 30100; + } + $resultArr = array( + "acctID"=>$account_id, + "userName"=>$userName, + "teamName"=>$teamName, + "sex"=>$sex, + "lv"=>$lv, + "lv_exp"=>$lv_exp, + "hiID"=>$hiID, + "hiFrameID"=>$hiFrameID, + "heroID"=>$heroID, + "killRank"=>$killRank, + "gameTimes"=>$gameTimes, + "winTimes"=>$winTimes, + "maxKill"=>$maxKill, + "totalKill"=>$totalKill, + "maxDamage"=>$maxDamage, + "totalDamage"=>$totalDamage, + "from"=>$from, + 'cureN' =>$cureN, + 'aliveTime' =>$aliveTimes + ); + } + else + { + $code = 99; + } + //获得所有英雄开始- + if($code == 100) + { + $conn = $this->getMysql($account_id); + $tmpHeroArr = array(); + $sqlStr = "SELECT id FROM hero WHERE accountid=:accountid;"; + $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); + if($row) + { + for($i = 0 ;$i < count($row);$i++) + { + $tmpHeroID = $row[$i]["id"]; + array_push($tmpHeroArr,$tmpHeroID); + } + } + else + { + $code = 99; + } + $resultArr["heroArr"] = $tmpHeroArr; + } + //获得所有英雄结束- + //获得改名卡道具数量开始-- + if($code == 100) + { + $conn = $this->getMysql($account_id); + $tmpHeroArr = array(); + $itemID = 10106; + $sqlStr = "SELECT * FROM bag WHERE accountid=:accountid AND id=:id;"; + $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':id'=>$itemID)); + if($row) + { + $itemNum = $row[0]["num"]; + } + else + { + $itemNum = 0; + } + $resultArr["bagItem"] = $itemNum; + } + //获得改名卡道具数量结束-- + $this->sendDataToClient($code,"getPlayerInfo",$resultArr); + } + public function changeHIFrameHero()//修改头像 头像框 英雄 + { + $account_id = $_REQUEST['account_id']; + $type = $_REQUEST['type']; + $itemID = $_REQUEST["itemID"]; + $conn = $this->getMysql($account_id); + $code = 100; + $updateInfo = null; + $heroSkinID = 0; + if($type == 2)//修改头像 + { + $updateInfo = array("hi_id" => $itemID); + } + else if($type == 3)//修改头像框 + { + $updateInfo = array("head_kuang_id" => $itemID); + } + else if($type == 4)//修改英雄 + { + $updateInfo = array('hero_id' => $itemID); + } + if($code == 100) + { + phpcommon\SqlHelper::update + ($this->getSelfMysql(), + 'user', + array( + 'accountid' => $this->getAccountId() + ), + $updateInfo + ); + } + + $resultArr = array("type"=>$type,"itemID"=>$itemID,"heroSkinID"=>$heroSkinID); + $this->sendDataToClient($code,"changeHIFrameHero",$resultArr); + } + + public function changeName()//修改昵称 + { + $account_id = $_REQUEST['account_id']; + $nickName = $_REQUEST['nickName']; + $conn = $this->getMysql($account_id); + $code = 100; + $itemID = 10106; + $itemNum = 1; + + $itemArr = array(); + $deleteItem = array("item_id"=>$itemID,"item_num"=>$itemNum); + array_push($itemArr,$deleteItem); + $code = $this->deleteItem($deleteItem); + if($code == 100) + { + $this->decItem($itemArr); + + //error_log("改名测试======".$code); + phpcommon\SqlHelper::update + ($this->getSelfMysql(), + 'user', + array( + 'accountid' => $this->getAccountId() + ), + array( + 'user_name' => $nickName + ) + ); + } + $this->sendDataToClient($code,"changeNickName",$nickName); + + // $sqlStr = "SELECT * FROM user WHERE accountid=:accountid; "; + // $row = $conn->execQuery($sqlStr,array(':accountid' => $account_id)); + } + } diff --git a/webapp/index.php b/webapp/index.php index ed9f4ff7..ca9ae658 100644 --- a/webapp/index.php +++ b/webapp/index.php @@ -28,7 +28,8 @@ $rewriteRule = array( 'Property' => 'Role', 'NBag' => 'Bag', 'NHero' => 'Hero', - 'NPlayer' => 'NPlayerInfo', + 'NPlayer' => 'Role', + 'NPlayerInfo' => 'Role', 'NRank' => 'Rank', );