|
@@ -36,6 +36,8 @@ class ShopProc {
|
|
list($type,$typeId,$buyNum) = req()->paras;
|
|
list($type,$typeId,$buyNum) = req()->paras;
|
|
$user = ctx();
|
|
$user = ctx();
|
|
|
|
|
|
|
|
+ $resultArr = array();
|
|
|
|
+
|
|
$equip = array();
|
|
$equip = array();
|
|
$gateGift = array();
|
|
$gateGift = array();
|
|
switch ($type) {
|
|
switch ($type) {
|
|
@@ -99,129 +101,79 @@ class ShopProc {
|
|
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
- case EnumShopGift::SJunBeiBox_Shop://S级军备
|
|
|
|
- $mo = GameConfig::shop_junbei_getItem($typeId);
|
|
|
|
|
|
+ case EnumShopGift::GemBox_Shop ://宝石宝箱
|
|
|
|
+ $mo = GameConfig::shop_box_getItem($typeId);
|
|
my_Assert($mo != null, ErrCode::err_const_no);
|
|
my_Assert($mo != null, ErrCode::err_const_no);
|
|
|
|
+
|
|
|
|
+ if($buyNum > 0){
|
|
|
|
+ $cost = $mo->cost_ten;
|
|
|
|
+ if($buyNum == 1){
|
|
|
|
+ $cost = $mo->cost_one;
|
|
|
|
+ }
|
|
|
|
+ my_Assert( $user->baseInfo->cash >= $cost, ErrCode::notenough_cash_msg);
|
|
|
|
+ $user->baseInfo->Consume_Cash($cost);
|
|
|
|
+ }
|
|
|
|
|
|
- my_Assert(now()>=$mo->startTs && now() < $mo->endTs, ErrCode::user_shop_activeExpire); //活动过期
|
|
|
|
- $numDic = $user->privateState->junbeiShopNumRecord;
|
|
|
|
- if(!StlUtil::dictHasProperty($numDic, $typeId)){
|
|
|
|
- $numDic->$typeId = 0;
|
|
|
|
- $user->privateState->junbeiShopNumRecord =$numDic;
|
|
|
|
- }
|
|
|
|
|
|
+ if($mo->type == 1){
|
|
|
|
+ if($buyNum == 0){
|
|
|
|
+ $buyNum = 1;
|
|
|
|
+ my_Assert(now()-$user->privateState->lastFreeGetTs_ShopBoxCommon >= $mo->freeDownTs*24*60*60, ErrCode::user_shop_FreeNumLimit);
|
|
|
|
+ }
|
|
|
|
+ $user->privateState->buyNum_ShopBoxCommon += $buyNum;
|
|
|
|
+ } else if($mo->type == 2){
|
|
|
|
+ if($buyNum == 0){
|
|
|
|
+ $buyNum = 1;
|
|
|
|
+ my_Assert(now()-$user->privateState->lastFreeGetTs_ShopBoxBright >= $mo->freeDownTs*24*60*60, ErrCode::user_shop_FreeNumLimit);
|
|
|
|
+ }
|
|
|
|
+ $user->privateState->buyNum_ShopBoxBright += $buyNum;
|
|
|
|
+ }
|
|
|
|
|
|
- $allDic = $user->privateState->junbeiShop_AllNumRecord;
|
|
|
|
- if(!StlUtil::dictHasProperty($allDic, $typeId)){
|
|
|
|
- $junbei = new Ins_JunBeiShop();
|
|
|
|
- $junbei->typeId = $typeId;
|
|
|
|
- $allDic->$typeId = $junbei;
|
|
|
|
- $user->privateState->junbeiShop_AllNumRecord =$allDic;
|
|
|
|
|
|
+ $arr = array();
|
|
|
|
+ $arr[] = 1;
|
|
|
|
+ $arr[] = 10;
|
|
|
|
+ if(!in_array($buyNum, $arr)){
|
|
|
|
+ $buyNum = 1;
|
|
}
|
|
}
|
|
|
|
|
|
- my_Assert($numDic->$typeId + $buyNum <= $mo->limitNum, ErrCode::user_shop_LimitNum);
|
|
|
|
- $costArr = explode(',', $mo->cost_item);
|
|
|
|
- $costId = $costArr[0];
|
|
|
|
- $costNum = $costArr[1];
|
|
|
|
-
|
|
|
|
- $cash = 0;
|
|
|
|
- if($buyNum == 1){//买一次
|
|
|
|
- $user->privateState->junbeiShopNumRecord->$typeId += 1;
|
|
|
|
- $cash = $mo->cost_one;
|
|
|
|
- } else {//买10次
|
|
|
|
- $user->privateState->junbeiShopNumRecord->$typeId += 10;
|
|
|
|
- $cash = $mo->cost_ten;
|
|
|
|
- $costNum *= 10;
|
|
|
|
|
|
+ $perList = explode(';',$mo->percent);
|
|
|
|
+ $allNum = 0;
|
|
|
|
+ foreach ($perList as $key => $value) {
|
|
|
|
+ $str = explode(',', $value);
|
|
|
|
+ $allNum += $str[1];
|
|
}
|
|
}
|
|
|
|
|
|
- if(StlUtil::dictHasProperty($user->store->items, $costId) && $user->store->items->$costId >= $costNum){
|
|
|
|
- $user->store->removeItem($costId, $costNum);
|
|
|
|
- } else {
|
|
|
|
- //判断下钻石是否充足
|
|
|
|
- my_Assert($user->baseInfo->cash >= $cash, ErrCode::notenough_cash_msg);
|
|
|
|
- $user->baseInfo->Consume_Cash($cash);
|
|
|
|
- }
|
|
|
|
- $bichu = explode(',', $mo->bichu_1);
|
|
|
|
- $bichu2 = explode(',', $mo->bichu_2);
|
|
|
|
- $dic = GameConfig::equip();
|
|
|
|
- $list = explode(';', $mo->percent);
|
|
|
|
-
|
|
|
|
- for ($i = 0; $i < $buyNum; $i++) {
|
|
|
|
- $qual = 0;
|
|
|
|
- $xiyoudu = 0;
|
|
|
|
- $randNum = rand(0,10000);
|
|
|
|
|
|
+ $allNum *= 1000;
|
|
|
|
+ for ($i = 0; $i < $buyNum; $i++) {
|
|
$start = 0;
|
|
$start = 0;
|
|
- $end = 0;
|
|
|
|
- foreach ($list as $item) {
|
|
|
|
- $arr = explode(',', $item);
|
|
|
|
- $per = $arr[2]*100;
|
|
|
|
- $end += $per;
|
|
|
|
- if($randNum >= $start && $randNum <$end){
|
|
|
|
- $qual = $arr[0];
|
|
|
|
- $xiyoudu = $arr[1];
|
|
|
|
|
|
+ $end = 0;
|
|
|
|
+ $qual = 0;
|
|
|
|
+ $randNum = rand (1,$allNum);
|
|
|
|
+ foreach ($perList as $k => $val) {
|
|
|
|
+ $str = explode(',', $value);
|
|
|
|
+ $end += $str[1]*1000;
|
|
|
|
+ if($randNum > $start && $randNum <= $end){
|
|
|
|
+ $qual = $str[0];
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
$start = $end;
|
|
$start = $end;
|
|
}
|
|
}
|
|
-
|
|
|
|
- $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 += 1;
|
|
|
|
- $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu2 += 1;
|
|
|
|
-
|
|
|
|
- $resultStr = $qual.",".$xiyoudu;
|
|
|
|
- $tag = false;
|
|
|
|
- if($qual == $bichu[1] && $xiyoudu == $bichu[2]){
|
|
|
|
- $resultStr = $bichu[1].",".$bichu[2];
|
|
|
|
- $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 = 0;
|
|
|
|
- //$tag = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if($qual == $bichu2[1] && $xiyoudu == $bichu2[2]){
|
|
|
|
- $resultStr = $bichu2[1].",".$bichu2[2];
|
|
|
|
- $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu2 = 0;
|
|
|
|
- if($user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 == $bichu[0]){
|
|
|
|
- $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 = 0;
|
|
|
|
- }
|
|
|
|
- //$tag = true;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// if($tag){
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- if($user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 == $bichu[0]){
|
|
|
|
- $resultStr = $bichu[1].",".$bichu[2];//得杰出
|
|
|
|
- $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu1 = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if($user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu2 == $bichu2[0]){
|
|
|
|
- $resultStr = $bichu2[1].",".$bichu2[2];//得S级杰出
|
|
|
|
- $user->privateState->junbeiShop_AllNumRecord->$typeId->num_bichu2 = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if($resultStr != null){
|
|
|
|
- $str = explode(',', $resultStr);
|
|
|
|
-
|
|
|
|
- $equipList = array();
|
|
|
|
- foreach ($dic as $tid => $item) {
|
|
|
|
- if($str[1] == 1 || $str[1] == 2){//稀有度为1的装备
|
|
|
|
- if($item->qual == $str[0] && $item->rarity == $str[1]){
|
|
|
|
- $equipList[] = $item->typeId;
|
|
|
|
- }
|
|
|
|
- }elseif ($str[1] == 3) {//特定装备的
|
|
|
|
- if($item->typeId == $str[0]){
|
|
|
|
- $equipList[] = $item->typeId;
|
|
|
|
|
|
+
|
|
|
|
+ if($qual >0){
|
|
|
|
+ $gemDic = GameConfig::gem();
|
|
|
|
+ $gemList = array();
|
|
|
|
+ foreach ($gemDic as $key => $value) {
|
|
|
|
+ if($value->qual == $qual){
|
|
|
|
+ $gemList[] = $value;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
- $rNum = rand(0, count($equipList)-1);
|
|
|
|
- $equipId = $equipList[$rNum];
|
|
|
|
- StoreProc::PutEquipInStore($equipId, 1);
|
|
|
|
- $equip[] = $equipId;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ $n = rand(0, count($gemList)-1);
|
|
|
|
+ $gem = StoreProc::initGem($gateGift[$n]->typeId);
|
|
|
|
+ $resultArr[] = $gem;
|
|
|
|
+ StoreProc::PutGemInStore2($gem);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- $user->baseInfo->Add_Gold($mo->gold*$buyNum);
|
|
|
|
|
|
+
|
|
|
|
|
|
break;
|
|
break;
|
|
case EnumShopGift::BujiBox_Shop://补给箱
|
|
case EnumShopGift::BujiBox_Shop://补给箱
|
|
@@ -344,6 +296,7 @@ class ShopProc {
|
|
ctx($user);
|
|
ctx($user);
|
|
UserProc::updateUserInfo();
|
|
UserProc::updateUserInfo();
|
|
return Resp::ok(array(
|
|
return Resp::ok(array(
|
|
|
|
+ 'resultArr' => $resultArr,
|
|
'gateGift'=>$gateGift,
|
|
'gateGift'=>$gateGift,
|
|
'equip'=>$equip,
|
|
'equip'=>$equip,
|
|
'cash'=>$user->baseInfo->cash,
|
|
'cash'=>$user->baseInfo->cash,
|