浏览代码

清理代码

gwang 5 年之前
父节点
当前提交
b5c6496c12

+ 0 - 34
Gameserver/Amfphp/model/User/CarbonModel.php

@@ -1,34 +0,0 @@
-<?php
-
-namespace loyalsoft;
-
-/**
- * 副本状态数据
- * @version
- *          1.0.0 Created at 2017-5-18. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright ? 2017-5-18, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
-class CarbonModel
-{
-    /**
-     *   副本设计: 依附于关卡, 需要用关卡掉落的道具开启副本,
-     *            开启后, 可从关卡界面进入副本, 副本中含有一系列的小关卡.
-     *            副本开启后立即开始关闭倒计时,倒计时结束,副本关闭, 可以再次重复开启流程.
-     *            副本通关后立即关闭副本.
-     *            副本关卡战斗,类似于普通关卡战斗, 同样会有掉落.
-     *            副本也有三个难度.
-     */
-
-    /**
-     * @var int 推进关卡索引
-     */
-    public $curIndex = 0;
-
-    /**
-     *
-     * @var int 何时关闭的时间戳
-     */
-    public $closeTs = 0;
-
-}

+ 7 - 47
Gameserver/Amfphp/model/User/PrivateStateModel.php

@@ -76,16 +76,6 @@ class PrivateStateModel extends Object_ext {
      */
     public $GemUpgrage;
 
-    /**
-     * @var array 当天租借好友记录
-     */
-    public $rentedFriends;
-
-    /**
-     * @var UserLotteryModel
-     */
-    public $lottery;
-
     /**
      * "tasks":{
      * "401101": {
@@ -111,18 +101,6 @@ class PrivateStateModel extends Object_ext {
      */
     public $TiliTime;
 
-    /**
-     * 宝箱累计的冷却时间。(到这个时间戳才能完全没有冷却)
-     * @var int
-     */
-    public $BoxCoolDownTime;
-
-    /**
-     * 宝箱是否被锁住,0代表没有锁住可以开,1代表锁住,不能开。
-     * @var int
-     */
-    public $BoxLock;
-
     /**
      * 登录天数
      * @var array
@@ -178,6 +156,11 @@ class PrivateStateModel extends Object_ext {
      */
     public $RankPassGateRewardRec = array();
 
+    /**
+     * @var int 上次检查被挑战记录的时间戳
+     */
+    public $lastCheckDefLog_ts = 0;
+
 // <editor-fold defaultstate="collapsed" desc="    初始化    ">
 
     /**
@@ -198,34 +181,11 @@ class PrivateStateModel extends Object_ext {
         $this->heroshengjie = 0;
         $this->heroshengxing = 0;
         $this->TiliTime = now();
-        $this->BoxCoolDownTime = now();
-        $this->BoxLock = 0;
+
         $this->LoginDays = ArrayInit();
         $this->LoginTaskComplete = 0;
-        $this->lottery = new UserLotteryModel;
+
         $this->usedTokens = ArrayInit();
-// <editor-fold defaultstate="collapsed" desc="    day7 相关">
-//        $con = GameConfig::day7();
-//        foreach ($con as $k => $v) {
-//            $this->day7->tasks->$k = json_decode('{"state":1}');
-//        }
-//        var_dump($this->day7);
-// </editor-fold>
-// <editor-fold defaultstate="collapsed" desc="    任务 相关">
-//        $conTasks = GameConfig::task();
-//        foreach ($conTasks as $k => $v) {
-//            $this->Tasks->$k = json_decode('{"state":1}');
-//        }
-// </editor-fold>
-// <editor-fold defaultstate="collapsed" desc="   成就任务 相关">
-//        $AchiTasks = GameConfig::task_achi();
-//        foreach ($AchiTasks as $k => $v) {
-//            $this->AchiTasks->$k = json_decode(json_encode(array(
-//                'state' => 1,
-//                'extData' => 0
-//            )));
-//        }
-// </editor-fold>
     }
 
 // </editor-fold>

+ 0 - 29
Gameserver/Amfphp/model/User/UserCarbonModel.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace loyalsoft;
-
-/**
- * 玩家关卡副本数据
- * @version
- *          1.0.0 Created at 2017-5-19. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright ? 2017-5-19, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
-class UserCarbonModel extends Object_ext
-{
-
-//put your code here
-    # 当前开启的副本
-    # 通关记录
-    /**
-     *
-     * @var  carbonmodel
-     */
-    public $openedCarbons;
-
-    public function initialize()
-    {
-        $this->openedCarbons = ObjectInit();
-    }
-
-}

+ 0 - 6
Gameserver/Amfphp/model/User/UserGameModel.php

@@ -148,12 +148,6 @@ class UserGameModel extends Object_ext {
      */
     public $heroTeamConfig;
 
-//    /**
-//     * 神兽图鉴数据
-//     * @var HeroManualModel
-//     */
-//    public $heroManual;
-
     /**
      * 新手引导
      * @var object

+ 0 - 117
Gameserver/Amfphp/model/User/UserLotteryModel.php

@@ -1,117 +0,0 @@
-<?php
-
-namespace loyalsoft;
-
-/**
- * 抽奖卡槽
- */
-class LotterySlotModel extends Object_ext
-{
-    /*
-     * 有4个卡槽, 按照等级解锁, 可花钻石提前解锁,
-     * 每个卡槽上可以托管一张抽奖后获得的英雄. 并开始冷却计时
-     * 冷却计时完成后, 可以收取对应的卡牌
-     * 涉及到的数据结构:
-     *       卡槽id,
-     *       解锁状态,
-     *       英雄modle_id,
-     *       英雄星级,
-     *       冷却时间,
-     */
-
-    /**
-     * @var int 卡槽id
-     */
-    public $id;
-
-    /**
-     * @var bool 解锁状态
-     */
-    public $locked = true;
-
-    /**
-     * @var int 英雄(原型)编号
-     */
-    public $herotype = 0;
-
-    /**
-     * @var int 英雄(实例)星级
-     */
-    public $herostar = 0;
-
-    /**
-     * @var ts 开放时间戳
-     */
-    public $opents = 0;
-
-    public function Clear()
-    {
-        $this->herostar = 0;
-        $this->herotype = 0;
-        $this->opents = 0;
-    }
-
-}
-
-/**
- * 设计一些卡槽
- * @version
- *          1.0.0 Created at 2017-7-20. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright ? 2017-7-20, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
-class UserLotteryModel extends Object_ext
-{
-
-    /**
-     * @var {} 当天抽奖记录(类型=>次数)
-     */
-    public $todayLotterys;
-
-    /**
-     * @var {} 总的抽奖记录(类型=>次数)
-     */
-    public $totalLotterys;
-
-    /**
-     * @var {} 保底奖励计数器(类型=>次数)
-     */
-    public $baodiLotterys;
-
-    /**
-     * @var {} 保底奖励领取记录(类型=>次数)
-     */
-    public $baodiDrawed;
-
-    public function __construct($arg = null)
-    {
-        if (func_num_args() == 1 && !is_null($arg)) {
-            parent::__construct($arg);
-        }
-        if (!isset($this->slot0)) {
-            $this->slot0 = new LotterySlotModel(array('id' => 0, 'locked' => false));
-        }
-        if (!isset($this->slot1)) {
-            $this->slot1 = new LotterySlotModel(array('id' => 1));
-        }
-        if (!isset($this->slot2)) {
-            $this->slot2 = new LotterySlotModel(array('id' => 2));
-        }
-        if (!isset($this->slot3)) {
-            $this->slot3 = new LotterySlotModel(array('id' => 3));
-        }
-        if (!isset($this->todayLotterys)) {
-            $this->todayLotterys = ObjectInit();
-        }
-        if (!isset($this->totalLotterys)) {
-            $this->totalLotterys = ObjectInit();
-        }
-        if (!isset($this->baodiLotterys)) {
-            $this->baodiLotterys = ObjectInit();
-        }
-        if (!isset($this->baodiDrawed)) {
-            $this->baodiDrawed = ObjectInit();
-        }
-    }
-
-}

+ 9 - 19
Gameserver/Amfphp/process/ActiveProc.php

@@ -38,14 +38,14 @@ class ActiveProc {
                 return ActiveProc::Tasks_DrawReward($req);
             case CmdCode::Task_Tili:                                            # 6508 体力变化
                 return ActiveProc::RecoveryTili($req);
-            case CmdCode::lottery:                                              # 6509 抽奖
-                return Boxes::OpenBox($req);                                    # 宝箱
+//            case CmdCode::lottery:                                              # 6509 抽奖
+//                return Boxes::OpenBox($req);                                    # 宝箱
 //                return Lotterys::Lottery($req);
 //                return Lotterys::Lottery_Hero($req);
-            case CmdCode::lottery_demo:                                         # 6510 新手引导: 抽奖
-                return Lotterys::demoLottery($req);
-            case CmdCode::lottery_baodi:                                        # 6511 抽奖 - 保底奖励
-                return Lotterys::baodiLottery($req);
+//            case CmdCode::lottery_demo:                                         # 6510 新手引导: 抽奖
+//                return Lotterys::demoLottery($req);
+//            case CmdCode::lottery_baodi:                                        # 6511 抽奖 - 保底奖励
+//                return Lotterys::baodiLottery($req);
             case CmdCode::active_token_drawReward:                              # 6512 兑换码礼包
                 return self::drawActivePackageByCode($req);
             case CmdCode::active_draw_onlinegift:                               # 6513 领取在线礼包
@@ -56,8 +56,7 @@ class ActiveProc {
                 return self::drawTiliGift($req);
             case CmdCode::active_get_regnum:                                    # 6516 查询当前全服注册人数
                 return self::getRegNumber($req);
-            case CmdCode::box_SubCoolDown:                                      # 6517 减少冷却时间
-                return Boxes::SubBoxCoolDown($req);
+
             default:
                 return Resp::err(ErrCode::cmd_err);
         }
@@ -304,7 +303,6 @@ class ActiveProc {
     static function DailyReset($req) {
         self::DailyResetTaskAccountNum($req);
         self::ResetEverydayTask($req);
-        self::ClearLotteryRecord($req);
         self::ClearOnlineGiftTs($req);
         self::ClearDailyTiliGift($req);
     }
@@ -317,14 +315,6 @@ class ActiveProc {
         $req->userInfo->game->privateState->dailyDrawedTiliGift = ArrayInit();
     }
 
-    /**
-     * 清理每天的抽奖次数记录
-     * @param Req $req
-     */
-    public static function ClearLotteryRecord($req) {
-        Lotterys::ClearLotteryRecord($req);
-    }
-
     /**
      * 查询当前分区开放时间戳
      * @param Req $req
@@ -450,8 +440,8 @@ class ActiveProc {
                 return $taskModel->canshu <= $req->userInfo->game->privateState->ItemUpgrage;
             case 32: //如果是宝石合成任务
                 return $taskModel->canshu <= $req->userInfo->game->privateState->GemUpgrage;
-            case 41: //如果是好友任务
-                return $taskModel->canshu <= FriendProc::getCurrentFriendsCount($req);
+//            case 41: //如果是好友任务
+//                return $taskModel->canshu <= FriendProc::getCurrentFriendsCount($req);
 
             default :
                 return false;

+ 0 - 220
Gameserver/Amfphp/process/ActiveProc/Boxes.php

@@ -1,220 +0,0 @@
-<?php
-
-namespace loyalsoft;
-
-require_once __DIR__ . '/Lotterys.php';
-
-/**
- * Description of Boxes
- * 控制理论: 模型预测, 反馈校正, 滚动优化.
- * 目标: 检测游戏内部一批指定的数据, 动态调整宝箱掉落物品.
- * @version
- *          1.0.0 Created at 2017-9-13. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright ? 2017-9-13, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
-class Boxes {
-
-    /**
-     * 消耗宝箱
-     * @param Req $req
-     * @param type $boxid
-     * @param type $num
-     */
-    public static function ComsumeBoxes($req, $boxid, $num = 1) {
-        $boxes = $req->userInfo->game->store->boxes;                            # 预取变量
-        if (CommUtil::isPropertyExists($boxes, $boxid)                          # 有这种宝箱
-                && $boxes->$boxid >= $num) {                                    # 且数量够
-            $boxes->$boxid -= $num;                                             # 扣减对应数量
-            $req->userInfo->game->store->boxes = $boxes;                        # 回存数据
-            return ErrCode::ok;                                                 # 返回成功
-        }
-        return ErrCode::box_not_enough;                                         # 数量不足
-    }
-
-    public static function SubBoxCoolDown($req) {
-        $user = $req->userInfo->game;                                           # 预取变量
-        if (count($req->paras) < 1) {                                           # 提取参数
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        echo var_dump($req);
-        $itemId = $req->paras[0];                                               # 减冷却时间的物品Id
-        $item = GameConfig::item_getItem($itemId);
-        if ($item == null) {                                                    # 检测是否存在装备的原始数据
-            return Resp::err(ErrCode::err_const_no);
-        }
-        $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $itemId, 1);
-        if ($err) {                                                             # 扣除失败
-            return Resp::err($err);
-        }
-
-        $user->privateState->BoxCoolDownTime -= $item->level;
-        if ($user->privateState->BoxCoolDownTime - time() > glc()->Box_Total_CoolDown) {
-            $user->privateState->BoxLock = 1;
-            //   return ResponseVo::err($req, ErrCode::onlinegift_timenotenough);
-        } else {
-            $user->privateState->BoxLock = 0;                                   # 照顾旧账号
-        }
-        UserProc::updateUserInfo();
-        return Resp::ok(array('err' => 0, #                                     # 返回值
-                    'store' => $user->store, #                                  # 仓库
-                    'cooldown' => $user->privateState->BoxCoolDownTime, #       # 冷却时间
-                    'BoxLock' => $user->privateState->BoxLock));                #是否加锁状态
-    }
-
-    /**
-     * 开启宝箱
-     * @param Req $req
-     */
-    public static function OpenBox($req) {
-        # 提取参数
-        $user = $req->userInfo->game;                                           # 预取变量
-        if (count($req->paras) < 1) {                                           # 提取参数
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $boxid = $req->paras[0];                                                # 宝箱Id
-        $num = 1;                                                               # 开箱数量, 可选参数, 默认为1
-        if (count($req->paras) > 1) {                                           # 如果传了,
-            $num = $req->paras[1];                                              # 提取可选参数:宝箱数量
-        }                                                                       # end 提取参数
-        $Cash = 0;
-        if (count($req->paras) > 2) {                                           # 如果传了,
-            $Cash = $req->paras[2];                                             # 提取可选参数:开宝箱用的钻石数量
-        }
-
-#                                                                               # 记录开箱子次数, (箱子也设置次数限制)
-        $err = Lotterys::AddLotteryTimes($user->privateState->lottery, $boxid, $left_cishu, $num);
-        if ($err) {                                                             # 发生错误
-            return Resp::err($err);
-        }
-
-        if ($Cash > 0) {//                                                      //如果传了免cd开宝箱的钻石数量,则需要扣除数量。
-            $bDeal = UserGameModel::Consume_Cash($user, $Cash);
-            if (!$bDeal) {
-                return Resp::err(ErrCode::notenough_cash_msg);
-            }
-        } else {//                                                              //如果没传免cd开宝箱的钻石数量,则需要走冷却这个限制
-            if ($user->privateState->BoxCoolDownTime - time() > glc()->Box_Total_CoolDown) {
-                $user->privateState->BoxLock = 1;
-                return Resp::err(ErrCode::onlinegift_timenotenough);
-            } else {
-                $user->privateState->BoxLock = 0; //                            //照顾旧账号
-            }
-        }
-//        if( $user->privateState->BoxLock==1)
-//        {
-//             if($user->privateState->BoxCoolDownTime>now())
-//             {
-//                  return ResponseVo::err($req, ErrCode::onlinegift_timenotenough);
-//             }
-//             else
-//                 {
-//                 $user->privateState->BoxLock=0;
-//                 }
-//        }
-
-        $err = self::ComsumeBoxes($req, $boxid, $num);                          # 扣除抽奖花费
-        if ($err) {                                                             # 发生错误
-            return Resp::err($err);
-        }
-        $req->userInfo->game = $user;                                           # 回写user数据,以防后续操作造成分歧
-        $boxInfo = GameConfig::box_getItem($boxid);                             # box数据
-        $Arr = GameConfig::boxpool_getItem($boxid);                             # 提取奖池
-        # 过滤奖池
-        $seqs = explode(',', $boxInfo->dropTypeSeq);                            # 掉落序列
-        $rewardArr = ArrayInit();                                               # 结果
-        for ($i = 0; $i < $num; $i++) {
-            foreach ($seqs as $dropindex) {
-                # 提取对应序列的奖池, 注意: 原始奖池Arr要保留, 因为每次循环都要从原始奖池中重新提取数据.
-                $itemArr = array_filter($Arr, function($item) use($dropindex) {
-                    return $item->dropType == $dropindex;
-                });
-
-                $itemArr = Lotterys::FilterPrizepool($req, $itemArr);           # 对奖池依解锁等级进行过滤
-                # 掉率修正
-                foreach ($itemArr as $item) {
-                    $profile = new UserProfile($user->profile);
-                    if ($profile->payment->GetClass() >= 3) {                   # 大R
-                        $prop = $item->bigR;
-                    } else {
-                        $prop = $item->normal;
-                    }
-//                    // 登录天数修正
-//                    $logins = array_filter($user->privateState->LoginDays, function ($tsday) {
-//                        return tsDay() - $tsday < 7;                          # 提取7日以内的登录记录
-//                    });
-//                    switch (count($logins)) {
-//                        case 1:
-//                        case 2:
-//                            $prop += $item->f_7day2on;
-//                            break;
-//                        case 3:
-//                        case 4:
-//                            $prop += $item->f_7day4on;
-//                            break;
-//                        case 5:
-//                        case 6:
-//                            $prop += $item->f_7day6on;
-//                            break;
-//                        default:
-//                            break;
-//                    }
-                    // 英雄碎片修正
-                    // ...碎片数据还没有...
-                    // ...卒
-                    if ($prop < 0) {
-                        $prop = 0;
-                    }
-                    $item->probability = $prop;
-                }
-                $err = Lotterys::Dice($itemArr, 1, $rewardstr);                 # 投骰子
-                if ($err) {                                                     # 出错了
-                    return Resp::err($err);
-                }
-                if (strlen($rewardstr) <= 0) {                                  # 抽奖结果为空
-                    return Resp::err(ErrCode::err_innerfault);
-                }
-                $rewardArr[] = $rewardstr;
-            }
-            #                                                                   # 金币
-            $gold = CommUtil::random($boxInfo->goldsMin, $boxInfo->goldsMax);
-            array_unshift($rewardArr, META_GOLD_ITEMID . ",$gold");             # 插入金币奖励
-            #                                                                   # 经验卡
-            foreach (GameConfig::boxJingYanCards_getItem($boxid) as $id => $card) {
-                if (CommUtil::randomPercent($card->probability)) {              # 投色子决定是否掉落此类经验卡
-                    $amt = CommUtil::random($card->cardsMin, $card->cardsMax);  # 掉落数量
-                    array_push($rewardArr, $card->cardId . ",$amt");            # 追加经验卡奖励
-                }
-            }
-        }
-        $err = StoreProc::AddMultiItemInStore($req, implode(';', $rewardArr), 3); # 发放物品
-        if (ErrCode::ok != $err) {
-            return Resp::err($err);
-        }
-
-        if ($user->privateState->BoxCoolDownTime < now()) {                     # 每开一次箱子,要加上该箱子的冷却时间
-            $user->privateState->BoxCoolDownTime = now();
-        }
-        if ($Cash > 0) {//                                                      //如果传了免cd开宝箱的钻石数量,则开宝箱时候不累加冷却时间
-            ///郎总说如果用钻石开宝箱去掉宝箱冷却
-        } else {
-            $user->privateState->BoxCoolDownTime += $boxInfo->coolDwonTime;
-        }
-
-        if ($user->privateState->BoxCoolDownTime - time() > glc()->Box_Total_CoolDown) {# 如果宝箱现在冷却时间大于宝箱冷却上线,则加锁
-            $user->privateState->BoxLock = 1; //                                //加宝箱锁,在一定时间内不能开启
-        } else {
-            $user->privateState->BoxLock = 0; ////照顾旧账号。
-        }
-        UserProc::updateUserInfo();                                         # 回存数据
-        return Resp::ok(array('err' => 0, #                                     # 返回值
-                    'store' => $user->store, #                                  # 仓库
-                    'heros' => $user->heros, #                                  # 最新英雄
-                    'cooldown' => $user->privateState->BoxCoolDownTime, #       # 冷却时间
-                    'reward' => implode(';', $rewardArr), #                     # 奖品
-                    'BoxLock' => $user->privateState->BoxLock, #                # 是否加锁状态
-                    'baodi' => $user->privateState->lottery->baodiLotterys,
-                    'left_cishu' => $left_cishu));                              # 当天剩余次数(限次)
-    }
-
-}

+ 2 - 2
Gameserver/Amfphp/process/ActiveProc/Day7Tasks.php

@@ -158,8 +158,8 @@ class Day7Tasks {
                 return $taskModel->canshu <= $req->userInfo->game->privateState->ItemUpgrage;
             case 32: // 如果是宝石合成任务
                 return $taskModel->canshu <= $req->userInfo->game->privateState->GemUpgrage;
-            case 41: // 如果是好友任务
-                return $taskModel->canshu <= FriendProc::getCurrentFriendsCount($req);
+//            case 41: // 如果是好友任务
+//                return $taskModel->canshu <= FriendProc::getCurrentFriendsCount($req);
             default :
                 return false;
         }

+ 0 - 575
Gameserver/Amfphp/process/ActiveProc/Lotterys.php

@@ -1,575 +0,0 @@
-<?php
-
-namespace loyalsoft;
-
-/**
- *  抽奖 模块
- * @version
- *          1.0.1 英雄抽奖, 奖品限定为英雄, 2017.07.20 by --gwang
- *          1.0.0 从active模块拆分出来, Created at 2017-7-20. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright ? 2017-7-20, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
-class Lotterys {
-    /**
-     * 改造方案:
-     *     1. 抽奖添加卡槽参数, 告诉服务端结果放到哪个卡槽中.
-     *     2. 抽奖时验证卡槽是否为空, 不空不可继续.
-     *     3. 抽奖结果不直接发放到玩家身上, 而是放到卡槽中, 等待读条完毕, 手动领取.
-     *     4. 增加领取抽奖结果api, 验证冷却完毕, 提取到玩家身上.
-     */
-
-    /**
-     * [6511] 抽奖 - 领取保底奖励, 奖品直接发放到玩家身上, 不计冷却时间
-     * @param Req $req
-     */
-    static function baodiLottery($req) {
-        # 保底奖励领取方案: 不需要扣除花费, 只需清零抽奖次数.
-        $user = $req->userInfo->game;
-        $lottery = new UserLotteryModel($req->userInfo->game->privateState->lottery);
-        if (count($req->paras) < 1) {                                           # 提取参数
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $lot_type = $req->paras[0];                                             # 抽奖类型: 金币,钻石,友情点... (物品id)
-        $cishu = 10;                                                            # 想要领取的奖励id(1,2,3)等阶对应需要满足的抽奖次数
-        if (count($req->paras) > 1) {                                           # 如果没有传第二个参数, 默认给1阶奖励(10次),
-            $cishu = $req->paras[1];
-        }
-
-        if ($lottery->baodiLotterys->$lot_type < $cishu) {                      # 检查累计次数
-            return Resp::err(ErrCode::lottery_baodi_times_lt);
-        }
-        $baodi = GameConfig::choujiang_baodi_getItem($lot_type, $cishu);        # 保底奖池
-        if (null == $baodi) {                                                   # 找不到
-            return Resp::err(ErrCode::err_const_no);
-        }
-        $settings = GameConfig::choujiang_settings_getItem($lot_type);          # 设定
-        if (null == $settings) {                                                # 找不到
-            return Resp::err(ErrCode::err_const_no);
-        }
-        # 当达到, 最后一次的时候, 执行减法扣除对应的值?或者其他算法.
-        # 保底的奖励物品, 要切换, 换成不同抽奖道具, 对应不同的奖品池, 因为道具价值不一样.
-        if ($lottery->baodiDrawed->$lot_type >= $cishu) {
-            return Resp::err(ErrCode::active_hasgetted);
-        }
-        $lottery->baodiDrawed->$lot_type = $cishu;
-        if ($cishu == $settings->baodiMax) {
-            $lottery->baodiDrawed->$lot_type = 0;                               # 防刷, 已经领过的次数要加记录
-            $lottery->baodiLotterys->$lot_type -= $cishu;                       # 清零次数
-        }
-        $err = self::Dice($baodi, 1, $rewardstr);                               # 投骰子
-        if ($err) {
-            return Resp::err($err);
-        }
-        if (strlen($rewardstr) <= 0) {                                          # 抽奖结果为空
-            return Resp::err(ErrCode::err_innerfault);
-        }
-        $err = StoreProc::AddMultiItemInStore($req, $rewardstr, 3);             # 发放物品
-        if ($err) {
-            return Resp::err($cishu);
-        }
-        $req->userInfo->game->privateState->lottery = $lottery;
-        UserProc::updateUserInfo();                                         # 回存数据
-//        var_dump($lottery);
-        return Resp::ok(array('err' => 0, #                                     # 返回值
-                    'store' => $user->store,
-                    'heros' => $user->heros,
-                    'reward' => $rewardstr,
-                    'baodi' => $lottery->baodiLotterys,
-                    'baodidrawed' => $lottery->baodiDrawed
-        ));
-    }
-
-    /**
-     * [6510] 活动 - 抽奖 - 新手引导定制版
-     * @param Req $req
-     */
-    static function demoLottery($req) {
-        $user = $req->userInfo->game;
-        if (count($req->paras) < 1) {                                           # 参数数量不足
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-#       # 提取参数
-        $type = $req->paras[0];                                                 # 金币,钻石,友情点...
-        $number = 1;                                                            # 抽奖次数
-        if (count($req->paras) > 1) {                                           # 可选参数
-            $number = $req->paras[1];
-        }
-        # 记录抽奖次数
-        $err = self::AddLotteryTimes($user->privateState->lottery, $type, $left_cishu, $number);
-        if ($err) {
-            return Resp::err($err);
-        }
-        $err = self::ConsumeLotteryCost($user, $type, $number);
-        if ($err) {
-            return Resp::err($err);
-        }
-        $req->userInfo->game = $user;                                           # 回写
-        $err = self::Dice(JsonUtil::decode(glc()->choujiang_guide_items), $number, $rewardstr);
-        if ($err) {                                                             # 出错了
-            return Resp::err($err);
-        }
-        if (strlen($rewardstr) <= 0) {
-            return Resp::err(ErrCode::err_innerfault);
-        }
-        $err = StoreProc::AddMultiItemInStore($req, $rewardstr, 3);             # 发放物品
-        if ($err) {
-            return Resp::err($err);
-        }
-        UserProc::updateUserInfo();                                         # 回存数据
-        return Resp::ok(array('err' => 0, #                                     # 返回值
-                    'store' => $user->store,
-                    'heros' => $user->heros,
-                    'reward' => $rewardstr,
-                    'baodi' => $user->privateState->lottery->baodiLotterys,
-                    'left_cishu' => $left_cishu));
-    }
-
-//
-// <editor-fold defaultstate="collapsed" desc="    抽奖 - 经典版">
-
-    /**
-     * [6509] 活动 - 抽奖
-     * @param Req $req
-     *  @ deprecated since version 1.0.1 新版只出英雄, . . .
-     *                        Ps. 1.0.0版可支持产出道具
-     */
-    static function Lottery($req) {
-        $user = $req->userInfo->game;
-
-        if (count($req->paras) < 1) {                                           # 提取参数
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $type = $req->paras[0];                                                 # 金币,钻石,友情点... (物品id)
-        $number = 1;                                                            # 抽奖次数
-        if (count($req->paras) > 1) {                                           # 可选参数
-            $number = $req->paras[1];
-        }
-        # 记录抽奖次数
-        $err = self::AddLotteryTimes($user->privateState->lottery, $type, $left_cishu, $number);
-        if ($err) {
-            return Resp::err($err);
-        }
-        # 扣除抽奖花费
-        $err = self::ConsumeLotteryCost($user, $type, $number);
-        if ($err) {
-            return Resp::err($err);
-        }
-        # 回写user数据
-        $req->userInfo->game = $user;
-        # 对奖池依解锁等级进行过滤
-        $arr = self::FilterPrizepool($req, GameConfig::choujiang_getItem($type));
-        $err = self::Dice($arr, $number, $rewardstr);                           # 投骰子
-        if ($err) {                                                             # 出错了
-            return Resp::err($err);
-        }
-        if (strlen($rewardstr) <= 0) {                                          # 抽奖结果为空
-            return Resp::err(ErrCode::err_innerfault);
-        }
-
-        $err = StoreProc::AddMultiItemInStore($req, $rewardstr, 3);             # 发放物品
-        if ($err) {                                                             # 出错了
-            return Resp::err($err);
-        }
-        UserProc::updateUserInfo();                                         # 回存数据
-        return Resp::ok(array('err' => 0, #                                     # 返回值
-                    'store' => $user->store,
-                    'heros' => $user->heros,
-                    'reward' => $rewardstr,
-                    'baodi' => $user->privateState->lottery->baodiLotterys,
-                    'left_cishu' => $left_cishu));
-    }
-
-// </editor-fold>
-//
-// <editor-fold defaultstate="collapsed" desc="    抽奖 - 新生到校版">
-
-    /**
-     * [6513] 活动 - 抽奖 查询信息(卡槽)
-     * @param Req $req
-     */
-    static function Lottery_Info($req) {
-        return Resp::ok(array(
-                    'lottery' => new UserLotteryModel($req->userInfo->game->privateState->lottery)
-        ));
-    }
-
-    /**
-     * [6515] 活动 - 抽奖 缩短搜索时间
-     * @param Req $req
-     */
-    static function Lottery_speedup_search($req) {
-        if (count($req->paras) < 1) {                                           # 提取参数
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $id = $req->paras[0];                                                   # 卡槽id: 0,1,2,
-        $slotid = 'slot' . $id;
-        $lottery = new UserLotteryModel($req->userInfo->game->privateState->lottery);
-        $slot = new LotterySlotModel($lottery->$slotid);
-        if ($slot->locked) {                                                    # 卡槽尚未解锁
-            return Resp::err(ErrCode::err_lottery_slot_locked);
-        }
-        if (!$slot->herotype) {                                                 # 卡槽空
-            return Resp::err(ErrCode::err_lottery_slot_emputy);
-        }
-        $itemid = glc()->choujiang_dachequan_itemid;                            # 打车券的itemid
-        if ($slot->opents > now()) {                                            # 已经到时间了,无需扣除,
-            # 先不替客户省钱了, 只要客户端发送请求就执行.
-            $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $itemid, 1);
-            if ($err) {
-                return Resp::err($err);
-            }
-            $slot->opents = now(-15);                                           # 往前偏移15秒
-        }
-        $lottery->$slotid = $slot;
-        $req->userInfo->game->privateState->lottery = $lottery;
-        UserProc::updateUserInfo();                                         # 回写数据
-        return Resp::ok(array('slot' => $slot));                                # 返回
-    }
-
-    /**
-     * [6514] 活动 - 抽奖 解锁卡槽
-     * @param Req $req
-     */
-    static function Lottery_unlock_Slot($req) {
-        if (count($req->paras) < 1) {                                           # 提取参数
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $id = $req->paras[0];                                                   # 卡槽id: 0,1,2,
-        $slotid = 'slot' . $id;
-        $lottery = new UserLotteryModel($req->userInfo->game->privateState->lottery);
-        $slot = new LotterySlotModel($lottery->$slotid);
-        if (!$slot->locked) {                                                   # 卡槽已经解锁
-            return Resp::err(ErrCode::err_lottery_slot_unlocked);
-        }
-        # 判断等级, 等级不足则扣除钻石
-        $sm_slot = GameConfig::choujiang_slot_getItem($id);                     # slot 配置
-        if ($req->userInfo->game->level < $sm_slot->level) {                    # 等级不足时需要扣除钻石
-            if (!UserGameModel::Consume_Cash($req->userInfo->game, $sm_slot->cash)) {
-                return Resp::err(ErrCode::notenough_cash_msg);
-            }
-        }
-        $slot->locked = false;                                                  # 解锁卡槽
-        $lottery->$slotid = $slot;
-        $req->userInfo->game->privateState->lottery = $lottery;
-        UserProc::updateUserInfo();                                         # 回写数据
-        return Resp::ok(array('slot' => $slot));                                # 返回
-    }
-
-    /**
-     * [6512] 活动 - 抽奖 领取到校英雄
-     * @param Req $req
-     */
-    static function drawReachHero($req) {
-        if (count($req->paras) < 1) {                                           # 提取参数
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $slotid = 'slot' . $req->paras[0];                                      # 卡槽id: 0,1,2,
-        $lottery = new UserLotteryModel($req->userInfo->game->privateState->lottery);
-        $slot = new LotterySlotModel($lottery->$slotid);
-        if ($slot->locked) {                                                    # 卡槽尚未解锁
-            return Resp::err(ErrCode::err_lottery_slot_locked);
-        }
-        if ($slot->opents > now()) {                                            # 卡槽时间未到
-            return Resp::err(ErrCode::err_lottery_slot_time);
-        }
-        if (!$slot->herotype || !$slot->herostar) {                             # 卡槽数据异常
-            return Resp::err(ErrCode::err_lottery_slot_emputy);
-        }
-        # 提取英雄...
-        $he = HeroProc::AddHeroWithStar($req, $slot->herotype, $slot->herostar);
-        $slot->Clear();
-        $lottery->$slotid = $slot;
-        $req->userInfo->game->privateState->lottery = $lottery;                 # 数据回写
-        UserProc::updateUserInfo();
-        return Resp::ok(array(
-                    'heros' => $req->userInfo->game->heros,
-                    'hero' => $he,
-                    'slot' => $slot
-        ));
-    }
-
-    /**
-     * [6509] 活动 - 抽奖
-     * @param Req $req
-     */
-    static function Lottery_Hero($req) {
-        if (count($req->paras) < 1) {                                           # 提取参数
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $type = $req->paras[0];                                                 # 金币,钻石,友情点... (物品id)
-        $slotid = 'slot' . $req->paras[1];                                      # 卡槽id: 0,1,2,3
-        #
-// 检查卡槽是否空闲
-        $user = $req->userInfo->game;
-        $lottery = new UserLotteryModel($user->privateState->lottery);
-        $slot = new LotterySlotModel($lottery->$slotid);
-        if ($slot->locked) {                                                    # 卡槽尚未解锁
-            return Resp::err(ErrCode::err_lottery_slot_locked);
-        }
-        if ($slot->opents > now() || $slot->herotype) {                         # 卡槽使用中
-            return Resp::err(ErrCode::err_lottery_slot_not_emputy);
-        }
-        $number = 1;                                                            # 抽奖次数, 固定为1
-        $err = self::AddLotteryTimes($lottery, $type, $left_cishu, $number);    # 记录抽奖次数
-        if ($err) {
-            return Resp::err($err);
-        }
-        $err = self::ConsumeLotteryCost($user, $type, $number);                 # 扣除抽奖花费(通知书)
-        if ($err) {
-            return Resp::err($err);
-        }
-
-
-        $err = self::Dice(GameConfig::choujiang_getItem($type), #               # 投骰子
-                        $number, $rewardstr);
-        if ($err) {
-            return Resp::err($err);
-        }
-        if (strlen($rewardstr) <= 0) {                                          # 抽奖结果为空
-            return Resp::err(ErrCode::err_innerfault);
-        }
-        # 依据抽奖次数找到星级数据库
-        $xingji = self::FindStarSource($lottery->todayLotterys->$type);
-        if (!$xingji) {
-            return Resp::err(ErrCode::err_const_no, "抽奖-星级");
-        }
-        self::DiceOutStar($xingji, $star);                                      # 计算星级
-        $val = explode(",", $rewardstr);
-        $itemId = $val[0];
-        # 发放英雄(异化为英雄放入卡槽...
-//        $he = HeroProc::AddHeroWithStar($req, $itemId, $star);
-        $slot->herostar = $star;
-        $slot->herotype = $itemId;
-        $slot->opents = now() + self::DiceOutCoolingTiem(GameConfig::choujiang_searchtime_getItem($star));
-        $lottery->$slotid = $slot;
-        $user->privateState->lottery = $lottery;                                # 回写数据
-        $req->userInfo->game = $user;                                           # 回写user数据
-        UserProc::updateUserInfo();                                         # 回存数据
-        return Resp::ok(array('err' => 0, #                                     # 返回值
-                    'store' => $user->store,
-                    'slot' => $slot, #                                          # 卡槽信息
-                    'left_cishu' => $left_cishu));
-    }
-
-// </editor-fold>
-//
-// <editor-fold defaultstate="collapsed" desc="    -==- 辅助函数 -==-   ">
-
-    /**
-     * 增加抽奖次数
-     * @param LotterySlotModel $user
-     * @param type $type
-     * @param int $left_cishu out
-     * @param type $number
-     * @return int errno
-     */
-    static function AddLotteryTimes(&$lottery, $type, &$left_cishu, $number = 1) {
-        $todaylotterys = $lottery->todayLotterys;
-        $totalLottreys = $lottery->totalLotterys;
-        $baodiLotterys = $lottery->baodiLotterys;
-        if (!$todaylotterys) {
-            $todaylotterys = JsonUtil::decode(sprintf('{"%s":0}', $type));
-        }
-        if (!$totalLottreys) {
-            $totalLottreys = JsonUtil::decode(sprintf('{"%s":0}', $type));
-        }
-        if (!$baodiLotterys) {
-            $baodiLotterys = JsonUtil::decode(sprintf('{"%s":0}', $type));
-        }
-        if (!isset($todaylotterys->$type)) {
-            $todaylotterys->$type = 0;
-        }
-        if (!isset($totalLottreys->$type)) {
-            $totalLottreys->$type = 0;
-        }
-        if (!isset($baodiLotterys->$type)) {
-            $baodiLotterys->$type = 0;
-        }
-        $todaylotterys->$type += $number;
-        $totalLottreys->$type += $number;
-        $baodiLotterys->$type += $number;
-
-        $settings = GameConfig::choujiang_settings_getItem($type);
-        if (null == $settings) {
-            return ErrCode::err_const_no;
-        }
-        $limit = $settings->dailyLimit;
-        if ($limit > 0 && $todaylotterys->$type > $limit) {
-            return ErrCode::err_lottery_daily_limit;                            # 达到每次次数限制, (@广电总局)
-        }
-        $left_cishu = $limit - $todaylotterys->$type;
-        if ($left_cishu < 0) {
-            $left_cishu = 0;
-        }
-        $lottery->todayLotterys = $todaylotterys;
-        $lottery->totalLotterys = $totalLottreys;
-        $lottery->baodiLotterys = $baodiLotterys;
-        return ErrCode::ok;
-    }
-
-    /**
-     * 扣除抽奖花费
-     * @param UserGameModel $user
-     * @param type $type
-     * @param type $number
-     * @return int errno
-     */
-    static function ConsumeLotteryCost($user, $type, $number = 1) {
-        $settings = GameConfig::choujiang_settings_getItem($type);
-        if (null == $settings) {
-            return ErrCode::err_const_no;
-        }
-        $amt = $settings->price;
-        if ($number > 1) {                                                      # n连抽
-            $amt *= $number;
-        }
-        switch ($type) {                                                        // 扣除花费
-            case META_GOLD_ITEMID:                                              # 金币抽奖
-                if (!UserGameModel::Consume_Gold($user, $amt)) {
-                    return ErrCode::notenough_gold_msg;
-                }
-                break;
-            case META_CASH_ITEMID:                                              # 钻石抽奖
-                if (!UserGameModel::Consume_Cash($user, $amt)) {
-                    return ErrCode::notenough_cash_msg;                         # 钻石余额不足
-                }
-                break;
-            case META_FriendShipPoit_ItemId:                                    # 友情点
-                if (!UserGameModel::Consume_FriendShipPoint($user, $amt)) {
-                    return ErrCode::notenough_friendshippoint;
-                }
-                break;
-            default:                                                            # 从包裹中消耗道具
-                $err = StoreProc::removeItemFromStore($user->store, $type, $amt);
-                if ($err) {
-                    return $err;
-                }
-                break;
-        }
-
-        return ErrCode::ok;
-    }
-
-    /**
-     * 过滤奖池
-     * @param Req $req
-     * @param array $arr 奖池
-     */
-    static function FilterPrizepool($req, $arr) {
-        # 等级限制
-        $ret = array_filter($arr, function ($value) use($req) {
-            return($req->userInfo->game->level >= $value->unlock_level);
-        });
-        return $ret;
-    }
-
-    /**
-     * 投骰子
-     * @param assoc_array $arr 抽奖物品概率
-     * @param int $number 连抽次数
-     * @return string itemid,num;itemid,num;...
-     */
-    static function Dice($arr, $number, &$rewardstr) {
-        $max = 0;                                                               # 计算物品权重总和
-        array_walk($arr, function ($value) use(&$max) {
-            $max += $value->probability;
-        });
-        if (!$max) {                                                            # 配置数据有问题
-            return ErrCode::err_const_no;
-        }
-        $reward = ArrayInit();
-        for ($i = 0; $i < $number; $i++) {
-            $rnd = CommUtil::random(1, $max);                                   # 投骰子
-            $start = 0;
-            $rew = null;
-            foreach ($arr as $item) {                                           # 循环判断落入那个物品上
-                if ($start < $rnd && $rnd <= $start + $item->probability) {     # 落入区间
-                    $rew = $item;                                               # 记录物品
-                    break;
-                }
-                $start += $item->probability;                                   # 继续判断是否落入下一物品的区间
-            } # foreach end
-            if (!$rew) {
-                return ErrCode::lottery_noselecteditem;
-            }
-            $reward[] = implode(',', array($rew->rewardItemId, $rew->number));
-        } # for end
-        $rewardstr = implode(';', $reward);
-        return ErrCode::ok;
-    }
-
-    /**
-     * 找到计算星级的数据源
-     * @param type $cishu
-     * @return array of sm_choujiang_xingji
-     */
-    public static function FindStarSource($cishu) {
-        foreach (GameConfig::choujiang_xingji() as $ci => $arr) {
-            if ($cishu <= $ci) {                                                # 找到对应的阶段了
-                return $arr;
-            }
-        }
-        return JsonUtil::decode('[{"star":1,"probability":100}]');              # 默认值, 爽吧
-    }
-
-    /**
-     * @deprecated since version now
-     * 投骰子获得一个卡牌的星级
-     * @param type $arr
-     * @param type $ret
-     * @return type
-     */
-    public static function DiceOutStar($arr, &$ret) {
-        $max = 0;
-        array_walk($arr, function ($value) use(&$max) {
-            $max += $value->probability;                                        # 计算物品权重总和
-        });
-        if (!$max) {                                                            # 配置数据有问题
-            return ErrCode::err_const_no;
-        }
-        $rnd = CommUtil::random(1, $max);                                       # 投骰子
-        $start = 0;                                                             # 起点
-        foreach ($arr as $item) {                                               # 循环判断落入那个物品上
-            if ($start < $rnd && $rnd <= $start + $item->probability) {         # 落入区间
-                $ret = $item->star;                                             # 设置结果
-                return ErrCode::ok;
-            }
-            $start += $item->probability;                                       # 继续判断是否落入下一物品的区间
-        }                                                                       # foreach end
-        return ErrCode::lottery_noselecteditem;                                 # 没有找到对应的结果
-    }
-
-    /**
-     * 依据星级投骰子获得一个到校时间
-     * @param type $arr
-     * @return type
-     */
-    public static function DiceOutCoolingTiem($arr) {
-        $max = 0;
-        array_walk($arr, function ($value) use(&$max) {
-            $max += $value->probability;                                        # 计算物品权重总和
-        });
-
-        $rnd = CommUtil::random(1, $max);                                       # 投骰子
-        $start = 0;                                                             # 起点
-        foreach ($arr as $item) {                                               # 循环判断落入那个物品上
-            if ($start < $rnd && $rnd <= $start + $item->probability) {         # 落入区间
-                return $item->time;                                             # 设置结果, 返回值
-            }
-            $start += $item->probability;                                       # 继续判断是否落入下一物品的区间
-        }                                                                       # foreach end
-        return 780;                                                             # 没有找到对应的结果, 给一个默认值13分钟
-    }
-
-    /**
-     * 清理每天的抽奖次数记录
-     * @param Req $req
-     */
-    public static function ClearLotteryRecord($req) {
-        $req->userInfo->game->privateState->lottery->todayLotterys = ObjectInit();
-    }
-
-    // </editor-fold>
-//
-}

+ 864 - 863
Gameserver/Amfphp/process/FriendProc.php

@@ -1,880 +1,881 @@
 <?php
 
-namespace loyalsoft;
-
-/**
- * 好友模块各种操作类型-枚举值
- */
-class enum_Friend_op extends Enum {
-
-    const __default = 0;
-    // 删除好友
-    const remove = 1;
-    // 加好友
-    const apply = 2;
-    // 接受请求
-    const accepted = 3;
-    // 示好, 送心...
-    const gift = 4;
-    // 加好友请求的发送记录
-    const applied = 5;
-    // 示好,送心的记录
-    const giftrecord = 6;
-
-}
-
-/**
- * 好友处理流程
- * @version
- *          1.0.0 Created at 2017-3-6. by --gwang
- * @author gwang (mail@wanggangzero.cn)
- * @copyright ? 2017-3-6, SJZ LoyalSoft Corporation & gwang. All rights reserved.
- */
-class FriendProc {
-
-    /**
-     * 好友发送消息的最大长度(超过的截断)
-     */
-    const MaxMessageLength = 80;
-
-    /**
-     * 逻辑分发
-     * 所有的Proc中必须有这样一个方法
-     * @param type $req
-     */
-    static function procMain($req) {
-        switch ($req->cmd) {
-            case CmdCode::cmd_user_friend_search:                               # [6110]查找好友
-                return FriendProc::SearchFriend($req);
-            case CmdCode::cmd_user_friend_suggestList:                          # [6111]添加好友界面获取一批推荐好友列表
-                return FriendProc::GetSuggestList($req);
-            case CmdCode::cmd_user_friend_get_list:                             # [6106]获取好友列表  ok下发好友个人公会信息
-                return FriendProc::getAppFriends($req);
-            case CmdCode::cmd_user_friend_get_infos:                            # [6107]获取详细信息
-                return FriendProc::getAppFriendInfos($req);
-// ------------------------------------------
-
-            case CmdCode::cmd_user_friend_gift_getlist:                         # [6113]拉取好友赠送礼物的记录
-                return FriendProc::getAppFriendGiftList($req);
-            case CmdCode::cmd_user_friend_gift_redraw:                          # [6114]领取好友赠送的礼物[并回赠]
-                return FriendProc::getAppFriendGift($req);
-            case CmdCode::cmd_user_friend_gift_send:                            # [6115]向好友发送礼物,示好
-                return FriendProc::sendGiftToAppFriend($req);
-            case CmdCode::cmd_user_friend_unduckmsg:
-                return FriendProc::CheckUnduckMessage($req);
-//--------------------------------------------
-            case CmdCode::cmd_user_friend_apply:                                # [6101]加好友
-                return FriendProc::ApplyToAddNewFriend($req);
-            case CmdCode::cmd_user_friend_accept:                               # [6102]接受好友请求
-                return FriendProc::Accept($req);
-            case CmdCode::cmd_user_friend_deny:                                 # [6103]拒绝好友请求
-                return FriendProc::Deny($req);
-            case CmdCode::cmd_user_friend_remove:                               # [6104]删除好友
-                return FriendProc::Remove($req);
-            case CmdCode::cmd_user_friend_getapplylist:                         # [6105]好友请求列表
-                return FriendProc::GetApplyList($req);
-//-----------------------------------------------
-            case CmdCode::cmd_user_friend_leave_message:                        # [6108]给好友发消息
-                return FriendProc::SendMessage($req);
-            case CmdCode::cmd_user_friend_get_message:                          # [6109]刷新消息
-                return FriendProc::GetNewMessage($req);
-
-//-----------------------------------------------
-            case CmdCode::cmd_user_friend_reload:                               # [6112]更新好友
-                return FriendProc::Reload($req);
-            case CmdCode::cmd_user_friend_LookGuildInfo:                        # [6117]查看好友所在部落信息
-                return FriendProc::LookGuildInfo($req);
-            case CmdCode::cmd_user_friend_LookFriendInfo:                       # [6118]查看好友简介
-                return FriendProc::LookFriendInfo($req);
-            default:
-                return Resp::err(ErrCode::cmd_err);
-        }
-    }
-
-    /**
-     * 查看好友的部落信息
-     * @param type $req
-     */
-    static function LookGuildInfo($req) {
-        $friendId = $req->paras[0];
-        $zoneid = $req->zoneid;
-        $mem = $req->mem;
-
-        $sql = "select * from `tab_rolename` where userID = '$friendId'";
-        $rows = daoInst()->query($sql)->fetchAll();
-        my_Assert(count($rows) > 0, ErrCode::err_user_no);                      # 找不到玩家数据 
-        $friendGuildInfo = GuildProc::getMemUserGuildInfo($mem, $friendId, $zoneid);
-        my_Assert($friendGuildInfo != null, "好友公会数据为空");
-        my_Assert($friendGuildInfo->guildId > 0, ErrCode::err_guild_userguildinfono);
-
-        $guildInfo = GuildProc::getMemGuildInfo($mem, $friendGuildInfo->guildId, $zoneid);
-        my_Assert($guildInfo != null, ErrCode::err_guild_guildinfono);                                       # 找不到公会
-
-        return Resp::ok($guildInfo);
-    }
-
-    /**
-     * 查看好友简介
-     * @param type $req
-     */
-    static function LookFriendInfo($req) {
-        $friendId = $req->paras[0];                                             //好友id
-        $mem = $req->mem;
-        $sql = "select * from `tab_rolename` where userID = '$friendId'";
-        $rows = daoInst()->query($sql)->fetchAll();
-        my_Assert(count($rows) > 0, ErrCode::err_user_no);                      # 找不到玩家角色记录 
-        $friendInfo = self::initfriendInfo($mem, $rows[0]['userID'], $rows[0]['zoneid']);
-        my_Assert($friendInfo != null, ErrCode::err_user_no);                   # 好友数据初始化成功
-        $friendInfo->fightPower = GuildProc::initFightTeamInfo($mem, $rows[0]['userID'], $rows[0]['zoneid']);
-        return Resp::ok(array("friendInfo" => $friendInfo,));
-    }
-
-    /**
-     * 检查玩家的好友信息是否有未处理的
-     * @param type $req
-     */
-    public static function CheckUnduckMessage($req) {
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $uid = $req->uid;
-        $result = -1;
-        // 别人的赠送列表
-        $fgiftlist = self::getOps($mem, $uid, $zoneid, enum_Friend_op::gift);
-        if (count((array) $fgiftlist) <= 0) {
-            $result = 0;
-        } else {
-            foreach ($fgiftlist as $key => $value) {
-                if (count((array) $value) <= 0) {
-                    continue;
-                } else {
-                    $result = 1;
-                    break;
-                }
-            }
-        }
-        //找别人发来的申请加好友的列表
-        if ($result == 0) {
-            $ret = FriendProc::getOps($req->mem, $req->uid, $req->zoneid, enum_Friend_op::apply);
-            $result = (count((array) $ret) > 0) ? 1 : 0;
-        }
-        return Resp::ok(array('ret' => $result));
-    }
-
-    /**
-     * [6112] 核算好友的离线操作
-     * @param Req $req
-     */
-    public static function Reload($req) {
-        $mem = $req->mem;
-        $uid = $req->uid;
-        $zoneid = $req->zoneid;
-
-        // 刷新接受请求列表, 将已接受的好友添加到
-        $allOps = self::getOps($mem, $uid, $zoneid);
-        $op = new enum_Friend_op(enum_Friend_op::accepted);
-        $ops = $allOps->$op;
-        if (count($ops) > 0) {
-            foreach ($ops as $u => $ts) {                                       # 立即将对方添加到好友列表
-                self::_AddFriend($mem, $uid, $zoneid, $u);
-            }
-            $ops = "{}";
-            $allOps->$op = $ops;
-        }
-
-        // 刷新删除列表, 看谁和我解除了好友关系, 删掉他
-        $op = new enum_Friend_op(enum_Friend_op::remove);
-        $ops = $allOps->$op;
-        if (count($ops) > 0) {
-            foreach ($ops as $u => $ts) {
-                self::_RemoveFriend($mem, $uid, $zoneid, $u);
-            }
-            $allOps->$op = "{}";
-        }
-        $g = glc();
-
-        self::filterOutDateRecords($allOps, #                                   # 清理过期的请求记录,
-                new enum_Friend_op(enum_Friend_op::applied), $g->User_Friends_Apply_ExpireTs);
-
-        self::filterOutDateRecords($allOps, #                                   # 刷新别人发来的好友请求列表, 过期而没有处理的也删掉(莫名其妙的消失,玩家会不会不爽?要不要加上倒计时?).
-                new enum_Friend_op(enum_Friend_op::apply), $g->User_Friends_Apply_ExpireTs);
-
-        self::saveOps($mem, $uid, $zoneid, $allOps, 0);                         # 回存数据
-        // 清理过期的互动记录, 不清除, 一个好友最多保留3条记录
-        // 更新好友数量
-        return Resp::ok(array("ret" => "ok"));
-    }
-
-    private static function filterOutDateRecords($allOps, $op, $outts) {
-        $ops = $allOps->$op;
-        if (count((array) $ops) > 0) {
-            $ops = array_filter((array) $ops, function ($ts)use($outts) {
-                return (intval($ts) + $outts) > now();
-            });
-            $allOps->$op = (is_null($ops) || 0 == count((array) $ops)) ? "{}" : $ops;
-        }
-    }
-
 //
-// <editor-fold defaultstate="collapsed" desc="  聊天/留言  ">
-    //
-
-    /**
-     * [6108]发送消息/留言
-     * @param Req $req
-     */
-    public static function SendMessage($req) {
-        // todo:检查是否好友
-        $mem = $req->mem;
-        $uid_from = $req->uid;
-        $uid_to = $req->paras[0];
-        $msg = $req->paras[1];
-        if (strlen($msg) > self::MaxMessageLength) {
-            $msg = substr($msg, 0, self::MaxMessageLength) . "...";
-        }
-        $key = MemKey_User::FriendsMsgQueue_hash($req->zoneid, $uid_to);
-        $arr = $mem->hget($key, $uid_from);
-        if (null == $arr) {
-            $arr = ArrayInit();
-        }
-        $ts = now();
-        array_push($arr, "{$msg}{$ts}");
-        if (count($arr) > glc()->User_Friends_MessageCount_Max) {
-            array_shift($arr);
-        }
-        $mem->hset($key, $uid_from, $arr);
-//
-        $mts = isset($req->paras[2]) ? $req->paras[2] : 0;
-        $newmsg = self::_GetNewMessage($mem, $req->zoneid, $uid_from, $uid_to, $mts);
-        return Resp::ok(array("ret" => "ok", 'newmsg' => $newmsg));
-    }
-
-    /**
-     * [6109]拉取最新消息/留言
-     *
-     * @param Req $req
-     */
-    public static function GetNewMessage($req) {
-        if (count($req->paras) < 2) {
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $uid_filter = $req->paras[0];
-        $ts = $req->paras[1];
-        $arr = self::_GetNewMessage($req->mem, $req->zoneid, $req->uid, $uid_filter, $ts);
-
-        return Resp::ok($arr);
-    }
-
-    /**
-     * 取留言消息
-     * @param CredisUtil $mem
-     * @param int $zoneid
-     * @param string $uid
-     * @param string $f_uid
-     * @param ts $ts
-     * @return asoc_array
-     */
-    private static function _GetNewMessage($mem, $zoneid, $uid, $f_uid, $ts) {
-        $key = MemKey_User::FriendsMsgQueue_hash($zoneid, $uid);
-        $arr = array($f_uid => $mem->hget($key, $f_uid));
-        // 依据ts时间戳,剔除客户端不需要的消息,然后传送.
-        foreach ($arr as &$msgq) {
-            if (null == $msgq) { // 防御
-                continue;
-            }
-            $msgq = array_filter($msgq, function($msg) use($ts) {
-                return $ts < substr($msg, -10);  // 时间戳10位
-            });
-        }
-        return $arr;
-    }
-
-    //
-    //
-// </editor-fold>
+//namespace loyalsoft;
 //
-// <editor-fold defaultstate="collapsed" desc="  待定  ">
-    //
-
-    /**
-     * 设置默认同意好友请求
-     * @param Req $req
-     */
-    public static function SetAutoAccept($req) {
-        
-    }
-
-// </editor-fold>
+///**
+// * 好友模块各种操作类型-枚举值
+// */
+//class enum_Friend_op extends Enum {
 //
-// <editor-fold defaultstate="collapsed" desc="  好友操作  ">
+//    const __default = 0;
+//    // 删除好友
+//    const remove = 1;
+//    // 加好友
+//    const apply = 2;
+//    // 接受请求
+//    const accepted = 3;
+//    // 示好, 送心...
+//    const gift = 4;
+//    // 加好友请求的发送记录
+//    const applied = 5;
+//    // 示好,送心的记录
+//    const giftrecord = 6;
 //
-
-    /**
-     * [6105] 拉取好友请求列表
-     * @param Req $req
-     */
-    public static function GetApplyList($req) {
-        $ret = FriendProc::getOps($req->mem, $req->uid, $req->zoneid, enum_Friend_op::apply);
-        return Resp::ok(array("ret" => (count((array) $ret) > 0) ? $ret : array()));
-    }
-
-    /**
-     * [6101]添加好友
-     * @param Req $req
-     */
-    public static function ApplyToAddNewFriend($req) {   // 取目标玩家的ops列表插入请求
-        $mem = $req->mem;
-        $uid_to = $req->paras[0];
-        $uid_from = $req->uid;
-        if ($uid_from == $uid_to) {
-            return Resp::err(ErrCode::paras_err, "添加的好友ID非法!");
-        }
-
-        $err = self::AddOp($mem, $req->zoneid, $uid_to, enum_Friend_op::apply, $uid_from);
-        if (ErrCode::ok != $err) {
-            return Resp::err($err);
-        }
-        $err = self::AddOp($mem, $req->zoneid, $req->uid, enum_Friend_op::applied, $uid_to);
-        if (ErrCode::ok != $err) {
-            return Resp::err($err);
-        }
-        return Resp::ok(array("ret" => "ok"));
-    }
-
-    /**
-     * [6102]接受好友请求
-     * @param Req $req
-     */
-    public static function Accept($req) {  // 将对方立即放到自己的好友列表中, 并给对方发送接受的op, 删除请求记录
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $uid_my = $req->uid;
-        $uid_arr = explode(',', $req->paras[0]);
-        foreach ($uid_arr as $uid_to) {
-            $myOp = self::getOps($mem, $req->uid, $zoneid, enum_Friend_op::apply); // 自己的请求列表
-            unset($myOp->$uid_to);     // 删除请求记录
-            self::saveOps($mem, $req->uid, $zoneid, $myOp, enum_Friend_op::apply); // 更新自己的请求列表
-
-            $err = self::AddOp($mem, $zoneid, $uid_to, enum_Friend_op::accepted, $uid_my); // 向对方的已接受列表中添加记录
-            if ($err != ErrCode::ok) { // 出错
-                return Resp::err($err);
-            }
-            self::_AddFriend($mem, $uid_my, $zoneid, $uid_to);
-//            $mem->sadd(MemKey_User::FriendsList_set($zoneid, $req->uid), $uid_to);      // 立即将对方添加到好友列表
-        }
-
-        return Resp::ok(array("ret" => "ok"));
-    }
-
-    /**
-     * [6103]拒接好友请求
-     * @param Req $req
-     */
-    public static function Deny($req) {   // 直接 删除请求记录, 不通知对方了
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $uid_my = $req->uid;
-        $uid_to = $req->paras[0];
-
-        // 从自己的列表中删除就行了,不用通知对方
-        $myOp = self::getOps($mem, $uid_my, $zoneid, enum_Friend_op::apply); // 自己的请求列表
-        unset($myOp->$uid_to);
-        self::saveOps($mem, $uid_my, $zoneid, $myOp, enum_Friend_op::apply); // 更新自己的请求列表
-
-        return Resp::ok(array("ret" => "ok"));
-    }
-
-    /**
-     * [6104]删除好友
-     * @param Req $req
-     */
-    public static function Remove($req) {// 将对方立即从自己的好友列表中删除, 并给对方发送remove的op
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $uid_to = $req->paras[0];  // 删除谁
-        $uid_my = $req->uid;
-
-        $tOp = self::getOps($mem, $uid_to, $zoneid, enum_Friend_op::remove); // 对方的删除列表
-        $ts = now();
-        $userInfo_my = UserProc::getUserInfo($mem, $zoneid, $uid_my);
-        $name = $userInfo_my->game->name;
-        $tOp->$uid_my = $ts . "_" . $name;
-        self::saveOps($mem, $uid_to, $zoneid, $tOp, enum_Friend_op::remove); // 更新对方的删除列表
-        self::_RemoveFriend($mem, $uid_my, $zoneid, $uid_to);
-
-        return Resp::ok(array("ret" => "ok"));
-    }
-
+//}
 //
-// </editor-fold>
+///**
+// * 好友处理流程
+// * @version
+// *          1.0.0 Created at 2017-3-6. by --gwang
+// * @author gwang (mail@wanggangzero.cn)
+// * @copyright ? 2017-3-6, SJZ LoyalSoft Corporation & gwang. All rights reserved.
+// */
+//class FriendProc {
 //
-// <editor-fold defaultstate="collapsed" desc="  搜索  ">
-
-    /**
-     * [6110]搜索好友
-     * @param Req $req
-     */
-    static function SearchFriend($req) {
-        //客户端参数解析
-        if (count($req->paras) <= 1) { // 参数非法
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $zoneid = $req->zoneid;
-        $filter = $req->paras[0];
-        $start = 0;
-        if (count($req->paras) > 1) {
-            $start = $req->paras[1];
-        }
-        $max = 8; // 每次查询返回的数据条目数量
-        $sql = "select * from `tab_rolename` where (`userID`='$filter' OR `roleName` like '%$filter%') and zoneid = $zoneid limit $start, $max ;";
-        $paydb = CPayInit();
-        $rows = $paydb->fetch_array($sql);
-        $ret = ArrayInit();
-        foreach ($rows as $row) {
-            $uid = $row['userID'];
-            $zone_all = $row['zoneid'];
-            if ($uid == $req->uid) {
-                continue;
-            }
-            $friendInfo = self::initfriendInfo($req->mem, $uid, $zone_all);
-            if ($friendInfo != null) {
-                $ret[] = $friendInfo;
-            }
-        }
-        $ops = self::getOps($req->mem, $req->uid, $req->zoneid, enum_Friend_op::applied);
-        return Resp::ok(array('fList' => $ret, 'applied' => $ops));
-    }
-
-    static function initfriendInfo($mem, $uid, $zoneid) {
-        $userInfo = UserProc::getUserInfo($mem, $zoneid, $uid);
-        if ($userInfo == null) {
-            return null;
-        }
-        $userGuildInfo = GuildProc::getMemUserGuildInfo($mem, $uid, $zoneid);
-        if ($userGuildInfo == null) {
-            $userGuildInfo = ObjectInit();
-            $userGuildInfo->guildName = "";
-            $userGuildInfo->guildId = 0;
-        }
-        $key_cur = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
-        $score = $mem->zscore($key_cur, $uid);
-        $userGuildInfo->cupScore = $score == null ? 0 : $score;
-        $friendObj = new initfriendInfoModel(null, $uid, $userInfo->game->name, $userInfo->game->level, $userInfo->game->img, #
-                $userInfo->game->imgBorderId, $userGuildInfo->guildName, $userGuildInfo->guildId, $userGuildInfo->cupScore);
-        return $friendObj;
-    }
-
-    /**
-     * [6111]添加好友界面获取一批推荐好友列表
-     * @param Req $req
-     */
-    static function GetSuggestList($req) {
-        //客户端参数解析
-        if (count($req->paras) < 1) { // 参数非法
-            return Resp::err(ErrCode::parasnotenough_msg);
-        }
-        $zoneid = $req->zoneid;
-        $start = $req->paras[0]; // 第几页
-        $max = 8; // 每次查询返回的数据条目数量
-        $sql = "select * from `tab_rolename` where `zoneid`=$zoneid order by ts desc limit $start, $max ;";
-        $paydb = CPayInit();
-        $rows = $paydb->fetch_array($sql);
-        $arr = ArrayInit();
-        foreach ($rows as $row) {
-            if ($row['userID'] == $req->uid) {
-                continue;
-            }
-            unset($row["tid"]);
-            unset($row["zoneid"]);
-
-            $arr[] = $row['userID'];
-        }
-        $applidops = self::getOps($req->mem, $req->uid, $req->zoneid, enum_Friend_op::applied);
-        $ret = array('fList' => array_unique($arr), 'applied' => $applidops);
-        return Resp::ok($ret);
-    }
-
-// </editor-fold>
+//    /**
+//     * 好友发送消息的最大长度(超过的截断)
+//     */
+//    const MaxMessageLength = 80;
 //
-// <editor-fold defaultstate="collapsed" desc="  好友列表  ">
-
-    /**
-     * [6106]获取好友ID列表
-     * @param Req $req
-     * @return int
-     */
-    static function getAppFriends($req) {
-        self::Reload($req);
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        //客户端参数解析
-        $friendIds = self::_GetFriendList($mem, $req->uid, $zoneid); // 取好友列表
-
-        $userArr = ArrayInit();
-        foreach ($friendIds as $index => $uid) {
-            $friendInfo = self::initfriendInfo($mem, $uid, $zoneid);
-            if ($friendInfo == null) {
-                continue;
-            }
-            $userArr[] = $friendInfo;
-        }
-        //$mygiftops = self::getOps($mem, $req->uid, $req->zoneid, enum_Friend_op::giftrecord);
-        $resp = Resp::ok(array(
-                    #"friends" => $friendIds,
-                    'userGuild' => $userArr,
-        ));
-        return $resp;
-    }
-
-    /**
-     * 查找好友数量
-     * @param Req $req
-     */
-    public static function getCurrentFriendsCount($req) {
-        return $req->mem->scard(MemKey_User::FriendsList_set($req->zoneid, $req->uid));
-    }
-
-    /**
-     * [6107] 获取好友信息列表
-     * @param Req $req
-     * @return type
-     */
-    static function getAppFriendInfos($req) {
-        $mem = $req->mem;
-        //客户端参数解析
-        $zoneid = $req->zoneid;
-        $fuids = explode(',', $req->paras[0]);        // 逗号分割uid字符串
-        $max = 8; # 一次最多取八个数据
-        $n = count($fuids);
-//        var_dump($fuids);
-        if ($n > 0 && $n <= $max) {
-            $fuidkeys = array_map(function ($i) use($zoneid) {
-                return MemKey_User::Info($zoneid, $i);
-            }, $fuids);
-            $arr = $mem->getMulti($fuidkeys);
-            $friendInfos = ArrayInit();
-            $n = 0;
-            foreach ($arr as $userInfo) {
-                isEditor() && $userInfo = new UserGameModel;
-                isEditor() && $shareInfo = new UserHeroModel;
-                $uid = $fuids[$n++];
-                if (!$userInfo                                  # 玩家数据不为空
-                        || !property_exists($userInfo, 'heros') # 存在heros数据
-                        || !$userInfo->heros) {                 # heros数据不为空
-                    continue;
-                }
-                $sharedHeroId = $userInfo->heros->firendSupportHeroUID;
-                if ($sharedHeroId) {
-                    $shareInfo = $userInfo->heros->collectHeros->$sharedHeroId;
-                } else { // todo: 暂定如果没有设置共享英雄,默认取集合中第一个英雄, 征询策划是否修订规则
-                    $coll = $userInfo->heros->collectHeros;
-                    $keys = array_keys((array) $coll);
-                    if (count($keys) <= 0) {
-                        continue;
-                    }
-                    $sharedHeroId = $keys[0];
-                    $shareInfo = $userInfo->heros->collectHeros->$sharedHeroId;
-                }
-                // 额外将英雄的装备数据替换为实例数据
-                self::getArmor($userInfo, $shareInfo, 'weapon');
-                self::getArmor($userInfo, $shareInfo, 'armor');
-                self::getArmor($userInfo, $shareInfo, 'ring');
-                $friendInfos[$uid] = array('sharedHero' => $shareInfo,
-                    'lastLoginTs' => isset($userInfo->lastLogin) ? $userInfo->lastLogin : 0,
-                    'level' => $userInfo->level,
-                    'nickname' => $userInfo->name
-                );
-            }
-            if (count($friendInfos) <= 0) {
-                $friendInfos = null;
-            }
-            $resp = Resp::ok(array('ret' => $friendInfos));
-        } else {
-            $resp = Resp::err(ErrCode::paras_err);
-        }
-        return $resp;
-    }
-
-    static function getArmor($userInfo, $hero, $armor) {
-        $armorid = $hero->equip->$armor->itemuid;
-
-        if ($armorid > 0 && isset($userInfo->store->equipment->$armorid)) {
-            $hero->equip->$armor = $userInfo->store->equipment->$armorid;
-        } else {
-            $hero->equip->$armor = null;
-        }
-    }
-
-// </editor-fold>
+//    /**
+//     * 逻辑分发
+//     * 所有的Proc中必须有这样一个方法
+//     * @param type $req
+//     */
+//    static function procMain($req) {
+//        switch ($req->cmd) {
+//            case CmdCode::cmd_user_friend_search:                               # [6110]查找好友
+//                return FriendProc::SearchFriend($req);
+//            case CmdCode::cmd_user_friend_suggestList:                          # [6111]添加好友界面获取一批推荐好友列表
+//                return FriendProc::GetSuggestList($req);
+//            case CmdCode::cmd_user_friend_get_list:                             # [6106]获取好友列表  ok下发好友个人公会信息
+//                return FriendProc::getAppFriends($req);
+//            case CmdCode::cmd_user_friend_get_infos:                            # [6107]获取详细信息
+//                return FriendProc::getAppFriendInfos($req);
+//// ------------------------------------------
 //
-// <editor-fold defaultstate="collapsed" desc="  示好  ">
+//            case CmdCode::cmd_user_friend_gift_getlist:                         # [6113]拉取好友赠送礼物的记录
+//                return FriendProc::getAppFriendGiftList($req);
+//            case CmdCode::cmd_user_friend_gift_redraw:                          # [6114]领取好友赠送的礼物[并回赠]
+//                return FriendProc::getAppFriendGift($req);
+//            case CmdCode::cmd_user_friend_gift_send:                            # [6115]向好友发送礼物,示好
+//                return FriendProc::sendGiftToAppFriend($req);
+//            case CmdCode::cmd_user_friend_unduckmsg:
+//                return FriendProc::CheckUnduckMessage($req);
+////--------------------------------------------
+//            case CmdCode::cmd_user_friend_apply:                                # [6101]加好友
+//                return FriendProc::ApplyToAddNewFriend($req);
+//            case CmdCode::cmd_user_friend_accept:                               # [6102]接受好友请求
+//                return FriendProc::Accept($req);
+//            case CmdCode::cmd_user_friend_deny:                                 # [6103]拒绝好友请求
+//                return FriendProc::Deny($req);
+//            case CmdCode::cmd_user_friend_remove:                               # [6104]删除好友
+//                return FriendProc::Remove($req);
+//            case CmdCode::cmd_user_friend_getapplylist:                         # [6105]好友请求列表
+//                return FriendProc::GetApplyList($req);
+////-----------------------------------------------
+//            case CmdCode::cmd_user_friend_leave_message:                        # [6108]给好友发消息
+//                return FriendProc::SendMessage($req);
+//            case CmdCode::cmd_user_friend_get_message:                          # [6109]刷新消息
+//                return FriendProc::GetNewMessage($req);
 //
-
-    /**
-     * [6115]向好友发送礼物(示好)
-     * @param Req $req
-     */
-    static function sendGiftToAppFriend($req) {
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $uid = $req->uid;
-        //客户端参数解析
-        $fuids = explode(',', $req->paras[0]);  // 逗号分割的uid数组
-//        $pr = $req->paras[1];   // other参数 preserved
-        $n = count($fuids);
-        if ($n <= 0) {
-            return Resp::ok(array("ret" => 0));
-        }
-        $mygiftrecord = self::getOps($mem, $uid, $zoneid, enum_Friend_op::giftrecord);
-        $m = 0;
-        for ($i = 0; $i < $n; $i++) {
-            $fid = $fuids[$i];
-            $tsDay = tsDay();
-            if (property_exists($mygiftrecord, $fid) // 判断对方是否能够领取礼物(当天已经发送过,则不再发送)
-                    && $mygiftrecord->$fid >= $tsDay) {
-                continue;
-            }
-            $mygiftrecord->$fid = $tsDay;  # 更新发送记录
-            $fgiftinfo = self::getOps($mem, $fid, $zoneid, enum_Friend_op::gift);
-            if (null == $fgiftinfo) { // 防御
-                $fgiftinfo = ObjectInit(); // 没找到好友数据, 则创建
-            }
-            // 给对方身上插入操作记录
-            if (!isset($fgiftinfo->$uid) or ! is_array($fgiftinfo->$uid)) {//防御
-                $fgiftinfo->$uid = ArrayInit();
-            }
-            $arr = $fgiftinfo->$uid;
-            $arr[] = tsDay();
-            if (count($arr) > 3) { // 最多保留3条记录
-                sort($arr);
-                array_shift($arr);
-            }
-            $fgiftinfo->$uid = $arr; // 更新下
-            self::saveOps($mem, $fid, $zoneid, $fgiftinfo, enum_Friend_op::gift);
-
-            $m++;
-        }
-        // 回存数据
-        self::saveOps($mem, $uid, $zoneid, $mygiftrecord, enum_Friend_op::giftrecord);
-        // 其他检查比如任务、成就系统
-        //   ...
-        // 返回结果
-        return Resp::ok(array("ret" => $m));
-    }
-
-    /**
-     * [6113]查询游戏中哪些好友给我发送了礼物的列表
-     * @param Req $req
-     */
-    static function getAppFriendGiftList($req) {
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $uid = $req->uid;
-        // 别人的赠送列表
-        $fgiftlist = self::getOps($mem, $uid, $zoneid, enum_Friend_op::gift);
-        if (count((array) $fgiftlist) <= 0) {
-            $fgiftlist = NULL;
-        }
-        return Resp::ok(array('ret' => $fgiftlist));
-    }
-
-    /**
-     * [6114]领取来自好友的礼物[并回赠]
-     * @param Req $req
-     */
-    static function getAppFriendGift($req) {
-        $mem = $req->mem;
-        $zoneid = $req->zoneid;
-        $uid = $req->uid;
-        //客户端参数解析
-        $fuids = explode(',', $req->paras[0]);  // 逗号分割的uidtsday数组
-        $bSendback = true;              // 是否回赠
-
-        $arr = array();
-        array_map(function($f)use(&$arr) {
-            $arr[substr($f, -5)] = substr($f, 0, -5); // tsday()占5个字符
-        }, $fuids);
-        $fgiftlist = self::getOps($mem, $uid, $zoneid, enum_Friend_op::gift);
-
-        $recieved = 0;
-        foreach ($arr as $ts => $fid) {
-            if (isset($fgiftlist->$fid) && in_array($ts, $fgiftlist->$fid)) {
-                StlUtil::arrayRemove($fgiftlist->$fid, $ts);
-                $recieved++;
-            }
-        }
-        $req->userInfo->game->friendPoint += $recieved;
-        self::saveOps($mem, $uid, $zoneid, $fgiftlist, enum_Friend_op::gift);
-        UserProc::updateUserInfo();
-        if ($bSendback && $recieved > 0) {
-            $uids_send = array_unique(array_values($arr));
-            $req->paras[0] = implode(',', $uids_send);
-//            var_dump($uids_send);
-            self::sendGiftToAppFriend($req);
-        }
-        // 当天领取好友礼物有没有上限? 比如100个心.
-        // 检查是否存在对应的礼物记录,
-        // 发送礼物
-        // 删除礼物记录
-        // 回写数据
-        // 返回值
-
-        return Resp::ok(array("ret" => $recieved));
-    }
-
-    /**
-     * 玩家初始化
-     * @param Req $req
-     */
-    static function Init($req) {
-        $mem = $req->mem;
-        $z = $req->zoneid;
-        $uid = $req->uid;
-//        $mem->sadd(MemKey_User::FriendsList_set($z, $uid), "");
-        $mem->hset(MemKey_User::FriendsMsgQueue_hash($z, $uid), "sys", "");
-        $mem->hmset(MemKey_User::FriendsOps_hash($z, $uid), array("apply" => "{}",
-            "applied" => "{}",
-            "gift" => "{}",
-            "accepted" => "{}",
-            "remove" => "{}",
-            'giftrecord' => "{}"));
-    }
-
+////-----------------------------------------------
+//            case CmdCode::cmd_user_friend_reload:                               # [6112]更新好友
+//                return FriendProc::Reload($req);
+//            case CmdCode::cmd_user_friend_LookGuildInfo:                        # [6117]查看好友所在部落信息
+//                return FriendProc::LookGuildInfo($req);
+//            case CmdCode::cmd_user_friend_LookFriendInfo:                       # [6118]查看好友简介
+//                return FriendProc::LookFriendInfo($req);
+//            default:
+//                return Resp::err(ErrCode::cmd_err);
+//        }
+//    }
 //
-// </editor-fold>
+//    /**
+//     * 查看好友的部落信息
+//     * @param type $req
+//     */
+//    static function LookGuildInfo($req) {
+//        $friendId = $req->paras[0];
+//        $zoneid = $req->zoneid;
+//        $mem = $req->mem;
 //
-//-------------以下是辅助方法-----------------
+//        $sql = "select * from `tab_rolename` where userID = '$friendId'";
+//        $rows = daoInst()->query($sql)->fetchAll();
+//        my_Assert(count($rows) > 0, ErrCode::err_user_no);                      # 找不到玩家数据 
+//        $friendGuildInfo = GuildProc::getMemUserGuildInfo($mem, $friendId, $zoneid);
+//        my_Assert($friendGuildInfo != null, "好友公会数据为空");
+//        my_Assert($friendGuildInfo->guildId > 0, ErrCode::err_guild_userguildinfono);
 //
-
-    /**
-     * 验证是否好友
-     * @param Req $req
-     */
-    public static function isFriendship($zoneid, $myUid, $fUid) {
-        return gMem()->sismember(MemKey_User::FriendsList_set($zoneid, $myUid), $fUid);
-    }
-
-    /**
-     * 添加fuid到好友列表
-     */
-    private static function _AddFriend($mem, $uid, $zoneid, $fuid) {
-        $mem->sadd(MemKey_User::FriendsList_set($zoneid, $uid), $fuid);
-    }
-
-    /**
-     * 从好友列表中删除fuid
-     */
-    private static function _RemoveFriend($mem, $uid, $zoneid, $fuid) {
-        $mem->sremove(MemKey_User::FriendsList_set($zoneid, $uid), $fuid);
-    }
-
-    private static function _GetFriendList($mem, $uid, $zoneid) {
-        $arr = $mem->smembers(MemKey_User::FriendsList_set($zoneid, $uid));
-        if (!$arr) {                                                            # 数据为空
-            $arr = ArrayInit();
-        }
-        $friendIds = array_values(array_filter($arr, function ($a) {
-                    return $a != "";
-                }));
-        return $friendIds;
-    }
-
+//        $guildInfo = GuildProc::getMemGuildInfo($mem, $friendGuildInfo->guildId, $zoneid);
+//        my_Assert($guildInfo != null, ErrCode::err_guild_guildinfono);                                       # 找不到公会
 //
-// <editor-fold defaultstate="collapsed" desc="  读写玩家好友数据  ">
-
-    /**
-     * 添加操作
-     * @param enum_Friend_op $op
-     * @param Req $req
-     */
-    private static function AddOp($mem, $zoneid, $uid, $op, $uid_from) {
-        $enop = new enum_Friend_op($op);
-        if (!$enop->isValidValue($op)) {
-            return ErrCode::paras_err;
-        }
-        $ts = now();
-        $tOp = FriendProc::getOps($mem, $uid, $zoneid, $op);
-
-        $userInfo = UserProc::getUserInfo($mem, $zoneid, $uid_from);
-        $userName = $userInfo->game->name;
-        $tOp->$uid_from = $ts . "_" . $userName;                            # 可以按照时间戳排序
-        return FriendProc::saveOps($mem, $uid, $zoneid, $tOp, $op);
-    }
-
-    /**
-     * 查询好友异步操作队列
-     * @param CRedisUtil $mem
-     * @param string $uid
-     * @param int $zoneid
-     * @param enum_Friend_op $op
-     * @return mixed
-     */
-    private static function getOps($mem, $uid, $zoneid, $op = 0) {
-        $ret = ObjectInit();
-        if ($op == enum_Friend_op::__default) {
-            $ret = $mem->hgetall(MemKey_User::FriendsOps_hash($zoneid, $uid));
-        } else {
-            $ret = $mem->hget(MemKey_User::FriendsOps_hash($zoneid, $uid), new enum_Friend_op($op));
-        }
-        if (is_null($ret)) {
-            $ret = ObjectInit();
-        }
-        return $ret;
-    }
-
-    /**
-     * 回写好友异步操作队列
-     * @param CRedisUtil $mem
-     * @param string $uid
-     * @param int $zoneid
-     * @param mixed $data
-     * @param int $op
-     */
-    private static function saveOps($mem, $uid, $zoneid, $data, $op) {
-        $enop = new enum_Friend_op($op);
-        if (!$enop->isValidValue($op)) {
-            return ErrCode::paras_err;
-        }
-
-        if ($op == enum_Friend_op::__default) {               # 全部数据
-            $mem->hmset(MemKey_User::FriendsOps_hash($zoneid, $uid), $data);
-        } else {
-            if (is_array($data) && count($data) == 0) {
-                $data = "{}";
-            }
-            $mem->hset(MemKey_User::FriendsOps_hash($zoneid, $uid), $enop, $data);
-        }
-        return ErrCode::ok;
-    }
-
+//        return Resp::ok($guildInfo);
+//    }
 //
-// // </editor-fold>
+//    /**
+//     * 查看好友简介
+//     * @param type $req
+//     */
+//    static function LookFriendInfo($req) {
+//        $friendId = $req->paras[0];                                             //好友id
+//        $mem = $req->mem;
+//        $sql = "select * from `tab_rolename` where userID = '$friendId'";
+//        $rows = daoInst()->query($sql)->fetchAll();
+//        my_Assert(count($rows) > 0, ErrCode::err_user_no);                      # 找不到玩家角色记录 
+//        $friendInfo = self::initfriendInfo($mem, $rows[0]['userID'], $rows[0]['zoneid']);
+//        my_Assert($friendInfo != null, ErrCode::err_user_no);                   # 好友数据初始化成功
+//        $friendInfo->fightPower = GuildProc::initFightTeamInfo($mem, $rows[0]['userID'], $rows[0]['zoneid']);
+//        return Resp::ok(array("friendInfo" => $friendInfo,));
+//    }
 //
-}
-
-class initfriendInfoModel extends Object_ext {
-
-    public $uid;
-    public $name;
-    public $level;
-    public $img;
-    public $imgBorderId;
-    public $guildName;
-    public $guildId;
-    public $cupScore;
-
-    function __construct($tag, $uid, $name, $level, $img, $imgBorderId, $guildName, $guildId, $cupScore) {
-        if (1 == func_num_args() && $tag) {                                     # 默认的Object初始化方法
-            parent::__construct($tag);
-        } else {
-            $this->uid = $uid;
-            $this->name = $name;
-            $this->level = $level;
-            $this->img = $img;
-            $this->imgBorderId = $imgBorderId;
-            $this->guildName = $guildName;
-            $this->guildId = $guildId;
-            $this->cupScore = $cupScore;
-        }
-    }
-
-}
+//    /**
+//     * 检查玩家的好友信息是否有未处理的
+//     * @param type $req
+//     */
+//    public static function CheckUnduckMessage($req) {
+//        $mem = $req->mem;
+//        $zoneid = $req->zoneid;
+//        $uid = $req->uid;
+//        $result = -1;
+//        // 别人的赠送列表
+//        $fgiftlist = self::getOps($mem, $uid, $zoneid, enum_Friend_op::gift);
+//        if (count((array) $fgiftlist) <= 0) {
+//            $result = 0;
+//        } else {
+//            foreach ($fgiftlist as $key => $value) {
+//                if (count((array) $value) <= 0) {
+//                    continue;
+//                } else {
+//                    $result = 1;
+//                    break;
+//                }
+//            }
+//        }
+//        //找别人发来的申请加好友的列表
+//        if ($result == 0) {
+//            $ret = FriendProc::getOps($req->mem, $req->uid, $req->zoneid, enum_Friend_op::apply);
+//            $result = (count((array) $ret) > 0) ? 1 : 0;
+//        }
+//        return Resp::ok(array('ret' => $result));
+//    }
+//
+//    /**
+//     * [6112] 核算好友的离线操作
+//     * @param Req $req
+//     */
+//    public static function Reload($req) {
+//        $mem = $req->mem;
+//        $uid = $req->uid;
+//        $zoneid = $req->zoneid;
+//
+//        // 刷新接受请求列表, 将已接受的好友添加到
+//        $allOps = self::getOps($mem, $uid, $zoneid);
+//        $op = new enum_Friend_op(enum_Friend_op::accepted);
+//        $ops = $allOps->$op;
+//        if (count($ops) > 0) {
+//            foreach ($ops as $u => $ts) {                                       # 立即将对方添加到好友列表
+//                self::_AddFriend($mem, $uid, $zoneid, $u);
+//            }
+//            $ops = "{}";
+//            $allOps->$op = $ops;
+//        }
+//
+//        // 刷新删除列表, 看谁和我解除了好友关系, 删掉他
+//        $op = new enum_Friend_op(enum_Friend_op::remove);
+//        $ops = $allOps->$op;
+//        if (count($ops) > 0) {
+//            foreach ($ops as $u => $ts) {
+//                self::_RemoveFriend($mem, $uid, $zoneid, $u);
+//            }
+//            $allOps->$op = "{}";
+//        }
+//        $g = glc();
+//
+//        self::filterOutDateRecords($allOps, #                                   # 清理过期的请求记录,
+//                new enum_Friend_op(enum_Friend_op::applied), $g->User_Friends_Apply_ExpireTs);
+//
+//        self::filterOutDateRecords($allOps, #                                   # 刷新别人发来的好友请求列表, 过期而没有处理的也删掉(莫名其妙的消失,玩家会不会不爽?要不要加上倒计时?).
+//                new enum_Friend_op(enum_Friend_op::apply), $g->User_Friends_Apply_ExpireTs);
+//
+//        self::saveOps($mem, $uid, $zoneid, $allOps, 0);                         # 回存数据
+//        // 清理过期的互动记录, 不清除, 一个好友最多保留3条记录
+//        // 更新好友数量
+//        return Resp::ok(array("ret" => "ok"));
+//    }
+//
+//    private static function filterOutDateRecords($allOps, $op, $outts) {
+//        $ops = $allOps->$op;
+//        if (count((array) $ops) > 0) {
+//            $ops = array_filter((array) $ops, function ($ts)use($outts) {
+//                return (intval($ts) + $outts) > now();
+//            });
+//            $allOps->$op = (is_null($ops) || 0 == count((array) $ops)) ? "{}" : $ops;
+//        }
+//    }
+//
+////
+//// <editor-fold defaultstate="collapsed" desc="  聊天/留言  ">
+//    //
+//
+//    /**
+//     * [6108]发送消息/留言
+//     * @param Req $req
+//     */
+//    public static function SendMessage($req) {
+//        // todo:检查是否好友
+//        $mem = $req->mem;
+//        $uid_from = $req->uid;
+//        $uid_to = $req->paras[0];
+//        $msg = $req->paras[1];
+//        if (strlen($msg) > self::MaxMessageLength) {
+//            $msg = substr($msg, 0, self::MaxMessageLength) . "...";
+//        }
+//        $key = MemKey_User::FriendsMsgQueue_hash($req->zoneid, $uid_to);
+//        $arr = $mem->hget($key, $uid_from);
+//        if (null == $arr) {
+//            $arr = ArrayInit();
+//        }
+//        $ts = now();
+//        array_push($arr, "{$msg}{$ts}");
+//        if (count($arr) > glc()->User_Friends_MessageCount_Max) {
+//            array_shift($arr);
+//        }
+//        $mem->hset($key, $uid_from, $arr);
+////
+//        $mts = isset($req->paras[2]) ? $req->paras[2] : 0;
+//        $newmsg = self::_GetNewMessage($mem, $req->zoneid, $uid_from, $uid_to, $mts);
+//        return Resp::ok(array("ret" => "ok", 'newmsg' => $newmsg));
+//    }
+//
+//    /**
+//     * [6109]拉取最新消息/留言
+//     *
+//     * @param Req $req
+//     */
+//    public static function GetNewMessage($req) {
+//        if (count($req->paras) < 2) {
+//            return Resp::err(ErrCode::parasnotenough_msg);
+//        }
+//        $uid_filter = $req->paras[0];
+//        $ts = $req->paras[1];
+//        $arr = self::_GetNewMessage($req->mem, $req->zoneid, $req->uid, $uid_filter, $ts);
+//
+//        return Resp::ok($arr);
+//    }
+//
+//    /**
+//     * 取留言消息
+//     * @param CredisUtil $mem
+//     * @param int $zoneid
+//     * @param string $uid
+//     * @param string $f_uid
+//     * @param ts $ts
+//     * @return asoc_array
+//     */
+//    private static function _GetNewMessage($mem, $zoneid, $uid, $f_uid, $ts) {
+//        $key = MemKey_User::FriendsMsgQueue_hash($zoneid, $uid);
+//        $arr = array($f_uid => $mem->hget($key, $f_uid));
+//        // 依据ts时间戳,剔除客户端不需要的消息,然后传送.
+//        foreach ($arr as &$msgq) {
+//            if (null == $msgq) { // 防御
+//                continue;
+//            }
+//            $msgq = array_filter($msgq, function($msg) use($ts) {
+//                return $ts < substr($msg, -10);  // 时间戳10位
+//            });
+//        }
+//        return $arr;
+//    }
+//
+//    //
+//    //
+//// </editor-fold>
+////
+//// <editor-fold defaultstate="collapsed" desc="  待定  ">
+//    //
+//
+//    /**
+//     * 设置默认同意好友请求
+//     * @param Req $req
+//     */
+//    public static function SetAutoAccept($req) {
+//        
+//    }
+//
+//// </editor-fold>
+////
+//// <editor-fold defaultstate="collapsed" desc="  好友操作  ">
+////
+//
+//    /**
+//     * [6105] 拉取好友请求列表
+//     * @param Req $req
+//     */
+//    public static function GetApplyList($req) {
+//        $ret = FriendProc::getOps($req->mem, $req->uid, $req->zoneid, enum_Friend_op::apply);
+//        return Resp::ok(array("ret" => (count((array) $ret) > 0) ? $ret : array()));
+//    }
+//
+//    /**
+//     * [6101]添加好友
+//     * @param Req $req
+//     */
+//    public static function ApplyToAddNewFriend($req) {   // 取目标玩家的ops列表插入请求
+//        $mem = $req->mem;
+//        $uid_to = $req->paras[0];
+//        $uid_from = $req->uid;
+//        if ($uid_from == $uid_to) {
+//            return Resp::err(ErrCode::paras_err, "添加的好友ID非法!");
+//        }
+//
+//        $err = self::AddOp($mem, $req->zoneid, $uid_to, enum_Friend_op::apply, $uid_from);
+//        if (ErrCode::ok != $err) {
+//            return Resp::err($err);
+//        }
+//        $err = self::AddOp($mem, $req->zoneid, $req->uid, enum_Friend_op::applied, $uid_to);
+//        if (ErrCode::ok != $err) {
+//            return Resp::err($err);
+//        }
+//        return Resp::ok(array("ret" => "ok"));
+//    }
+//
+//    /**
+//     * [6102]接受好友请求
+//     * @param Req $req
+//     */
+//    public static function Accept($req) {  // 将对方立即放到自己的好友列表中, 并给对方发送接受的op, 删除请求记录
+//        $mem = $req->mem;
+//        $zoneid = $req->zoneid;
+//        $uid_my = $req->uid;
+//        $uid_arr = explode(',', $req->paras[0]);
+//        foreach ($uid_arr as $uid_to) {
+//            $myOp = self::getOps($mem, $req->uid, $zoneid, enum_Friend_op::apply); // 自己的请求列表
+//            unset($myOp->$uid_to);     // 删除请求记录
+//            self::saveOps($mem, $req->uid, $zoneid, $myOp, enum_Friend_op::apply); // 更新自己的请求列表
+//
+//            $err = self::AddOp($mem, $zoneid, $uid_to, enum_Friend_op::accepted, $uid_my); // 向对方的已接受列表中添加记录
+//            if ($err != ErrCode::ok) { // 出错
+//                return Resp::err($err);
+//            }
+//            self::_AddFriend($mem, $uid_my, $zoneid, $uid_to);
+////            $mem->sadd(MemKey_User::FriendsList_set($zoneid, $req->uid), $uid_to);      // 立即将对方添加到好友列表
+//        }
+//
+//        return Resp::ok(array("ret" => "ok"));
+//    }
+//
+//    /**
+//     * [6103]拒接好友请求
+//     * @param Req $req
+//     */
+//    public static function Deny($req) {   // 直接 删除请求记录, 不通知对方了
+//        $mem = $req->mem;
+//        $zoneid = $req->zoneid;
+//        $uid_my = $req->uid;
+//        $uid_to = $req->paras[0];
+//
+//        // 从自己的列表中删除就行了,不用通知对方
+//        $myOp = self::getOps($mem, $uid_my, $zoneid, enum_Friend_op::apply); // 自己的请求列表
+//        unset($myOp->$uid_to);
+//        self::saveOps($mem, $uid_my, $zoneid, $myOp, enum_Friend_op::apply); // 更新自己的请求列表
+//
+//        return Resp::ok(array("ret" => "ok"));
+//    }
+//
+//    /**
+//     * [6104]删除好友
+//     * @param Req $req
+//     */
+//    public static function Remove($req) {// 将对方立即从自己的好友列表中删除, 并给对方发送remove的op
+//        $mem = $req->mem;
+//        $zoneid = $req->zoneid;
+//        $uid_to = $req->paras[0];  // 删除谁
+//        $uid_my = $req->uid;
+//
+//        $tOp = self::getOps($mem, $uid_to, $zoneid, enum_Friend_op::remove); // 对方的删除列表
+//        $ts = now();
+//        $userInfo_my = UserProc::getUserInfo($mem, $zoneid, $uid_my);
+//        $name = $userInfo_my->game->name;
+//        $tOp->$uid_my = $ts . "_" . $name;
+//        self::saveOps($mem, $uid_to, $zoneid, $tOp, enum_Friend_op::remove); // 更新对方的删除列表
+//        self::_RemoveFriend($mem, $uid_my, $zoneid, $uid_to);
+//
+//        return Resp::ok(array("ret" => "ok"));
+//    }
+//
+////
+//// </editor-fold>
+////
+//// <editor-fold defaultstate="collapsed" desc="  搜索  ">
+//
+//    /**
+//     * [6110]搜索好友
+//     * @param Req $req
+//     */
+//    static function SearchFriend($req) {
+//        //客户端参数解析
+//        if (count($req->paras) <= 1) { // 参数非法
+//            return Resp::err(ErrCode::parasnotenough_msg);
+//        }
+//        $zoneid = $req->zoneid;
+//        $filter = $req->paras[0];
+//        $start = 0;
+//        if (count($req->paras) > 1) {
+//            $start = $req->paras[1];
+//        }
+//        $max = 8; // 每次查询返回的数据条目数量
+//        $sql = "select * from `tab_rolename` where (`userID`='$filter' OR `roleName` like '%$filter%') and zoneid = $zoneid limit $start, $max ;";
+//        $paydb = CPayInit();
+//        $rows = $paydb->fetch_array($sql);
+//        $ret = ArrayInit();
+//        foreach ($rows as $row) {
+//            $uid = $row['userID'];
+//            $zone_all = $row['zoneid'];
+//            if ($uid == $req->uid) {
+//                continue;
+//            }
+//            $friendInfo = self::initfriendInfo($req->mem, $uid, $zone_all);
+//            if ($friendInfo != null) {
+//                $ret[] = $friendInfo;
+//            }
+//        }
+//        $ops = self::getOps($req->mem, $req->uid, $req->zoneid, enum_Friend_op::applied);
+//        return Resp::ok(array('fList' => $ret, 'applied' => $ops));
+//    }
+//
+//    static function initfriendInfo($mem, $uid, $zoneid) {
+//        $userInfo = UserProc::getUserInfo($mem, $zoneid, $uid);
+//        if ($userInfo == null) {
+//            return null;
+//        }
+//        $userGuildInfo = GuildProc::getMemUserGuildInfo($mem, $uid, $zoneid);
+//        if ($userGuildInfo == null) {
+//            $userGuildInfo = ObjectInit();
+//            $userGuildInfo->guildName = "";
+//            $userGuildInfo->guildId = 0;
+//        }
+//        $key_cur = MemKey_GameRun::Game_PVPScoreByZone_zset($zoneid);
+//        $score = $mem->zscore($key_cur, $uid);
+//        $userGuildInfo->cupScore = $score == null ? 0 : $score;
+//        $friendObj = new initfriendInfoModel(null, $uid, $userInfo->game->name, $userInfo->game->level, $userInfo->game->img, #
+//                $userInfo->game->imgBorderId, $userGuildInfo->guildName, $userGuildInfo->guildId, $userGuildInfo->cupScore);
+//        return $friendObj;
+//    }
+//
+//    /**
+//     * [6111]添加好友界面获取一批推荐好友列表
+//     * @param Req $req
+//     */
+//    static function GetSuggestList($req) {
+//        //客户端参数解析
+//        if (count($req->paras) < 1) { // 参数非法
+//            return Resp::err(ErrCode::parasnotenough_msg);
+//        }
+//        $zoneid = $req->zoneid;
+//        $start = $req->paras[0]; // 第几页
+//        $max = 8; // 每次查询返回的数据条目数量
+//        $sql = "select * from `tab_rolename` where `zoneid`=$zoneid order by ts desc limit $start, $max ;";
+//        $paydb = CPayInit();
+//        $rows = $paydb->fetch_array($sql);
+//        $arr = ArrayInit();
+//        foreach ($rows as $row) {
+//            if ($row['userID'] == $req->uid) {
+//                continue;
+//            }
+//            unset($row["tid"]);
+//            unset($row["zoneid"]);
+//
+//            $arr[] = $row['userID'];
+//        }
+//        $applidops = self::getOps($req->mem, $req->uid, $req->zoneid, enum_Friend_op::applied);
+//        $ret = array('fList' => array_unique($arr), 'applied' => $applidops);
+//        return Resp::ok($ret);
+//    }
+//
+//// </editor-fold>
+////
+//// <editor-fold defaultstate="collapsed" desc="  好友列表  ">
+//
+//    /**
+//     * [6106]获取好友ID列表
+//     * @param Req $req
+//     * @return int
+//     */
+//    static function getAppFriends($req) {
+//        self::Reload($req);
+//        $mem = $req->mem;
+//        $zoneid = $req->zoneid;
+//        //客户端参数解析
+//        $friendIds = self::_GetFriendList($mem, $req->uid, $zoneid); // 取好友列表
+//
+//        $userArr = ArrayInit();
+//        foreach ($friendIds as $index => $uid) {
+//            $friendInfo = self::initfriendInfo($mem, $uid, $zoneid);
+//            if ($friendInfo == null) {
+//                continue;
+//            }
+//            $userArr[] = $friendInfo;
+//        }
+//        //$mygiftops = self::getOps($mem, $req->uid, $req->zoneid, enum_Friend_op::giftrecord);
+//        $resp = Resp::ok(array(
+//                    #"friends" => $friendIds,
+//                    'userGuild' => $userArr,
+//        ));
+//        return $resp;
+//    }
+//
+//    /**
+//     * 查找好友数量
+//     * @param Req $req
+//     */
+//    public static function getCurrentFriendsCount($req) {
+//        return $req->mem->scard(MemKey_User::FriendsList_set($req->zoneid, $req->uid));
+//    }
+//
+//    /**
+//     * [6107] 获取好友信息列表
+//     * @param Req $req
+//     * @return type
+//     */
+//    static function getAppFriendInfos($req) {
+//        $mem = $req->mem;
+//        //客户端参数解析
+//        $zoneid = $req->zoneid;
+//        $fuids = explode(',', $req->paras[0]);        // 逗号分割uid字符串
+//        $max = 8; # 一次最多取八个数据
+//        $n = count($fuids);
+////        var_dump($fuids);
+//        if ($n > 0 && $n <= $max) {
+//            $fuidkeys = array_map(function ($i) use($zoneid) {
+//                return MemKey_User::Info($zoneid, $i);
+//            }, $fuids);
+//            $arr = $mem->getMulti($fuidkeys);
+//            $friendInfos = ArrayInit();
+//            $n = 0;
+//            foreach ($arr as $userInfo) {
+//                isEditor() && $userInfo = new UserGameModel;
+//                isEditor() && $shareInfo = new UserHeroModel;
+//                $uid = $fuids[$n++];
+//                if (!$userInfo                                  # 玩家数据不为空
+//                        || !property_exists($userInfo, 'heros') # 存在heros数据
+//                        || !$userInfo->heros) {                 # heros数据不为空
+//                    continue;
+//                }
+//                $sharedHeroId = $userInfo->heros->firendSupportHeroUID;
+//                if ($sharedHeroId) {
+//                    $shareInfo = $userInfo->heros->collectHeros->$sharedHeroId;
+//                } else { // todo: 暂定如果没有设置共享英雄,默认取集合中第一个英雄, 征询策划是否修订规则
+//                    $coll = $userInfo->heros->collectHeros;
+//                    $keys = array_keys((array) $coll);
+//                    if (count($keys) <= 0) {
+//                        continue;
+//                    }
+//                    $sharedHeroId = $keys[0];
+//                    $shareInfo = $userInfo->heros->collectHeros->$sharedHeroId;
+//                }
+//                // 额外将英雄的装备数据替换为实例数据
+//                self::getArmor($userInfo, $shareInfo, 'weapon');
+//                self::getArmor($userInfo, $shareInfo, 'armor');
+//                self::getArmor($userInfo, $shareInfo, 'ring');
+//                $friendInfos[$uid] = array('sharedHero' => $shareInfo,
+//                    'lastLoginTs' => isset($userInfo->lastLogin) ? $userInfo->lastLogin : 0,
+//                    'level' => $userInfo->level,
+//                    'nickname' => $userInfo->name
+//                );
+//            }
+//            if (count($friendInfos) <= 0) {
+//                $friendInfos = null;
+//            }
+//            $resp = Resp::ok(array('ret' => $friendInfos));
+//        } else {
+//            $resp = Resp::err(ErrCode::paras_err);
+//        }
+//        return $resp;
+//    }
+//
+//    static function getArmor($userInfo, $hero, $armor) {
+//        $armorid = $hero->equip->$armor->itemuid;
+//
+//        if ($armorid > 0 && isset($userInfo->store->equipment->$armorid)) {
+//            $hero->equip->$armor = $userInfo->store->equipment->$armorid;
+//        } else {
+//            $hero->equip->$armor = null;
+//        }
+//    }
+//
+//// </editor-fold>
+////
+//// <editor-fold defaultstate="collapsed" desc="  示好  ">
+////
+//
+//    /**
+//     * [6115]向好友发送礼物(示好)
+//     * @param Req $req
+//     */
+//    static function sendGiftToAppFriend($req) {
+//        $mem = $req->mem;
+//        $zoneid = $req->zoneid;
+//        $uid = $req->uid;
+//        //客户端参数解析
+//        $fuids = explode(',', $req->paras[0]);  // 逗号分割的uid数组
+////        $pr = $req->paras[1];   // other参数 preserved
+//        $n = count($fuids);
+//        if ($n <= 0) {
+//            return Resp::ok(array("ret" => 0));
+//        }
+//        $mygiftrecord = self::getOps($mem, $uid, $zoneid, enum_Friend_op::giftrecord);
+//        $m = 0;
+//        for ($i = 0; $i < $n; $i++) {
+//            $fid = $fuids[$i];
+//            $tsDay = tsDay();
+//            if (property_exists($mygiftrecord, $fid) // 判断对方是否能够领取礼物(当天已经发送过,则不再发送)
+//                    && $mygiftrecord->$fid >= $tsDay) {
+//                continue;
+//            }
+//            $mygiftrecord->$fid = $tsDay;  # 更新发送记录
+//            $fgiftinfo = self::getOps($mem, $fid, $zoneid, enum_Friend_op::gift);
+//            if (null == $fgiftinfo) { // 防御
+//                $fgiftinfo = ObjectInit(); // 没找到好友数据, 则创建
+//            }
+//            // 给对方身上插入操作记录
+//            if (!isset($fgiftinfo->$uid) or ! is_array($fgiftinfo->$uid)) {//防御
+//                $fgiftinfo->$uid = ArrayInit();
+//            }
+//            $arr = $fgiftinfo->$uid;
+//            $arr[] = tsDay();
+//            if (count($arr) > 3) { // 最多保留3条记录
+//                sort($arr);
+//                array_shift($arr);
+//            }
+//            $fgiftinfo->$uid = $arr; // 更新下
+//            self::saveOps($mem, $fid, $zoneid, $fgiftinfo, enum_Friend_op::gift);
+//
+//            $m++;
+//        }
+//        // 回存数据
+//        self::saveOps($mem, $uid, $zoneid, $mygiftrecord, enum_Friend_op::giftrecord);
+//        // 其他检查比如任务、成就系统
+//        //   ...
+//        // 返回结果
+//        return Resp::ok(array("ret" => $m));
+//    }
+//
+//    /**
+//     * [6113]查询游戏中哪些好友给我发送了礼物的列表
+//     * @param Req $req
+//     */
+//    static function getAppFriendGiftList($req) {
+//        $mem = $req->mem;
+//        $zoneid = $req->zoneid;
+//        $uid = $req->uid;
+//        // 别人的赠送列表
+//        $fgiftlist = self::getOps($mem, $uid, $zoneid, enum_Friend_op::gift);
+//        if (count((array) $fgiftlist) <= 0) {
+//            $fgiftlist = NULL;
+//        }
+//        return Resp::ok(array('ret' => $fgiftlist));
+//    }
+//
+//    /**
+//     * [6114]领取来自好友的礼物[并回赠]
+//     * @param Req $req
+//     */
+//    static function getAppFriendGift($req) {
+//        $mem = $req->mem;
+//        $zoneid = $req->zoneid;
+//        $uid = $req->uid;
+//        //客户端参数解析
+//        $fuids = explode(',', $req->paras[0]);  // 逗号分割的uidtsday数组
+//        $bSendback = true;              // 是否回赠
+//
+//        $arr = array();
+//        array_map(function($f)use(&$arr) {
+//            $arr[substr($f, -5)] = substr($f, 0, -5); // tsday()占5个字符
+//        }, $fuids);
+//        $fgiftlist = self::getOps($mem, $uid, $zoneid, enum_Friend_op::gift);
+//
+//        $recieved = 0;
+//        foreach ($arr as $ts => $fid) {
+//            if (isset($fgiftlist->$fid) && in_array($ts, $fgiftlist->$fid)) {
+//                StlUtil::arrayRemove($fgiftlist->$fid, $ts);
+//                $recieved++;
+//            }
+//        }
+//        $req->userInfo->game->friendPoint += $recieved;
+//        self::saveOps($mem, $uid, $zoneid, $fgiftlist, enum_Friend_op::gift);
+//        UserProc::updateUserInfo();
+//        if ($bSendback && $recieved > 0) {
+//            $uids_send = array_unique(array_values($arr));
+//            $req->paras[0] = implode(',', $uids_send);
+////            var_dump($uids_send);
+//            self::sendGiftToAppFriend($req);
+//        }
+//        // 当天领取好友礼物有没有上限? 比如100个心.
+//        // 检查是否存在对应的礼物记录,
+//        // 发送礼物
+//        // 删除礼物记录
+//        // 回写数据
+//        // 返回值
+//
+//        return Resp::ok(array("ret" => $recieved));
+//    }
+//
+//    /**
+//     * 玩家初始化
+//     * @param Req $req
+//     */
+//    static function Init($req) {
+//        $mem = $req->mem;
+//        $z = $req->zoneid;
+//        $uid = $req->uid;
+////        $mem->sadd(MemKey_User::FriendsList_set($z, $uid), "");
+//        $mem->hset(MemKey_User::FriendsMsgQueue_hash($z, $uid), "sys", "");
+//        $mem->hmset(MemKey_User::FriendsOps_hash($z, $uid), array("apply" => "{}",
+//            "applied" => "{}",
+//            "gift" => "{}",
+//            "accepted" => "{}",
+//            "remove" => "{}",
+//            'giftrecord' => "{}"));
+//    }
+//
+////
+//// </editor-fold>
+////
+////-------------以下是辅助方法-----------------
+////
+//
+//    /**
+//     * 验证是否好友
+//     * @param Req $req
+//     */
+//    public static function isFriendship($zoneid, $myUid, $fUid) {
+//        return gMem()->sismember(MemKey_User::FriendsList_set($zoneid, $myUid), $fUid);
+//    }
+//
+//    /**
+//     * 添加fuid到好友列表
+//     */
+//    private static function _AddFriend($mem, $uid, $zoneid, $fuid) {
+//        $mem->sadd(MemKey_User::FriendsList_set($zoneid, $uid), $fuid);
+//    }
+//
+//    /**
+//     * 从好友列表中删除fuid
+//     */
+//    private static function _RemoveFriend($mem, $uid, $zoneid, $fuid) {
+//        $mem->sremove(MemKey_User::FriendsList_set($zoneid, $uid), $fuid);
+//    }
+//
+//    private static function _GetFriendList($mem, $uid, $zoneid) {
+//        $arr = $mem->smembers(MemKey_User::FriendsList_set($zoneid, $uid));
+//        if (!$arr) {                                                            # 数据为空
+//            $arr = ArrayInit();
+//        }
+//        $friendIds = array_values(array_filter($arr, function ($a) {
+//                    return $a != "";
+//                }));
+//        return $friendIds;
+//    }
+//
+////
+//// <editor-fold defaultstate="collapsed" desc="  读写玩家好友数据  ">
+//
+//    /**
+//     * 添加操作
+//     * @param enum_Friend_op $op
+//     * @param Req $req
+//     */
+//    private static function AddOp($mem, $zoneid, $uid, $op, $uid_from) {
+//        $enop = new enum_Friend_op($op);
+//        if (!$enop->isValidValue($op)) {
+//            return ErrCode::paras_err;
+//        }
+//        $ts = now();
+//        $tOp = FriendProc::getOps($mem, $uid, $zoneid, $op);
+//
+//        $userInfo = UserProc::getUserInfo($mem, $zoneid, $uid_from);
+//        $userName = $userInfo->game->name;
+//        $tOp->$uid_from = $ts . "_" . $userName;                            # 可以按照时间戳排序
+//        return FriendProc::saveOps($mem, $uid, $zoneid, $tOp, $op);
+//    }
+//
+//    /**
+//     * 查询好友异步操作队列
+//     * @param CRedisUtil $mem
+//     * @param string $uid
+//     * @param int $zoneid
+//     * @param enum_Friend_op $op
+//     * @return mixed
+//     */
+//    private static function getOps($mem, $uid, $zoneid, $op = 0) {
+//        $ret = ObjectInit();
+//        if ($op == enum_Friend_op::__default) {
+//            $ret = $mem->hgetall(MemKey_User::FriendsOps_hash($zoneid, $uid));
+//        } else {
+//            $ret = $mem->hget(MemKey_User::FriendsOps_hash($zoneid, $uid), new enum_Friend_op($op));
+//        }
+//        if (is_null($ret)) {
+//            $ret = ObjectInit();
+//        }
+//        return $ret;
+//    }
+//
+//    /**
+//     * 回写好友异步操作队列
+//     * @param CRedisUtil $mem
+//     * @param string $uid
+//     * @param int $zoneid
+//     * @param mixed $data
+//     * @param int $op
+//     */
+//    private static function saveOps($mem, $uid, $zoneid, $data, $op) {
+//        $enop = new enum_Friend_op($op);
+//        if (!$enop->isValidValue($op)) {
+//            return ErrCode::paras_err;
+//        }
+//
+//        if ($op == enum_Friend_op::__default) {               # 全部数据
+//            $mem->hmset(MemKey_User::FriendsOps_hash($zoneid, $uid), $data);
+//        } else {
+//            if (is_array($data) && count($data) == 0) {
+//                $data = "{}";
+//            }
+//            $mem->hset(MemKey_User::FriendsOps_hash($zoneid, $uid), $enop, $data);
+//        }
+//        return ErrCode::ok;
+//    }
+//
+////
+//// // </editor-fold>
+////
+//}
+//
+//class initfriendInfoModel extends Object_ext {
+//
+//    public $uid;
+//    public $name;
+//    public $level;
+//    public $img;
+//    public $imgBorderId;
+//    public $guildName;
+//    public $guildId;
+//    public $cupScore;
+//
+//    function __construct($tag, $uid, $name, $level, $img, $imgBorderId, $guildName, $guildId, $cupScore) {
+//        if (1 == func_num_args() && $tag) {                                     # 默认的Object初始化方法
+//            parent::__construct($tag);
+//        } else {
+//            $this->uid = $uid;
+//            $this->name = $name;
+//            $this->level = $level;
+//            $this->img = $img;
+//            $this->imgBorderId = $imgBorderId;
+//            $this->guildName = $guildName;
+//            $this->guildId = $guildId;
+//            $this->cupScore = $cupScore;
+//        }
+//    }
+//
+//}

+ 3 - 36
Gameserver/Amfphp/process/HeroProc.php

@@ -946,40 +946,6 @@ class HeroProc {
 
 // <editor-fold defaultstate="collapsed" desc="辅助方法">
 
-    /**
-     * 尝试图鉴整合
-     * @param CredisUtil $mem
-     * @param HeroManualModel $manual
-     * @param type $hero
-     */
-    static function tryNewManual(&$manual, $hero) {
-        $godpetId = $hero->typeId;
-        $level = 0;
-
-        self:: changeManual($manual, $godpetId, $level);
-    }
-
-    /**
-     * 更改图鉴数据
-     * @global int $AchievementIsManualExpAddedGlobal
-
-     * @param type $manual
-     * @param type $heroModelId
-     * @param type $level
-     */
-    static function changeManual(&$manual, $heroModelId, $level) {
-        if (!property_exists($manual, "godpetDic")) {
-            $manual->godpetDic = ObjectInit();
-        }
-        $godpetDic = $manual->godpetDic;
-
-        if (!CommUtil::isPropertyExists($godpetDic, $heroModelId)) {
-            $godpetDic->$heroModelId = array(0);
-        } else {
-            
-        }
-    }
-
     /**
      * 获得一个英雄, 并且给他指定星级
      * @param Req $req
@@ -1156,11 +1122,12 @@ class HeroProc {
         $fp = 0;                                                                # 返回值
         if ($team) {
             foreach ($team->heros as $hid) {
-//                isEditor() and $hero = new GameHeroModel();
                 if ($hid) {
                     $hero = $heros->collectHeros->$hid;
                     if ($hero) {
-                        $fp += self::calcHeroFightPower($hero);
+//                        $fp += self::calcHeroFightPower($hero);
+                        $h = new UserHeroModel($hero);
+                        $fp += $h->GetPower();
                     }
                 }
             }

+ 3 - 3
Gameserver/Amfphp/process/StoreProc.php

@@ -80,9 +80,9 @@ class StoreProc {
         }                                                                       # end 提取参数
         $typeId = substr($itemId, 0, 3);                                        # 道具分类前缀
         switch ($typeId) {                                                      # 使用道具()
-            case '701':                                                         # 宝箱
-                $resp = Boxes::OpenBox($req);                                   # 调用开宝箱功能
-                break;
+//            case '701':                                                         # 宝箱
+//                $resp = Boxes::OpenBox($req);                                   # 调用开宝箱功能
+//        break;
             default :                                                           # 其他
                 Err(ErrCode::store_itemcantuse);
                 break;

+ 1 - 1
Gameserver/Amfphp/process/UserProc.php

@@ -452,7 +452,7 @@ class UserProc {
         UserProc::checkContidays($req, 1);                                      # 每日状态检查
 //        UserProc::fetchFromInteract($mem, $req);  # 从interact拉取数据,Ps.初始化的过程应该还拉取不到什么有效数据
         UserProc::updateUserInfo();                                         # 回存用户数据
-        FriendProc::Init($req);
+//        FriendProc::Init($req);
 //        StatProc::                                                            ...
         gMem()->increment(MemKey_GameRun::Stat_UserCountByZone_int($req->zoneid));   # 增加玩家数量计数
 //        GoalsDailyProc::dealDailyLogin($mem, $req, $resp);                   # 每日登录任务