|
@@ -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;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 从仓库移除碎片
|
|
* 从仓库移除碎片
|