|
@@ -55,9 +55,11 @@ class ActiveProc {
|
|
|
case CmdCode::active_FlipCardLottery_BuyTickets: # 6115 金蛇献瑞购买抽奖券
|
|
|
return self::FlipCardLottery_BuyTickets();
|
|
|
case CmdCode::active_FlipCardLottery_DrawGrandReward: # 6116 领取大奖信息
|
|
|
- return self::FlipCardLottery_DrawGrandReward();
|
|
|
+ return self::FlipCardLottery_DrawGrandReward();
|
|
|
case CmdCode::active_FlipCardLottery_DrawAccumulateReward: # 6117 领取卡牌累计次数奖励
|
|
|
return self::FlipCardLottery_DrawAccumulateReward();
|
|
|
+ case CmdCode::active_FlipCardLottery_Exchange: # 6118 金蛇兌換 6118 金蛇兌換
|
|
|
+ return self::FlipCardLottery_Exchange();
|
|
|
default:
|
|
|
Err(ErrCode::cmd_err);
|
|
|
}
|
|
@@ -72,7 +74,7 @@ class ActiveProc {
|
|
|
self::ClearOnlineGiftTs();
|
|
|
ActiveProc::ClearYanBaoBuyItemActive_drawReward();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 重置金蛇数据
|
|
|
*/
|
|
@@ -82,15 +84,17 @@ class ActiveProc {
|
|
|
if (now() >= $mo->startTs && now() < $mo->endTs && $mo->endTs != ctx()->privateState->flipCardLottery_endTs) {//当活动重启再次开启的时候再重置数据
|
|
|
ctx()->privateState->flipCardLottery_endTs = $mo->endTs;
|
|
|
ctx()->privateState->flipCardNum_all = 0;
|
|
|
+ ctx()->privateState->flipCardNum_turnNum = 0;
|
|
|
//初始化大奖
|
|
|
ctx()->privateState->flipCard_RewardRecord = array();
|
|
|
- ctx()->privateData(true)->flipCard_randGrandReward = self::RandGrandReward();
|
|
|
-
|
|
|
+ ctx()->privateData(true)->flipCard_randGrandReward = self::RandGrandRewardOrder();
|
|
|
+
|
|
|
ctx()->privateState->flipCardLottery_AccumulateReward = array();
|
|
|
//初始化对应任务数据
|
|
|
self::InitFlipLotteryTask();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 初始化金蛇任务数据
|
|
|
*/
|
|
@@ -99,23 +103,23 @@ class ActiveProc {
|
|
|
$arr = array();
|
|
|
foreach ($activeTaskInfo as $taskUid => $ins_task) {
|
|
|
$ins_taskStep_active = new Ins_TaskStep_Active($ins_task);
|
|
|
- if($ins_taskStep_active->mo()->type == Enum_ActiveTaskType::FlipCardLotteryTask){
|
|
|
+ if ($ins_taskStep_active->mo()->type == Enum_ActiveTaskType::FlipCardLotteryTask) {
|
|
|
$arr[] = $taskUid;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if(count($arr) > 0){
|
|
|
+
|
|
|
+ if (count($arr) > 0) {
|
|
|
foreach ($arr as $uid) {
|
|
|
StlUtil::arrayRemove($activeTaskInfo, $uid);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- $list = explode(',',GameConfig::glc2()->FlipCardLotteryTask);
|
|
|
+
|
|
|
+ $list = explode(',', GameConfig::glc2()->FlipCardLotteryTask);
|
|
|
$length = ctx()->task->activeTaskLength;
|
|
|
- foreach ($list as $taskId){
|
|
|
+ foreach ($list as $taskId) {
|
|
|
$mo = GameConfig::activeTask_getItem($taskId);
|
|
|
my_Assert(null != $mo, ErrCode::err_const_no);
|
|
|
-
|
|
|
+
|
|
|
$length += 1;
|
|
|
$ins_TaskStep_Active = new Ins_TaskStep_Active($mo->id);
|
|
|
$ins_TaskStep_Active->uid = $length;
|
|
@@ -125,34 +129,81 @@ class ActiveProc {
|
|
|
ctx()->task->activeTaskLength = $length;
|
|
|
self::autoRecoverState_activeTask();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 6118 金蛇兌換
|
|
|
+ */
|
|
|
+ public static function FlipCardLottery_Exchange() {
|
|
|
+ list($id) = req()->paras;
|
|
|
+
|
|
|
+ $arr = array_count_values(ctx()->privateState->flipCardLottery_exchange);
|
|
|
+ $num = $arr[$id];
|
|
|
+
|
|
|
+ $mo = GameConfig::activity_flipcardlottery_exchange_getItem($id);
|
|
|
+ my_Assert($mo != null, ErrCode::err_const_no);
|
|
|
+ my_Assert($num < $mo->exchangeNum, ErrCode::active_lotteryExchangeNumLimit);
|
|
|
+
|
|
|
+ $itemNum = 0;
|
|
|
+ $cost = explode(',', $mo->cost);
|
|
|
+ $costId = $cost[0];
|
|
|
+ if (StlUtil::dictHasProperty(ctx()->store->items, $costId)) {
|
|
|
+ $itemNum = ctx()->store->items->$costId;
|
|
|
+ }
|
|
|
+
|
|
|
+ my_Assert($itemNum >= $cost[1], ErrCode::notenough_item);
|
|
|
+ ctx()->store->removeItem($costId, $cost[1]);
|
|
|
+
|
|
|
+ StoreProc::AddMultiItemInStore($mo->reward);
|
|
|
+ ctx()->privateState->flipCardLottery_exchange[] = $id;
|
|
|
+
|
|
|
+ UserProc::updateUserInfo();
|
|
|
+ return Resp::ok(array(
|
|
|
+ "store" => ctx()->store,
|
|
|
+ 'cash' => ctx()->baseInfo->cash,
|
|
|
+ 'gold' => ctx()->baseInfo->gold,
|
|
|
+ 'reward' => StoreProc::$reward,
|
|
|
+ 'reward_Gem' => StoreProc::$reward_Gem,
|
|
|
+ 'reward_equip' => StoreProc::$reward_equip,
|
|
|
+ ));
|
|
|
+
|
|
|
+// return Resp::ok(array(
|
|
|
+// 'gold' => ctx()->baseInfo->gold,
|
|
|
+// 'cash' => ctx()->baseInfo->cash,
|
|
|
+// 'store' => ctx()->store,
|
|
|
+// 'heros' => ctx()->heros,
|
|
|
+// 'privateState' => ctx()->privateState,
|
|
|
+// 'reward_equip'=> StoreProc::$reward_equip,
|
|
|
+// 'reward_Gem'=> StoreProc::$reward_Gem,
|
|
|
+// 'reward'=> StoreProc::$reward,
|
|
|
+// ));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 6117 领取卡牌累计次数奖励
|
|
|
*/
|
|
|
public static function FlipCardLottery_DrawAccumulateReward() {
|
|
|
$dic = GameConfig::activity_flipcardlottery_accumulate();
|
|
|
-
|
|
|
+
|
|
|
$accumulateRewardList = ctx()->privateState->flipCardLottery_AccumulateReward;
|
|
|
$allNum = ctx()->privateState->flipCardNum_all;
|
|
|
foreach ($dic as $numId => $mo) {
|
|
|
- if($allNum >= $numId && !in_array($numId, $accumulateRewardList)){
|
|
|
+ if ($allNum >= $numId && !in_array($numId, $accumulateRewardList)) {
|
|
|
StoreProc::AddMultiItemInStore($mo->reward);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return Resp::ok(array(
|
|
|
'gold' => ctx()->baseInfo->gold,
|
|
|
'cash' => ctx()->baseInfo->cash,
|
|
|
'store' => ctx()->store,
|
|
|
'heros' => ctx()->heros,
|
|
|
- 'privateState' => ctx()->privateState,
|
|
|
- 'reward_equip'=> StoreProc::$reward_equip,
|
|
|
- 'reward_Gem'=> StoreProc::$reward_Gem,
|
|
|
- 'reward'=> StoreProc::$reward,
|
|
|
+ 'privateState' => ctx()->privateState,
|
|
|
+ 'reward_equip' => StoreProc::$reward_equip,
|
|
|
+ 'reward_Gem' => StoreProc::$reward_Gem,
|
|
|
+ 'reward' => StoreProc::$reward,
|
|
|
));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 6116 领取大奖信息
|
|
|
* @return type
|
|
@@ -162,7 +213,7 @@ class ActiveProc {
|
|
|
$lineArr = array();
|
|
|
$list = ctx()->privateState->flipCard_randGrandReward;
|
|
|
$index = 0;
|
|
|
- foreach ($list as $id) {
|
|
|
+ foreach ($list as $orderId) {
|
|
|
$mo = GameConfig::activity_flipCardLottery_lineIds_getItem($index);
|
|
|
$s = explode(',', $mo->cardIds);
|
|
|
$tag = true;
|
|
@@ -172,32 +223,40 @@ class ActiveProc {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if($tag){
|
|
|
- $lineArr[] = $id;
|
|
|
+
|
|
|
+ if ($tag) {
|
|
|
+ $lineArr[] = $orderId;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
$index += 1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (count($lineArr) >= GameConfig::glc2()->FlipCardLottery_ResetNum) {
|
|
|
+ $reward = self::GetCurGrandReward();
|
|
|
+ if ($reward != "") {
|
|
|
+ $str = explode(';', $reward);
|
|
|
+ foreach ($lineArr as $orderId) {
|
|
|
+ $s = explode(',', $str[$orderId]);
|
|
|
+ StoreProc::AddMultiItemInStore($s[0] . ',' . $s[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
ctx()->privateState->flipCard_RewardRecord = array();
|
|
|
- ctx()->privateData(true)->flipCard_randGrandReward = self::RandGrandReward();
|
|
|
+ ctx()->privateData(true)->flipCard_randGrandReward = self::RandGrandRewardOrder();
|
|
|
+ ctx()->privateState->flipCardNum_turnNum += 1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return Resp::ok(array(
|
|
|
'gold' => ctx()->baseInfo->gold,
|
|
|
'cash' => ctx()->baseInfo->cash,
|
|
|
'store' => ctx()->store,
|
|
|
'heros' => ctx()->heros,
|
|
|
- 'privateState' => ctx()->privateState,
|
|
|
- 'reward_equip'=> StoreProc::$reward_equip,
|
|
|
- 'reward_Gem'=> StoreProc::$reward_Gem,
|
|
|
- 'reward'=> StoreProc::$reward,
|
|
|
+ 'privateState' => ctx()->privateState,
|
|
|
+ 'reward_equip' => StoreProc::$reward_equip,
|
|
|
+ 'reward_Gem' => StoreProc::$reward_Gem,
|
|
|
+ 'reward' => StoreProc::$reward,
|
|
|
));
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
|
|
|
/*
|
|
|
* 6114 金蛇献瑞抽奖
|
|
@@ -239,7 +298,7 @@ class ActiveProc {
|
|
|
$dic = GameConfig::activity_flipCardLottery_lineIds();
|
|
|
$lineList = array();
|
|
|
|
|
|
- $curUnlockLine = 999;
|
|
|
+ $curUnlockLine = array();
|
|
|
foreach ($dic as $id => $mo) {
|
|
|
$s = explode(',', $mo->cardIds);
|
|
|
$tag = true;
|
|
@@ -253,7 +312,7 @@ class ActiveProc {
|
|
|
if ($tag) {
|
|
|
$lineList[] = $id;
|
|
|
if (in_array($cardId, $s)) {
|
|
|
- $curUnlockLine = $id;
|
|
|
+ $curUnlockLine[] = $id;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -269,7 +328,7 @@ class ActiveProc {
|
|
|
'privateState' => ctx()->privateState,
|
|
|
'cardReward' => $rewardStr,
|
|
|
//'grandReward' => $grandReward,
|
|
|
- 'curUnlockLine'=> $curUnlockLine,
|
|
|
+ 'curUnlockLine' => $curUnlockLine,
|
|
|
// 'reward_equip'=> StoreProc::$reward_equip,
|
|
|
'cardId' => $cardId,
|
|
|
));
|
|
@@ -285,25 +344,32 @@ class ActiveProc {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ public static function GetCurGrandReward() {
|
|
|
+ $turnNum = ctx()->privateState->flipCardNum_turnNum;
|
|
|
+ //$lineList = array();
|
|
|
+
|
|
|
+ $dic = GameConfig::activity_flipcardlottery_grandreward();
|
|
|
+ $reward = "";
|
|
|
+ foreach ($dic as $id => $mo) {
|
|
|
+ if ($turnNum >= $mo->flipCount_start && $turnNum <= $mo->flipCount_end) {
|
|
|
+ $reward = $mo->reward;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $reward;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 初始化大奖信息 12个大奖在数组的位置对应了 界面上 0-12个位置
|
|
|
* @return type
|
|
|
*/
|
|
|
- public static function RandGrandReward() {
|
|
|
- $lineList = array();
|
|
|
- $dic = GameConfig::activity_flipcardlottery_grandreward();
|
|
|
- foreach ($dic as $id => $mo) {
|
|
|
- $lineList[] = $id;
|
|
|
- }
|
|
|
+ public static function RandGrandRewardOrder() {
|
|
|
+ $numbers = range(0, 11);
|
|
|
|
|
|
- $typeIdArr = array();
|
|
|
- $num = count($lineList);
|
|
|
- for ($i = 0; $i < $num; $i++) {
|
|
|
- $rand = rand(0, count($lineList) - 1);
|
|
|
- $typeIdArr[] = $lineList[$rand];
|
|
|
- StlUtil::arrayRemoveAt($lineList, $rand);
|
|
|
- }
|
|
|
- return $typeIdArr;
|
|
|
+// 使用shuffle函数打乱数组顺序
|
|
|
+ shuffle($numbers);
|
|
|
+ return $numbers;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -312,55 +378,62 @@ class ActiveProc {
|
|
|
*/
|
|
|
public static function RandCardReward() {
|
|
|
$randGrandReward = ctx()->privateState->flipCard_randGrandReward;
|
|
|
+ $grandReward = self::GetCurGrandReward();
|
|
|
+ $gList = explode(';', $grandReward);
|
|
|
|
|
|
$cId = 0;
|
|
|
- while (true) {
|
|
|
- $perNum = 0; //大奖总概率
|
|
|
- foreach ($randGrandReward as $id) {
|
|
|
- $perNum += GameConfig::activity_flipcardlottery_grandreward_getItem($id)->per;
|
|
|
- }
|
|
|
-
|
|
|
- $rand = rand(1, $perNum);
|
|
|
- $start = 0;
|
|
|
- $end = 0;
|
|
|
- $lineId = null;
|
|
|
- $grandId = null;
|
|
|
- $index = 0;
|
|
|
- foreach ($randGrandReward as $id) {
|
|
|
- $mo = GameConfig::activity_flipcardlottery_grandreward_getItem($id);
|
|
|
- $end += $mo->per;
|
|
|
- if ($rand >= $start && $rand < $end) {
|
|
|
- $lineId = $index;
|
|
|
- $grandId = $id;
|
|
|
+ $index = 0;
|
|
|
+ $noflipArr = array();
|
|
|
+ foreach ($randGrandReward as $orderId) {
|
|
|
+ $mo = GameConfig::activity_flipCardLottery_lineIds_getItem($index);
|
|
|
+ $s = explode(',', $mo->cardIds);
|
|
|
+ $tag = true;
|
|
|
+ foreach ($s as $cId) {
|
|
|
+ if (!self::isExistCard($cId)) {
|
|
|
+ $tag = false;
|
|
|
break;
|
|
|
}
|
|
|
- $start = $end;
|
|
|
- $index += 1;
|
|
|
}
|
|
|
- if ($lineId != null && $grandId != null) {
|
|
|
- $lineMo = GameConfig::activity_flipCardLottery_lineIds_getItem($lineId);
|
|
|
- $str = explode(',', $lineMo->cardIds);
|
|
|
- $cardArr = array();
|
|
|
- $isExistNoFlip = false;
|
|
|
- foreach ($str as $cardId) {
|
|
|
- if (!self::isExistCard($cardId)) {
|
|
|
- $cardArr[] = $cardId;
|
|
|
- $isExistNoFlip = true;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if ($isExistNoFlip) {
|
|
|
- $n = rand(0, count($cardArr) - 1);
|
|
|
- $cId = $cardArr[$n];
|
|
|
- break;
|
|
|
- } else {
|
|
|
- StlUtil::arrayRemove($randGrandReward, $grandId);
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if (!$tag) {//true 意思就是没有被全部翻牌
|
|
|
+ $noflipArr[] = $orderId;
|
|
|
+ }
|
|
|
+ $index += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ $perNum = 0; //大奖总概率
|
|
|
+ foreach ($noflipArr as $k) {
|
|
|
+ $s = explode(',', $gList[$k]);
|
|
|
+ $perNum += $s[2];
|
|
|
+ }
|
|
|
+ $rand = rand(1, $perNum);
|
|
|
+ $start = 0;
|
|
|
+ $end = 0;
|
|
|
+ $grandId = null;
|
|
|
+ foreach ($noflipArr as $k) {
|
|
|
+ $s = explode(',', $gList[$k]);
|
|
|
+ $end += $s[2];
|
|
|
+ if ($rand >= $start && $rand < $end) {
|
|
|
+ $grandId = $k;
|
|
|
break;
|
|
|
}
|
|
|
+ $start = $end;
|
|
|
}
|
|
|
|
|
|
+ if ($grandId != null) {
|
|
|
+ $lineId = array_search($grandId, $randGrandReward);
|
|
|
+ $lineMo = GameConfig::activity_flipCardLottery_lineIds_getItem($lineId);
|
|
|
+ $str = explode(',', $lineMo->cardIds);
|
|
|
+ $cardArr = array();
|
|
|
+ foreach ($str as $cardId) {
|
|
|
+ if (!self::isExistCard($cardId)) {
|
|
|
+ $cardArr[] = $cardId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $n = rand(0, count($cardArr) - 1);
|
|
|
+ $cId = $cardArr[$n];
|
|
|
+ }
|
|
|
return $cId;
|
|
|
}
|
|
|
|