|
@@ -36,6 +36,7 @@ class ShopProc {
|
|
list($type,$typeId) = req()->paras;
|
|
list($type,$typeId) = req()->paras;
|
|
$user = ctx();
|
|
$user = ctx();
|
|
|
|
|
|
|
|
+ $equipId = 0;
|
|
switch ($type) {
|
|
switch ($type) {
|
|
case EnumShopGift::GateGift_Shop://章节礼包
|
|
case EnumShopGift::GateGift_Shop://章节礼包
|
|
my_Assert(!in_array($typeId, ctx()->privateState->gateGiftReceived), ErrCode::user_shop_NotRepeatBuy);
|
|
my_Assert(!in_array($typeId, ctx()->privateState->gateGiftReceived), ErrCode::user_shop_NotRepeatBuy);
|
|
@@ -57,11 +58,11 @@ class ShopProc {
|
|
|
|
|
|
switch ($mo->costType) {
|
|
switch ($mo->costType) {
|
|
case EnumShopCost::Gold:
|
|
case EnumShopCost::Gold:
|
|
- my_Assert($user->baseInfo->gold>= $mo->costNum, ErrCode::err_const_no);
|
|
|
|
|
|
+ my_Assert($user->baseInfo->gold>= $mo->costNum, ErrCode::notenough_gold_msg);
|
|
ctx()->baseInfo->Consume_Gold($mo->costNum);
|
|
ctx()->baseInfo->Consume_Gold($mo->costNum);
|
|
break;
|
|
break;
|
|
case EnumShopCost::Cash:
|
|
case EnumShopCost::Cash:
|
|
- my_Assert($user->baseInfo->cash>= $mo->costNum, ErrCode::err_const_no);
|
|
|
|
|
|
+ my_Assert($user->baseInfo->cash>= $mo->costNum, ErrCode::notenough_cash_msg);
|
|
ctx()->baseInfo->Consume_Cash($mo->costNum);
|
|
ctx()->baseInfo->Consume_Cash($mo->costNum);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -78,27 +79,108 @@ class ShopProc {
|
|
|
|
|
|
break;
|
|
break;
|
|
case EnumShopGift::BujiBox_Shop://补给箱
|
|
case EnumShopGift::BujiBox_Shop://补给箱
|
|
|
|
+ $mo = GameConfig::shop_supply_getItem($typeId);
|
|
|
|
+ my_Assert($mo != null, ErrCode::err_const_no);
|
|
|
|
|
|
|
|
+ $list = explode(',', $mo->cost);
|
|
|
|
+ my_Assert(StlUtil::dictHasProperty($user->store->items, $list[0]), ErrCode::notenough_item);
|
|
|
|
|
|
|
|
+ $user->store->removeItem($list[0], $list[1]);
|
|
|
|
+ $user->baseInfo->Add_Cash($mo->gold);
|
|
|
|
+
|
|
|
|
+ //必出
|
|
|
|
+ $bichu = $mo->bichu;
|
|
|
|
+ if($mo->type == 1){
|
|
|
|
+ $num = $user->privateState->supplyShopNum_JunyongBox;
|
|
|
|
+ } else {
|
|
|
|
+ $num = $user->privateState->supplyShopNum_BujiBox;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $qual = null;
|
|
|
|
+ if($num%$bichu == 0){
|
|
|
|
+ $qual = $mo->bichu_qual;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($qual == null){
|
|
|
|
+ $list = explode(';', $mo->percent);
|
|
|
|
+ $randNum = rand(0,10000);
|
|
|
|
+ $start = 0;
|
|
|
|
+ $end = 0;
|
|
|
|
+
|
|
|
|
+ $result = 0;
|
|
|
|
+ foreach ($list as $item) {
|
|
|
|
+ $arr = explode(',', $item);
|
|
|
|
+
|
|
|
|
+ $per = $arr[2]*100;
|
|
|
|
+ $end += $per;
|
|
|
|
+ if($randNum >= $start && $randNum <$end){
|
|
|
|
+ $qual = $arr[0].','.$arr[1];
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ $start = $end;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if($qual != null){
|
|
|
|
+ $str = explode(';', $qual);
|
|
|
|
+
|
|
|
|
+ $equipList = array();
|
|
|
|
+ $dic = GameConfig::equip();
|
|
|
|
+ foreach ($dic as $tid => $item) {
|
|
|
|
+ if($item->type == $str[0] && $item->rarity == $str[1]){
|
|
|
|
+ $equipList[] = $item->typeId;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $rNum = rand(0, count($equipList));
|
|
|
|
+ $equipId = $equipList[$rNum];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ StoreProc::PutEquipInStore($equipId, 1);
|
|
break;
|
|
break;
|
|
case EnumShopGift::Cash_Shop://商城-钻石
|
|
case EnumShopGift::Cash_Shop://商城-钻石
|
|
|
|
+ $mo = GameConfig::shop_cash_getItem($typeId);
|
|
|
|
+ my_Assert($mo != null, ErrCode::err_const_no);
|
|
|
|
|
|
|
|
+ $tag = false;
|
|
|
|
+ if(StlUtil::dictHasProperty($user->privateState->cashShopReceived, $typeId)){
|
|
|
|
+ $tag = true;
|
|
|
|
+ }
|
|
|
|
|
|
- break;
|
|
|
|
- case EnumShopGift::Gold_Shop://商城-金币
|
|
|
|
|
|
+ $reward = $mo->reward;
|
|
|
|
+ if(!$tag){
|
|
|
|
+ $reward = $mo->reward.';'.$mo->reward;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ StoreProc::AddMultiItemInStore($reward);
|
|
|
|
+ $user->baseInfo->charge_amt += $mo->price;
|
|
|
|
|
|
|
|
+ break;
|
|
|
|
+ case EnumShopGift::Gold_Shop://商城-金币--可以多次购买
|
|
|
|
+ $mo = GameConfig::shop_gold_getItem($typeId);
|
|
|
|
+ my_Assert($mo != null, ErrCode::err_const_no);
|
|
|
|
+
|
|
|
|
+ $tempNum = 0;
|
|
|
|
+ foreach ($user->privateState->goldShopReceived as $key) {
|
|
|
|
+ if($key == $typeId){
|
|
|
|
+ $tempNum += 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($tempNum >= $mo->freeNum){
|
|
|
|
+ my_Assert($user->baseInfo->cash>= $mo->costNum, ErrCode::notenough_cash_msg);
|
|
|
|
+ ctx()->baseInfo->Consume_Cash($mo->price);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ StoreProc::AddMultiItemInStore($mo->reward);
|
|
|
|
+
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
- //my_Assert(StlUtil::dictHasProperty($user->store->equip, $uid), ErrCode::user_store_NoEquip);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
UserProc::updateUserInfo();
|
|
UserProc::updateUserInfo();
|
|
- return Resp::ok(array(
|
|
|
|
|
|
+ return Resp::ok(array(
|
|
|
|
+ 'equip'=>$equipId,
|
|
'base'=>$user->baseInfo,
|
|
'base'=>$user->baseInfo,
|
|
'privateState' => $user->privateState,
|
|
'privateState' => $user->privateState,
|
|
'store' => $user->store,));
|
|
'store' => $user->store,));
|
|
@@ -110,6 +192,9 @@ class ShopProc {
|
|
*/
|
|
*/
|
|
public static function ShopDailyClear() {
|
|
public static function ShopDailyClear() {
|
|
ctx()->privateState->dailyShopReceived = array();
|
|
ctx()->privateState->dailyShopReceived = array();
|
|
|
|
+ ctx()->privateState->goldShopReceived = array();
|
|
|
|
+ ctx()->privateState->supplyShopNum_BujiBox = 0;
|
|
|
|
+ ctx()->privateState->supplyShopNum_JunyongBox = 0;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|