|
@@ -63,9 +63,9 @@ class ActiveProc {
|
|
|
*/
|
|
|
static function GetShenmiaoData() {
|
|
|
$req = req();
|
|
|
- $shenmiaoInfo = $req->userInfo->game->shenmiao;
|
|
|
+ //$shenmiaoInfo = $req->userInfo->game->shenmiao;
|
|
|
|
|
|
- //$shenmiaoInfo = new Info_ShenMiao();
|
|
|
+ $shenmiaoInfo = new Info_ShenMiao($req->userInfo->game->shenmiao);
|
|
|
$shenmiaoInfo->initActiveItem();
|
|
|
$req->userInfo->game->shenmiao = $shenmiaoInfo;
|
|
|
|
|
@@ -94,8 +94,8 @@ class ActiveProc {
|
|
|
$shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);
|
|
|
if($shenmo->discount != 0){
|
|
|
$sList = explode(',', $shenmo->cost);
|
|
|
- //$costVal = $sList[1] - $sList[1]*$shenmo->discount/100;
|
|
|
- //$costStr = $sList[0].','.$costVal*$num;
|
|
|
+ $costVal = $sList[1] - $sList[1]*$shenmo->discount/100;
|
|
|
+ $costStr = $sList[0].','.$costVal*$num;
|
|
|
StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$costVal*$num);
|
|
|
}
|
|
|
|
|
@@ -120,55 +120,28 @@ class ActiveProc {
|
|
|
|
|
|
if($shenmiaoInfo->activeDic->$type->totalNum >= 20){
|
|
|
StlUtil::dictRemove($shenmiaoInfo->activeDic, $type);
|
|
|
- }
|
|
|
-
|
|
|
- } else if(Enum_Active::OpenWish == $type){
|
|
|
- $old = intval($shenmiaoInfo->activeDic->$type->totalNum/90);
|
|
|
- $shenmiaoInfo->activeDic->$type->totalNum += $num;
|
|
|
- $new = intval($shenmiaoInfo->activeDic->$type->totalNum/90);
|
|
|
- $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);
|
|
|
+ }
|
|
|
+ } else if(Enum_Active::OpenWish == $type){
|
|
|
+ $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);
|
|
|
if($num == 1){
|
|
|
$shenmiaoInfo->activeDic->$type->num += $num;
|
|
|
$sList = explode(',', $shenmo->cost);
|
|
|
StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]);
|
|
|
|
|
|
- $itemType = self::activeRandom($shenmo->per, $shenmo);
|
|
|
-
|
|
|
- $aid =self::getActiveRandomItem($itemType, $shenmo);
|
|
|
- if($shenmiaoInfo->activeDic->$type->num%10 == 0){
|
|
|
- if($shenmiaoInfo->activeDic->$type->num%90 == 0){
|
|
|
- if($shenmiaoInfo->activeDic->$type->Ur == 0){
|
|
|
- $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ur, $shenmo);
|
|
|
- $list[] = $aid;
|
|
|
- } else {
|
|
|
- $list[] = $aid;
|
|
|
- $shenmiaoInfo->activeDic->$type->Ur = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if($shenmiaoInfo->activeDic->$type->Ssr == 0){
|
|
|
- $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ssr, $shenmo);
|
|
|
- $list[] = $aid;
|
|
|
- } else {
|
|
|
- $list[] = $aid;
|
|
|
- $shenmiaoInfo->activeDic->$type->Ssr = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if($itemType == Enum_ActiveItemType::Ssr){
|
|
|
- $shenmiaoInfo->activeDic->$type->Ssr = 1;
|
|
|
- }
|
|
|
+ $itemType = self::activeRandom($shenmo->per, $shenmo);
|
|
|
+ $aid =self::getActiveRandomItem($itemType, $shenmo);
|
|
|
|
|
|
- if($itemType == Enum_ActiveItemType::Ur){
|
|
|
- $shenmiaoInfo->activeDic->$type->Ssr = 1;
|
|
|
- $shenmiaoInfo->activeDic->$type->Ur = 1;
|
|
|
- }
|
|
|
- $list[] = $aid;
|
|
|
- }
|
|
|
+ if($shenmiaoInfo->activeDic->$type->num % glc()->Active_UR_Num == 0 && $itemType != Enum_ActiveItemType::Ur){
|
|
|
+ $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ur, $shenmo);
|
|
|
+ $list[] = $aid;
|
|
|
+ } else {
|
|
|
+ $list[] = $aid;
|
|
|
+ }
|
|
|
} else {//10连抽
|
|
|
- $sList = explode(',', $shenmo->cost);
|
|
|
- //$costStr = $sList[0].','.$sList[1]*$num;
|
|
|
- StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]*$num);
|
|
|
+ $sList = explode(',', $shenmo->cost);
|
|
|
+ StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]*$num);
|
|
|
|
|
|
+ $shenmiaoInfo->activeDic->$type->totalNum += $num;
|
|
|
$tag = false;
|
|
|
$n = 0;
|
|
|
for ($index1 = 0; $index1 < $num; $index1++) {
|
|
@@ -180,67 +153,35 @@ class ActiveProc {
|
|
|
if($n==10 && $tag == false){
|
|
|
$list[] =self::getActiveRandomItem(Enum_ActiveItemType::Ssr, $shenmo);
|
|
|
} else {
|
|
|
- $list[] =self::getActiveRandomItem($itemType, $shenmo);
|
|
|
- if($itemType == Enum_ActiveItemType::Ur){
|
|
|
- $shenmiaoInfo->activeDic->$type->Ur = 1;
|
|
|
- }
|
|
|
+ $list[] =self::getActiveRandomItem($itemType, $shenmo);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if($old != $new){//说明过了一个90次的抽奖
|
|
|
- if($shenmiaoInfo->activeDic->$type->Ur == 0){
|
|
|
- $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ur, $shenmo);
|
|
|
- $list[0] = $aid;
|
|
|
- } else {
|
|
|
- $shenmiaoInfo->activeDic->$type->Ur = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {//不定期活动
|
|
|
- $old = intval($shenmiaoInfo->activeDic->$type->totalNum/90);
|
|
|
- $shenmiaoInfo->activeDic->$type->totalNum += $num;
|
|
|
- $new = intval($shenmiaoInfo->activeDic->$type->totalNum/90);
|
|
|
- $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);
|
|
|
-
|
|
|
+ }
|
|
|
+ if($shenmiaoInfo->activeDic->$type->totalNum >= glc()->Active_UR_Num){//第90次必得
|
|
|
+ $aid =self::getActiveRandomItem(Enum_ActiveItemType::Ur, $shenmo);
|
|
|
+ $list[0] = $aid;
|
|
|
+ $shenmiaoInfo->activeDic->$type->totalNum = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {//不定期活动
|
|
|
+ $shenmo = GameConfig::shenmiao_getItem($shenmiaoInfo->activeDic->$type->id);
|
|
|
if($num == 1){
|
|
|
$shenmiaoInfo->activeDic->$type->num += $num;
|
|
|
$sList = explode(',', $shenmo->cost);
|
|
|
StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]);
|
|
|
|
|
|
$itemType = self::activeRandom($shenmo->per, $shenmo);
|
|
|
- $aid =self::getActiveRandomItem_2($itemType, $shenmo);//随机出的id
|
|
|
- if($shenmiaoInfo->activeDic->$type->num%10 == 0){
|
|
|
- if($shenmiaoInfo->activeDic->$type->num%90 == 0){
|
|
|
- if($shenmiaoInfo->activeDic->$type->Ur == 0){
|
|
|
- $aid =self::getActiveRandomItem_2(Enum_ActiveItemType::Ur, $shenmo);
|
|
|
- $list[] = $aid;
|
|
|
- } else {
|
|
|
- $list[] = $aid;
|
|
|
- $shenmiaoInfo->activeDic->$type->Ur = 0;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if($shenmiaoInfo->activeDic->$type->Ssr == 0){
|
|
|
- $aid =self::getActiveRandomItem_2(Enum_ActiveItemType::Ssr, $shenmo);
|
|
|
- $list[] = $aid;
|
|
|
- } else {
|
|
|
- $list[] = $aid;
|
|
|
- $shenmiaoInfo->activeDic->$type->Ssr = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if($itemType == Enum_ActiveItemType::Ssr){
|
|
|
- $shenmiaoInfo->activeDic->$type->Ssr = 1;
|
|
|
- }
|
|
|
- if($itemType == Enum_ActiveItemType::Ur){
|
|
|
- $shenmiaoInfo->activeDic->$type->Ssr = 1;
|
|
|
- $shenmiaoInfo->activeDic->$type->Ur = 1;
|
|
|
- }
|
|
|
+ $aid =self::getActiveRandomItem_3($itemType, $shenmo);//随机出的id
|
|
|
+ if($shenmiaoInfo->activeDic->$type->num% glc()->Active_UR_Num == 0){
|
|
|
+ $aid =self::getActiveRandomItem_3(Enum_ActiveItemType::Ur, $shenmo);
|
|
|
$list[] = $aid;
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ $list[] = $aid;
|
|
|
+ }
|
|
|
} else {
|
|
|
$sList = explode(',', $shenmo->cost);
|
|
|
- StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]);
|
|
|
+ StoreProc::removeItemFromStore($req->userInfo->game->store,$sList[0],$sList[1]*$num);
|
|
|
+
|
|
|
+ $shenmiaoInfo->activeDic->$type->totalNum += $num;
|
|
|
|
|
|
$tag = false;
|
|
|
$n = 0;
|
|
@@ -251,23 +192,17 @@ class ActiveProc {
|
|
|
$tag = true;
|
|
|
}
|
|
|
if($n==10 && $tag == false){
|
|
|
- $list[] =self::getActiveRandomItem_2(Enum_ActiveItemType::Ssr, $shenmo);
|
|
|
+ $list[] =self::getActiveRandomItem_3(Enum_ActiveItemType::Ssr, $shenmo);
|
|
|
} else {
|
|
|
- $list[] =self::getActiveRandomItem_2($itemType, $shenmo);
|
|
|
- if($itemType == Enum_ActiveItemType::Ur){
|
|
|
- $shenmiaoInfo->activeDic->$type->Ur = 1;
|
|
|
- }
|
|
|
+ $list[] =self::getActiveRandomItem_3($itemType, $shenmo);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if($old != $new){//说明过了一个90次的抽奖
|
|
|
- if($shenmiaoInfo->activeDic->$type->Ur == 0){
|
|
|
- $aid =self::getActiveRandomItem_2(Enum_ActiveItemType::Ur, $shenmo);
|
|
|
- $list[0] = $aid;
|
|
|
- } else {
|
|
|
- $shenmiaoInfo->activeDic->$type->Ur = 0;
|
|
|
- }
|
|
|
- }
|
|
|
+ if($shenmiaoInfo->activeDic->$type->totalNum >= glc()->Active_UR_Num){//第90次必得
|
|
|
+ $aid =self::getActiveRandomItem_3(Enum_ActiveItemType::Ur, $shenmo);
|
|
|
+ $list[0] = $aid;
|
|
|
+ $shenmiaoInfo->activeDic->$type->totalNum = 0;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -281,10 +216,10 @@ class ActiveProc {
|
|
|
|
|
|
return Resp::ok(array(# # 返回值
|
|
|
'shenmiaoInfo' => $shenmiaoInfo,
|
|
|
- 'list'=>$list,
|
|
|
+ 'list'=>$list,
|
|
|
+ 'store'=>$req->userInfo->game->store,
|
|
|
));
|
|
|
-
|
|
|
- }
|
|
|
+ }
|
|
|
/**
|
|
|
*
|
|
|
* @param type $randCtx
|
|
@@ -306,31 +241,24 @@ class ActiveProc {
|
|
|
$type += 1;
|
|
|
$start = $end;
|
|
|
}
|
|
|
- return $type;
|
|
|
-
|
|
|
-// $id = 0;
|
|
|
-// switch ($type) {
|
|
|
-// case Enum_ActiveItemType::Sr:
|
|
|
-// $id = array_rand($mo->srList);
|
|
|
-// break;
|
|
|
-// case Enum_ActiveItemType::Ssr:
|
|
|
-// $id = array_rand($mo->ssrList);
|
|
|
-//
|
|
|
-// break;
|
|
|
-// case Enum_ActiveItemType::Ur:
|
|
|
-// $id = array_rand($mo->urList);
|
|
|
-// break;
|
|
|
-// default:
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// return $id;
|
|
|
+ return $type;
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param type $arr
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
public static function randList($arr) {
|
|
|
$rand = rand(0, count($arr)-1);
|
|
|
return $arr[$rand];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param type $type
|
|
|
+ * @param type $mo
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
public static function getActiveRandomItem($type,$mo) {
|
|
|
$id = 0;
|
|
|
switch ($type) {
|
|
@@ -355,7 +283,9 @@ class ActiveProc {
|
|
|
* @param sm_shenmiao $mo
|
|
|
* @return type
|
|
|
*/
|
|
|
- public static function getActiveRandomItem_2($type,$mo) {
|
|
|
+ public static function getActiveRandomItem_3($type,$mo) {
|
|
|
+ $shenmiaoInfo = req()->userInfo->game->shenmiao;
|
|
|
+
|
|
|
$id = 0;
|
|
|
switch ($type) {
|
|
|
case Enum_ActiveItemType::Sr:
|
|
@@ -365,25 +295,43 @@ class ActiveProc {
|
|
|
if($mo->ssrUp != null){
|
|
|
$dic = new \stdClass();
|
|
|
$ssrList = explode(';', $mo->ssrUp);
|
|
|
+
|
|
|
+ $tNum = 0;
|
|
|
foreach ($ssrList as $val) {
|
|
|
$sList = explode(',', $val);
|
|
|
$sid = $sList[0];
|
|
|
$dic->$sid = $sList[1];
|
|
|
- }
|
|
|
- $rand = rand(1,100);
|
|
|
- $start = 0;
|
|
|
- foreach ($dic as $k=>$val) {
|
|
|
- $end = $val + $start;
|
|
|
- if($rand > $start && $rand <= $end){
|
|
|
- $id = $k;
|
|
|
- break;
|
|
|
- } else {
|
|
|
- $id = array_rand($mo->ssrList);
|
|
|
- break;
|
|
|
- }
|
|
|
- $start = $end;
|
|
|
- }
|
|
|
+ $tNum += $sList[1];
|
|
|
+ }
|
|
|
|
|
|
+ if($shenmiaoInfo->activeDic->$type->isUpSsr == 1){
|
|
|
+ $rand = rand(1,$tNum);
|
|
|
+ $start = 0;
|
|
|
+ foreach ($dic as $k=>$val) {
|
|
|
+ $end = $val + $start;
|
|
|
+ if($rand > $start && $rand <= $end){//随机到Up得id
|
|
|
+ $id = $k;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $start = $end;
|
|
|
+ }
|
|
|
+ $shenmiaoInfo->activeDic->$type->isUpSsr = 0;
|
|
|
+ } else {
|
|
|
+ $rand = rand(1,10000);
|
|
|
+ $start = 0;
|
|
|
+ foreach ($dic as $k=>$val) {
|
|
|
+ $end = $val + $start;
|
|
|
+ if($rand > $start && $rand <= $end){//随机到Up得id
|
|
|
+ $id = $k;
|
|
|
+ break;
|
|
|
+ } else {//随机到普通的id
|
|
|
+ $shenmiaoInfo->activeDic->$type->isUpSsr = 1;
|
|
|
+ $id = self::randList(explode(',', $mo->ssrList));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $start = $end;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
$id = self::randList(explode(',', $mo->ssrList));
|
|
|
}
|
|
@@ -392,25 +340,42 @@ class ActiveProc {
|
|
|
if($mo->ssrUp != null){
|
|
|
$dic = new \stdClass();
|
|
|
$urList = explode(';', $mo->urUp);
|
|
|
+ $tNum = 0;
|
|
|
foreach ($urList as $val) {
|
|
|
$sList = explode(',', $val);
|
|
|
$sid = $sList[0];
|
|
|
$dic->$sid = $sList[1];
|
|
|
- }
|
|
|
- $rand = rand(1,100);
|
|
|
- $start = 0;
|
|
|
- foreach ($dic as $k=>$val) {
|
|
|
- $end = $val + $start;
|
|
|
- if($rand > $start && $rand <= $end){
|
|
|
- $id = $k;
|
|
|
- break;
|
|
|
- } else {
|
|
|
- $id = array_rand($mo->urList);
|
|
|
- break;
|
|
|
- }
|
|
|
- $start = $end;
|
|
|
- }
|
|
|
+ $tNum += $sList[1];
|
|
|
+ }
|
|
|
|
|
|
+ if($shenmiaoInfo->activeDic->$type->isUpUr == 1){
|
|
|
+ $rand = rand(1,$tNum);
|
|
|
+ $start = 0;
|
|
|
+ foreach ($dic as $k=>$val) {
|
|
|
+ $end = $val + $start;
|
|
|
+ if($rand > $start && $rand <= $end){//随机到Up得id
|
|
|
+ $id = $k;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $start = $end;
|
|
|
+ }
|
|
|
+ $shenmiaoInfo->activeDic->$type->$isUpUr = 0;
|
|
|
+ } else {
|
|
|
+ $rand = rand(1,10000);
|
|
|
+ $start = 0;
|
|
|
+ foreach ($dic as $k=>$val) {
|
|
|
+ $end = $val + $start;
|
|
|
+ if($rand > $start && $rand <= $end){
|
|
|
+ $id = $k;
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ $shenmiaoInfo->activeDic->$type->isUpUr = 1;
|
|
|
+ $id = self::randList(explode(',', $mo->urList));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $start = $end;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
$id = self::randList(explode(',', $mo->urList));
|
|
|
}
|
|
@@ -420,6 +385,31 @@ class ActiveProc {
|
|
|
}
|
|
|
return $id;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从SSr 和 uR中得一个
|
|
|
+ * @param type $param
|
|
|
+ */
|
|
|
+ public function functionName($per) {
|
|
|
+ $list = explode(',', $randCtx);
|
|
|
+ $n = 0;
|
|
|
+ foreach ($list as $value) {
|
|
|
+ if($n == 0){
|
|
|
+ contains($value);
|
|
|
+ }
|
|
|
+ $n+= 1;
|
|
|
+ }
|
|
|
+ $start = 0;
|
|
|
+ foreach ($list as $val) {
|
|
|
+ $end = $val + $start;
|
|
|
+ if($rand > $start && $rand <= $end){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $type += 1;
|
|
|
+ $start = $end;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
*
|