This commit is contained in:
aozhiwei 2024-10-08 15:10:15 +08:00
parent b85a1903e0
commit 6267ef51a7

View File

@ -8,14 +8,36 @@ class BattleBoxService {
const DAILY_PHASE_DROP_LAST_TIME_KEY = ':'; const DAILY_PHASE_DROP_LAST_TIME_KEY = ':';
const DAILY_PHASE_DROP_TOTAL_KEY = ':'; const DAILY_PHASE_DROP_TOTAL_KEY = ':';
const DAILY_PHASE_ALLOC_NUM_KEY = ':';
const DAILY_PHASE_ALREADY_ALLOC_NUM_KEY = ':';
public static function allocBox() public static function allocBox()
{ {
if (!myself()->_switchIsOpen('bigEventBoxDrop')) { if (!myself()->_switchIsOpen('bigEventBoxDrop')) {
return 0; return 0;
} }
$boxNum = 0;
$currPhase = self::getCurrentPhase(); $currPhase = self::getCurrentPhase();
$allocableNum = self::getDailyPhaseAllocNum($currPhase, myself()->_getNowDaySeconds());
$alreadyAllocNum = self::getDailyPhaseAlreadyAllocNum($currPhase, myself()->_getNowDaySeconds());
if ($allocNum > 0) {
$lstVal = mt\Parameter::getListValue('battle_event_loot_per_game');
if ($allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2) {
myself()->_rspData(array(
'box_num' => 0
));
return;
}
$rnd = rand($lstVal[0], $lstVal[1]);
if ($rnd <= 0) {
myself()->_rspData(array(
'box_num' => 0
));
return;
}
$boxNum = min($rnd, $allocableNum);
}
return $boxNum;
} }
public static function getCurrentPhase() public static function getCurrentPhase()
@ -39,6 +61,22 @@ class BattleBoxService {
return empty($num) ? 0 : $num; return empty($num) ? 0 : $num;
} }
private static function getDailyPhaseAllocNum($phase, $time)
{
$key = self::DAILY_PHASE_ALLOC_NUM_KEY . $phase . ':' . $time;
$r = $this->_getRedis($key);
$num = $r->get($key);
return empty($num) ? 0 : $num;
}
private static function getDailyPhaseAlreadyAllocNum($phase, $time)
{
$key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time;
$r = $this->_getRedis($key);
$num = $r->get($key);
return empty($num) ? 0 : $num;
}
private static function incAlreadyTodayAllocBoxNum($val) private static function incAlreadyTodayAllocBoxNum($val)
{ {
$key = 'box_daily_already_alloc_num:' . myself()->_getNowDaySeconds(); $key = 'box_daily_already_alloc_num:' . myself()->_getNowDaySeconds();