Преглед на файлове

fixed: 关卡掉落时, 道具/武器/言灵进入背包的操作未及时更新逻辑.

gwang преди 5 години
родител
ревизия
26d21dbc22
променени са 4 файла, в които са добавени 114 реда и са изтрити 146 реда
  1. 2 2
      Gameserver/Amfphp/process/FightProc/SweepGatesProc.php
  2. 85 140
      Gameserver/Amfphp/process/StoreProc.php
  3. 1 1
      Gameserver/Amfphp/process/UserProc.php
  4. 26 3
      Gameserver/Amfphp/test.php

+ 2 - 2
Gameserver/Amfphp/process/FightProc/SweepGatesProc.php

@@ -224,7 +224,7 @@ class SweepGatesProc {
         $rewardArr = array();                                                   # 统计所获奖励物品
         $rewardArr = array_merge($rewardArr, self::SetRewards($req, $rwdstr));  # 通关奖励
 
-        UserGameModel::Add_Gold($req->userInfo->game, $gold);        # 发金币
+        UserGameModel::Add_Gold($req->userInfo->game, $gold);                   # 发金币
         UserGameModel::Add_Exp($req->userInfo->game, $exp);                     # 给玩家(指挥官)增加经验
 
         UserProc::updateUserInfo();                                         # 回写玩家数据.
@@ -567,7 +567,7 @@ class SweepGatesProc {
                 StoreProc::PutEquipInStore($itemId, $req);
                 break;
             case "304":                                                         // 宝石的获取
-                StoreProc:: PutOverlyingItemInStore($itemId, $itemNum, $req);
+                StoreProc:: PutOverlyingItemInStore($itemId, $itemNum);
                 break;
             case "399":
                 if ($itemId == "399002") {                                      // 金币的获取

+ 85 - 140
Gameserver/Amfphp/process/StoreProc.php

@@ -669,77 +669,36 @@ class StoreProc {
             $val = explode(",", $value);
             $itemId = $val[0];
             $num = $val[1]; //数量
-            $str1 = substr($itemId, 0, 3);  # prefix
-            switch ($str1) {
-                // 10x 怪物卡或者英雄卡牌获取
-                case "101":
-                case "202":
-                case "201":
-//                    if (1 == $src && $user->heros->maxCollectCount <= StoreProc::CheckHeroNum($req)) {
-//                        # 战斗模块获得的英雄,超过上限丢弃
-//                        echo "英雄满了."; # 满了如何处理? 直接丢弃吗? 是的, ok. gwang 2017年4月22日 16:49:58 问过
-//                    } else {
-//                        HeroProc::AddHeroTFromStore($req, $itemId);
-//                    }
+            $smItem = GameConfig::item_base_getItem($itemId);                   # 道具mo
+            switch ($smItem->subType) {                                         # 根据类型分别添加到容器中
+                case 1:                                                         # 金币
+                    UserGameModel::Add_Gold($user, $num);
                     break;
-                // 30x 装备物品的获取.
-                case "301":
-                case "302":
-                case "303":
-                    if (StoreProc::GetItemMaxNum($req) > StoreProc::CheckItemNum($req)) {
-                        StoreProc::PutEquipInStore($itemId, $req);
-                    }
+                case 2:                                                         # 钻石
+                    UserGameModel::Add_Cash($user, $num);
                     break;
-                //宝石的获取 +  抽奖券+经验书
-                case "304":
-                case "305":
-                case "307":
-                    if (StoreProc::GetItemMaxNum($req) > StoreProc::CheckItemNum($req)) {
-                        StoreProc:: PutOverlyingItemInStore($itemId, $num, $req);
-                    }
+                case 3:                                                         # 体力       
+                    UserGameModel::Add_tili($req, $num);
                     break;
-//              // 31x 碎片
-                case "310":                              # 英雄碎片
-                case "311":                              # 小怪碎片
-                case "312":                              # boss碎片
-                case "313":                              # 装备碎片
-                case "314":                              # 装备碎片
-                case "315":                              # 装备碎片\
-                    if (StoreProc::GetItemMaxNum($req) > StoreProc::CheckItemNum($req)) {
-                        StoreProc::addSegmentIntoStore($req->userInfo->game->store, $itemId, $num);
-                    }
+                case 4:                                                         # 友情值
+                    UserGameModel::Add_FriendPoint($user, $num);
                     break;
-                case "701":                              # 宝箱
-                case "702":
-                case "703":
-                case "704":
-
-                    StoreProc::putBoxexInStore($req->userInfo->game->store, $itemId, $num);
-
+                case 101:                                                       # 武器 
+                    StoreProc::PutEquipInStore($itemId, $req);
                     break;
-                // 游戏内货币的获取
-                case "399":
-                    switch ($itemId) {
-                        case META_CASH_ITEMID:            # 钻石
-                            UserGameModel::Add_Cash($req->userInfo->game, $num);
-                            break;
-                        case META_GOLD_ITEMID:            # 金币
-                            UserGameModel::Add_Gold($req->userInfo->game, $num);
-                            break;
-                        case META_tili_ITEMID:            # 体力
-                            UserGameModel::Add_tili($req, $num);
-                            break;
-                        case META_FriendShipPoit_ItemId:  # 友情
-                            UserGameModel::Add_FriendPoint($req->userInfo->game, $num);
-                            break;
-                        default :
-                    }
+                case 401:                                                       # 言灵
+                    StoreProc::PutYanLingInStore($itemId, $req);
                     break;
-                ////熔炼元素的获取
-                case "388":
-//                    StoreProc::PutElementInStore($itemId, $num, $req);
+                case 201:                                                       # 碎片
+                    StoreProc::PutOverlyingItemInStore($itemId, $num);
                     break;
-                default:
+                case 311:                                                       # 基因(经验丹)
+                    StoreProc::PutOverlyingItemInStore($itemId, $num);
+                    break;
+                case 341:                                                       # 战场中掉落,不会进入包裹
+                case 342:
+                case 343:
+                    Err(ErrCode::err_innerfault, "落入包裹时,出现了非法物品");
                     break;
             }
         }
@@ -758,9 +717,9 @@ class StoreProc {
         if ($itemType < 4) {
             StoreProc::PutEquipInStore($itemId, $req);
         } else if ($itemType == 4) {
-            StoreProc:: PutOverlyingItemInStore($itemId, $num, $req);
+            StoreProc:: PutOverlyingItemInStore($itemId, $num);
         } else if ($itemType == 10) {
-            StoreProc:: PutOverlyingItemInStore($itemId, $num, $req); ///准备添加其他
+            StoreProc:: PutOverlyingItemInStore($itemId, $num); ///准备添加其他
         }
 
         //  更新数据库数据
@@ -790,17 +749,35 @@ class StoreProc {
 //        SystemProc::GetEquip($req->zoneid, $req->userInfo->game, $itemId);      # 添加获得装备的消息
     }
 
+    /**
+     * 将言灵放入背包
+     * @param type $itemId
+     * @param Req $req
+     */
+    static function PutYanLingInStore($itemId, &$req) {
+        $privateState = $req->userInfo->game->privateState;
+        if (!CommUtil::isPropertyExists($privateState, "currentId")) {          // 如果仓库中已经有这种元素,则其数目+1
+            $req->userInfo->game->privateState->currentId = 1;
+        }
+        $cid = $req->userInfo->game->privateState->currentId++;
+        $equip = ObjectInit();
+        $equip->typeId = $itemId;
+        $req->userInfo->game->store->yanling->$cid = $equip;
+        return $cid;
+//        SystemProc::GetEquip($req->zoneid, $req->userInfo->game, $itemId);      # 添加获得装备的消息
+    }
+
     /**
      * 将可叠加物品放入背包
      * @param type $itemId
      * @param UserGameModel $game
      */
-    static function PutOverlyingItemInStore($itemId, $num, &$req) {
-        //  $game->userInfo->game;
-        if (CommUtil::isPropertyExists($req->userInfo->game->store->items, $itemId)) {// 如果仓库中已经有这种元素,则其数目+1
-            $req->userInfo->game->store->items->$itemId += $num;
-        } else {// 如果仓库中没有这种元素,则其数目置1
-            $req->userInfo->game->store->items->$itemId = $num;
+    static function PutOverlyingItemInStore($itemId, $num) {
+        $items = req()->userInfo->game->store->items;                           # dic: itemid=>number
+        if (CommUtil::isPropertyExists($items, $itemId)) {                      # 如果仓库中已经有这种元素,则其数目+=num
+            $items->$itemId += $num;
+        } else {                                                                # 如果仓库中没有这种元素,则其数目置为num
+            $items->$itemId = $num;
         }
     }
 
@@ -811,6 +788,7 @@ class StoreProc {
      * @return type
      */
     static function addSeprateItem($itemModel, $req) {
+        Err(ErrCode::err_method_obsoleted, "未更新包裹操作");
 //        var_dump($itemModel);
         $user = $req->userInfo->game;
         $store = $req->userInfo->game->store;
@@ -932,9 +910,8 @@ class StoreProc {
         }
         $collectHeros->$herouid->equip->weapon->itemuid = 0;                    # 卸下
 
-        UserProc::updateUserInfo();                                         # 回写数据
-        $ret = array('resp' => "succeed!");
-        $resp = Resp::ok($ret);                                                 // 返回 
+        UserProc::updateUserInfo();                                             # 回写数据
+        $resp = Resp::ok(array('resp' => "succeed!"));                          // 返回 
 //        StoreProc::CheckItemNum($req);
         return $resp;
     }
@@ -945,28 +922,17 @@ class StoreProc {
      * @return type
      */
     static function WearEquipToHero($req) {
+        list($itemtype, $equipuid, $herouid) = $req->paras;                     # 提取参数: 装备类型, 装备的UID, 英雄的UID  
         $user = $req->userInfo->game;                                           # user引用
-        list($itemtype, $equipuid, $herouid) = $req->paras;                     # 提取参数: 装备类型, 装备的UID, 英雄的UID 
-
-
-        if (!CommUtil::isPropertyExists($user->store->equipment, $equipuid)) {  # 检测是否存在该装备
-            Err(ErrCode::store_itemno_err);
-        }
+        my_Assert(CommUtil::isPropertyExists($user->store->equipment, $equipuid) < -ErrCode::store_itemno_err);  # 检测是否存在该装备
         $equipVo = $user->store->equipment->$equipuid;                          # 取装备对象
         if ($equipVo->herouid > 0) {                                            # 检测该装备是否装备到其他英雄身上 
-            if ($equipVo->herouid != $herouid) {
-                Err(ErrCode::store_equipWeared_err);
-            }
+            my_Assert($equipVo->herouid == $herouid, ErrCode::store_equipWeared_err);
             $user->store->equipment->$equipuid->herouid = 0;                    # 清理原来已经装备的言灵的反指向
         }
         $collectHeros = $user->heros->collectHeros;
-        if (!$collectHeros) {                                                   # 防御对象为空
-            Err(ErrCode::err_innerfault);
-        }
-        if (!CommUtil::isPropertyExists($collectHeros, $herouid)) {             # 检查是否存在需要装备的英雄
-            Err(ErrCode::hero_no);
-        }
-
+        my_default_Obj($collectHeros);
+        my_Assert(CommUtil::isPropertyExists($collectHeros, $herouid), ErrCode::hero_no);             # 检查是否存在需要装备的英雄
         $user->store->equipment->$equipuid->herouid = $herouid;                 # 装备上添加反向引用, 避免查询时的循环
         $oldEquipId = 0;
         switch ($itemtype) {                                                    # 添加或替换英雄该部位的装备
@@ -989,12 +955,9 @@ class StoreProc {
         if ($oldEquipId > 0) {
             $user->store->equipment->$oldEquipId->herouid = 0;
         }
-
-        UserProc::updateUserInfo();                                         // 5.回写数据
-        $ret = array('resp' => "succeed!");
-        $resp = Resp::ok($ret);                                                 // 返回 
+        UserProc::updateUserInfo();                                             // 5.回写数据
 //        StoreProc::CheckItemNum($req);
-        return $resp;
+        return Resp::ok(array('resp' => "succeed!"));                           // 返回 
     }
 
     /**
@@ -1003,19 +966,13 @@ class StoreProc {
      * @return type
      */
     static function UnWieldEquip($req) {
-        $user = $req->userInfo->game;                                           # user引用
         list($itemtype, $equipuid, $herouid) = $req->paras;                     # 提取参数: 装备类型, 装备的UID, 拥有该装备的英雄的UID 
+        $user = $req->userInfo->game;                                           # user引用
 
         $collectHeros = $user->heros->collectHeros;
-        if (!$collectHeros) {
-            Err(ErrCode::err_innerfault);
-        }
-        if (!CommUtil::isPropertyExists($collectHeros, $herouid)) {             # 检测是否存在拥有该装备的英雄
-            Err(ErrCode::hero_no);
-        }
-        if (!CommUtil::isPropertyExists($user->store->equipment, $equipuid)) {  # 检测是否存在该装备
-            Err(ErrCode::store_itemno_err);
-        }
+        my_default_Obj($collectHeros);
+        my_Assert(CommUtil::isPropertyExists($collectHeros, $herouid), ErrCode::hero_no);             # 检测是否存在拥有该装备的英雄
+        my_Assert(CommUtil::isPropertyExists($user->store->equipment, $equipuid), ErrCode::store_itemno_err);  # 检测是否存在该装备
         if ($user->store->equipment->$equipuid->herouid == $herouid) {          # 取装备对象
             $user->store->equipment->$equipuid->herouid = 0;
         }
@@ -1041,11 +998,9 @@ class StoreProc {
             default :
                 Err(ErrCode::store_equip_type);
         }
-        UserProc::updateUserInfo();                                         # 回写数据
-        $ret = array('resp' => "succeed!");
-        $resp = Resp::ok($ret);                                                 // 返回 
+        UserProc::updateUserInfo();                                             # 回写数据
 //        StoreProc::CheckItemNum($req);
-        return $resp;
+        return Resp::ok(array('resp' => "succeed!"));                                                 // 返回
     }
 
 // </editor-fold>
@@ -1068,7 +1023,7 @@ class StoreProc {
 
     /**
      * 检查背包中物品的个数
-     * @param type $req
+     * @param req $req
      * @return int
      */
     public static function CheckItemNum($req) {
@@ -1119,43 +1074,33 @@ class StoreProc {
 
     /**
      * 获取物品格子的上限值
-     * @param type $req
      * @return int 上限数值
      */
-    public static function GetItemMaxNum($req) {
-        $g = glc();
-        if (!CommUtil::isPropertyExists($req->userInfo->game->privateState, "maxItemNum")) {
-            $req->userInfo->game->privateState->maxItemNum = $g->Item_Packet_MaxNum;
+    public static function GetItemMaxNum() {
+        $user = req()->userInfo->game;
+        if (!CommUtil::isPropertyExists($user->privateState, "maxItemNum")) {
+            $user->privateState->maxItemNum = glc()->Item_Packet_MaxNum;
         }
-        return $req->userInfo->game->privateState->maxItemNum;
+        return $user->privateState->maxItemNum;
     }
 
+    /**
+     * 背包扩容
+     * @param type $req
+     * @return type
+     */
     public static function AddPacketNum($req) {
-        $g = glc();
-        //    $user = $req->userInfo->game; # user引用
-        if (!CommUtil::isPropertyExists($req->userInfo->game->privateState, "maxItemNum")) {
-            $req->userInfo->game->privateState->maxItemNum = $g->Item_Packet_MaxNum;
-        }
-        $costCash = $g->Item_Packet_NumCostCash;
-
-        $bDeal = false;
-        if ($costCash > 0) {
-            if ($req->userInfo->game->cash < $costCash) {
-                Err(ErrCode::notenough_spar);
-            }
-            $bDeal = UserGameModel::Consume_Cash($req->userInfo->game, $costCash);
-        } else {
-            Err(ErrCode::paras_err);
+        $user = $req->userInfo->game;                                           # user引用
+        if (!CommUtil::isPropertyExists($user->privateState, "maxItemNum")) {
+            $user->privateState->maxItemNum = glc()->Item_Packet_MaxNum;
         }
+        $costCash = glc()->Item_Packet_NumCostCash;                             # 钻石花费
+        my_Assert($costCash > 0, ErrCode::paras_err);
+        my_Assert(UserGameModel::Consume_Cash($user, $costCash), ErrCode::notenough_cash_msg); # 6.进行消耗
 
-        //6.进行消耗
-        if ($bDeal) {
-            $req->userInfo->game->privateState->maxItemNum += 10;
-            UserProc::updateUserInfo();
-            $result = ObjectInit();
-            $result->maxItemNum = $req->userInfo->game->privateState->maxItemNum;
-            $resp = Resp::ok($result);
-        }
+        $user->privateState->maxItemNum += 10;                                  # 扩容
+        UserProc::updateUserInfo();                                             # 保存玩家数据
+        $resp = Resp::ok(array('maxItemNum' => $user->privateState->maxItemNum)); # 返回值
         StoreProc::CheckItemNum($req);
         return $resp;
     }

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

@@ -88,7 +88,7 @@ class UserProc {
                 $arr = explode(',', $expinfo);
                 $itemid = $arr[0];
                 $num = $arr[1];
-                StoreProc::PutOverlyingItemInStore($itemid, $num, $req);
+                StoreProc::PutOverlyingItemInStore($itemid, $num);
             }
             UserProc::updateUserInfo();                                         # 回存玩家数据
             return Resp::ok(array('store' => $req->userInfo->game->store));

+ 26 - 3
Gameserver/Amfphp/test.php

@@ -8,9 +8,32 @@ include __DIR__ . '/main.php';
 //set_time_limit(15);                                                           # 设置执行超时时间
 echoLine("phpver:" . PHP_VERSION);
 
-$order_id = 101201789456;
+class ABC {
 
-echo substr(sprintf("%1$06d", $order_id), -6);
+    public $age;
+    public $name = "wg";
+    static $_ins;
 
-//var_dump(min($maxLevel, $playerLimit));
+    public static function Ins() {
+        if (null == self::$_ins) {
+            self::$_ins = new ABC();
+        }
+        return self::$_ins;
+    }
 
+}
+
+$abc = new ABC();
+$abc->age = 33;
+
+function Get() {
+    return ABC::Ins();
+}
+
+$ref = Get();
+$ref->name = "中国年";
+$ref = $abc;
+$ref->name = "王刚";
+
+var_dump($ref);
+var_dump(ABC::Ins());