|
@@ -52,11 +52,205 @@ class StoreProc {
|
|
|
return StoreProc::RemoveEquip();
|
|
|
case CmdCode::store_equip_gemSlotBuy: # 6416 购买装备宝石槽
|
|
|
return StoreProc::Gem_BuySlot();
|
|
|
+ case CmdCode::store_equip_compose: # 6417 装备合成
|
|
|
+ return StoreProc::Equip_Compose();
|
|
|
+ case CmdCode::store_equip_OnekeyCompose: # 6418 装备一键合成
|
|
|
+ return StoreProc::Equip_OnekeyCompose();
|
|
|
default:
|
|
|
Err(ErrCode::cmd_err);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 6417 装备合成
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
+ public static function Equip_Compose() {
|
|
|
+ list($uid, $equipUids_cost) = req()->paras;
|
|
|
+
|
|
|
+ $equipDic = ctx()->store->equip;
|
|
|
+ my_Assert(StlUtil::dictHasProperty($equipDic, $uid), ErrCode::user_store_NotExistEquip);
|
|
|
+ $ins_equip = new Ins_Equip($equipDic->$uid);
|
|
|
+
|
|
|
+ $composeMo = GameConfig::equip_compose_getItem($ins_equip->qual);
|
|
|
+ my_Assert(null != $composeMo, ErrCode::err_const_no);
|
|
|
+ $arr = explode(',', $composeMo->compose_condition);
|
|
|
+
|
|
|
+ $type = $arr[0];
|
|
|
+ $costQual = $arr[1];
|
|
|
+ $num = $arr[2];
|
|
|
+ $costEquipsArr = explode(',', $equipUids_cost);
|
|
|
+ my_Assert(count($costEquipsArr) == $num, ErrCode::user_store_equipMaterialNumErr);
|
|
|
+ foreach ($costEquipsArr as $eqUid) {
|
|
|
+ my_Assert(StlUtil::dictHasProperty($equipDic, $eqUid), ErrCode::user_store_NotExistEquip);
|
|
|
+
|
|
|
+ $costIns_Equip = new Ins_Equip($equipDic->$eqUid);
|
|
|
+ my_Assert($costIns_Equip->qual == $costQual, ErrCode::user_store_equipMaterialQualErr);
|
|
|
+ if ($type == 1) {//本体
|
|
|
+ my_Assert($costIns_Equip->typeId == $ins_equip->typeId, ErrCode::user_store_equipMaterialTypeErr);
|
|
|
+ } else {
|
|
|
+ my_Assert($costIns_Equip->mo()->position == $ins_equip->mo()->position, ErrCode::user_store_equipMaterialTypeErr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ctx()->store(true)->equip->$uid = self::ComposeNewEquip($ins_equip);
|
|
|
+
|
|
|
+ //消耗的装备 回收
|
|
|
+ foreach ($costEquipsArr as $eqUid) {
|
|
|
+ $costIns_Equip = new Ins_Equip($equipDic->$eqUid);
|
|
|
+ self::equipLevelUp_Material_Recovery($costIns_Equip->mo()->rarity, $costIns_Equip->qual, $costIns_Equip->mo()->position, $costIns_Equip->level);
|
|
|
+ StlUtil::dictRemove(ctx()->store(true)->equip, $eqUid);
|
|
|
+ }
|
|
|
+
|
|
|
+ UserProc::updateUserInfo();
|
|
|
+ return Resp::ok(array(
|
|
|
+ 'gold' => ctx()->baseInfo->gold,
|
|
|
+ 'store' => ctx()->store,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 装备等级提升 消耗的金币图纸回收
|
|
|
+ * @param type $rarity
|
|
|
+ * @param type $qual
|
|
|
+ * @param type $posId
|
|
|
+ * @param type $level
|
|
|
+ */
|
|
|
+ public static function equipLevelUp_Material_Recovery($rarity, $qual, $posId, $level) {
|
|
|
+ $gold = 0;
|
|
|
+ $tuzhi = 0;
|
|
|
+
|
|
|
+ $tuzhiId = GameConfig::equip_position_getItem($posId)->costTuzhiId;
|
|
|
+ for ($i = 1; $i <= $level - 1; $i++) {
|
|
|
+ $mo = GameConfig::equip_levelupgrade_getItem($rarity, $qual, $posId, $i);
|
|
|
+ $gold += $mo->needGold;
|
|
|
+ $tuzhi += $mo->needItemNum;
|
|
|
+ }
|
|
|
+ if ($gold > 0) {
|
|
|
+ StoreProc::AddMultiItemInStore("1," . $gold);
|
|
|
+ StoreProc::AddMultiItemInStore($tuzhiId . ',' . $tuzhi);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 合成一个新的装备
|
|
|
+ * @param type Ins_Equip
|
|
|
+ */
|
|
|
+ public static function ComposeNewEquip(&$ins_equip) {
|
|
|
+ $newEquipTypeId = $ins_equip->typeId;
|
|
|
+ $qual = $ins_equip->qual + 1;
|
|
|
+ if ($ins_equip->qual < 4) {
|
|
|
+ $newEquipTypeId = substr($ins_equip->typeId, 0, strlen($ins_equip->typeId) - 6);
|
|
|
+ $qual = GameConfig::equip_compose_getItem($newEquipTypeId)->qual;
|
|
|
+ }
|
|
|
+
|
|
|
+ $ins_equip->typeId = $newEquipTypeId;
|
|
|
+ $ins_equip->qual = $qual;
|
|
|
+
|
|
|
+ return $ins_equip;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function initEquip($typeId, $uid = 0) {
|
|
|
+ if ($uid == 0) {
|
|
|
+ $uid = count((array) ctx()->store->equip) + 1;
|
|
|
+ }
|
|
|
+ $ins_equip = new Ins_Equip();
|
|
|
+ $ins_equip->uid = $uid;
|
|
|
+ $ins_equip->typeId = $typeId;
|
|
|
+ $ins_equip->qual = GameConfig::equip_compose_getItem($typeId)->qual;
|
|
|
+ return $ins_equip;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 6418 装备一键合成
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
+ public static function Equip_OnekeyCompose() {
|
|
|
+ list() = req()->paras;
|
|
|
+
|
|
|
+ $equipDic = ctx()->store->equip;
|
|
|
+ $arr = array();
|
|
|
+ foreach ($equipDic as $uid => $equip) {
|
|
|
+ $ins_equip = new Ins_Equip($equip);
|
|
|
+ if ($ins_equip->qual > 4) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $arr[] = $ins_equip;
|
|
|
+ }
|
|
|
+//等级从大到小
|
|
|
+ $len = count($arr);
|
|
|
+ for ($i = 0; $i < $len - 1; $i++) {
|
|
|
+ for ($j = $len - 1; $j > $i; $j--) {
|
|
|
+ if ($arr[$j]->level > $arr[$j - 1]->level) {
|
|
|
+ $temp = $arr[$j];
|
|
|
+ $arr[$j] = $arr[$j - 1];
|
|
|
+ $arr[$j - 1] = $temp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $composeEquip = array();
|
|
|
+
|
|
|
+ if ($len > 0) {
|
|
|
+ while (true) {
|
|
|
+ $equip_compose = $arr[0];
|
|
|
+ $str = explode(',', GameConfig::equip_compose_getItem($equip_compose->qual)->compose_condition);
|
|
|
+ $type = $str[0];
|
|
|
+ $costQual = $str[1];
|
|
|
+ $num = $str[2];
|
|
|
+
|
|
|
+ $n = count($arr);
|
|
|
+ $composeArr = array();
|
|
|
+ $tag = false;
|
|
|
+
|
|
|
+ $ing_compose = false;
|
|
|
+ for ($k = $n - 1; $k >= 0; $k--) {
|
|
|
+ if ($arr[$k]->uid == $equip_compose->uid) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ($type == 1 && $arr[$k]->qual == $costQual && $arr[$k]->typeId == $equip_compose->typeId) {
|
|
|
+ $tag = true;
|
|
|
+ } else if ($type == 2 && $arr[$k]->qual == $costQual && $arr[$k]->mo()->position == $equip_compose->mo()->position) {
|
|
|
+ $tag = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($tag) {
|
|
|
+ $composeArr[] = $arr[$k];
|
|
|
+ if (count($composeArr) >= $num) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(count($composeArr) >= $num){
|
|
|
+ $newEquip = self::ComposeNewEquip($equip_compose);
|
|
|
+ $uid = $newEquip->uid;
|
|
|
+ ctx()->store(true)->equip->$uid = $newEquip;
|
|
|
+ $composeEquip[] = $uid;
|
|
|
+ $ing_compose = true;
|
|
|
+ }
|
|
|
+ //合成的 材料不够不能合成的都要删除
|
|
|
+ foreach ($composeArr as $val) {
|
|
|
+ if($ing_compose){//合成的回收 不合成的可不能给回收了
|
|
|
+ self::equipLevelUp_Material_Recovery($val->mo()->rarity, $val->qual,$val->mo()->position, $val->level);
|
|
|
+ }
|
|
|
+ StlUtil::arrayRemove($arr, $val);
|
|
|
+ }
|
|
|
+ StlUtil::arrayRemove($arr, $equip_compose);
|
|
|
+ if (count($arr) <= 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ UserProc::updateUserInfo();
|
|
|
+ return Resp::ok(array(
|
|
|
+ 'gold' => ctx()->baseInfo->gold,
|
|
|
+ 'store' => ctx()->store,
|
|
|
+ 'composeEquip'=>$composeEquip,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 6416 购买装备宝石槽
|
|
|
* @return type
|
|
@@ -91,7 +285,6 @@ class StoreProc {
|
|
|
ctx()->store(true)->equip->$uid = $ins_equip;
|
|
|
|
|
|
UserProc::updateUserInfo();
|
|
|
-
|
|
|
return Resp::ok(array(
|
|
|
'cash' => ctx()->baseInfo->cash,
|
|
|
'store' => ctx()->store,
|
|
@@ -414,23 +607,23 @@ class StoreProc {
|
|
|
$isCompose = false;
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
- if(!self::GemIsCanCompose($gemUid)){
|
|
|
+
|
|
|
+ if (!self::GemIsCanCompose($gemUid)) {
|
|
|
$isCompose = false;
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
my_Assert($isCompose == true, ErrCode::user_store_GemCanotCompose);
|
|
|
-
|
|
|
- foreach ($gem_composeCost as $gemUid) {
|
|
|
- self::RemoveGemInStore($gemUid);
|
|
|
+
|
|
|
+ foreach ($gem_composeCost as $gemUid) {
|
|
|
+ self::RemoveGemInStore($gemUid);
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($gem_composeIds as $gemTypeId) {
|
|
|
+ $composeGem = self::initGem($gemTypeId);
|
|
|
+ self::PutGemInStore($composeGem);
|
|
|
+ $composeArr[] = $composeGem->uid; //临时放这
|
|
|
}
|
|
|
-
|
|
|
- foreach ($gem_composeIds as $gemTypeId) {
|
|
|
- $composeGem = self::initGem($gemTypeId);
|
|
|
- self::PutGemInStore($composeGem);
|
|
|
- $composeArr[] = $composeGem->uid; //临时放这
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
TaskProc::OnComposeNumGem();
|
|
@@ -449,26 +642,26 @@ class StoreProc {
|
|
|
* @param type $uid
|
|
|
* @return bool
|
|
|
*/
|
|
|
- private static function GemIsCanCompose($uid) {
|
|
|
+ private static function GemIsCanCompose($uid) {
|
|
|
$ins_gem = new Ins_Gem($uid);
|
|
|
- if($ins_gem->isUnlock == 1){
|
|
|
+ if ($ins_gem->isUnlock == 1) {
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$isExist = true;
|
|
|
$equip = ctx()->store->equip;
|
|
|
- foreach ($equip as $uid => $item) {
|
|
|
+ foreach ($equip as $uid => $item) {
|
|
|
$arr = get_object_vars($item->gemSetSlot);
|
|
|
$values = array_values($arr);
|
|
|
- if(in_array($uid, $values)){
|
|
|
+ if (in_array($uid, $values)) {
|
|
|
$isExist = false;
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return $isExist;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 装备宝石
|
|
|
* @return type
|