game2005api/webapp/controller/NPlayerInfoController.class.php
aozhiwei b8bb70a77f 1
2021-06-18 22:23:50 +08:00

227 lines
7.6 KiB
PHP

<?php
class NPlayerInfoController extends BaseAuthedController {
public 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 sendGMFToClient()
{
$tmpCnt = $this->getGiveMeFive();
$this->sendDataToClient(100,"getGiveMeFive",$tmpCnt);
}
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"];//总伤害
//$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
);
}
else
{
$code = 99;
}
if($code == 100)
{
$tmpSkinID = 0;
$tmpHeroID = $resultArr["heroID"];
$conn = $this->getMysql($account_id);
$sqlStr = "SELECT skinid FROM hero WHERE accountid=:accountid AND id=:id";
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':id' => $tmpHeroID));
if($row)
{
$resultArr["skinID"] = $row[0]["skinid"];
}
else
{
$code = 99;
}
//array_push($resultArr,"Test"=>0);
}
//获得所有英雄开始-
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;
}
//获得所有英雄结束-
$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);
$sqlStr = "SELECT skinid FROM hero WHERE accountid=:accountid AND id=:id";
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id,':id' => $itemID));
if($row)
{
$heroSkinID = $row[0]["skinid"];
}
else
{
$code = 99;
}
}
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;
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));
}
}