game2005api/webapp/controller/RoleController.class.php
2021-11-22 19:17:18 +08:00

1350 lines
49 KiB
PHP

<?php
require 'classes/Quest.php';
require 'classes/AddReward.php';
require 'NTaskController.class.php';
require_once('mt/Parameter.php');
require_once('mt/Drop.php');
require_once('mt/EquipUpgrade.php');
require_once('mt/Season.php');
require_once('mt/SeasonPoint.php');
require_once('mt/RankReward.php');
require_once('mt/Equip.php');
require_once('mt/Player.php');
class RoleController extends BaseAuthedController {
public function roleInfo()
{
$account_id = $_REQUEST['account_id'];
//$user_name = $_REQUEST['name'];
//$avatar_url = $_REQUEST['avatar_url'];
$user_name = '极乐玩家';
$avatar_url = '18003';
$switch_id = 1;
$switch_id = isset($_REQUEST['switch_id']);
//new classes\Quest();
$testTask = new NTaskController();
$testTask->updateTaskToDB(QUEST_DAY_LOGIN,1);
$this->updateSwitch($account_id, $switch_id);
$userInfo = $this->safeGetOrmUserInfo();
if (!$userInfo) {
$this->createNewUser();
$userInfo = $this->getOrmUserInfo();
}
if ($this->loginCheck($userInfo)) {
$userInfo = $this->getOrmUserInfo();
}
$dtoUser = $this->getDtoUserInfo($userInfo);
$dtoUser['errcode'] = 0;
$dtoUser['errmsg'] = '';
$this->rspRawData($dtoUser);
}
private function loginCheck($userInfo)
{
$fieldsKv = array();
if ($userInfo['vip_score'] >= 5 && $userInfo['act_ad_status'] != 2) {
$fieldsKv['act_ad_status'] = 1;
}
if (($this->getNowDaySeconds() - phpcommon\getDaySeconds($userInfo['update_time']) > 0)) {
if ($userInfo['new_second_equip'] == 2 && $userInfo['new_first_equip'] == 1) {
$fieldsKv['new_second_equip'] = 1;
}
$fieldsKv['daily_first_login'] = 0;
$fieldsKv['free_box'] = 0;
$fieldsKv['kefu_status'] = 0;
$fieldsKv['coin_times'] = 0;
$fieldsKv['first_day_ad'] = 0;
$fieldsKv['share_video_times'] = 0;
$fieldsKv['daily_max_single'] = 0;
$fieldsKv['daily_score'] = 0;
$fieldsKv['daily_offline'] = 0;
$this->checkSeasonStatus($userInfo, $fieldsKv);
}
if (count($fieldsKv) > 0) {
$fieldsKv['modify_time'] = $this->getNowTime();
$this->updateUserInfo($fieldsKv);
}
return count($fieldsKv) > 0;
}
private function createNewUser()
{
phpcommon\SqlHelper::upsert
($this->getSelfMysql(),
'user',
array(
'accountid' => $this->getAccountId()
),
array(
),
array(
'accountid' => $this->getAccountId(),
'user_name' => $user_name,
'avatar_url' => $avatar_url,
'coin_num' => 10000,
'season_status' => 1,
'newInfo' => '',
'new_second_equip' => 2,
'head_kuang_id' => 19003,
'sex' => 2,
'hi_id' => 18001,
'hero_id' => 30100,
'integral' => 0,
'season_time' => mt\Season::getCurrSeasonTime(),
'team_name' => '',
'create_time' => phpcommon\getNowTime(),
'modify_time' => phpcommon\getNowTime(),
'update_time' => phpcommon\getNowTime(),
)
);
{
$paramMeta = mt\Parameter::getByName('creator_hero_id');
if ($paramMeta) {
$heros = mt\Parameter::getListValue($paramMeta);
foreach ($heros as $heroId) {
$heroMeta = mt\Player::get($heroId);
if ($heroMeta) {
$this->addHero($heroMeta);
}
}
}
}
{
$this->addItem(array(
'item_id' => 16001,
'item_num' => 0,
));
}
}
protected function checkSeasonStatus($userInfo, &$fieldsKv)
{
if ($this->getNowTime() > $userInfo['season_time'] && $userInfo['season_time'] != 0) {
$fieldsKv['pass_status'] = 0;
$fieldsKv['score'] = 0;
$fieldsKv['season_status'] = 0;
$fieldsKv['integral'] = mt\SeasonPoint::calcTopoint($userInfo);;
$fieldsKv['season_end_score'] = $userInfo['integral'];
$fieldsKv['season_games'] = 0;
$fieldsKv['sea_max_kill'] = 0;
$fieldsKv['sea_max_hart'] = 0;
$fieldsKv['sea_avg_kill'] = 0;
$fieldsKv['season_win'] = 0;
$fieldsKv['season_time'] = mt\Season::getCurrSeasonTime();
$fieldsKv['passcard'] = 0;
phpcommon\SqlHelper::update
($this->getSelfMysql(),
'passinfo',
array(
'accountid' => $account_id,
),
array(
'active_status' => 0,
'honor_status' => 0,
'modify_time' => $this->getNowTime()
)
);
}
}
public function clientBattleReport()
{
$this->updateUserInfo(array(
'first_fight' => function () {
return '1';
}
));
$this->rspOk();
}
public function battleReport()
{
$taskObj = new NTaskController();
$taskObj->updateTaskToDB(PLAY_GAME, 1);
$alive_time = $_REQUEST["alive_time"];
$tmpAlive_time = floor($alive_time/1000);
$taskObj->updateTaskToDB(ALIVE_TIME, $tmpAlive_time);
$killNum = $_REQUEST['kills'];
$taskObj->updateTaskToDB(KILL_NUM, $killNum);
$damageNum = $_REQUEST['harm'];
$taskObj->updateTaskToDB(DAMAGE_NUM70006, $damageNum);
$helpOtherPlayer = $_REQUEST['rescue_member'];
$taskObj->updateTaskToDB(HELP_OP70008, $helpOtherPlayer);
$this->oldBattleReport();
}
private function oldBattleReport()
{
$account_id = $_REQUEST['account_id']; //账号
$conn = $this->getMysql($account_id);
$map_id = $_REQUEST['map_id'];
$map_tpl_name = $_REQUEST['map_tpl_name'];
$room_uuid = $_REQUEST['room_uuid']; //战斗id
$map_name = $_REQUEST['map_name']; //地图名
$game_time = $_REQUEST['game_time']; //游戏结束时间
$hurt = $_REQUEST['hurt']; //承受伤害
$rank = $_REQUEST['rank']; //排名
$kills = $_REQUEST['kills']; //击杀数
$harm = $_REQUEST['harm']; //伤害
$add_HP = $_REQUEST['add_HP']; //治疗量
$alive_time = $_REQUEST['alive_time']; //存活时间
$team_status = $_REQUEST['team_status']; //是否是组队状态
$snipe_kill = $_REQUEST['snipe_kill']; //狙击枪击杀数
$rifle_kill = $_REQUEST['rifle_kill']; //步枪击杀数
$pistol_kill = $_REQUEST['pistol_kill']; //手枪击杀数
$submachine_kill = $_REQUEST['submachine_kill'];//冲锋枪击杀数
$rescue_member = $_REQUEST['rescue_member']; //救起队友次数
$kill_his = $kills;
$harm_his = $harm;
$alive_time_his = $alive_time;
$add_HP_his = $add_HP;
$coin_num = $_REQUEST['coin_num']; //金币
$integral = $_REQUEST['rank_score']; //排位积分
$score = $_REQUEST['pass_score']; //通行证积分
if ($_REQUEST['items'] != '') {
$item_list = $this->getExplode($_REQUEST['items']);
$addreward = new classes\AddReward();
$addreward->addReward((int)$item_list[0][0], (int)$item_list[0][1], $account_id, 0, 0);
}
if (!$map_id) {
$map_id = 0;
}
if (!$map_tpl_name) {
$map_tpl_name = '';
}
$addreward = new classes\AddReward();
$val = $addreward->getVipVal($account_id, 1);
$coin_num = floor($coin_num + $coin_num * $val / 100);
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家1');
return;
}
//更新击杀信息时间
$k = 0;
if ($row['game_times'] != 0) {
$k = $row['kill_his'] / $row['game_times'];
}
if (($row['kill_his'] + $kills) / ($row['game_times'] + 1) != $k) {
$killret = $conn->execScript('UPDATE user SET kill_modifytime=:kill_modifytime ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':kill_modifytime' => phpcommon\getNowTime(),
));
if (!$killret) {
die();
return;
}
}
//更新胜场信息时间
if ($rank == 1) {
$winret = $conn->execScript('UPDATE user SET win_times=:win_times, season_win=:season_win, win_modifytime=:win_modifytime ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':win_times' => $row['win_times'] + 1,
':season_win' => $row['season_win'] + 1,
':win_modifytime' => phpcommon\getNowTime(),
));
if (!$winret) {
die();
return;
}
}
//更新排位积分信息时间
if ($integral != 0) {
$min_score = 0;
$update_maxscore = $row['max_integral'];
if ($integral > 0) {
$update_maxscore = $integral + $row['max_integral'];
}
$update_score = $integral + $row['integral'];
$is_pro = 0;
$seaPoint_meta_table = require('../res/seasomPoint@seasomPoint.php');
for ($ii = 1; $ii <= count($seaPoint_meta_table); $ii++) {
$seaPoint = mt\SeasonPoint::getOldSeasonPoint($ii);
if ($row['integral'] >= $seaPoint['min'] && $row['integral'] <= $seaPoint['max']
|| $row['integral'] >= $seaPoint['min'] && $seaPoint['max'] == -1) {
$is_pro = $seaPoint['is_protect'];
$min_score = $seaPoint['min'];
}
}
if ($is_pro == 1 && $min_score > $update_score) {
$update_score = $min_score;
}
$inret = $conn->execScript('UPDATE user SET integral=:integral, max_integral=:max_integral, rank_modifytime=:rank_modifytime ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':integral' => $update_score,
':rank_modifytime' => phpcommon\getNowTime(),
':max_integral' => $update_maxscore,
));
if (!$inret) {
die();
return;
}
}
//更新历史最高信息
if ($kill_his < $row['kill_his']) {
$kill_his = $row['kill_his'];
}
if ($harm_his < $row['harm_his']) {
$harm_his = $row['harm_his'];
}
$sea_max_hart = $harm;
if ($sea_max_hart < $row['sea_max_hart']) {
$sea_max_hart = $row['sea_max_hart'];
}
$sea_max_kill = $kills;
if ($sea_max_kill < $row['sea_max_kill']) {
$sea_max_kill = $row['sea_max_kill'];
}
if ($alive_time_his < $row['alive_time_his']) {
$alive_time_his = $row['alive_time_his'];
}
if ($add_HP_his < $row['add_HP_his']) {
$add_HP_his = $row['add_HP_his'];
}
//添加空投箱
$box_num = $row['box_num'];
if ($row['box_num'] + 1 <= 20) {
$box_num = $row['box_num'] + 1;
}
$nowTime = phpcommon\getdayseconds(phpcommon\getNowTime());
$daily_time = $row['daily_time'];
if ($daily_time == 0 || ($nowTime - phpcommon\getdayseconds($daily_time) > 0)) {
$daily_time = phpcommon\getNowTime();
}
$daily_first_login = $row['daily_first_login'];
/* $switch = $this->getSwitch($account_id);
if ($switch == 1) {
$daily_first_login = $daily_first_login + 1;
}*/
$newhand = $row['newhand'];
$newhand2 = $row['newhand2'];
$game_times2 = $row['game_times2'];
$p1 = mt\Parameter::getOldParam(NEWHAND_NUM1);
$fight_times = $p1['param_value'];
$p2 = mt\Parameter::getOldParam(NEWHAND_NUM2);
$view_times = $p2['param_value'];
$p3 = mt\Parameter::getOldParam(CREAM_TASK_01);
$fight_times2 = $p3['param_value'];
$p4 = mt\Parameter::getOldParam(CREAM_TASK_02);
$view_times2 = $p4['param_value'];
if ($row['game_times'] + 1 == $fight_times && $row['vip_score'] >= $view_times) {
$newhand = 1;
}
if ($newhand == 2) {
if ($row['game_times2'] + 1 == $fight_times2 && $row['view_times2'] >= $view_times2) {
$newhand2 = 1;
}
$game_times2++;
}
$ret = $conn->execScript('UPDATE user SET game_times=:game_times, kills=:kills, harm=:harm, add_HP=:add_HP, alive_time=:alive_time, kill_his=:kill_his, alive_time_his=:alive_time_his, harm_his=:harm_his, add_HP_his=:add_HP_his, coin_num=:coin_num, modify_time=:modify_time, first_fight=1, box_num=:box_num, score=:score, daily_time=:daily_time, season_games=:season_games, sea_max_kill=:sea_max_kill, sea_max_hart=:sea_max_hart, sea_avg_kill=:sea_avg_kill, newhand=:newhand, newhand2=:newhand2, game_times2=:game_times2 ' .
'WHERE accountid=:accountid;',
array(
':game_times' => $row['game_times'] + 1,
':kill_his' => $kill_his,
':kills' => $row['kills'] + $kills,
':harm_his' => $harm_his,
':harm' => $row['harm'] + $harm,
':add_HP' => $row['add_HP'] + $add_HP,
':alive_time' => $row['alive_time'] + $alive_time,
':alive_time_his' => $alive_time_his,
':add_HP_his' => $add_HP_his,
':accountid' => $account_id,
':coin_num' => $row['coin_num'] + $coin_num,
':modify_time' => phpcommon\getNowTime(),
':box_num' => $box_num,
':score' => $row['score'],
':daily_time' => $daily_time,
':season_games' => $row['season_games'] + 1,
':sea_max_kill' => $sea_max_kill,
':sea_max_hart' => $sea_max_hart,
':sea_avg_kill' => $row['sea_avg_kill'] + $kills,
':newhand' => $newhand,
':newhand2' => $newhand2,
':game_times2' => $game_times2,
));
if (!$ret) {
die();
return;
}
$addreward = new classes\Addreward();
$vip_level = $addreward->getVipLevel($account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'kill_his' => $kill_his,
'alive_time_his' => $alive_time_his,
'harm_his' => $harm_his,
'add_HP_his' => $add_HP_his,
));
}
public function shareGame()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
// $quest = new classes\Quest();
// $quest->triggerQuest(QUEST_DAY_SHARE, 1, 1, $account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
));
}
public function getPreSettlementInfo()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$pre_settlement_info = '';
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'pre_settlement_info' => $pre_settlement_info
));
}
public function getRobotInfo()
{
$account_id = $_REQUEST['account_id'];
$member = array();
$i = Rand(1, 100);
$coin = Rand(1, 100) * 0.01;
$num = 1;
$robot_id = 1000 + $i;
$address = '../res/robot@robot' . $num . '.php';
$robot_meta_cluster = require($address);
$robot_meta = getRobotConfig($robot_meta_cluster, $robot_id);
$rob = array(
'id' => $robot_meta['id'],
'name' => $robot_meta['name'],
'avatar_url' => $robot_meta['avatar_url'],
'sex' => $robot_meta['sex']
);
array_push ($member, array(
'account_id' => $rob['id'],
'name' => $rob['name'],
'avatar_url' => $rob['avatar_url'],
));
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'member_list' => $member,
'sin_member' => $robot_meta_cluster,
'num' => $coin,
));
}
protected function updateSwitch($account_id, $switch_id)
{
$r = $this->getRedis($account_id);
if (!$r) {
die();
return;
}
$switch_uuid = 'game2005api_switch:' . $account_id;
$r -> set($switch_uuid, $switch_id);
$r -> pexpire($switch_uuid, 1000 * 3600 * 24);
}
protected function getSwitch($account_id)
{
$r = $this->getRedis($account_id);
if (!$r) {
die();
return;
}
$switch_uuid = 'game2005api_switch:' . $account_id;
$user_db_str = $r->get($switch_uuid);
$switch = json_decode($user_db_str, true);
return $switch;
}
public function getFightReward()
{
$account_id = $_REQUEST['account_id'];
$coin_num = $_REQUEST['coin_num'];
$reward_id = $_REQUEST['reward_id'];
$reward_num = $_REQUEST['reward_num'];
$addreward = new classes\AddReward();
$p = mt\Parameter::getOldParam(GAMEOVER_REWARD_TIMES);
$times = $p['param_value'] - 1;
$addreward = new classes\AddReward();
$val = $addreward->getVipVal($account_id, 1);
$coin_num = floor($coin_num + $coin_num * $val / 100);
$addreward->addReward(10001, $coin_num * $times, $account_id, 0, 0);
if ($reward_id != 0) {
$addreward->addReward($reward_id, $reward_num * $times, $account_id, 0, 0);
}
$coin_num = $addreward->getCoinNum($account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
'coin_nums' => $coin_num,
));
}
public function getNewHandReward()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$row = $conn->execQueryOne('SELECT newhand, newhand2 FROM user WHERE accountid=:account_id;',
array(
':account_id' => $account_id
));
$type = 1;
if (isset($_REQUEST['type'])) {
$type = $_REQUEST['type'];
}
$reward_id = 29001;
if ($type == 1) {
$reward_id = 29001;
if (!$row || $row['newhand'] != 1) {
phpcommon\sendError(ERR_USER_BASE + 2, '未达到领取条件');
return;
}
$ret = $conn->execScript('UPDATE user SET newhand=2, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':modify_time' => phpcommon\getNowTime(),
':accountid' => $account_id
));
if (!$ret) {
die();
return;
}
} else if ($type == 2) {
$reward_id = 29002;
if (!$row || $row['newhand2'] != 1) {
phpcommon\sendError(ERR_USER_BASE + 2, '未达到领取条件');
return;
}
$ret = $conn->execScript('UPDATE user SET newhand2=2, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':modify_time' => phpcommon\getNowTime(),
':accountid' => $account_id
));
if (!$ret) {
die();
return;
}
}
$d = mt\Drop::getOldDrop($reward_id);
if (!$d) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
return;
}
$item_list = array();
$all_item_list = array();
$item_id_array = $this->getExplode($d['item_id']);
$item_num_array = $this->getExplode($d['num']);
for ($i = 0; $i < count($item_id_array); $i++) {
$item_id = $item_id_array[$i][0];
$item_num = $item_num_array[$i][0];
array_push($item_list, array(
'item_id' => $item_id,
'item_num' => $item_num,
'time' => 0
));
}
$addreward = new classes\AddReward();
foreach ($item_list as $item) {
$items = $addreward->addReward($item['item_id'], $item['item_num'], $account_id, $item['time'], 0);
foreach($items as $i) {
array_push($all_item_list, array(
'item_id' => $i['item_id'],
'item_num' => $i['item_num'],
'time' => $i['time'],
));
}
}
$coin_num = $addreward->getCoinNum($account_id);
$num = $addreward->getRmbNum($account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
'item_list' => $item_list,
'coin_num' => $coin_num,
'rmb_nums' => $num,
'all_item_list' => $all_item_list
));
}
public function getSessionId()
{
$account_id = $_REQUEST['account_id'];
$registertime = $_REQUEST['registertime'];
$session_key = $_REQUEST['session_key'];
$session_id = $this->createSessionId($account_id, $registertime, $session_key);
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
'session_id' => $session_id,
));
}
protected function createSessionId($accountid, $registertime, $session_key)
{
$nowtime = phpcommon\getNowTime();
$session_id = $nowtime
. '_'
. $registertime
. '_'
. md5($accountid . 'f3a6a9a5-217a-4079-ab99-b5d69b8212be' . $registertime . $nowtime)
. '_'
. md5('f3a6a9a5-217a-4079-ab99-b5d69b8212be'
. $accountid
. $session_key
. phpcommon\getNowTime()
. rand()
);
return $session_id;
}
public function exchangeCoin()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$rowUser = $conn->execQueryOne('SELECT coin_times, coin_num FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (!$rowUser) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$id = 12141;
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
}
$rowEquip = $conn->execQueryOne('SELECT id, lv FROM equip WHERE accountid=:accountid AND id=:id;',
array(
':accountid' => $account_id,
':id' => $id,
));
if (!$rowEquip) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个装备');
return;
}
$coin_times = $rowUser['coin_times'];
$p1 = mt\Parameter::getOldParam(DAILYCOIN_TIMES);
$max_times = $p1['param_value'];
$p2 = mt\Parameter::getOldParam(DAILYCOIN_DECAY);
$val = $p2['param_value'];
$p3 = mt\Parameter::getOldParam(DAILYCOIN_NUM);
$num = $p3['param_value'];
$e = mt\EquipUpgrade::getOldEquipUp($rowEquip['id']);
$eg = mt\Equip::getOldEquip($rowEquip['id']);
if (!$e || !$eg) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个装备');
return;
}
if (isset($_REQUEST['num'])) {
$coin_num = $_REQUEST['num'];
} else {
$coin_list = $this->getExplode($e['coin_num']);
$coin_arr = $this->getExplode($eg['promote_gold']);
$coin_num = $coin_list[$rowEquip['lv']][0] * $coin_arr[$rowEquip['lv']][0];
}
if ($coin_times >= $max_times) {
phpcommon\sendError(ERR_USER_BASE + 2, '今日次数达到上限');
return;
}
//$coin_num = $_REQUEST['num'];
//$coin_num = round($num * pow($val, $coin_times));
$ret = $conn->execScript('UPDATE user SET coin_times=:coin_times, coin_num=:coin_num, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':coin_times' => $coin_times + 1,
':coin_num' => $coin_num + $rowUser['coin_num'],
':modify_time' => phpcommon\getNowTime()
));
if (!$ret) {
die();
return;
}
$coin = $coin_num + $rowUser['coin_num'];
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'coin_nums' => $coin,
'coin_times' => $coin_times + 1
));
}
public function saveNewbie()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
//$info = array();
$id = $_REQUEST['id'];
$rowUser = $conn->execQueryOne('SELECT newInfo FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (!$rowUser) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$info = json_decode($rowUser['newInfo']);
if (empty($info)) {
$info = array();
}
array_push($info, (int)$id);
$ret = $conn->execScript('UPDATE user SET newInfo=:newInfo,modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':newInfo' => json_encode($info),
':modify_time' => phpcommon\getNowTime()
));
if (!$ret) {
die();
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
));
}
public function getVideoReward()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$rowUser = $conn->execQueryOne('SELECT rmb_num, share_video_times FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (!$rowUser) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$p = mt\Parameter::getOldParam(SHARE_VIDEO_REWARD);
$num = $p['param_value'];
$ret = $conn->execScript('UPDATE user SET rmb_num=:rmb_num, share_video_times=:share_video_times, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':rmb_num' => $rowUser['rmb_num'] + $num,
':share_video_times' => $rowUser['share_video_times'] + 1,
':modify_time' => phpcommon\getNowTime()
));
if (!$ret) {
die();
return;
}
$addreward = new classes\AddReward();
$rmb_num = $addreward->getRmbNum($account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
'rmb_nums' => $rmb_num,
));
}
public function getDeskReward()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$rowUser = $conn->execQueryOne('SELECT first_gift FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (!$rowUser) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$ret = $conn->execScript('UPDATE user SET first_gift=1, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => phpcommon\getNowTime()
));
if (!$ret) {
die();
return;
}
$addreward = new classes\AddReward();
$item_list = array();
$all_item_list = array();
$items = $addreward->addReward(13003, 1, $account_id, 0, 0);
array_push($item_list, array(
'item_id' => 13003,
'item_num' => 1,
'time' => 0,
));
array_push($item_list, array(
'item_id' => 10003,
'item_num' => 88,
'time' => 0,
));
foreach($items as $i) {
array_push($all_item_list, array(
'item_id' => $i['item_id'],
'item_num' => $i['item_num'],
'time' => $i['time'],
));
}
$items = $addreward->addReward(10003, 88, $account_id, 0, 0);
foreach($items as $i) {
array_push($all_item_list, array(
'item_id' => $i['item_id'],
'item_num' => $i['item_num'],
'time' => $i['time'],
));
}
$rmb_num = $addreward->getRmbNum($account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
'item_list'=>$item_list,
'all_item_list' => $all_item_list,
'rmb_nums' => $rmb_num,
'flag' => 1,
));
}
public function getShareVideoReward()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$rowUser = $conn->execQueryOne('SELECT act_video_status FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (!$rowUser) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
if ($rowUser['act_video_status'] != 1){
phpcommon\sendError(ERR_USER_BASE + 2, '奖励不可领取');
return;
}
$ret = $conn->execScript('UPDATE user SET act_video_status=2, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => phpcommon\getNowTime()
));
if (!$ret) {
die();
return;
}
$addreward = new classes\AddReward();
$item_list = array();
$all_item_list = array();
array_push($item_list,array(
'item_id' => 13018,
'item_num' => 1,
'time' => 0
));
$items = $addreward->addReward(13018, 1, $account_id, 0, 0);
foreach($items as $i) {
array_push($all_item_list, array(
'item_id' => $i['item_id'],
'item_num' => $i['item_num'],
'time' => $i['time'],
));
}
array_push($item_list,array(
'item_id' => 15018,
'item_num' => 1,
'time' => 0
));
$items = $addreward->addReward(15018, 1, $account_id, 0, 0);
foreach($items as $i) {
array_push($all_item_list, array(
'item_id' => $i['item_id'],
'item_num' => $i['item_num'],
'time' => $i['time'],
));
}
$rmb_num = $addreward->getRmbNum($account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
'rmb_nums' => $rmb_num,
'item_list' => $item_list,
'all_item_list' => $all_item_list,
'status' => 2,
));
}
public function getWatchAdReward()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$rowUser = $conn->execQueryOne('SELECT act_ad_status FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (!$rowUser) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
if ($rowUser['act_ad_status'] != 1){
phpcommon\sendError(ERR_USER_BASE + 2, '奖励不可领取');
return;
}
$ret = $conn->execScript('UPDATE user SET act_ad_status=2, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => phpcommon\getNowTime()
));
if (!$ret) {
die();
return;
}
$addreward = new classes\AddReward();
$item_list = array();
$all_item_list = array();
array_push($item_list,array(
'item_id' => 13003,
'item_num' => 1,
'time' => 0
));
$items = $addreward->addReward(13003, 1, $account_id, 0, 0);
foreach($items as $i) {
array_push($all_item_list, array(
'item_id' => $i['item_id'],
'item_num' => $i['item_num'],
'time' => $i['time'],
));
}
array_push($item_list,array(
'item_id' => 15003,
'item_num' => 1,
'time' => 0
));
$items = $addreward->addReward(15003, 1, $account_id, 0, 0);
foreach($items as $i) {
array_push($all_item_list, array(
'item_id' => $i['item_id'],
'item_num' => $i['item_num'],
'time' => $i['time'],
));
}
$rmb_num = $addreward->getRmbNum($account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
'rmb_nums' => $rmb_num,
'item_list' => $item_list,
'all_item_list' => $all_item_list,
'status' => 2,
));
}
public function addVideotimes()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$row = $conn->execQueryOne('SELECT share_video_sums, act_video_status FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$status = $row['act_video_status'];
if ($row['share_video_sums'] + 1 >= 3 && $row['act_video_status'] < 1){
$status = 1;
}
$ret = $conn->execScript('UPDATE user SET share_video_sums=:share_video_sums, modify_time=:modify_time, act_video_status=:act_video_status ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => phpcommon\getNowTime(),
':share_video_sums' => $row['share_video_sums'] + 1,
':act_video_status' => $status,
));
if (!$ret) {
die();
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
));
}
public function getFightEquip()
{
$account_id = $_REQUEST['account_id'];
$id = $_REQUEST['id'];
$conn = $this->getMysql($account_id);
$addreward = new classes\AddReward();
$item_list = array();
array_push($item_list, array(
'item_id' => $id,
'item_num' => 1,
'time' => 0
));
$all_item_list = $addreward->addReward($id, 1, $account_id, 0, 0);
$p1 = mt\Parameter::getOldParam(OPENING_SPEAR);
$equip1 = $p1['param_value'];
$p2 = mt\Parameter::getOldParam(OPENING_SPEAR2);
$equip2 = $p2['param_value'];
if ($equip1 == $id) {
$ret = $conn->execScript('UPDATE user SET new_first_equip=1, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => phpcommon\getNowTime(),
));
if (!$ret) {
die();
return;
}
$ret = $conn->execScript('UPDATE equip SET using_id=:using_id, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':using_id' => $id,
':modify_time' => phpcommon\getNowTime(),
));
if (!$ret) {
die();
return;
}
} else if ($equip2 == $id) {
$ret = $conn->execScript('UPDATE user SET new_second_equip=1, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => phpcommon\getNowTime(),
));
if (!$ret) {
die();
return;
}
}
echo json_encode(array(
'errcode' => 0,
'errmsg'=> '',
'item_list' => $item_list,
'all_item_list' => $all_item_list,
));
}
public function updateMoney()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$sqlStr = "SELECT coin_num FROM user WHERE accountid=:accountid; ";
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
if($row) {
error_log("UpdateMoney======".json_encode($row));
}
else{
error_log("Test06=======");
}
$this->sendDataToClient(1,"ok",$row[0]);
}
public function updateMoneyAndLottery()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$sqlStr = "SELECT coin_num,rmb_num FROM user WHERE accountid=:accountid; ";
$row = $conn->execQuery($sqlStr,array(':accountid' => $account_id));
if($row) {
error_log("UpdateMoneyAndLottery======".json_encode($row));
}
else{
}
$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));
}
}