|
@@ -43,7 +43,8 @@ class StoreProc {
|
|
|
case CmdCode::cmd_store_AddMaxPacketNum: # 6412 扩展包裹格子数量
|
|
|
return StoreProc::AddPacketNum($req);
|
|
|
case CmdCode::cmd_store_MeltEquip: # 6413 装备融合
|
|
|
- return StoreProc::MeltEquip($req);
|
|
|
+ Err(ErrCode::err_method_obsoleted);
|
|
|
+// return StoreProc::MeltEquip($req);
|
|
|
case CmdCode::cmd_store_PiecesCompose: # 6415 碎片合成
|
|
|
return StoreProc::composePieces($req);
|
|
|
|
|
@@ -60,7 +61,7 @@ class StoreProc {
|
|
|
* @return type
|
|
|
*/
|
|
|
static public function Test($req) {
|
|
|
- return StoreProc::MeltEquip($req);
|
|
|
+// return StoreProc::MeltEquip($req);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -201,115 +202,11 @@ class StoreProc {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * [6413] 装备熔炼
|
|
|
- * @param Req $req
|
|
|
+ *
|
|
|
+ * @param type $req
|
|
|
* @return type
|
|
|
+ * @deprecated since version 0
|
|
|
*/
|
|
|
- static function MeltEquip($req) {
|
|
|
- ////1获取参数
|
|
|
- $uid = $req->paras[0]; //获取物品uid
|
|
|
- if ($uid < 1) {
|
|
|
- Err(ErrCode::paras_err);
|
|
|
- }
|
|
|
- $resp = new Resp();
|
|
|
- $user = $req->userInfo->game; # user引用
|
|
|
- ///2检测装备是否在英雄身上
|
|
|
-
|
|
|
- $HeroObj = $req->userInfo->game->heros->collectHeros;
|
|
|
- ////检测英雄装备到身上的情况,装备到英雄身上要减去.
|
|
|
- if ($HeroObj) {
|
|
|
- foreach ($HeroObj as $value) {
|
|
|
- // echo var_dump($HeroObj);
|
|
|
-
|
|
|
- $HeroEquipId = $value->equip->weapon->itemuid;
|
|
|
- if ($HeroEquipId == $uid) {
|
|
|
- echoLine("该物品已经装备到英雄身上无法熔炼");
|
|
|
- Err(ErrCode::store_equipWeared_err);
|
|
|
- }
|
|
|
- $HeroEquipId = $value->equip->armor->itemuid;
|
|
|
- if ($HeroEquipId == $uid) {
|
|
|
- echoLine("该物品已经装备到英雄身上无法熔炼");
|
|
|
- Err(ErrCode::store_equipWeared_err);
|
|
|
- }
|
|
|
- $HeroEquipId = $value->equip->ring->itemuid;
|
|
|
- if ($HeroEquipId == $uid) {
|
|
|
- echoLine("该物品已经装备到英雄身上无法熔炼");
|
|
|
- Err(ErrCode::store_equipWeared_err);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- ///3检查装备熔炼等级,是否打到熔炼上限,如果达到上限,报错.然后查看相应等级需要的七宗罪元素数量是否足够,金币是否足够.
|
|
|
-
|
|
|
- $itemId = $user->store->equipment->$uid->typeId;
|
|
|
- $item = GameConfig::item_getItem($itemId);
|
|
|
- if ($item == null) { ////检测是否存在装备的原始数据
|
|
|
- Err(ErrCode::err_const_no);
|
|
|
- }
|
|
|
- // echoLine($item->baoji);
|
|
|
- if ($user->store->equipment->$uid->melt_level > $item->melt_level) {
|
|
|
- $meltLevel = $user->store->equipment->$uid->melt_level;
|
|
|
- } else {
|
|
|
- $meltLevel = $item->melt_level;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $meltLevel++;
|
|
|
- var_dump($meltLevel);
|
|
|
- // var_dump(GameConfig::smelting());
|
|
|
- $melt = GameConfig::smelting_getItem($meltLevel);
|
|
|
- // var_dump($melt);
|
|
|
- if ($melt == null) { ////在装备熔炼等级表里找不到该等级的熔炼规则
|
|
|
- Err(ErrCode::err_const_no);
|
|
|
- }
|
|
|
- $gold = $melt->spendgold; ////当前熔炼等级需要的金币数
|
|
|
- $costElement = $melt->costamoun; ////当前熔炼等级消耗的熔炼元素数
|
|
|
- $successRate = $melt->successrate; ////当前熔炼等级的成功率
|
|
|
- ////消耗金币和元素
|
|
|
- $ok = StoreProc::RemoveElementFromStore($req, $costElement);
|
|
|
- if (!$ok) {//1.如果背包道具移出时出错,则直接返回错误
|
|
|
- Err(ErrCode::store_removefail);
|
|
|
- }
|
|
|
-
|
|
|
- $bDeal = UserGameModel::Consume_Gold($user, $gold);
|
|
|
- if ($bDeal) {
|
|
|
- $result = array(
|
|
|
- 'resp' => "succeed!"
|
|
|
- );
|
|
|
- $resp = Resp::ok($result);
|
|
|
- } else {
|
|
|
- Err(ErrCode::notenough_gold_msg);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ///4按熔炼等级来确定当前操作的成功率,投骰子决定是否成功,失败的话,装备不变且不返还金币和元素。成功的话,消耗金币和元素,装备升级(按数据表要求增加属性)
|
|
|
- # 投骰子
|
|
|
-
|
|
|
-
|
|
|
- if (0 == $resp->err) {
|
|
|
- $rnd = CommUtil::random(0, 99);
|
|
|
- echoLine($rnd);
|
|
|
- if ($successRate > $rnd) {
|
|
|
- StoreProc:: UpgradeMeltEquip($req);
|
|
|
- $result = array(
|
|
|
- 'store' => $req->userInfo->game->store,
|
|
|
- 'resp' => "succeed!"
|
|
|
- );
|
|
|
- } else {
|
|
|
- $result = array(
|
|
|
- 'element' => $req->userInfo->game->store->element,
|
|
|
- 'resp' => "Failed!"
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- $resp = Resp::ok($result);
|
|
|
- }
|
|
|
- UserProc::updateUserInfo($req);
|
|
|
- return $resp;
|
|
|
- }
|
|
|
-
|
|
|
static function UpgradeMeltEquip($req) {
|
|
|
$store = $req->userInfo->game->store;
|
|
|
$uid = $req->paras[0]; //获取物品uid
|
|
@@ -747,72 +644,6 @@ class StoreProc {
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 从仓库移除七宗罪炼金元素(道具)
|
|
|
- * @param $req
|
|
|
- * @param int $elementid
|
|
|
- * @param int $num
|
|
|
- */
|
|
|
- static function RemoveElementFromStore(&$req, $num) {
|
|
|
- if ($num < 0) {
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- echoLine("元素数量");
|
|
|
- $ok = StoreProc::CheckElementNum($req, $num);
|
|
|
- if (!$ok) {
|
|
|
- echoLine("元素数量不足");
|
|
|
- } else {
|
|
|
-
|
|
|
- $ElementObj = $req->userInfo->game->store->element;
|
|
|
-
|
|
|
- if ($ElementObj) {
|
|
|
- foreach ($ElementObj as $key => $value) {
|
|
|
- // echo var_dump($HeroObj);
|
|
|
- if ($value >= $num) {
|
|
|
- $req->userInfo->game->store->element->$key -= $num;
|
|
|
- } else {
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 检测身上的熔炼元素是否够数量
|
|
|
- * @param type $req
|
|
|
- * @param type $num
|
|
|
- */
|
|
|
- static function CheckElementNum($req, $num) {
|
|
|
-
|
|
|
- if (!CommUtil::isPropertyExists($req->userInfo->game->store, "element")) {
|
|
|
- echoLine("没有element节点,开始创建");
|
|
|
- // $req->userInfo->game->store->element= ObjectInit();
|
|
|
- $req->userInfo->game->store->element = array('388001' => 0, '388002' => 0, '388003' => 0, '388004' => 0, '388005' => 0, '388006' => 0, '388007' => 0);
|
|
|
- UserProc::updateUserInfo($req);
|
|
|
- }
|
|
|
- $ElementObj = $req->userInfo->game->store->element;
|
|
|
- ////检测英雄装备到身上的情况,装备到英雄身上要减去.
|
|
|
- if ($ElementObj) {
|
|
|
- foreach ($ElementObj as $value) {
|
|
|
- // echo var_dump($HeroObj);
|
|
|
- if ($value < $num) {
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- return FALSE;
|
|
|
- }
|
|
|
-
|
|
|
// </editor-fold>
|
|
|
//
|
|
|
// <editor-fold defaultstate="collapsed" desc=" 放入物品 ">
|
|
@@ -926,7 +757,7 @@ class StoreProc {
|
|
|
break;
|
|
|
////熔炼元素的获取
|
|
|
case "388":
|
|
|
- StoreProc::PutElementInStore($itemId, $num, $req);
|
|
|
+// StoreProc::PutElementInStore($itemId, $num, $req);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
@@ -995,28 +826,6 @@ class StoreProc {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 将炼金元素放入仓库
|
|
|
- * @param type $itemId
|
|
|
- *
|
|
|
- */
|
|
|
- static function PutElementInStore($elementId, $num, &$req) {
|
|
|
-
|
|
|
- // $game->userInfo->game;
|
|
|
- $g = glc();
|
|
|
- if (CommUtil::isPropertyExists($req->userInfo->game->store->element, $elementId)) {// 如果仓库中已经有这种元素,则其数目+
|
|
|
- if ($req->userInfo->game->store->element->$elementId + $num < $g->Melt_Element_MaxNum) { ////如果炼金元素增加之后的数量没到上限,则加
|
|
|
- $req->userInfo->game->store->element->$elementId += $num;
|
|
|
- } else {
|
|
|
- $req->userInfo->game->store->element->$elementId = $g->Melt_Element_MaxNum; ////如果到上限了,就直接等于上限.
|
|
|
- }
|
|
|
- } else {// 如果仓库中没有这种元素,则当做之前数量零处理
|
|
|
- if ($num > $g->Melt_Element_MaxNum) { ////如果要添加的数量超过最大值,那么等于最大值.
|
|
|
- $req->userInfo->game->store->element->$elementId = $g->Melt_Element_MaxNum;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 物品包裹打散成独立道具到仓库
|
|
|
* @param GoodsItemModel $itemModel
|
|
@@ -1081,123 +890,94 @@ class StoreProc {
|
|
|
// self::checkActiveItem($req, $itemModel);
|
|
|
}
|
|
|
|
|
|
- ///给英雄穿装备
|
|
|
+ /**
|
|
|
+ * [6410] 给英雄穿装备
|
|
|
+ * @param req $req
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
static function WearEquipToHero($req) {
|
|
|
- $user = $req->userInfo->game; # user引用
|
|
|
- $itemtype = $req->paras[0]; //装备类型
|
|
|
- $equipuid = $req->paras[1]; //装备的UID
|
|
|
- $herouid = $req->paras[2]; //英雄的UID
|
|
|
- echo "开始进去";
|
|
|
- //1.检测是否存在该装备
|
|
|
+ $user = $req->userInfo->game; # user引用
|
|
|
+ list($itemtype, $equipuid, $herouid) = $req->pars; # 提取参数: 装备类型, 装备的UID, 英雄的UID
|
|
|
|
|
|
- if (!CommUtil::isPropertyExists($user->store->equipment, $equipuid)) {
|
|
|
+ if (!CommUtil::isPropertyExists($user->store->equipment, $equipuid)) { # 1.检测是否存在该装备
|
|
|
Err(ErrCode::store_itemno_err);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //2.检查是否存在需要装备的英雄
|
|
|
-
|
|
|
$collectHeros = $user->heros->collectHeros;
|
|
|
- if (!$collectHeros) {
|
|
|
- $collectHeros = ObjectInit();
|
|
|
+ if (!$collectHeros) { # 防御对象为空
|
|
|
+ Err(ErrCode::err_innerfault);
|
|
|
}
|
|
|
-
|
|
|
- if (!CommUtil::isPropertyExists($collectHeros, $herouid)) {
|
|
|
+ if (!CommUtil::isPropertyExists($collectHeros, $herouid)) { # 2.检查是否存在需要装备的英雄
|
|
|
Err(ErrCode::hero_no);
|
|
|
}
|
|
|
|
|
|
- //3.检测该装备是否装备到其他英雄身上
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- foreach ($collectHeros as $tmpheroid => $tempvalue) {
|
|
|
-
|
|
|
- if ($tempvalue->equip->weapon->itemuid == $equipuid) {
|
|
|
+ foreach ($collectHeros as $tmpheroid => $tempvalue) { // 3.检测该装备是否装备到其他英雄身上
|
|
|
+ if ($tempvalue->equip->weapon->itemuid == $equipuid) { # 武器
|
|
|
Err(ErrCode::store_equipWeared_err);
|
|
|
- } elseif ($tempvalue->equip->armor->itemuid == $equipuid) {
|
|
|
+ } elseif ($tempvalue->equip->armor->itemuid == $equipuid) { # 防具
|
|
|
Err(ErrCode::store_equipWeared_err);
|
|
|
- } elseif ($tempvalue->equip->ring->itemuid == $equipuid) {
|
|
|
+ } elseif ($tempvalue->equip->ring->itemuid == $equipuid) { # 饰品
|
|
|
Err(ErrCode::store_equipWeared_err);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ///4.添加或替换英雄该部位的装备
|
|
|
- if ($itemtype == 1) {
|
|
|
+ if ($itemtype == 1) { // 4.添加或替换英雄该部位的装备
|
|
|
$collectHeros->$herouid->equip->weapon->itemuid = $equipuid;
|
|
|
}
|
|
|
- if ($itemtype == 2) {
|
|
|
+ if ($itemtype == 2) { # 防具
|
|
|
$collectHeros->$herouid->equip->armor->itemuid = $equipuid;
|
|
|
}
|
|
|
- if ($itemtype == 3) {
|
|
|
+ if ($itemtype == 3) { # 防具
|
|
|
$collectHeros->$herouid->equip->ring->itemuid = $equipuid;
|
|
|
}
|
|
|
|
|
|
- //5.回写数据
|
|
|
- UserProc::updateUserInfo($req);
|
|
|
+ UserProc::updateUserInfo($req); // 5.回写数据
|
|
|
$ret = array('resp' => "succeed!");
|
|
|
- $resp = Resp::ok($ret); //返回必须是object
|
|
|
- StoreProc::CheckItemNum($req);
|
|
|
+ $resp = Resp::ok($ret); // 返回
|
|
|
+// StoreProc::CheckItemNum($req);
|
|
|
return $resp;
|
|
|
}
|
|
|
|
|
|
- ///给英雄穿装备
|
|
|
+ /**
|
|
|
+ * [6411] 给英雄脱装备
|
|
|
+ * @param req $req
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
static function UnWieldEquip($req) {
|
|
|
- $user = $req->userInfo->game; # user引用
|
|
|
- $itemtype = $req->paras[0]; //装备类型
|
|
|
- $equipuid = $req->paras[1]; //装备的UID
|
|
|
- $herouid = $req->paras[2]; //拥有该装备的英雄的UID
|
|
|
- echo "开始进去";
|
|
|
- //1.检测是否存在拥有该装备的英雄
|
|
|
+ $user = $req->userInfo->game; # user引用
|
|
|
+ list($itemtype, $equipuid, $herouid) = $req->pars; # 提取参数: 装备类型, 装备的UID, 拥有该装备的英雄的UID
|
|
|
|
|
|
$collectHeros = $user->heros->collectHeros;
|
|
|
if (!$collectHeros) {
|
|
|
- $collectHeros = ObjectInit();
|
|
|
+ Err(ErrCode::err_innerfault);
|
|
|
}
|
|
|
-
|
|
|
- if (!CommUtil::isPropertyExists($collectHeros, $herouid)) {
|
|
|
+ if (!CommUtil::isPropertyExists($collectHeros, $herouid)) { // 1.检测是否存在拥有该装备的英雄
|
|
|
Err(ErrCode::hero_no);
|
|
|
}
|
|
|
-
|
|
|
- //2.检测该装备是否装备在该英雄身上
|
|
|
-
|
|
|
- if ($itemtype == 1) {
|
|
|
- if ($collectHeros->$herouid->equip->weapon->itemuid != $equipuid) {
|
|
|
- Err(ErrCode::store_noequip_err);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if ($itemtype == 2) {
|
|
|
- if ($collectHeros->$herouid->equip->armor->itemuid != $equipuid) {
|
|
|
- Err(ErrCode::store_noequip_err);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if ($itemtype == 3) {
|
|
|
- if ($collectHeros->$herouid->equip->ring->itemuid != $equipuid) {
|
|
|
- Err(ErrCode::store_noequip_err);
|
|
|
- }
|
|
|
- }
|
|
|
- ///4.卸下英雄该部位的装备
|
|
|
- if ($itemtype == 1) {
|
|
|
- $collectHeros->$herouid->equip->weapon->itemuid = 0;
|
|
|
- }
|
|
|
- if ($itemtype == 2) {
|
|
|
- $collectHeros->$herouid->equip->armor->itemuid = 0;
|
|
|
- }
|
|
|
- if ($itemtype == 3) {
|
|
|
- $collectHeros->$herouid->equip->ring->itemuid = 0;
|
|
|
+ switch ($itemtype) { // 2.检测该装备是否装备在该英雄身上
|
|
|
+ case 1: # 武器
|
|
|
+ if ($collectHeros->$herouid->equip->weapon->itemuid != $equipuid) {
|
|
|
+ Err(ErrCode::store_noequip_err);
|
|
|
+ }
|
|
|
+ $collectHeros->$herouid->equip->weapon->itemuid = 0; // 卸下
|
|
|
+ break;
|
|
|
+ case 2: # 防具
|
|
|
+ if ($collectHeros->$herouid->equip->armor->itemuid != $equipuid) {
|
|
|
+ Err(ErrCode::store_noequip_err);
|
|
|
+ }
|
|
|
+ $collectHeros->$herouid->equip->armor->itemuid = 0;
|
|
|
+ break;
|
|
|
+ case 3: # 饰品
|
|
|
+ if ($collectHeros->$herouid->equip->ring->itemuid != $equipuid) {
|
|
|
+ Err(ErrCode::store_noequip_err);
|
|
|
+ }
|
|
|
+ $collectHeros->$herouid->equip->ring->itemuid = 0;
|
|
|
+ break;
|
|
|
+ default :
|
|
|
+ Err(ErrCode::store_equip_type);
|
|
|
}
|
|
|
-
|
|
|
- //5.回写数据
|
|
|
- UserProc::updateUserInfo($req);
|
|
|
+ UserProc::updateUserInfo($req); # 5.回写数据
|
|
|
$ret = array('resp' => "succeed!");
|
|
|
- $resp = Resp::ok($ret); //返回必须是object
|
|
|
- StoreProc::CheckItemNum($req);
|
|
|
+ $resp = Resp::ok($ret); // 返回
|
|
|
+// StoreProc::CheckItemNum($req);
|
|
|
return $resp;
|
|
|
}
|
|
|
|