<?php
require_once DISCUZ_ROOT.'source/function/function_member.php';
require_once DISCUZ_ROOT.'source/plugin/gplay/function/function_core.php';
require_once DISCUZ_ROOT.'source/plugin/gplay/function/function_vip.php';
require_once DISCUZ_ROOT.'source/plugin/gplay/function/function_jhzb.php';
require_once DISCUZ_ROOT.'source/plugin/gplay/module/front/gplay_taskcom_change.php';
require_once DISCUZ_ROOT.'source/plugin/gplay/function/function_figure.php';
require_once DISCUZ_ROOT.'source/plugin/gplay/function/function_mineral.php';
require_once DISCUZ_ROOT.'source/plugin/gplay/function/function_equipment.php';
require_once DISCUZ_ROOT.'source/plugin/gplay/function/function_product.php';
require_once DISCUZ_ROOT.'source/plugin/gplay/function/function_answer.php';
if(file_exists(DISCUZ_ROOT.'source/plugin/gplay_achievement/function/function_achievement.php')){
require_once DISCUZ_ROOT.'source/plugin/gplay_achievement/function/function_achievement.php';
}
$set=C::t('#gplay#gplay_set')->fetch_by_sid(1);
$info = C::t('common_member')->fetch($_GET['uid']);
$viparr=C::t('#gplay#gplay_vip')->fetch_by_dzgroupid($info['groupid']);
if($viparr){
$s1=explode('/',$viparr['specil']);
foreach($s1 as $k=>$v){
$s2[$v]=$v;
}
$viparr['specil']=$s2;
$viparr['specilval']=explode('/',$viparr['specilval']);
//require DISCUZ_ROOT.'source/plugin/gplay/module/front/gplay_vip.php';
}
if($_GET['code']=='cupc'){
//登录验证
$username = u2g($_GET['username']);
$array = userlogin($username,$_GET['password']);
if($array['status'] == 1) {
$member=C::t('#gplay#gplay_member')->fetch_by_uid($array['ucresult']['uid']);
if(!$member){
echo '{"result":2,"uid":'.$array['ucresult']['uid'].'}';
} else {
$member['result'] = 1;
$figure=C::t('#gplay#gplay_figure')->fetch_by_fid($member['fid']);
$member['head_portrait'] = $figure['img1'];
$group=C::t('#gplay#gplay_group')->fetch_by_id($member['groupid']);
$member['group_name'] = $group['name'];
$member = g2u($member);
echo json_encode($member);
}
} else {
echo '{"result":0}';
}
} else if($_GET['code']=='gmi'){
//用户基本信息
//参数 uid
$member=C::t('#gplay#gplay_member')->fetch_by_uid($_GET['uid']);
$figure=C::t('#gplay#gplay_figure')->fetch_by_fid($member['fid']);
$member['head_portrait'] = $figure['img1'];
$group=C::t('#gplay#gplay_group')->fetch_by_id($member['groupid']);
$member['group_name'] = $group['name'];
$member = g2u($member);
echo json_encode($member);
} else if($_GET['code']=='flsqjh'){
//首次登录信息设置
//参数 uid:用户ID
// set:性别
// username:江湖专属名称
$uname = u2g($_GET['username']);
$name=C::t('#gplay#gplay_member')->fetch_by_username($uname);
if($name){
echo '{"result":0}';
exit;
}
$insert=array(
'uid'=>$_GET['uid'],
'username'=>$uname,
'sex'=>$_GET['sex'],
'money'=>$set['first_money'],
'strength'=>100,
'strength_max'=>100,
'level'=>1,
'this_experience'=>0,
'next_experience'=>$experiencelevel[1][ex_num],
'all_experience'=>0,
'prestige_level'=>1,
'this_prestige'=>0,
'next_prestige'=>$pretigelevel[1][prenum],
'all_prestige'=>0,
'defendce'=>'2',
'attack'=>'2',
'live'=>'200',
'blood'=>'200',
//'groupid'=>$_GET['groupid'],
'bagmax'=>25,
'jiontime'=>TIMESTAMP,
'logintime'=>TIMESTAMP,
);
C::t('#gplay#gplay_member')->insert($insert);
//日志
$logarr=array(
'uid'=>$_GET['uid'],
'type'=>'1',
'money_change'=>$set['first_money'],
'desc'=>lang('plugin/gplay', '24').$uname.lang('plugin/gplay', '23').$set['first_money'],
'createtime'=>TIMESTAMP,
);
C::t('#gplay#gplay_loginlog')->insert($logarr);
echo '{"result":1}';
} else if($_GET['code']=='ptl') {
//剧情任务列表
//参数 uid
// start:开始位置
$taskcomarr=C::t('#gplay#gplay_task_com')->fetch_all($_GET['start'],10);
//获取当前用户的在进行的任务和下一级任务
foreach($taskcomarr as $key=>$value){
$status=C::t('#gplay#gplay_task_comlog')->fetch_by_status($value['id'],$_GET['uid']);
if($status['status']=='3'||$status['status']==''){
if($status['level']<$value['maxlevel']){
$taskcom[$key]=$value;
$taskcom[$key]['status']='';
$taskcom[$key]['level']=$status['level']+1;
$taskcom[$key]['taskid']=$value['id'];
}else{
$taskcom[$key]=$status;
$taskcom[$key]['name']=$value['name'];
$taskcom[$key]['image']=$value['image'];
$taskcom[$key]['desc']=$value['desc'];
$taskcom[$key]['model']=$value['model'];
}
}else{
$taskcom[$key]=$status;
$taskcom[$key]['level']=$status['level'];
$taskcom[$key]['name']=$value['name'];
$taskcom[$key]['desc']=$value['desc'];
$taskcom[$key]['image']=$value['image'];
$taskcom[$key]['model']=$value['model'];
}
}
//获取当前用户的在进行的任务的进度
foreach($taskcom as $key=>$value){
if($value['taskid']){$tid=$value['taskid'];}else{$tid=$value['id'];}
$usnum=C::t('#gplay#gplay_task_comlog')->fetch_all_user($tid);
$taskcom[$key]['usnum']=count($usnum);
$maxmc=C::t('#gplay#gplay_task_comlog')->fetch_maxmc($tid);
$taskcom[$key]['maxlevel']=$maxmc['level'];
$taskcom[$key]['maxuname']=$maxmc['username'];
$taskcom[$key]['ynum']=C::t('#gplay#gplay_task_comlog')->count_by_tid_status_level($tid,$value['level'],">1");
$taskcom[$key]['jnum']=C::t('#gplay#gplay_task_comlog')->count_by_tid_status_level($tid,$value['level'],"<2");
if($value['status']&&$value['status']=='1'){
if($value['model']=='commoney'){//富豪任务的进度
$m1=C::t('#gplay#gplay_task_comlog')->count_mmoney($_GET['uid']);
//$m2=C::t('#gplay#gplay_task_comlog')->count_tmoney($_G['uid']);
$m3=C::t('#gplay#gplay_task_comlog')->count_bmoney($_GET['uid']);
$m4=C::t('#gplay#gplay_task_comlog')->count_cmoney($_GET['uid']);
//$taskcom[$key]['jd']=$m1+$m2+$m3+$m4;
$taskcom[$key]['jd']=$m1+$m3+$m4;
//$taskcom[$key]['jd']=C::t('#gplay#gplay_task_comlog')->count_money($_G['uid']);
}else if($value['model']=='compretige'){//德高望重的进度
foreach($pretigelevel as $k=>$v){
if($member['prestige_level']>$k){
$ss+=$v['prenum'];
}else{
$ss+=$member['this_prestige'];
}
}
$taskcom[$key]['jd']=$ss;
}else if($value['model']=='compk'){//PK之路的进度
$taskcom[$key]['jd']=C::t('#gplay#gplay_task_comlog')->fetch_pk_win_num($_GET['uid']);
}else if($value['model']=='commonster'){//斩妖除魔的进度
$taskcom[$key]['jd']=C::t('#gplay#gplay_task_comlog')->fetch_mon_win_num($_GET['uid']);
}
}
}
$taskcom = g2u($taskcom);
echo json_encode($taskcom);
} else if($_GET['code']=='dt') {
//领取任务
//参数 uid:用户ID
// model:任务类型
// tid:任务ID
// level:级别
$member=C::t('#gplay#gplay_member')->fetch_by_uid($_GET['uid']);
if($_GET['model']=='commoney'){
//富豪之路
$comtask=C::t('#gplay#gplay_task_com')->fetch_by_tid($_GET['tid']);
$s1=$comtask['reward']*pow($_GET['level'],2);
$s2=$comtask['requirenumber']*pow(2,$_GET['level']);
$comtasklog=array(
'uid'=>$_GET['uid'],
'username'=>$member['username'],
'taskid'=>$comtask['id'],
'level'=>$_GET['level'],
'gettasktime'=>TIMESTAMP,
'rewardtype'=>$comtask['rewardtype'],
'reward'=>$s1,
'requiretype'=>$comtask['requiretype'],
'requirenumber'=>$s2,
//'status'=>'1',
'createtime'=>TIMESTAMP,
);
$m1=C::t('#gplay#gplay_task_comlog')->count_mmoney($_GET['uid']);
//$m2=C::t('#gplay#gplay_task_comlog')->count_tmoney($_G['uid']);
$m3=C::t('#gplay#gplay_task_comlog')->count_bmoney($_GET['uid']);
$m4=C::t('#gplay#gplay_task_comlog')->count_cmoney($_GET['uid']);
//$mm=$m1+$m2+$m3+$m4;
$mm=$m1+$m3+$m4;
if($mm>=$s2){
$mc=C::t('#gplay#gplay_task_comlog')->fetch_mc($_GET['tid'],$_GET['level']);
if(!$mc){$mc=1;}else{$mc=$mc+1;}
$comtasklog['status']='2';
$comtasklog['mingci']=$mc;
$comtasklo