|
@@ -33,22 +33,22 @@ class StoreProc {
|
|
|
case CmdCode::cmd_store_equipUpgrade_MaxLv: # 6405 一键升级(装备)
|
|
|
return StoreProc::equipUpgrade_MaxLv();
|
|
|
case CmdCode::store_gemCompose: # 6406 宝石合成
|
|
|
- return StoreProc::gemCompose();
|
|
|
+ return StoreProc::gemCompose();
|
|
|
case CmdCode::store_switchEquipPag: # 6408 切换装备分页
|
|
|
return StoreProc::switchEquipPag();
|
|
|
case CmdCode::store_gemLockState: # 6409 宝石开锁解锁
|
|
|
return StoreProc::gemLockState();
|
|
|
case CmdCode::store_equip_removeEquipUpgradeTip: # 6410 移除装备可以升级绿点提示
|
|
|
- return StoreProc::removeEquipUpgradeTip();
|
|
|
+ return StoreProc::removeEquipUpgradeTip();
|
|
|
case CmdCode::store_equip_removeNewGemTip: # 6411 移除是新宝石绿点提示
|
|
|
- return StoreProc::removeNewGemTip();
|
|
|
+ return StoreProc::removeNewGemTip();
|
|
|
case CmdCode::store_allEquipUpgrade: # 6412 所有装备的一键升级
|
|
|
- return StoreProc::allEquipUpgrade();
|
|
|
+ return StoreProc::allEquipUpgrade();
|
|
|
default:
|
|
|
Err(ErrCode::cmd_err);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 宝石开锁解锁
|
|
|
* @return Resp
|
|
@@ -56,34 +56,34 @@ class StoreProc {
|
|
|
public static function gemLockState() {
|
|
|
list($uid) = req()->paras;
|
|
|
$user = ctx();
|
|
|
-
|
|
|
+
|
|
|
//把 qual pos u一样的宝石开锁关锁
|
|
|
- $gemStore = $user->store->gemStore;
|
|
|
+ $gemStore = $user->store->gemStore;
|
|
|
$gem = $gemStore->$uid;
|
|
|
- $tag = 0;
|
|
|
- if($gem->isUnlock == 0){
|
|
|
+ $tag = 0;
|
|
|
+ if ($gem->isUnlock == 0) {
|
|
|
$gem->isUnlock = 1;
|
|
|
$tag = 1;
|
|
|
} else {
|
|
|
- $gem->isUnlock = 0;
|
|
|
+ $gem->isUnlock = 0;
|
|
|
$tag = 0;
|
|
|
}
|
|
|
- $gemStore->$uid = $gem;
|
|
|
+ $gemStore->$uid = $gem;
|
|
|
foreach ($gemStore as $k => $ins_gem) {
|
|
|
- if($ins_gem->typeId ==$gem->typeId && $ins_gem->predicateId == $gem->predicateId){
|
|
|
+ if ($ins_gem->typeId == $gem->typeId && $ins_gem->predicateId == $gem->predicateId) {
|
|
|
$gemStore->$k->isUnlock = $tag;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
- $user->store->gemStore = $gemStore;
|
|
|
-
|
|
|
+ $user->store->gemStore = $gemStore;
|
|
|
+
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
return Resp::ok(array(
|
|
|
- 'gold'=>0,
|
|
|
- 'store' => $user->store,
|
|
|
+ 'gold' => 0,
|
|
|
+ 'store' => $user->store,
|
|
|
));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 切换装备分页
|
|
|
* @return Resp
|
|
@@ -91,14 +91,14 @@ class StoreProc {
|
|
|
public static function switchEquipPag() {
|
|
|
list($index) = req()->paras;
|
|
|
$user = ctx();
|
|
|
-
|
|
|
+
|
|
|
$user->store->equipPag = $index;
|
|
|
-
|
|
|
+
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
return Resp::ok(array());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 所有装备的一键升级
|
|
|
* 规则:等级不同从等级小到大,等级一样按照部位顺序
|
|
@@ -110,104 +110,101 @@ class StoreProc {
|
|
|
$user = ctx();
|
|
|
|
|
|
$equipDic = $user->store->equip;
|
|
|
-
|
|
|
+
|
|
|
$arr = array();
|
|
|
- if($equipDic != null){
|
|
|
+ if ($equipDic != null) {
|
|
|
foreach ($equipDic as $k => &$equip) {
|
|
|
$equip = new Ins_Equip($equip);
|
|
|
-
|
|
|
+
|
|
|
$lvMo = GameConfig::equip_levelupgrade_getItem($equip->level);
|
|
|
$needGold = $lvMo->needGold;
|
|
|
$needItemNum = $lvMo->needItemNum;
|
|
|
$neeItemId = $equip->mo()->costTuzhiId;
|
|
|
-
|
|
|
- if($user->baseInfo->gold >= $needGold && StlUtil::dictHasProperty($user->store->items, $neeItemId) && $user->store->items->$neeItemId >= $needItemNum){
|
|
|
+
|
|
|
+ if ($user->baseInfo->gold >= $needGold && StlUtil::dictHasProperty($user->store->items, $neeItemId) && $user->store->items->$neeItemId >= $needItemNum) {
|
|
|
$arr[] = $equip;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if(count($arr) > 0){
|
|
|
+
|
|
|
+ if (count($arr) > 0) {
|
|
|
//进行排序
|
|
|
$len = count($arr);
|
|
|
- for($i = 0; $i < $len - 1; $i++){
|
|
|
- for($j = 0; $j < $len -$i - 1; $j++){
|
|
|
- if($arr[$j]->level > $arr[$j+1]->level){//从小到大
|
|
|
+ for ($i = 0; $i < $len - 1; $i++) {
|
|
|
+ for ($j = 0; $j < $len - $i - 1; $j++) {
|
|
|
+ if ($arr[$j]->level > $arr[$j + 1]->level) {//从小到大
|
|
|
$temp = $arr[$j];
|
|
|
- $arr[$j] = $arr[$j+1];
|
|
|
- $arr[$j+1] = $temp;
|
|
|
- } elseif ($arr[$j]->level == $arr[$j+1]->level) {
|
|
|
+ $arr[$j] = $arr[$j + 1];
|
|
|
+ $arr[$j + 1] = $temp;
|
|
|
+ } elseif ($arr[$j]->level == $arr[$j + 1]->level) {
|
|
|
$j_equip = new Ins_Equip($arr[$j]);
|
|
|
- $jj_equip = new Ins_Equip($arr[$j+1]);
|
|
|
- if($j_equip->mo()->position > $jj_equip->mo()->position){
|
|
|
+ $jj_equip = new Ins_Equip($arr[$j + 1]);
|
|
|
+ if ($j_equip->mo()->position > $jj_equip->mo()->position) {
|
|
|
$temp = $arr[$j];
|
|
|
- $arr[$j] = $arr[$j+1];
|
|
|
- $arr[$j+1] = $temp;
|
|
|
+ $arr[$j] = $arr[$j + 1];
|
|
|
+ $arr[$j + 1] = $temp;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//升级,扣除金币和图纸
|
|
|
while (true) {
|
|
|
$tag = 9999;
|
|
|
- foreach ($arr as $index => &$equip) {
|
|
|
+ foreach ($arr as $index => &$equip) {
|
|
|
$ins_equip = new Ins_Equip($equip);
|
|
|
$lvMo = GameConfig::equip_levelupgrade_getItem($ins_equip->level);
|
|
|
$needGold = $lvMo->needGold;
|
|
|
$needItemNum = $lvMo->needItemNum;
|
|
|
$neeItemId = $ins_equip->mo()->costTuzhiId;
|
|
|
- if($user->baseInfo->gold >= $needGold && StlUtil::dictHasProperty($user->store->items, $neeItemId) && $user->store->items->$neeItemId >= $needItemNum){
|
|
|
- $id = $ins_equip->typeId;
|
|
|
+ if ($user->baseInfo->gold >= $needGold && StlUtil::dictHasProperty($user->store->items, $neeItemId) && $user->store->items->$neeItemId >= $needItemNum) {
|
|
|
+ $id = $ins_equip->typeId;
|
|
|
$ins_equip->level += 1;
|
|
|
- $equipDic->$id->level += 1;
|
|
|
+ $equipDic->$id->level += 1;
|
|
|
$user->baseInfo->Consume_Gold($needGold);
|
|
|
- $user->store->removeItem($neeItemId, $needItemNum);
|
|
|
- if($ins_equip->level >= 50){
|
|
|
+ $user->store->removeItem($neeItemId, $needItemNum);
|
|
|
+ if ($ins_equip->level >= 50) {
|
|
|
$tag = $index;
|
|
|
break;
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
$tag = $index;
|
|
|
- break;
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- if($tag != 9999){
|
|
|
- if(array_key_exists($tag, $arr)){
|
|
|
+
|
|
|
+ if ($tag != 9999) {
|
|
|
+ if (array_key_exists($tag, $arr)) {
|
|
|
StlUtil::arrayRemoveAt($arr, $tag);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- if(count($arr) <= 0){
|
|
|
+
|
|
|
+ if (count($arr) <= 0) {
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
return Resp::ok(array(
|
|
|
'gold' => $user->baseInfo->gold,
|
|
|
'store' => $user->store,));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 移除是新宝石绿点提示
|
|
|
* @return Resp
|
|
|
*/
|
|
|
public static function removeNewGemTip() {
|
|
|
- list($uid) = req()->paras;//宝石uid
|
|
|
+ list($uid) = req()->paras; //宝石uid
|
|
|
$user = ctx();
|
|
|
|
|
|
my_Assert(StlUtil::dictHasProperty($user->store->gemStore, $uid), ErrCode::user_store_NoItem);
|
|
|
-
|
|
|
+
|
|
|
//$ins_gem = new Ins_Gem($user->store->gemStore->$uid);
|
|
|
$user->store->gemStore->$uid->isNew = 0;
|
|
|
-
|
|
|
+
|
|
|
// $equipPag = $user->store->equipPag;
|
|
|
$typeId = $user->store->gemStore->$uid->typeId;
|
|
|
$mo = GameConfig::gem_getItem($typeId);
|
|
@@ -215,48 +212,47 @@ class StoreProc {
|
|
|
$position = $mo->position;
|
|
|
$gemEquip = $user->store->gemEquip;
|
|
|
//$tag = 0;
|
|
|
-
|
|
|
+
|
|
|
foreach ($gemEquip as $pag => $val) {
|
|
|
foreach ($val as $posId => $dic) {
|
|
|
- if($posId != $position){
|
|
|
+ if ($posId != $position) {
|
|
|
continue;
|
|
|
}
|
|
|
foreach ($dic as $index => $gem) {
|
|
|
- if($gem->uid == $uid){
|
|
|
+ if ($gem->uid == $uid) {
|
|
|
$user->store->gemEquip->$pag->$posId->$index->isNew = 0;
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
ctx($user);
|
|
|
- UserProc::updateUserInfo();
|
|
|
+ UserProc::updateUserInfo();
|
|
|
return Resp::ok(array(
|
|
|
'gold' => 0,
|
|
|
'store' => $user->store,));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 移除装备可以升级绿点提示
|
|
|
* @return Resp
|
|
|
*/
|
|
|
public static function removeEquipUpgradeTip() {
|
|
|
- list($posId) = req()->paras;//装备部位
|
|
|
+ list($posId) = req()->paras; //装备部位
|
|
|
$user = ctx();
|
|
|
-
|
|
|
+
|
|
|
my_Assert(StlUtil::dictHasProperty($user->store->equip, $posId), ErrCode::user_store_NoEquip);
|
|
|
-
|
|
|
+
|
|
|
$user->store->equip->$posId->tip = 0;
|
|
|
-
|
|
|
+
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
return Resp::ok(array(
|
|
|
'gold' => 0,
|
|
|
'store' => $user->store,));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 6406 合成
|
|
|
* @return type
|
|
@@ -267,100 +263,97 @@ class StoreProc {
|
|
|
|
|
|
//做校验
|
|
|
$composeArr = array();
|
|
|
-
|
|
|
+
|
|
|
//$gemIds = substr($gemIds, 0, -1);
|
|
|
$list = explode(';', $gemIds);
|
|
|
- krsort($list);
|
|
|
-
|
|
|
+ krsort($list);
|
|
|
+
|
|
|
foreach ($list as $str) {
|
|
|
- $str = substr($str, 0, -1);
|
|
|
- $gemUidList = explode(',', $str);
|
|
|
+ $str = substr($str, 0, -1);
|
|
|
+ $gemUidList = explode(',', $str);
|
|
|
$firstGemUId = $gemUidList[0];
|
|
|
$qual = 0;
|
|
|
$posId = 0;
|
|
|
- if(StlUtil::dictHasProperty($user->store->gemStore, $firstGemUId)){
|
|
|
+ if (StlUtil::dictHasProperty($user->store->gemStore, $firstGemUId)) {
|
|
|
$ins_gem = $user->store->gemStore->$firstGemUId;
|
|
|
$mo = GameConfig::gem_getItem($ins_gem->typeId);
|
|
|
$qual = $mo->qual;
|
|
|
$posId = $mo->position;
|
|
|
- }
|
|
|
+ }
|
|
|
$isCompose = true;
|
|
|
//在做一次校验
|
|
|
foreach ($gemUidList as $uid) {
|
|
|
- if(StlUtil::dictHasProperty($user->store->gemStore, $uid)){
|
|
|
+ if (StlUtil::dictHasProperty($user->store->gemStore, $uid)) {
|
|
|
$ins_gem = $user->store->gemStore->$uid;
|
|
|
$mo = GameConfig::gem_getItem($ins_gem->typeId);
|
|
|
-
|
|
|
- if($mo->qual != $qual || $mo->position != $posId){
|
|
|
+
|
|
|
+ if ($mo->qual != $qual || $mo->position != $posId) {
|
|
|
$isCompose = false;
|
|
|
break;
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
my_Assert($isCompose == true, ErrCode::user_store_GemCanotCompose);
|
|
|
-
|
|
|
+
|
|
|
//查找要合成的宝石配置信息
|
|
|
$gemConf = self::GemComposeSynthesis($qual, $posId);
|
|
|
my_Assert($gemConf != null, ErrCode::err_const_no);
|
|
|
$synthesisList = explode('_', $gemConf->synthesis);
|
|
|
$composePosition = $synthesisList[0];
|
|
|
$composeQual = $synthesisList[1];
|
|
|
- $composeNum = $synthesisList[2];
|
|
|
-
|
|
|
+ $composeNum = $synthesisList[2];
|
|
|
+
|
|
|
foreach ($composeArr as $val) {
|
|
|
$mo = GameConfig::gem_getItem($val->typeId);
|
|
|
- if($mo->qual == $composeQual && $mo->position == $composePosition){
|
|
|
+ if ($mo->qual == $composeQual && $mo->position == $composePosition) {
|
|
|
$gemUidList[] = $val->uid;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if(count($gemUidList) >= $composeNum){
|
|
|
- if($gemConf != null){
|
|
|
+
|
|
|
+ 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){
|
|
|
+ if ($composeArr[$i]->uid == $uid) {
|
|
|
StlUtil::arrayRemoveAt($composeArr, $i);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if($index % $composeNum == 0){
|
|
|
- $res +=1;
|
|
|
+
|
|
|
+ if ($index % $composeNum == 0) {
|
|
|
+ $res += 1;
|
|
|
$composeGem = self::initGem($gemConf->typeId);
|
|
|
self::PutGemInStore2($composeGem);
|
|
|
- $composeArr[] = $composeGem;//临时放这
|
|
|
+ $composeArr[] = $composeGem; //临时放这
|
|
|
}
|
|
|
-
|
|
|
- if($res >= $maxGemNum){
|
|
|
+
|
|
|
+ if ($res >= $maxGemNum) {
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
$resultArr = array();
|
|
|
foreach ($composeArr as $value) {
|
|
|
$resultArr[] = $value->uid;
|
|
|
}
|
|
|
|
|
|
- ctx($user);
|
|
|
+ ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
- return Resp::ok(array(
|
|
|
+ return Resp::ok(array(
|
|
|
'composeGemIds' => $resultArr,
|
|
|
'store' => $user->store,));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 该宝石是否可以参与合成,其他页镶嵌的,已经被锁的都不能参与
|
|
|
* @param type $uid
|
|
@@ -368,51 +361,49 @@ class StoreProc {
|
|
|
*/
|
|
|
private static function GemIsCanCompose($uid) {
|
|
|
$Ins_gemItem = new Ins_Gem(ctx()->store->gemStore->$uid);
|
|
|
-
|
|
|
+
|
|
|
$equipGemDic = ctx()->store->gemEquip;
|
|
|
$equipPag = ctx()->store->equipPag;
|
|
|
-
|
|
|
+
|
|
|
$isExist = false;
|
|
|
foreach ($equipGemDic as $pag => $dic) {
|
|
|
- if($equipPag == $pag){
|
|
|
+ if ($equipPag == $pag) {
|
|
|
continue;
|
|
|
}
|
|
|
- if(StlUtil::dictHasProperty($dic, $Ins_gemItem->mo()->position)){
|
|
|
+ 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){
|
|
|
+ if ($ins_gem->uid == $Ins_gemItem->uid) {
|
|
|
$isExist = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if ($isExist)
|
|
|
- {
|
|
|
+
|
|
|
+ if ($isExist) {
|
|
|
break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return $isExist;
|
|
|
}
|
|
|
-
|
|
|
- private static function GemComposeSynthesis($qual,$posId) {
|
|
|
+
|
|
|
+ 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;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
@@ -421,33 +412,33 @@ class StoreProc {
|
|
|
* @return type
|
|
|
*/
|
|
|
public static function gemSet() {
|
|
|
- list($uid,$type,$replaceUId) = req()->paras;//宝石uid 手动的时候记得校验u
|
|
|
+ list($uid, $type, $replaceUId) = req()->paras; //宝石uid 手动的时候记得校验u
|
|
|
$user = ctx();
|
|
|
|
|
|
my_Assert(StlUtil::dictHasProperty($user->store->gemStore, $uid), ErrCode::user_store_NoItem);
|
|
|
$ins_gem = new Ins_Gem($user->store->gemStore->$uid);
|
|
|
-
|
|
|
+
|
|
|
$pag = $user->store->equipPag;
|
|
|
$posId = $ins_gem->mo()->position;
|
|
|
- $dic = $user->store->gemEquip->$pag->$posId;
|
|
|
-
|
|
|
+ $dic = $user->store->gemEquip->$pag->$posId;
|
|
|
+
|
|
|
$tag_index = 0;
|
|
|
$tag_gem = null;
|
|
|
foreach ($dic as $index => &$gem) {
|
|
|
$gem = new Ins_Gem($gem);
|
|
|
- if($gem->predicateMo()->uniqueKey == $ins_gem->predicateMo()->uniqueKey){
|
|
|
+ if ($gem->predicateMo()->uniqueKey == $ins_gem->predicateMo()->uniqueKey) {
|
|
|
$tag_index = $index;
|
|
|
$tag_gem = $gem;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
switch ($type) {
|
|
|
case 1://镶嵌
|
|
|
my_Assert($tag_gem == null, ErrCode::user_store_GemCanotSet);
|
|
|
- for ($i = 1; $i <=5; $i++) {
|
|
|
- if(!StlUtil::dictHasProperty($dic, $i)){
|
|
|
- $dic->$i = $ins_gem;
|
|
|
+ for ($i = 1; $i <= 5; $i++) {
|
|
|
+ if (!StlUtil::dictHasProperty($dic, $i)) {
|
|
|
+ $dic->$i = $ins_gem;
|
|
|
//StlUtil::dictRemove($user->store->gemStore, $uid);
|
|
|
break;
|
|
|
}
|
|
@@ -458,9 +449,9 @@ class StoreProc {
|
|
|
//满不满都高替低品阶
|
|
|
my_Assert(StlUtil::dictHasProperty($dic, $replaceUId), ErrCode::user_store_NoExistGemReplace);
|
|
|
$replace_ins_Gem = new Ins_Gem($dic->$replaceUId); //这个uid是5个坑位的index id
|
|
|
- my_Assert($replace_ins_Gem->mo()->qual < $ins_gem->mo()->qual, ErrCode::user_store_NoExistGemReplace);
|
|
|
+ my_Assert($replace_ins_Gem->mo()->qual < $ins_gem->mo()->qual, ErrCode::user_store_NoExistGemReplace);
|
|
|
$dic->$replaceUId = $ins_gem;
|
|
|
-
|
|
|
+
|
|
|
// $id = $replace_ins_Gem->uid;
|
|
|
// $user->store->gemStore->$id = $replace_ins_Gem;
|
|
|
// $dic->$replaceUId = $ins_gem;
|
|
@@ -468,19 +459,19 @@ class StoreProc {
|
|
|
//$user->store->gemEquip->$pag->$posId = $dic;
|
|
|
break;
|
|
|
case 3://手动
|
|
|
- my_Assert(count((array)$dic)>=5, ErrCode::user_store_GemCanotSet);
|
|
|
+ my_Assert(count((array) $dic) >= 5, ErrCode::user_store_GemCanotSet);
|
|
|
my_Assert(StlUtil::dictHasProperty($dic, $replaceUId), ErrCode::user_store_NoExistGemReplace);
|
|
|
$replace_ins_Gem = new Ins_Gem($dic->$replaceUId);
|
|
|
//$id = $replace_ins_Gem->uid;
|
|
|
- if($tag_gem != null){//如果有u那
|
|
|
+ if ($tag_gem != null) {//如果有u那
|
|
|
my_Assert($replace_ins_Gem->uid == $tag_gem->uid, ErrCode::user_store_SameGemCanotEquip); //点的不是u一样的,则提示同一件装备无法镶嵌多个技能相同的宝石 【错误】
|
|
|
//有U一样的,则点击正好是这个直接替换
|
|
|
//$user->store->gemStore->$id = $replace_ins_Gem;
|
|
|
- $dic->$replaceUId = $ins_gem;
|
|
|
+ $dic->$replaceUId = $ins_gem;
|
|
|
} else {
|
|
|
//$user->store->gemStore->$id = $replace_ins_Gem;
|
|
|
- $dic->$replaceUId = $ins_gem;
|
|
|
- }
|
|
|
+ $dic->$replaceUId = $ins_gem;
|
|
|
+ }
|
|
|
//StlUtil::dictRemove($user->store->gemStore, $uid);
|
|
|
break;
|
|
|
case 4://不能
|
|
@@ -490,13 +481,13 @@ class StoreProc {
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
- $user->store->gemEquip->$pag->$posId = $dic;
|
|
|
+
|
|
|
+ $user->store->gemEquip->$pag->$posId = $dic;
|
|
|
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
- return Resp::ok(array(
|
|
|
- 'gold'=>0,
|
|
|
+ return Resp::ok(array(
|
|
|
+ 'gold' => 0,
|
|
|
'store' => $user->store,));
|
|
|
}
|
|
|
|
|
@@ -505,35 +496,35 @@ class StoreProc {
|
|
|
* @return type
|
|
|
*/
|
|
|
public static function gemRemove() {
|
|
|
- list($uid) = req()->paras;//装备宝石id
|
|
|
+ list($uid) = req()->paras; //装备宝石id
|
|
|
$user = ctx();
|
|
|
-
|
|
|
+
|
|
|
$pag = $user->store->equipPag;
|
|
|
$posDic = $user->store->gemEquip->$pag;
|
|
|
-
|
|
|
+
|
|
|
$tag_pos = 0;
|
|
|
$tag_index = 0;
|
|
|
$tag_gem = null;
|
|
|
foreach ($posDic as $posId => $dic) {
|
|
|
foreach ($dic as $index => $gem) {
|
|
|
- if($gem->uid == $uid){
|
|
|
+ if ($gem->uid == $uid) {
|
|
|
$tag_pos = $posId;
|
|
|
$tag_index = $index;
|
|
|
$tag_gem = $gem;
|
|
|
break 2;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- if($tag_index >0 && $tag_gem != null){
|
|
|
- StlUtil::dictRemove($posDic->$tag_pos, $tag_index);
|
|
|
+
|
|
|
+ if ($tag_index > 0 && $tag_gem != null) {
|
|
|
+ StlUtil::dictRemove($posDic->$tag_pos, $tag_index);
|
|
|
$user->store->gemEquip->$pag = $posDic;
|
|
|
//$user->store->gemStore->$uid = $tag_gem;
|
|
|
}
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
- return Resp::ok(array(
|
|
|
- 'gold'=>0,
|
|
|
+ return Resp::ok(array(
|
|
|
+ 'gold' => 0,
|
|
|
'store' => $user->store,));
|
|
|
}
|
|
|
|
|
@@ -544,20 +535,20 @@ class StoreProc {
|
|
|
public static function equipUpgrade() {
|
|
|
list($posId) = req()->paras; //装备的部位id
|
|
|
$user = ctx();
|
|
|
-
|
|
|
+
|
|
|
$lv = $user->store->equip->$posId->level;
|
|
|
$mo = GameConfig::equip_levelupgrade_getItem($lv);
|
|
|
my_Assert($user->baseInfo->gold >= $mo->needGold, ErrCode::notenough_gold_msg);
|
|
|
$costTuzhiId = GameConfig::equip_getItem($posId)->costTuzhiId;
|
|
|
-
|
|
|
+
|
|
|
$tuzhiNum = 0;
|
|
|
- if(StlUtil::dictHasProperty($user->store->items, $costTuzhiId)){
|
|
|
+ if (StlUtil::dictHasProperty($user->store->items, $costTuzhiId)) {
|
|
|
$tuzhiNum = $user->store->items->$costTuzhiId;
|
|
|
- }
|
|
|
- my_Assert($tuzhiNum>= $mo->needItemNum, ErrCode::notenough_item);
|
|
|
+ }
|
|
|
+ my_Assert($tuzhiNum >= $mo->needItemNum, ErrCode::notenough_item);
|
|
|
$user->store->removeItem($costTuzhiId, $mo->needItemNum);
|
|
|
ctx()->baseInfo->Consume_Gold($mo->needGold);
|
|
|
-
|
|
|
+
|
|
|
$user->store->equip->$posId->level += 1;
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
@@ -578,12 +569,12 @@ class StoreProc {
|
|
|
|
|
|
$lv = $equip->level;
|
|
|
$levelupgrade = GameConfig::equip_levelupgrade();
|
|
|
- $maxLv = count((array)$levelupgrade);
|
|
|
-
|
|
|
+ $maxLv = count((array) $levelupgrade);
|
|
|
+
|
|
|
$need_gold = 0;
|
|
|
- $need_item = 0;
|
|
|
+ $need_item = 0;
|
|
|
$tuzhiId = GameConfig::equip_getItem($posId)->costTuzhiId;
|
|
|
-
|
|
|
+
|
|
|
$itemNum_store = 0;
|
|
|
if (StlUtil::dictHasProperty($user->store->items, $tuzhiId)) {
|
|
|
$itemNum_store = $user->store->items->$tuzhiId;
|
|
@@ -612,7 +603,7 @@ class StoreProc {
|
|
|
ctx($user);
|
|
|
UserProc::updateUserInfo();
|
|
|
return Resp::ok(array(
|
|
|
- 'gold' => $user->baseInfo->gold,
|
|
|
+ 'gold' => $user->baseInfo->gold,
|
|
|
'store' => $user->store,
|
|
|
));
|
|
|
}
|
|
@@ -639,7 +630,7 @@ class StoreProc {
|
|
|
* @param type $src
|
|
|
*/
|
|
|
public static function AddMultiItemInStore($goodsStr, $src = 1) {
|
|
|
- if($goodsStr == null){
|
|
|
+ if ($goodsStr == null) {
|
|
|
return;
|
|
|
}
|
|
|
$ary = explode(";", $goodsStr);
|
|
@@ -655,7 +646,7 @@ class StoreProc {
|
|
|
switch ($itemMo->itemType) {
|
|
|
case 1:
|
|
|
ctx()->baseInfo->Add_Gold($num);
|
|
|
- self::checkEquipUpgradeTip();
|
|
|
+ self::checkEquipUpgradeTip();
|
|
|
break;
|
|
|
case 2:
|
|
|
ctx()->baseInfo->Add_Cash($num);
|
|
@@ -667,10 +658,10 @@ class StoreProc {
|
|
|
ctx()->baseInfo->Add_Exp($num);
|
|
|
break;
|
|
|
case 100:
|
|
|
- case 103:
|
|
|
+ case 103:
|
|
|
self::PutItemsInStore($itemId, $num);
|
|
|
- if($itemMo->itemType == 100){//图纸
|
|
|
- self::checkEquipUpgradeTip();
|
|
|
+ if ($itemMo->itemType == 100) {//图纸
|
|
|
+ self::checkEquipUpgradeTip();
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
@@ -688,7 +679,7 @@ class StoreProc {
|
|
|
} else {
|
|
|
$items->$itemId = $num;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
ctx()->store->items = $items;
|
|
|
}
|
|
|
|
|
@@ -707,85 +698,101 @@ class StoreProc {
|
|
|
// $n += 1;
|
|
|
// }
|
|
|
// }
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 得到金币或是图纸的时候校验下,是否满足装备升级条件,满足则tip字段设置为1
|
|
|
*/
|
|
|
public static function checkEquipUpgradeTip() {
|
|
|
$equipDic = ctx()->store->equip;
|
|
|
- if($equipDic != null){
|
|
|
+ if ($equipDic != null) {
|
|
|
foreach ($equipDic as $k => &$equip) {
|
|
|
$equip = new Ins_Equip($equip);
|
|
|
$lvMo = GameConfig::equip_levelupgrade_getItem($equip->level);
|
|
|
$needGold = $lvMo->needGold;
|
|
|
$needItemNum = $lvMo->needItemNum;
|
|
|
$neeItemId = $equip->mo()->costTuzhiId;
|
|
|
-
|
|
|
- if(ctx()->baseInfo->gold >= $needGold
|
|
|
- && StlUtil::dictHasProperty(ctx()->store->items, $neeItemId)
|
|
|
- && ctx()->store->items->$neeItemId >= $needItemNum){
|
|
|
- $equipDic->$k->tip = 1;//绿点是每次得到金币或是图纸了,只要满足升级条件都变绿
|
|
|
+
|
|
|
+ if (ctx()->baseInfo->gold >= $needGold && StlUtil::dictHasProperty(ctx()->store->items, $neeItemId) && ctx()->store->items->$neeItemId >= $needItemNum) {
|
|
|
+ $equipDic->$k->tip = 1; //绿点是每次得到金币或是图纸了,只要满足升级条件都变绿
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
ctx()->store->equip = $equipDic;
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 新宝石入库
|
|
|
*/
|
|
|
- public static function PutGemInStore($id,$num=1) {
|
|
|
+ public static function PutGemInStore($id, $num = 1) {
|
|
|
for ($i = 0; $i < $num; $i++) {
|
|
|
$gem = self::initGem($id);
|
|
|
- $length = $gem->uid;
|
|
|
+ $length = $gem->uid;
|
|
|
ctx()->store->gemStore->$length = $gem;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- public static function PutGemInStore2($gem,$num=1) {
|
|
|
- for ($i = 0; $i < $num; $i++) {
|
|
|
- $length = $gem->uid;
|
|
|
+
|
|
|
+ public static function PutGemInStore2($gem, $num = 1) {
|
|
|
+ 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;
|
|
|
+ $length += 1;
|
|
|
$gem = new Ins_Gem();
|
|
|
$gem->uid = $length;
|
|
|
$gem->typeId = $id;
|
|
|
- $gem->predicateId = self::RandomGemPredicateId($id);
|
|
|
+ $gem->predicateId = self::RandomGemPredicateId($id);
|
|
|
$tag = self::CheckNewGemTip($gem);
|
|
|
- $gem->isNew = $tag;
|
|
|
-
|
|
|
+ $gem->isNew = $tag;
|
|
|
+
|
|
|
ctx()->store->gemLength = $length;
|
|
|
-
|
|
|
+
|
|
|
return $gem;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 从仓库移除宝石
|
|
|
*/
|
|
|
public static function RemoveGemInStore($uid) {
|
|
|
- if(StlUtil::dictHasProperty(ctx()->store->gemStore, $uid)){
|
|
|
+ if (StlUtil::dictHasProperty(ctx()->store->gemStore, $uid)) {
|
|
|
StlUtil::dictRemove(ctx()->store->gemStore, $uid);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 新宝石随机词条 临时等刚哥
|
|
|
*/
|
|
|
public static function RandomGemPredicateId($id) {
|
|
|
-
|
|
|
- return 40;
|
|
|
- }
|
|
|
+ $mo = GameConfig::gem_getItem($id);
|
|
|
+
|
|
|
+ if ($mo->isfixed_predicateId == 1) {
|
|
|
+ return $mo->predicateId;
|
|
|
+ }
|
|
|
+
|
|
|
+ $posId = $mo->position;
|
|
|
+ $qual = $mo->qual;
|
|
|
+ $arr = array();
|
|
|
+ $predicateMo = GameConfig::predicate();
|
|
|
+ foreach ($predicateMo as $key => $value) {
|
|
|
+ if ($value->position != null) {
|
|
|
+ $list = explode(',', $value->position);
|
|
|
+ if ($value->qual == $qual && in_array($posId,$list) && $value->attachTarget == "gem") {
|
|
|
+ $arr[] = $value->id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// my_Assert(count($arr) > 0, "宝石没有对应词条信息");
|
|
|
+// $n = mt_rand(0, count($arr)-1);
|
|
|
+// return $n;
|
|
|
|
|
|
+ return 40;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 新宝石提示
|
|
@@ -794,15 +801,15 @@ class StoreProc {
|
|
|
$gemStore = ctx()->store->gemStore;
|
|
|
$tag = false;
|
|
|
foreach ($gemStore as $k => $ins_gem) {
|
|
|
- if($ins_gem->typeId ==$gem->typeId && $ins_gem->predicateId == $gem->predicateId){
|
|
|
+ if ($ins_gem->typeId == $gem->typeId && $ins_gem->predicateId == $gem->predicateId) {
|
|
|
$tag = true;
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- return $tag == true?0:1;
|
|
|
+
|
|
|
+ return $tag == true ? 0 : 1;
|
|
|
}
|
|
|
+
|
|
|
//临时代码
|
|
|
// public static function InitGemInfo() {
|
|
|
// if(count((array)ctx()->store->gemStore) > 0){
|
|
@@ -825,5 +832,4 @@ class StoreProc {
|
|
|
//
|
|
|
//
|
|
|
// }
|
|
|
-
|
|
|
}
|