自己保存的测试代码

高司机 2017-07-11 08:29:18
public function updateCharacter($accountId,$targetId)
{
//找到自己的角色信息
$CharacterInfo = $this->Player->getUserBlobInfo(array("usercharacter"),$accountId);
if(count($CharacterInfo["usercharacter"]) == 0)
{
$return_Data = array( "ts"=> time(), "errcode" => -2, "errmsg" => "You have no this charater");
return ($return_Data);
}
if(!isset($CharacterInfo["usercharacter"][$targetId]))
{
$return_Data = array( "ts"=> time(), "errcode" => -3, "errmsg" => "You have no this charater");
return ($return_Data);
}
//判断下要不要解锁
if(isset($CharacterInfo["usercharacter"][$targetId]['needadvance']) && $CharacterInfo["usercharacter"][$targetId]['needadvance'] == true)//如果是可以进阶了需要加一个锁
{
$return_Data = array( "ts"=> time(), "errcode" => -7, "errmsg" => "you need advance charater");
return ($return_Data);
}

$CharacterData = xmlConfig::LoadXmlData("role.xml");
//计算下这些成长值可以升级到多少
$old_level = $CharacterInfo["usercharacter"][$targetId]['level'];//升级之前的等级
$cost_arr = array();
$findFlag = false;
$need_lock = false;
foreach($CharacterData["role_".$targetId."s"][$targetId] as $sheet_key => $sheet_value){
foreach($sheet_value as $item_key => $value){
if($value['id'] == $old_level + 1)
{
$quality_array = explode("-",$value['quality']);
if(count($quality_array) == 2)//相当于进阶
{
$need_lock = true;
}else{//升级
$cost_arr = xmlConfig::getReward($value['cost']);
$findFlag = true;
}

}
if($value['id'] > $old_level + 1)
{
break;
}
}
}
...全文
177 点赞 收藏 1
写回复
1 条回复
傲雪星枫 2017年07月15日
回复 点赞
发动态
发帖子
基础编程
创建于2007-09-28

9734

社区成员

14.0w+

社区内容

从PHP安装配置,PHP入门,PHP基础到PHP应用
社区公告
暂无公告