game2005api/webapp/controller/RoleController.class.php
2021-11-22 11:45:59 +08:00

2018 lines
81 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');
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);
//创建任务对象结束--
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
if (empty($_REQUEST['account_id'])) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$this->updateSwitch($account_id, $switch_id);
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
//$newInfo = array();
if (!$row) {
$season_time = 0;
$season_meta_table = require('../res/season@season.php');
for ($i = 1; $i <= count($season_meta_table); $i++) {
$season = mt\Season::getOldSeason($i);
if (phpcommon\getNowTime() >= strtotime($season['open_time']) && phpcommon\getNowTime() <= strtotime($season['end_time'])) {
$season_time = strtotime($season['end_time']);
break;
}
}
$ret = $conn->execScript('INSERT INTO user(accountid, user_name, avatar_url, game_times, win_times, kills, harm, add_HP, alive_time, coin_num, integral, kill_his, alive_time_his, harm_his, add_HP_his, act_share_time, act_share_status, create_time, modify_time, first_fight, collect_status, keys_num, battle_re_times, shop_flush_times, kefu_status, sign_sum, box_num, diamond_num, sum_coin, pass_status, score, season_status, recharge_times_total, first_gift, season_time, free_coin, free_diamond, season_end_score, kill_modifytime, win_modifytime, rank_modifytime, vip_score, first_login, daily_first_login, daily_time, free_box, update_time, season_games, season_win, sea_max_kill, sea_max_hart, sea_avg_kill, free_lot_ticket, free_dou_lot_ticket, daily_order1, daily_order2, daily_order3, first_bee, newhand, coin_times, newInfo, first_day_ad, share_video_times, share_video_sums, act_video_status, act_ad_status, biogame_times, shop_view_times, new_first_equip, newhand2,game_times2, view_times2, guildcoin_num, new_second_equip, rmb_num, max_single_recharge, passcard, rmb_lot_ticket, daily_max_single, head_kuang_id, daily_score, daily_offline, create_user, sex, sumlot_coin, max_integral,lv,lv_exp,money_of_week,team_name,hi_id,hero_id) ' .
' VALUES(:accountid, :user_name, :avatar_url, 0, 0, 0, 0, 0, 0, 10000, 0, 0, 0, 0, 0, 0, 0, :create_time, :modify_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, :season_time, 0, 0, 0, 0, 0, 0, 0, 0, 0, :daily_time, 0,:update_time,0,0,0,0,0,0,0,0,0,0,0,0,0,:newInfo,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0, 0, 0, 19003, 0, 0, 0, 2, 0, 0,0,0,0,"",18001,30100) ' .
' ON DUPLICATE KEY UPDATE accountid=:accountid, user_name=:user_name, avatar_url=:avatar_url, game_times=0, win_times=0, kills=0, harm=0, add_HP=0, alive_time=0, coin_num=0, integral=0, kill_his=0, alive_time_his=0, harm_his=0, add_HP_his=0, act_share_time=0, act_share_status=0, modify_time=:modify_time, first_fight=0, collect_status=0, keys_num=0, battle_re_times=0, shop_flush_times=0, kefu_status=0, sign_sum=0, box_num=0, diamond_num=0, sum_coin=0, pass_status=0, score=0, season_status=1, recharge_times_total=0, first_gift=0, season_time=:season_time, free_coin=0, free_diamond=0, season_end_score=0, kill_modifytime=0, win_modifytime=0, rank_modifytime=0, vip_score=0, first_login=0, daily_first_login=0, daily_time=:daily_time, free_box=0, update_time=:update_time, season_games=0, season_win=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, free_lot_ticket=0, free_dou_lot_ticket=0, daily_order1=0, daily_order2=0, daily_order3=0, first_bee=0, newhand=0, coin_times=0, newInfo=:newInfo, first_day_ad=0, share_video_times=0, share_video_sums=0, act_video_status=0, act_ad_status=0, biogame_times=0, shop_view_times=0, new_first_equip=0, newhand2=0, game_times2=0,view_times2=0, guildcoin_num=0, new_second_equip=2, rmb_num=0, max_single_recharge=0, passcard=0, rmb_lot_ticket=0, daily_max_single=0, head_kuang_id=0, daily_score=0, daily_offline=0, create_user=0, sex=2, sumlot_coin=0, max_integral=0,lv_exp = 0,money_of_week = 0 ,team_name = "",hi_id = 18001,hero_id = 30100;',
array(
':accountid' => $account_id,
':user_name' => $user_name,
':avatar_url' => $avatar_url,
':create_time' => phpcommon\getNowTime(),
':modify_time' => phpcommon\getNowTime(),
':daily_time' => 0,
':update_time' => phpcommon\getNowTime(),
':newInfo' => '',
':season_time' => $season_time
));
if (!$ret) {
die();
return;
}
//赠送玩家英雄开始--
$this->addHeroToDB();
//赠送玩家英雄结束--
//新玩家赠送材料,表情
$this->newPlayerReward($account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'game_times' => 0,
'win_times' => 0,
'high_kill' => 0,
'kills' => 0,
'high_harm' => 0,
'harm' => 0,
'add_HP' => 0,
'alive_time' => 0,
'coin_num' => 10000,
'first_fight' => 0,
'collect_status' => 0,
'keys_num' => 0,
'kefu_status' => 0,
'box_num' => 0,
'diamond_num' => 0,
'pass_status' => 0,
'season_status' => 1,
'first_gift' => 0,
'sum_coin' => 0,
'recharge_times_total' => 0,
'first_login' => 0,
'daily_first_login' => 0,
'free_box' => 0,
'season_games' => 0,
'season_win' => 0,
'sea_max_kill' => 0,
'sea_max_hart' => 0,
'sea_avg_kill' => 0,
'free_lot_ticket' => 0,
'free_dou_lot_ticket' => 0,
'time' => phpcommon\getNowTime(),
'newhand' => 0,
'vip_score' => 0,
'coin_times' => 0,
'newInfo' => '',
'first_day_ad' => 0,
'integral' => 0,
'share_video_times' => 0,
'share_video_sums' => 0,
'act_video_status' => 0,
'act_ad_status' => 0,
'biogame_times' => 0,
'coin_nums' => 10000,
'diamond_times' => 0,
'shop_view_times' => 0,
'new_first_equip' => 0,
'newhand2' =>0,
'game_times2'=>0,
'view_times2'=>0,
'guildcoin_num' => 0,
'new_second_equip' => 2,
'rmb_num' => 0,
'max_single_recharge' => 0,
'passcard' => 0,
'rmb_lot_ticket' => 0,
'daily_max_single' => 0,
'head_kuang_id' => 0,
'daily_score' => 0,
'score' => 0,
'daily_offline' => 0,
'user_name' => $user_name,
'avatar_url' => $avatar_url,
'create_user' => 0,
'sex' => 2,
'lv' => 0,
'lv_exp'=> 0,
'hiid' => 18001,
'hero_id' => 30100,
'max_seasonScore' => 0
));
} else {
// if ($avatar_url != '') {
// if ($user_name != $row['user_name']) {
// $ret = $conn->execScript('UPDATE user SET user_name=:user_name, modify_time=:modify_time ' .
// ' WHERE accountid=:accountid;',
// array(
// ':accountid' => $account_id,
// ':user_name' => $user_name,
// ':modify_time' => phpcommon\getNowTime()
// ));
// }
// if ($avatar_url != $row['avatar_url']) {
// $ret = $conn->execScript('UPDATE user SET avatar_url=:avatar_url, modify_time=:modify_time ' .
// ' WHERE accountid=:accountid;',
// array(
// ':accountid' => $account_id,
// ':avatar_url' => $avatar_url,
// ':modify_time' => phpcommon\getNowTime()
// ));
// }
// }
$nowTime = phpcommon\getdayseconds(phpcommon\getNowTime());
$daily_first_login = $row['daily_first_login'];
$coin_times = $row['coin_times'];
$kefu_status = $row['kefu_status'];
$first_day_ad = $row['first_day_ad'];
$share_video_times = $row['share_video_times'];
$act_ad_status = $row['act_ad_status'];
$new_second_equip = $row['new_second_equip'];
$passcard = $row['passcard'];
if ($row['vip_score'] >= 5 && $act_ad_status != 2) {
$act_ad_status = 1;
$ret = $conn->execScript('UPDATE user SET act_ad_status=:act_ad_status WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':act_ad_status' => $act_ad_status
));
if (!$ret) {
die();
return;
}
}
if ($row['update_time'] == 0 || ($nowTime - phpcommon\getdayseconds($row['update_time']) > 0)) {
if ($new_second_equip == 2 && $row['new_first_equip'] == 1) {
$new_second_equip = 0;
}
$ret = $conn->execScript('UPDATE user SET daily_first_login=0, free_box=0, kefu_status=0, coin_times=0, ' .
'modify_time=:modify_time, first_day_ad=0, share_video_times=0, new_second_equip=:new_second_equip, daily_max_single=0, daily_score=0, daily_offline=0 WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => phpcommon\getNowTime(),
':new_second_equip' => $new_second_equip,
));
if (!$ret) {
die();
return;
}
$daily_first_login = 0;
$kefu_status = 0;
$coin_times = 0;
$first_day_ad = 0;
$share_video_times = 0;
if (phpcommon\getNowTime() > $row['season_time'] && $row['season_time'] != 0) {
$this->updateSeasonStatus($account_id);
}
}
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'game_times' => $row['game_times'],
'win_times' => $row['win_times'],
'high_kill' => $row['kill_his'],
'kills' => $row['kills'],
'high_harm' => $row['harm_his'],
'harm' => $row['harm'],
'add_HP' => $row['add_HP'],
'alive_time' => $row['alive_time'],
'coin_num' => $row['coin_num'],
'first_fight' => $row['first_fight'],
'collect_status' => $row['collect_status'],
'keys_num' => $row['keys_num'],
'kefu_status' => $kefu_status,
'box_num' => $row['box_num'],
'diamond_num' => $row['diamond_num'],
'pass_status' => $row['pass_status'],
'season_status' => $row['season_status'],
'first_gift' => $row['first_gift'],
'sum_coin' => $row['sum_coin'],
'recharge_times_total' => $row['recharge_times_total'],
'first_login' => $row['first_login'],
'daily_first_login' =>$daily_first_login,
'vip_score' => $row['vip_score'],
'coin_nums' => $row['coin_num'],
'diamond_nums' => $row['diamond_num'],
'free_box' => $row['free_box'],
'season_games' => $row['season_games'],
'season_win' => $row['season_win'],
'sea_max_kill' => $row['sea_max_kill'],
'sea_max_hart' => $row['sea_max_hart'],
'sea_avg_kill' => $row['sea_avg_kill'],
'free_dou_lot_ticket' => $row['free_dou_lot_ticket'],
'free_lot_ticket' => $row['free_lot_ticket'],
'time' => phpcommon\getNowTime(),
'newhand' => $row['newhand'],
'coin_times' => $coin_times,
'newInfo' => $row['newInfo'],
'first_day_ad' => $first_day_ad,
'integral' => $row['integral'],
'share_video_times' => $share_video_times,
'share_video_sums' => $row['share_video_sums'],
'act_video_status' => $row['act_video_status'],
'act_ad_status' => $act_ad_status,
'biogame_times' => $row['biogame_times'],
'shop_view_times' => $row['shop_view_times'],
'new_first_equip' => $row['new_first_equip'],
'newhand2' =>$row['newhand2'],
'game_times2'=>$row['game_times2'],
'view_times2'=>$row['view_times2'],
'guildcoin_num'=> $row['guildcoin_num'],
'new_second_equip' => $new_second_equip,
'rmb_num' => $row['rmb_num'],
'max_single_recharge' => $row['max_single_recharge'],
'passcard' => $row['passcard'],
'rmb_lot_ticket' => $row['rmb_lot_ticket'],
'daily_max_single' => $row['daily_max_single'],
'head_kuang_id' => $row['head_kuang_id'],
'daily_score' => $row['daily_score'],
'score' => $row['score'],
'daily_offline' => $row['daily_offline'],
'user_name' => $row['user_name'],
'avatar_url' => $row['avatar_url'],
'create_user' => $row['create_user'],
'sex' => $row['sex'],
'lv' => $row['lv'],
'lv_exp'=> $row['lv_exp'],
'hiid' => $row['hi_id'],
'hero_id' => $row['hero_id'],
'max_seasonScore' => $row['max_integral']
));
}
}
public function addHeroToDB()
{
// $itemArr = [10101,10102,10103,10104,10105,10106,10200,10201,
// 10202,10203,10204,10205,10206,10207,10208,12100,12102,12103,12104,
// 12105,12106,12107,12119,12120,12121];
$globleCfg = mt\Parameter::get(212);
$paramValue = $globleCfg["param_value"];
$paramStrArr = explode("|",$paramValue);
$itemIDArr = array();
for($i = 0 ; $i < count($paramStrArr); $i++)
{
array_push($itemIDArr,$paramStrArr[$i]);
error_log("newPlayerHero========".$paramStrArr[$i]);
}
$playerCfg = require('../res/player@player.php');
$itemArr = array();
$len = count($itemIDArr);
for($i = 0; $i< $len; $i++)
{
$heroID = $itemIDArr[$i];
if($playerCfg[$heroID])
{
$heroCfg = $playerCfg[$heroID];
$skinListStr = $heroCfg["skinlist"];
$skinIDArr = explode("|",$skinListStr);
$skinID = $skinIDArr[0];
$itemData = array("hero_id"=>$heroID,"skin_id"=>$skinID);
array_push($itemArr,$itemData);
$skinData = array(
'accountid' => $this->getAccountId(),'hero_id' => $heroID,'skin_id' => $skinID,
'skin_state' => 0,
'get_from' => 0,
'consume_num' => 0,
'trytime' => 0
);
$this->addHeroSkin($skinData);
}
}
$this->addAllHero($itemArr);
}
public function addAllHero($items)
{
foreach ($items as $item) {
phpcommon\SqlHelper::insertOrUpdate
($this->getSelfMysql(),
'hero',
array(
'accountid' => $this->getAccountId(),
'id' => $item['hero_id']
),
array(
'accountid' => $this->getAccountId(),
'id' => $item['hero_id'],
'lv' => 1,
'skinid' => $item['skin_id'],
'skill1_lv1' =>1,
'skill1_lv2' =>1,
'yokeexp' => 0,
'yoketotalexp' => 0,
'createtime' => $this->getNowTime(),
'modifytime' => $this->getNowTime()
),
array(
'skill_lv1' => 1,
'modifytime' => $this->getNowTime()
)
);
}
}
public function addHeroSkin($item)
{
phpcommon\SqlHelper::insertOrUpdate
($this->getSelfMysql(),
'hero_skin',
array(
'accountid' => $this->getAccountId(),
'hero_id' => $item['hero_id'],
'skin_id' => $item['skin_id']
),
array(
'accountid' => $this->getAccountId(),
'hero_id' => $item['hero_id'],
'skin_id' => $item['skin_id'],
'skin_state' => $item['skin_state'],
'get_from' => $item['get_from'],
'consume_num' => $item['consume_num'],
'trytime' => $item['trytime'],
'createtime' => $this->getNowTime(),
'modifytime' => $this->getNowTime()
),
array(
'skin_state' => 3,
'modifytime' => $this->getNowTime()
)
);
}
protected function newPlayerReward($account_id)
{
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
die();
}
// $ret1 = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, num, active_time, create_time, modify_time) ' .
// ' VALUES(:account_id, :id, 0, :status, 400, :active_time, :create_time, :modify_time) ' .
// ' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, num=400, active_time=:active_time, modify_time=:modify_time;',
// array(
// ':account_id' => $account_id,
// ':id' => 10010,
// ':active_time' => 0,
// ':status' => 0,
// ':create_time' => phpcommon\getNowTime(),
// ':modify_time' => phpcommon\getNowTime()
// ));
$ret2 = $conn->execScript('INSERT INTO bag(accountid, id, color_id, status, num, active_time, create_time, modify_time) ' .
' VALUES(:account_id, :id, 0, :status, 0, :active_time, :create_time, :modify_time) ' .
' ON DUPLICATE KEY UPDATE accountid=:account_id, id=:id, color_id=0, status=:status, num=0, active_time=:active_time, modify_time=:modify_time;',
array(
':account_id' => $account_id,
':id' => 16001,
':active_time' => 0,
':status' => 0,
':create_time' => phpcommon\getNowTime(),
':modify_time' => phpcommon\getNowTime()
));
}
protected function updateSeasonStatus($account_id)
{
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
die();
}
//刷新赛季奖励状态
$rowUser = $conn->execQueryOne('SELECT season_time, pass_status, integral ' .
' FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
));
if (phpcommon\getNowTime() > $rowUser['season_time'] && $rowUser['season_time'] != 0) {
$season_meta_table = require('../res/season@season.php');
$end_time = 0;
for ($i = 1; $i <= count($season_meta_table); $i++) {
$season = mt\Season::getOldSeason($i);
if (phpcommon\getNowTime() >= strtotime($season['open_time']) && phpcommon\getNowTime() <= strtotime($season['end_time'])) {
$end_time = strtotime($season['end_time']);
break;
}
}
$season_point_table = require('../res/seasomPoint@seasomPoint.php');
$integral = 0;
for ($j = 1; $j <= count($season_point_table); $j++) {
$seasonpoint = mt\Season::getOldSeasonPoint($j);
if ($rowUser['integral'] <= $seasonpoint['max'] ||
$seasonpoint['max'] == -1) {
$integral = $seasonpoint['topoint'];
break;
}
}
$user_ret = $conn->execScript('UPDATE user SET pass_status=0, score=0, season_status=0, integral=:integral, season_end_score=:season_end_score, modify_time=:modify_time, season_games=0, sea_max_kill=0, sea_max_hart=0, sea_avg_kill=0, season_win=0, season_time=:season_time, passcard=0 ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':season_end_score' => $rowUser['integral'],
':modify_time' => phpcommon\getNowTime(),
':season_time' => $end_time,
':integral' => $integral
));
if (!$user_ret) {
die();
}
$pass_ret = $conn->execScript('UPDATE passinfo SET active_status=0, honor_status=0, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => phpcommon\getNowTime()
));
if (!$pass_ret) {
die();
}
}
}
protected function updateDaily($account_id, $daily_time)
{
$nowTime = phpcommon\getdayseconds(phpcommon\getNowTime());
$conn = $this->getMysql($account_id);
$daily_first_login = $daily_first_login + 1;
//更新人物信息
if ($daily_time == 0 || ($nowTime - phpcommon\getdayseconds($daily_time) > 0)) {
$daily_first_login = 0;
}
$ret = $conn->execScript('UPDATE user SET daily_first_login=:daily_first_login, ' .
'modify_time=:modify_time WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => phpcommon\getNowTime(),
':daily_first_login' => $daily_first_login,
));
if (!$ret) {
die();
}
return $daily_first_login;
}
public function clientBattleReport()
{
$account_id = $_REQUEST['account_id']; //账号
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
phpcommon\SqlHelper::update
($conn,
'user',
array(
'accountid' => $account_id,
),
array(
'first_fight' => function () {
return '1';
}
)
);
$this->rspOk();
}
public function battleReport()
{
// error_log("游戏结束====".json_encode($_REQUEST));
//任务参与 N场比赛开始--
$taskObj = new NTaskController();
$taskObj->updateTaskToDB(PLAY_GAME,1);
//任务参与 N场比赛结束--
//累计生存时间多少分钟开始--
$alive_time = $_REQUEST["alive_time"];
$tmpAlive_time = floor($alive_time/1000);
$taskObj->updateTaskToDB(ALIVE_TIME,$tmpAlive_time);
// error_log("玩家存活时间======".$alive_time."==".$tmpAlive_time);
//累计生存时间多少分钟结束--
//累计击杀10个敌人开始--
$killNum = $_REQUEST['kills'];
$taskObj->updateTaskToDB(KILL_NUM,$killNum);
//累计击杀10个敌人结束--
//造成800伤害70006开始--
$damageNum = $_REQUEST['harm'];
$taskObj->updateTaskToDB(DAMAGE_NUM70006,$damageNum);
//造成800伤害70006结束--
//---------
//救起2个队友开始--
$helpOtherPlayer = $_REQUEST['rescue_member'];
$taskObj->updateTaskToDB(HELP_OP70008,$helpOtherPlayer);
//救起2个队友结束--
if (!isset($_REQUEST['room_mode']) || $_REQUEST['room_mode'] == 0) {
$this->oldBattleReport();
} else {
$this->bioBattleReport();
}
}
public function bioBattleReport()
{
$account_id = $_REQUEST['account_id']; //账号
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$rank = $_REQUEST['rank'];
$ar = mt\RankReward::getOldRankReward($rank);
$coin_num = $ar['zbmode_param'];
$addreward = new classes\AddReward();
$val = $addreward->getVipVal($account_id, 1);
$coin_num = floor($coin_num + $coin_num * $val / 100);
$row = $conn->execQueryOne('SELECT daily_time, coin_num, biogame_times FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家1');
return;
}
/*
$newhand = $row['newhand'];
$p1 = mt\Parameter::getOldParam(NEWHAND_NUM1);
$fight_times = $p1['param_value'];
$p2 = mt\Parameter::getOldParam(NEWHAND_NUM2);
$view_times = $p2['param_value'];
if ($row['game_times'] + 1 == $fight_times && $row['vip_score'] >= $view_times) {
$newhand = 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();
}
$ret = $conn->execScript('UPDATE user SET coin_num=:coin_num, modify_time=:modify_time, daily_time=:daily_time, biogame_times=:biogame_times ' .
'WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':coin_num' => $row['coin_num'] + $coin_num,
':modify_time' => phpcommon\getNowTime(),
':daily_time' => $daily_time,
':biogame_times' => $row['biogame_times'] + 1,
));
if (!$ret) {
die();
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
));
}
public function oldBattleReport()
{
$account_id = $_REQUEST['account_id']; //账号
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$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\Season::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 historyRecord()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$record_list = array();
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$rowCount = $conn->execQueryRowCount('SELECT * FROM history_record WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if ($rowCount != 0) {
$rows = $conn->execQuery('SELECT * FROM history_record WHERE accountid=:account_id order by game_time desc limit 0,10;',
array(
':account_id' => $account_id
));
foreach ($rows as $row) {
array_push($record_list, array(
'map_name' => $row['map_name'],
'game_time' => $row['game_time'],
'rank' => $row['rank'],
'kills' => $row['kills'],
'harms' => $row['harms'],
'hurts' => $row['hurts'],
'alive_time' => $row['alive_time']
));
}
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'record_list' => $record_list
));
}
public function shareGame()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
// $quest = new classes\Quest();
// $quest->triggerQuest(QUEST_DAY_SHARE, 1, 1, $account_id);
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
));
}
public function historyInfo()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$row = $conn->execQueryOne('SELECT * FROM user WHERE accountid=:accountid;',
array(
':accountid' => $account_id
));
if (!$row) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'kill_his' => $row['kill_his'],
'alive_time_his' => $row['alive_time_his'],
'harm_his' => $row['harm_his'],
'add_HP_his' => $row['add_HP_his']
));
}
public function collectReward()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$record_list = array();
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$ret = $conn->execScript('UPDATE user SET collect_status=1, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':modify_time' => phpcommon\getNowTime(),
':accountid' => $account_id
));
if (!$ret) {
die();
return;
}
$d = mt\Drop::getOldDrop(24003);
if (!$d) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
return;
}
$item_id_array = $this->getExplode($d['item_id']);
$num_array = $this->getExplode($d['num']);
$weight_array = $this->getExplode($d['weight']);
$i = 0;
$item_list = array();
foreach ($weight_array as $item) {
if ($item[0] >= Rand(0, 10000)) {
$item_id = $item_id_array[$i][0];
$item_num = $num_array[$i][0];
$addreward = new classes\AddReward();
$addreward->addReward($item_id, $item_num, $account_id);
array_push($item_list, array(
'item_id' => $item_id,
'item_num' => $item_num
));
}
$i++;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'item_list' => $item_list
));
}
public function collectDoubleReward()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$record_list = array();
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$d = mt\Drop::getOldDrop(24003);
if (!$d) {
phpcommon\sendError(ERR_USER_BASE + 3, '没有这个奖励');
return;
}
$item_id_array = $this->getExplode($d['item_id']);
$num_array = $this->getExplode($d['num']);
$weight_array = $this->getExplode($d['weight']);
$i = 0;
$item_list = array();
$p = mt\Parameter::getOldParam(REWARD_TIMES);
$times = $p['param_value'] - 1;
foreach ($weight_array as $item) {
if ($item[0] >= Rand(0, 10000)) {
$item_id = $item_id_array[$i][0];
$item_num = $num_array[$i][0];
$addreward = new classes\AddReward();
$addreward->addReward($item_id, $item_num * $times, $account_id);
}
$i++;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
));
}
public function getPreSettlementInfo()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
$pre_settlement_info = '';
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
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);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$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);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$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);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
//$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 updateDailyAD()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$num = $_REQUEST['num'];
$ret = $conn->execScript('UPDATE user SET first_day_ad=:first_day_ad,modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':first_day_ad' => $num,
':modify_time' => phpcommon\getNowTime()
));
if (!$ret) {
die();
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'num' => $num
));
}
public function getVideoReward()
{
$account_id = $_REQUEST['account_id'];
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$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);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$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);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$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);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$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);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$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);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$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));
}
}