public function resetGameCopy($accountId, $stageId)
{
//扫荡消耗什么,还有多少次扫荡机会
$gamecopyInfo = $this->Player->getUserFeildInfo(array("gamecopy","vip"),$accountId);
if(count($gamecopyInfo["gamecopy"]) == 0 )
{
return array( "ts"=> time(), "errcode" => -2, "errmsg" => "cannot find this gamecopy");
}
if(!array_key_exists($stageId,$gamecopyInfo["gamecopy"]['stage']))////检查这个关卡是不是存在
{
return array( "ts"=> time(), "errcode" => -3, "errmsg" => "cannot find this gamecopy");
}
if($gamecopyInfo["gamecopy"]['stage'][$stageId]["lock"] == true)//检查是不是解锁了
{
return array( "ts"=> time(), "errcode" => -4, "errmsg" => "current gamecopy is locked");
}
//检查当前VIP等级的重置次数够不够
$vip_reset_count = 0;
//等待完善读取VIP表格
if($vip_reset_count <= $gamecopyInfo["gamecopy"]['stage'][$stageId]["resetcount"])
{
return array( "ts"=> time(), "errcode" => -5, "errmsg" => "reset gamecopy limited");
}
$this->checkGameCopy($gamecopyInfo["gamecopy"]);
$cur_stage_arr = array();
$gameCopyData = xmlConfig::LoadXmlData("stage.xml");
//修改一下分解的
foreach($gameCopyData["stage_stages"]["stage"] as $sheet_key => $sheet_value){
foreach($sheet_value as $stage_item_key => $stage_item_value){
if($stage_item_value['id'] == $stageId)
{
$cur_stage_arr = $stage_item_value;
break;
}
}
}
if(count($cur_stage_arr) == 0)
{
return array( "ts"=> time(), "errcode" => -6, "errmsg" => "current stage is not open");
}
//够不够
if($this->CheckPlayerRes($cur_stage_arr['reset'],$accountId) == false){
return array("ts"=> time(), "errcode" => -7, "errmsg" => "You have not enough resources");
}
//扣资源
$cost_res = array();//last_stage
foreach($cur_stage_arr['reset'] as $cost_key => $cost_value)
{
$cost_res[$cost_key] = 0 - $cost_value;
}
$this->addItemToPlayer($cost_res,$accountId);
$gamecopyInfo["gamecopy"]['stage'][$stageId]["leftcount"] = $cur_stage_arr['restriction'];
$gamecopyInfo["gamecopy"]['stage'][$stageId]["resetcount"] += 1;
$this->updateUserBlobInfo(array("gamecopy"=>$gamecopyInfo["gamecopy"]),$accountId);
return array( "ts"=> time(), "errcode" => 0, "errmsg" => "", "current_stage"=>$gamecopyInfo["gamecopy"]['stage'][$stageId]);
}
//扫荡
public function sweepGameCopy($accountId, $stageId)
{
//扫荡消耗什么,还有多少次扫荡机会
$gamecopyInfo = $this->Player->getUserBlobInfo(array("gamecopy"),$accountId);
if(count($gamecopyInfo["gamecopy"]) == 0 )
{
return array( "ts"=> time(), "errcode" => -2, "errmsg" => "cannot find this gamecopy");
}
if(!array_key_exists($stageId,$gamecopyInfo["gamecopy"]['stage']))////检查这个关卡是不是存在
{
return array( "ts"=> time(), "errcode" => -3, "errmsg" => "cannot find this gamecopy");
}
if($gamecopyInfo["gamecopy"]['stage'][$stageId]["lock"] == true)//检查是不是解锁了
{
return array( "ts"=> time(), "errcode" => -4, "errmsg" => "current gamecopy is locked");
}
$this->checkGameCopy($gamecopyInfo["gamecopy"]);
if($gamecopyInfo["gamecopy"]['stage'][$stageId]["leftcount"] == 0)//检查剩余挑战次数
{
return array( "ts"=> time(), "errcode" => -5, "errmsg" => "you have no enough challenge times");
}
if($gamecopyInfo["gamecopy"]['stage'][$stageId]["star"] != 3)//检查星级
{
return array( "ts"=> time(), "errcode" => -5, "errmsg" => "your stage must be 3 stars");
}
$cur_stage_arr = array();
$gameCopyData = xmlConfig::LoadXmlData("stage.xml");
//修改一下分解的
foreach($gameCopyData["stage_stages"]["stage"] as $sheet_key => $sheet_value){
foreach($sheet_value as $stage_item_key => $stage_item_value){
if($stage_item_value['id'] == $stageId)
{
$cur_stage_arr = $stage_item_value;
break;
}
}
}
if(count($cur_stage_arr) == 0)
{
return array( "ts"=> time(), "errcode" => -5, "errmsg" => "current stage is not open");
}
//检查扫荡券够不够
if($this->CheckPlayerRes($cur_stage_arr['saodang'],$accountId) == false){
return array("ts"=> time(), "errcode" => -3, "errmsg" => "You have not enough resources");
}
$gamecopyInfo["gamecopy"]['stage'][$stageId]["leftcount"] -= 1;
$this->updateUserBlobInfo(array("gamecopy"=>$gamecopyInfo["gamecopy"]),$accountId);
//给奖励
$reward_res = xmlConfig::getReward($cur_stage_arr['loot3']);//$last_stage
foreach($cur_stage_arr['saodang'] as $cost_key => $cost_value)
{
$reward_res[$cost_key] = 0 - $cost_value;
}
$this->addItemToPlayer($reward_res,$accountId);
return array( "ts"=> time(), "errcode" => 0, "errmsg" => "", "current_stage"=>$gamecopyInfo["gamecopy"]['stage'][$stageId]);
} //完成关卡
public function finishGameCopy($accountId, $stageId, $star ,$result)
{
$gamecopyInfo = $this->Player->getUserBlobInfo(array("gamecopy","userinfo"),$accountId);
if(count($gamecopyInfo["gamecopy"]) == 0)
{
return array( "ts"=> time(), "errcode" => -2, "errmsg" => "cannot find this gamecopy");
}
{
return array( "ts"=> time(), "errcode" => -3, "errmsg" => "cannot find this gamecopy");
}
if($gamecopyInfo["gamecopy"]['stage'][$stageId]["lock"] == true)//检查是不是解锁了
{
return array( "ts"=> time(), "errcode" => -4, "errmsg" => "current gamecopy is locked");
}
$this->checkGameCopy($gamecopyInfo["gamecopy"]);
if($gamecopyInfo["gamecopy"]['stage'][$stageId]["leftcount"] == 0)//检查剩余挑战次数
{
return array( "ts"=> time(), "errcode" => -5, "errmsg" => "you have no enough challenge times");
}
if($star > 3)//检查星级
{
return array( "ts"=> time(), "errcode" => -5, "errmsg" => "you challenge failed");
}
$cur_stage_arr = array();
$next_stage_arr = array();
$gameCopyData = xmlConfig::LoadXmlData("stage.xml");
//修改一下分解的
foreach($gameCopyData["stage_stages"]["stage"] as $sheet_key => $sheet_value){
foreach($sheet_value as $stage_item_key => $stage_item_value){
if($stage_item_value['id'] == $stageId)
{
$cur_stage_arr = $stage_item_value;
}
if($stage_item_value['id'] == $stageId + 1)
{
$next_stage_arr = $stage_item_value;
break;
}
}
}
if(count($cur_stage_arr) == 0)
{
return array( "ts"=> time(), "errcode" => -5, "errmsg" => "current stage is not open");
}
if($cur_stage_arr['aixin'] > $gamecopyInfo['userinfo']['aixin'])
{
return array( "ts"=> time(), "errcode" => -5, "errmsg" => "you have no enough aixin");
}