Jelajahi Sumber

Merge branch 'dev' into TTT

cyzhao 3 tahun lalu
induk
melakukan
9572314faf

+ 4 - 0
Gameserver/Amfphp/base/ErrCode.php

@@ -592,6 +592,10 @@ class ErrCode {
     const store_weaponCantBuy = 3424;
     const store_weaponCantBuy = 3424;
     
     
     const store_expandStorage = 3425;
     const store_expandStorage = 3425;
+    
+    const store_NotHaveStorage = 3426;
+    
+    const store_StorageEnough= 3427;
 // </editor-fold>
 // </editor-fold>
     //  
     //  
     // <editor-fold defaultstate="collapsed" desc="   任务错误码 35xx系列   ">
     // <editor-fold defaultstate="collapsed" desc="   任务错误码 35xx系列   ">

+ 3 - 4
Gameserver/Amfphp/model/User/Info_Store.php

@@ -84,12 +84,11 @@ class Info_Store extends Object_ext {
         $this->weaponPool = ObjectInit();
         $this->weaponPool = ObjectInit();
         $this->weaponReward = ObjectInit();
         $this->weaponReward = ObjectInit();
         
         
-        $this->storage = ObjectInit();
         $key = 1;
         $key = 1;
         $key2 = 2;
         $key2 = 2;
-        $this->storage->$key = array();
-        $this->storage->$key2 = array();
-        
+        $this->storage->$key = new Ins_storage();
+        $this->storage->$key2 = new Ins_storage();
+              
     }
     }
 
 
     /**
     /**

+ 30 - 0
Gameserver/Amfphp/model/User/Ins_storage.php

@@ -0,0 +1,30 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+namespace loyalsoft;
+
+/**
+ * Description of Ins_storage
+ *
+ * @author c'y'zhao
+ */
+class Ins_storage {
+    public $itemlist = null;
+
+    public $equipmentlist = null;
+
+    public $yanlinglist = null;
+
+    public function __construct($arg = null) {
+        parent::__construct($arg);
+        
+        $this->itemlist = ObjectInit();
+        $this->equipmentlist = ObjectInit();
+        $this->yanlinglist = ObjectInit();
+    }
+}

+ 21 - 6
Gameserver/Amfphp/process/MapProc.php

@@ -44,11 +44,14 @@ class MapProc {
 
 
         $newMap->unlockedFootholds->$mapid->exploreRewardGeted = true;
         $newMap->unlockedFootholds->$mapid->exploreRewardGeted = true;
 
 
-        StoreProc::AddMultiItemInStore(GameConfig::map_scene_getItem($mapid)->exploreReward);
+        $cost = GameConfig::map_scene_getItem($mapid)->exploreReward;
+        StoreProc::AddMultiItemInStore($cost);
         ctx()->newMap = $newMap;
         ctx()->newMap = $newMap;
 
 
         UserProc::updateUserInfo();
         UserProc::updateUserInfo();
-        return Resp::ok($newMap);
+        return Resp::ok(
+                array("newMap"=>$newMap,"cost"=>$cost,)
+                );
     }
     }
 
 
     /**
     /**
@@ -88,23 +91,35 @@ class MapProc {
      */
      */
 
 
     public static function countFootHoldExplorerNum($mapid, $newMap) {
     public static function countFootHoldExplorerNum($mapid, $newMap) {
-        $explorer = 0;
+        $explorer = 0;       
         if (StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
         if (StlUtil::dictHasProperty($newMap->unlockMapTypeList, $mapid)) {
             $list = $newMap->unlockMapTypeList->$mapid;
             $list = $newMap->unlockMapTypeList->$mapid;
-            $mapList = GameConfig::map_explorer_getItemArray($mapid);                        
+            $mapList = GameConfig::map_explorer_getItemArray($mapid);   
+            
+            $tempList = array();
             if ($mapList != null) {
             if ($mapList != null) {
                 foreach ($mapList as $item) {
                 foreach ($mapList as $item) {
+                    if($item->paras == null){
+                        continue;
+                    }
                     $cmd = $item->cmd;
                     $cmd = $item->cmd;
-                    $parasList = explode(',', $item->paras);                  
+                    $parasList = explode(',', $item->paras);                        
                     foreach ($list as $para) {                       
                     foreach ($list as $para) {                       
-                        $strList = explode('_', $para);                       
+                        $strList = explode('_', $para);
+                        $tempStr = $strList[1].'-'.$strList[2];
+                        if(in_array($tempStr, $tempList)){
+                            continue;
+                        }
+                                          
                         if ($strList[1] == $cmd && $strList[2] == $parasList[0]) {
                         if ($strList[1] == $cmd && $strList[2] == $parasList[0]) {
+                            $tempList[] = $tempStr;
                             $explorer += $parasList[1];
                             $explorer += $parasList[1];
                         }
                         }
                     }
                     }
                 }
                 }
             }
             }
         }     
         }     
+        
         return $explorer;
         return $explorer;
     }
     }
 
 

+ 83 - 9
Gameserver/Amfphp/process/StoreProc.php

@@ -94,25 +94,88 @@ class StoreProc {
      * @return type
      * @return type
      */
      */
     public static function changeStorage() {
     public static function changeStorage() {
-        $type = req()->paras[0];       # 1:放入 2移除到背包
-        $index = req()->paras[1];      #放入第几个格子
-        $itemid = req()->paras[2];      # itemid
+        $index = req()->paras[0];     # 选中的第几个格子
+        $type = req()->paras[1];      # 1:放入 2移除到背包
+        $itemType = req()->paras[2];  # 道具类型
+        $uid = req()->paras[3];       # 道具的uid
         
         
         $store = ctx()->store(true);
         $store = ctx()->store(true);
-       
-        StoreProc::removeEquipFromStore($uid, $typeId);
-        ctx()->store(true)->storage->$key = array();
+        my_Assert(StlUtil::dictHasProperty($store->storage, $index), ErrCode::store_NotHaveStorage);
+        
+        $storage = $store->storage->$index;
+        $num = 0;
+        foreach ($storage as $k => $dic) {
+            $num += count((array)$dic);
+        }       
+        
+        switch ($itemType) {
+            case 401://武器
+                if($type == 1){                   
+                    my_Assert($num < 50, ErrCode::store_StorageEnough);
+                    $equipVo = $store->equipment->$uid;
+                    $storage->equipmentlist->$uid = $equipVo;//添加
+                                      
+                    StoreProc::removeEquipFromStore($uid, $equipVo->typeId);//移除
+                } else {
+                    $equipVo = $storage->equipmentlist->$uid;
+                    $store->equipment->$uid = $equipVo;
+                    
+                    unset($storage->equipmentlist->$uid);                                      
+                }
+    
+                break;
+            case 101://言灵
+                if($type == 1){                   
+                    my_Assert($num < 50, ErrCode::store_StorageEnough);
+                    $yanlingVo = $store->yanling->$uid;
+                    $storage->yanlinglist->$uid = $yanlingVo;//添加
+                                      
+                    StoreProc::removeYanlingFromStore($uid, $yanlingVo->typeId);//移除
+                } else {
+                    $yanlingVo = $storage->yanlinglist->$uid;
+                    $store->yanling->$uid = $yanlingVo;
+                    
+                    unset($storage->yanlinglist->$uid);                                      
+                }
+
+                break;
+            default://其他道具
+                if($type == 1){                   
+                    my_Assert($num < 50, ErrCode::store_StorageEnough); 
+                    $itemNum = $store->items->$uid;
+                    if(!StlUtil::dictHasProperty($storage->itemlist, $uid)){
+                        $storage->itemlist->$uid = 0;
+                    }                                                         
+                    $storage->itemlist->$uid += $itemNum;//添加                                                  
+                    StoreProc::removeItemFromStore($store, $uid, $itemNum);
+                } else {
+                    $itemNum = $storage->itemlist->$uid;
+                    $goodsStr = $uid.",".$itemNum;
+                    StoreProc::AddMultiItemInStore($goodsStr); 
+                    
+                    unset($storage->itemlist->$uid);                                                             
+                }
+                
+                break;
+        }
+        
+        $store->storage->$index = $storage;
+                      
+        ctx()->store(true) = $store;
         UserProc::updateUserInfo();
         UserProc::updateUserInfo();
 
 
         return Resp::ok(array("store"=>$store,));
         return Resp::ok(array("store"=>$store,));
     }
     }
-    
+    /**
+     * 储物间扩容
+     * @return type
+     */
     public static function expandStorage() {
     public static function expandStorage() {
         $cost = GameConfig::globalsettings()->expandStorageCost;
         $cost = GameConfig::globalsettings()->expandStorageCost;
         $list = explode(',', $cost);
         $list = explode(',', $cost);
         
         
         $key = 3;
         $key = 3;
-        my_Assert(StlUtil::dictHasProperty(!ctx()->store(true)->storage, $key), ErrCode::store_expandStorage);
+        my_Assert(!StlUtil::dictHasProperty(ctx()->store(true)->storage, $key), ErrCode::store_expandStorage);
       
       
         if($list[0] == 1){
         if($list[0] == 1){
             my_Assert(ctx()->base(true)->gold >= $list[1], ErrCode::notenough_gold_msg);
             my_Assert(ctx()->base(true)->gold >= $list[1], ErrCode::notenough_gold_msg);
@@ -122,7 +185,8 @@ class StoreProc {
             ctx()->base(true)->Consume_Cash($list[1]);
             ctx()->base(true)->Consume_Cash($list[1]);
         }
         }
         $str = $list[0].",". $list[1];
         $str = $list[0].",". $list[1];
-        ctx()->store(true)->storage->$key = array();
+        ctx()->store(true)->storage->$key = new Ins_storage();
+        
         UserProc::updateUserInfo();
         UserProc::updateUserInfo();
 
 
         return Resp::ok(array("storage"=>ctx()->store(true)->storage,"cost"=>$str,));
         return Resp::ok(array("storage"=>ctx()->store(true)->storage,"cost"=>$str,));
@@ -817,6 +881,16 @@ class StoreProc {
         }
         }
         return $ok;
         return $ok;
     }
     }
+    
+    static function removeYanlingFromStore($uid, $typeId) {
+        $ok = false;
+        if (CommUtil::isPropertyExists(ctx()->store->yanling, $uid)) {
+            my_Assert($typeId == ctx()->store->yanling->$uid->typeId, "typeid检验错误"); // typeid相同;
+            unset(ctx()->store->yanling->$uid);
+            $ok = true;
+        }
+        return $ok;
+    }
 
 
     /**
     /**
      * 从仓库移除碎片
      * 从仓库移除碎片