|
@@ -221,14 +221,137 @@ class StoreProc {
|
|
list($gemIds) = req()->paras;
|
|
list($gemIds) = req()->paras;
|
|
$user = ctx();
|
|
$user = ctx();
|
|
|
|
|
|
|
|
+ //做校验
|
|
|
|
+ $composeArr = array();
|
|
|
|
+ $list = explode(';', $gemIds);
|
|
|
|
+ krsort($list);
|
|
|
|
+
|
|
|
|
|
|
|
|
+ foreach ($list as $str) {
|
|
|
|
+ $gemUidList = explode(',', $str);
|
|
|
|
+ $firstGemUId = $gemUidList[0];
|
|
|
|
+ $qual = 0;
|
|
|
|
+ $posId = 0;
|
|
|
|
+ if(StlUtil::dictHasProperty($user->store->gemStore, $gemUidList[0])){
|
|
|
|
+ $ins_gem = $user->store->gemStore->$firstGemUId;
|
|
|
|
+ $qual = $ins_gem->mo()->qual;
|
|
|
|
+ $posId = $ins_gem->mo()->position;
|
|
|
|
+ }
|
|
|
|
+ //查找要合成的宝石配置信息
|
|
|
|
+ $gemConf = self::GemComposeSynthesis($qual, $posId);
|
|
|
|
+ $synthesisList = explode('_', $gemConf->synthesis);
|
|
|
|
+ $composePosition = $synthesisList[0];
|
|
|
|
+ $composeQual = $synthesisList[1];
|
|
|
|
+ $composeNum = $synthesisList[2];
|
|
|
|
+
|
|
|
|
+ foreach ($composeArr as $val) {
|
|
|
|
+ if($val->mo()->qual == $composeQual && $val->mo()->position == $composePosition){
|
|
|
|
+ $gemUidList[] = $val->uid;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(count($gemUidList) >= $composeNum){
|
|
|
|
+ if($gemConf != null){
|
|
|
|
+ $maxGemNum = intval(count($gemUidList) / $composeNum);
|
|
|
|
+ $index = 0;
|
|
|
|
+ $res = 0;
|
|
|
|
+ foreach ($gemUidList as $uid) {
|
|
|
|
+ my_Assert(self::GemIsCanCompose($uid) == false && $user->store->gemStore->$uid->isUnlock == 0, ErrCode::user_store_GemCanotCompose);
|
|
|
|
+
|
|
|
|
+ $index += 1;
|
|
|
|
+ self::RemoveGemInStore($uid);
|
|
|
|
+ //$composeArr 有的话删除
|
|
|
|
+ for ($i = 0; $i < count($composeArr); $i++) {
|
|
|
|
+ if($composeArr[$i]->uid == $uid){
|
|
|
|
+ StlUtil::arrayRemoveAt($composeArr, $i);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($index % $composeNum == 0){
|
|
|
|
+ $res +=1;
|
|
|
|
+ $composeGem = self::initGem($gemConf->typeId);
|
|
|
|
+ self::PutGemInStore2($composeGem,$maxGemNum);
|
|
|
|
+ $composeArr[] = $composeGem;//临时放这
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($res >= $maxGemNum){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ $resultArr = array();
|
|
|
|
+ foreach ($composeArr as $value) {
|
|
|
|
+ $resultArr[] = $value->uid;
|
|
|
|
+ }
|
|
|
|
|
|
- //my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);
|
|
|
|
|
|
+ krsort($resultArr);
|
|
|
|
+ ctx($user);
|
|
UserProc::updateUserInfo();
|
|
UserProc::updateUserInfo();
|
|
- return Resp::ok(array(
|
|
|
|
- 'gold' => $user->baseInfo->gold,
|
|
|
|
|
|
+ return Resp::ok(array(
|
|
|
|
+ 'composeGemIds' => $resultArr,
|
|
'store' => $user->store,));
|
|
'store' => $user->store,));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 该宝石是否可以参与合成,其他页镶嵌的,已经被锁的都不能参与
|
|
|
|
+ * @param type $uid
|
|
|
|
+ * @return bool
|
|
|
|
+ */
|
|
|
|
+ private static function GemIsCanCompose($uid) {
|
|
|
|
+ $Ins_gemItem = ctx()->store->gemStore->$uid;
|
|
|
|
+
|
|
|
|
+ $equipGemDic = ctx()->store->gemEquip;
|
|
|
|
+ $equipPag = ctx()->store->equipPag;
|
|
|
|
+
|
|
|
|
+ $isExist = false;
|
|
|
|
+ foreach ($equipGemDic as $pag => $dic) {
|
|
|
|
+ if($equipPag == $pag){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if(StlUtil::dictHasProperty($dic, $Ins_gemItem->mo()->position)){
|
|
|
|
+ $posId = $Ins_gemItem->mo()->position;
|
|
|
|
+ $tDic = $dic->$posId;
|
|
|
|
+ foreach ($tDic as $index => $ins_gem) {
|
|
|
|
+ if($ins_gem->uid == $Ins_gemItem->uid){
|
|
|
|
+ $isExist = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ($isExist)
|
|
|
|
+ {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $isExist;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static function GemComposeSynthesis($qual,$posId) {
|
|
|
|
+ $gem = GameConfig::gem();
|
|
|
|
+ foreach ($gem as $key => $value) {
|
|
|
|
+ if($value->synthesis != null){
|
|
|
|
+ $synthesisList = explode('_', $value->synthesis);
|
|
|
|
+ $composePosition = $synthesisList[0];
|
|
|
|
+ $composeQual = $synthesisList[1];
|
|
|
|
+ $composeNum = $synthesisList[2];
|
|
|
|
+
|
|
|
|
+ if($composeQual != 0 && $composePosition != 0 && $composeQual== $qual && $posId == $composePosition){
|
|
|
|
+ return $value;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 装备宝石
|
|
* 装备宝石
|
|
@@ -545,24 +668,49 @@ class StoreProc {
|
|
/**
|
|
/**
|
|
* 新宝石入库
|
|
* 新宝石入库
|
|
*/
|
|
*/
|
|
- public static function PutGemInStore($id,$num) {
|
|
|
|
- $length = ctx()->store->gemLength;
|
|
|
|
-
|
|
|
|
|
|
+ public static function PutGemInStore($id,$num) {
|
|
for ($i = 0; $i < $num; $i++) {
|
|
for ($i = 0; $i < $num; $i++) {
|
|
- $length +=1;
|
|
|
|
- $gem = new Ins_Gem();
|
|
|
|
- $gem->uid = $length;
|
|
|
|
- $gem->typeId = $id;
|
|
|
|
- $gem->predicateId = self::RandomGemPredicateId($id);
|
|
|
|
- $tag = self::CheckNewGemTip($gem);
|
|
|
|
- $gem->isNew = $tag;
|
|
|
|
-
|
|
|
|
|
|
+ $gem = self::initGem($id);
|
|
|
|
+ $length = $gem->uid;
|
|
ctx()->store->gemStore->$length = $gem;
|
|
ctx()->store->gemStore->$length = $gem;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function PutGemInStore2($gem,$num) {
|
|
|
|
+ for ($i = 0; $i < $num; $i++) {
|
|
|
|
+ $length = $gem->uid;
|
|
|
|
+ ctx()->store->gemStore->$length = $gem;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function initGem($id) {
|
|
|
|
+ $length = ctx()->store->gemLength;
|
|
|
|
+ $length +=1;
|
|
|
|
+ $gem = new Ins_Gem();
|
|
|
|
+ $gem->uid = $length;
|
|
|
|
+ $gem->typeId = $id;
|
|
|
|
+ $gem->predicateId = self::RandomGemPredicateId($id);
|
|
|
|
+ $tag = self::CheckNewGemTip($gem);
|
|
|
|
+ $gem->isNew = $tag;
|
|
|
|
+
|
|
ctx()->store->gemLength = $length;
|
|
ctx()->store->gemLength = $length;
|
|
|
|
+
|
|
|
|
+ return $gem;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 从仓库移除宝石
|
|
|
|
+ */
|
|
|
|
+ public static function RemoveGemInStore($uid) {
|
|
|
|
+ if(StlUtil::dictHasProperty(ctx()->store->gemStore, $uid)){
|
|
|
|
+ StlUtil::dictRemove(ctx()->store->gemStore, $uid);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 新宝石随机词条 临时等刚哥
|
|
* 新宝石随机词条 临时等刚哥
|
|
*/
|
|
*/
|