|
@@ -14,6 +14,7 @@ namespace loyalsoft;
|
|
|
* @author c'y'zhao
|
|
|
*/
|
|
|
class StoreProc {
|
|
|
+
|
|
|
/**
|
|
|
* 逻辑分发
|
|
|
* 所有的Proc中必须有这样一个方法
|
|
@@ -22,44 +23,41 @@ class StoreProc {
|
|
|
public static function procMain($req) {
|
|
|
switch ($req->cmd) {
|
|
|
case CmdCode::cmd_store_put: # 6401 放入仓库
|
|
|
- return StoreProc::AddItemInStore();
|
|
|
- case CmdCode::cmd_store_equip: # 6402
|
|
|
- return StoreProc::equip();
|
|
|
- case CmdCode::cmd_store_RemoveEquip: #6403卸下装备
|
|
|
- return StoreProc::RemoveEquip();
|
|
|
- case CmdCode::cmd_store_equipUpgrade: # 6403
|
|
|
- return StoreProc::equipUpgrade();
|
|
|
- case CmdCode::cmd_store_equipUpgrade_MaxLv: # 6404
|
|
|
- return StoreProc::equipUpgrade_MaxLv();
|
|
|
- case CmdCode::cmd_store_equipCompose: # 6404
|
|
|
- return StoreProc::equipCompose();
|
|
|
-
|
|
|
+ return StoreProc::AddItemInStore();
|
|
|
+ case CmdCode::cmd_store_equip: # 6402 装备
|
|
|
+ return StoreProc::equip();
|
|
|
+ case CmdCode::cmd_store_RemoveEquip: # 6403 卸下装备
|
|
|
+ return StoreProc::RemoveEquip();
|
|
|
+ case CmdCode::cmd_store_equipUpgrade: # 6404 装备升级
|
|
|
+ return StoreProc::equipUpgrade();
|
|
|
+ case CmdCode::cmd_store_equipUpgrade_MaxLv: # 6405 一键升级(装备)
|
|
|
+ return StoreProc::equipUpgrade_MaxLv();
|
|
|
+ case CmdCode::cmd_store_equipCompose: # 6406 装备合成(升阶/进化)
|
|
|
+ return StoreProc::equipCompose();
|
|
|
default:
|
|
|
Err(ErrCode::cmd_err);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- * 合成
|
|
|
+ * 6406 合成
|
|
|
* @return type
|
|
|
*/
|
|
|
public static function equipCompose() {
|
|
|
list($uid) = req()->paras;
|
|
|
$user = ctx();
|
|
|
|
|
|
- //my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ //my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
UserProc::updateUserInfo();
|
|
|
- return Resp::ok(array(
|
|
|
- 'heros' => $user->heros,
|
|
|
+ return Resp::ok(array(
|
|
|
+ 'heros' => $user->heros,
|
|
|
'store' => $user->store,));
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 装备
|
|
|
* @return type
|
|
@@ -68,52 +66,49 @@ class StoreProc {
|
|
|
list($uid) = req()->paras;
|
|
|
$user = ctx();
|
|
|
|
|
|
- my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);
|
|
|
-
|
|
|
+ my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);
|
|
|
+
|
|
|
$mo = GameConfig::equip_getItem($user->store->equip->$uid->typeId);
|
|
|
my_Assert($mo != null, ErrCode::err_const_no);
|
|
|
$posId = $mo->position;
|
|
|
-
|
|
|
+
|
|
|
$heroId = $user->heros->CurrentHeroId;
|
|
|
-
|
|
|
- $user->store->equip->$uid->posId = $posId;
|
|
|
- if($user->heros->Dic->$heroId->equipPosition->$posId > 0){
|
|
|
+
|
|
|
+ $user->store->equip->$uid->posId = $posId;
|
|
|
+ if ($user->heros->Dic->$heroId->equipPosition->$posId > 0) {
|
|
|
$oldUid = $user->heros->Dic->$heroId->equipPosition->$posId;
|
|
|
- $user->store->equip->$oldUid->posId = 0;
|
|
|
+ $user->store->equip->$oldUid->posId = 0;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$user->heros->Dic->$heroId->equipPosition->$posId = $uid;
|
|
|
-
|
|
|
+
|
|
|
UserProc::updateUserInfo();
|
|
|
- return Resp::ok(array(
|
|
|
- 'heros' => $user->heros,
|
|
|
+ return Resp::ok(array(
|
|
|
+ 'heros' => $user->heros,
|
|
|
'store' => $user->store,));
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 卸下装备
|
|
|
* @return type
|
|
|
*/
|
|
|
public static function RemoveEquip() {
|
|
|
- list($posId) = req()->paras;
|
|
|
+ list($posId) = req()->paras;
|
|
|
$user = ctx();
|
|
|
|
|
|
$heroId = $user->heros->CurrentHeroId;
|
|
|
- if($user->heros->Dic->$heroId->equipPosition->$posId > 0){
|
|
|
+ if ($user->heros->Dic->$heroId->equipPosition->$posId > 0) {
|
|
|
$oldUid = $user->heros->Dic->$heroId->equipPosition->$posId;
|
|
|
- $user->store->equip->$oldUid->posId = 0;
|
|
|
+ $user->store->equip->$oldUid->posId = 0;
|
|
|
$user->heros->Dic->$heroId->equipPosition->$posId = 0;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
UserProc::updateUserInfo();
|
|
|
return Resp::ok(array(
|
|
|
- 'heros' => $user->heros,
|
|
|
+ 'heros' => $user->heros,
|
|
|
'store' => $user->store,));
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 升级装备
|
|
|
* @return type
|
|
@@ -122,78 +117,74 @@ class StoreProc {
|
|
|
list($uid) = req()->paras; //mask = 1:表示战斗中掉落
|
|
|
$user = ctx();
|
|
|
|
|
|
- $lv = $user->store->equip->$uid->level;
|
|
|
- $Mo = GameConfig::equip_levelupgrade_getItem($lv+1);
|
|
|
- my_Assert($user->baseInfo->gold >= $Mo->needGold, ErrCode::notenough_gold_msg);
|
|
|
-
|
|
|
- $position = GameConfig::equip_getItem($user->store->equip->$uid->typeId)->position;//图纸
|
|
|
+ $lv = $user->store->equip->$uid->level;
|
|
|
+ $Mo = GameConfig::equip_levelupgrade_getItem($lv + 1);
|
|
|
+ my_Assert($user->baseInfo->gold >= $Mo->needGold, ErrCode::notenough_gold_msg);
|
|
|
+
|
|
|
+ $position = GameConfig::equip_getItem($user->store->equip->$uid->typeId)->position; //图纸
|
|
|
$typeId = 0;
|
|
|
$strArr = explode(';', GameConfig::globalsettings()->equipLeveUpTuzhi);
|
|
|
foreach ($strArr as $str) {
|
|
|
$list = explode(',', $str);
|
|
|
- if($list[0] == $position){
|
|
|
+ if ($list[0] == $position) {
|
|
|
$typeId = $list[1];
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
$num = $Mo->needItemNum;
|
|
|
- if (StlUtil::dictHasProperty($user->store->items,$typeId) && $user->store->items->$typeId >= $num)
|
|
|
- {
|
|
|
+ if (StlUtil::dictHasProperty($user->store->items, $typeId) && $user->store->items->$typeId >= $num) {
|
|
|
$user->store->removeItem($typeId, $num);
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ $user->store->equip->$uid->level += 1;
|
|
|
|
|
|
- $user->store->equip->$uid->level += 1;
|
|
|
-
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
return Resp::ok(array(
|
|
|
- 'gold' => $user->baseInfo->gold,
|
|
|
+ 'gold' => $user->baseInfo->gold,
|
|
|
'store' => $user->store));
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 装备一键升级
|
|
|
* @return type
|
|
|
*/
|
|
|
public static function equipUpgrade_MaxLv() {
|
|
|
list($uid) = req()->paras; //mask = 1:表示战斗中掉落
|
|
|
- $user = ctx();
|
|
|
-
|
|
|
+ $user = ctx();
|
|
|
+
|
|
|
$equip = $user->store->equip->$uid;
|
|
|
|
|
|
$lv = $equip->level;
|
|
|
$maxLv = GameConfig::equip_getItem($equip->typeId)->maxLv;
|
|
|
-
|
|
|
+
|
|
|
$need_gold = 0;
|
|
|
$need_item = 0;
|
|
|
|
|
|
$itemNum = 0;
|
|
|
- $position = GameConfig::equip_getItem($equip->typeId)->position;
|
|
|
+ $position = GameConfig::equip_getItem($equip->typeId)->position;
|
|
|
$tuzhiId = 0;
|
|
|
$strArr = explode(';', GameConfig::globalsettings()->equipLeveUpTuzhi);
|
|
|
foreach ($strArr as $str) {
|
|
|
$list = explode(',', $str);
|
|
|
- if($list[0] == $position){
|
|
|
+ if ($list[0] == $position) {
|
|
|
$tuzhiId = $list[1];
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$needItem2 = 0;
|
|
|
- if (StlUtil::dictHasProperty($user->store->items,$tuzhiId))
|
|
|
- {
|
|
|
+ if (StlUtil::dictHasProperty($user->store->items, $tuzhiId)) {
|
|
|
$itemNum = $user->store->items->$tuzhiId;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
$nGold = 0;
|
|
|
$ll = 0;
|
|
|
- for ($i = $lv+1; $i <= $maxLv; $i++)
|
|
|
- {
|
|
|
- $nGold += GameConfig::equip_levelupgrade_getItem($i)->needGold;
|
|
|
+ for ($i = $lv + 1; $i <= $maxLv; $i++) {
|
|
|
+ $nGold += GameConfig::equip_levelupgrade_getItem($i)->needGold;
|
|
|
$needItem2 += GameConfig::equip_levelupgrade_getItem($i)->needItemNum;
|
|
|
- if ($user->baseInfo->gold >= $nGold && $itemNum >= $needItem2)
|
|
|
- {
|
|
|
+ if ($user->baseInfo->gold >= $nGold && $itemNum >= $needItem2) {
|
|
|
$need_gold = $nGold;
|
|
|
$need_item = $needItem2;
|
|
|
$ll = $i;
|
|
@@ -201,24 +192,21 @@ class StoreProc {
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
$user->baseInfo->gold -= $need_gold;
|
|
|
- $user->store->removeItem($tuzhiId, $need_item);
|
|
|
+ $user->store->removeItem($tuzhiId, $need_item);
|
|
|
$user->store->equip->$uid->level += $ll;
|
|
|
-
|
|
|
+
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
return Resp::ok(array(
|
|
|
'gold' => $user->baseInfo->gold,
|
|
|
//'tili' => $user->baseInfo->tili,
|
|
|
- 'store' => $user->store,
|
|
|
- ));
|
|
|
-
|
|
|
+ 'store' => $user->store,
|
|
|
+ ));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
public static function AddItemInStore() {
|
|
|
list($rwdStr) = req()->paras; //mask = 1:表示战斗中掉落
|
|
|
$user = ctx();
|
|
@@ -226,16 +214,15 @@ class StoreProc {
|
|
|
$err = self::AddMultiItemInStore($rwdStr);
|
|
|
|
|
|
my_Assert(ErrCode::ok == $err, $err);
|
|
|
-
|
|
|
+
|
|
|
UserProc::updateUserInfo();
|
|
|
return Resp::ok(array(
|
|
|
//'gold' => $user->baseInfo->gold,
|
|
|
//'tili' => $user->baseInfo->tili,
|
|
|
- //'cash' => $user->baseInfo->cash,
|
|
|
+ //'cash' => $user->baseInfo->cash,
|
|
|
'store' => $user->store));
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 具体奖励存入背包
|
|
|
* @param type $goodsStr
|
|
@@ -248,8 +235,8 @@ class StoreProc {
|
|
|
my_Assert(count($val) > 1, "解析奖励字符串出错");
|
|
|
|
|
|
list($itemId, $num) = $val; # ID, 数量
|
|
|
- if(GameConfig::equip_getItem($itemId) != null){
|
|
|
- self::PutEquipInStore($itemId, $num);
|
|
|
+ if (GameConfig::equip_getItem($itemId) != null) {
|
|
|
+ self::PutEquipInStore($itemId, $num);
|
|
|
} else {
|
|
|
$itemMo = GameConfig::item_getItem($itemId);
|
|
|
switch ($itemMo->itemType) {
|
|
@@ -265,45 +252,40 @@ class StoreProc {
|
|
|
case 100:
|
|
|
case 101:
|
|
|
case 102:
|
|
|
- self::PutItemsInStore($itemId, $num);
|
|
|
+ self::PutItemsInStore($itemId, $num);
|
|
|
|
|
|
- break;
|
|
|
+ break;
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public static function PutItemsInStore($itemId,$num) {
|
|
|
+
|
|
|
+ public static function PutItemsInStore($itemId, $num) {
|
|
|
$items = ctx()->store->items;
|
|
|
- if(StlUtil::dictHasProperty($items, $itemId)){
|
|
|
+ if (StlUtil::dictHasProperty($items, $itemId)) {
|
|
|
$items->$itemId += $num;
|
|
|
} else {
|
|
|
$items->$itemId = $num;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
ctx()->store->items = $items;
|
|
|
}
|
|
|
-
|
|
|
- public static function PutEquipInStore($equipId,$num) {
|
|
|
- if($equipId == 0){
|
|
|
+
|
|
|
+ public static function PutEquipInStore($equipId, $num) {
|
|
|
+ if ($equipId == 0) {
|
|
|
return;
|
|
|
}
|
|
|
- $n = count((array)ctx()->store->equip)+1;
|
|
|
-
|
|
|
+ $n = count((array) ctx()->store->equip) + 1;
|
|
|
+
|
|
|
for ($index = 0; $index < $num; $index++) {
|
|
|
$Equip = new Ins_Equip();
|
|
|
$Equip->uid = $n;
|
|
|
$Equip->typeId = $equipId;
|
|
|
- $Equip->qual = GameConfig::equip_getItem($equipId)->qual;
|
|
|
- ctx()->store->equip->$n = $Equip;
|
|
|
+ $Equip->qual = GameConfig::equip_getItem($equipId)->qual;
|
|
|
+ ctx()->store->equip->$n = $Equip;
|
|
|
$n += 1;
|
|
|
}
|
|
|
}
|