重构DiceLotteryConfig为DiceLotteryPoolConfig
This commit is contained in:
@@ -3,7 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace app\api\service;
|
||||
|
||||
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use support\think\Cache;
|
||||
|
||||
@@ -37,7 +37,7 @@ class LotteryService
|
||||
return self::REDIS_KEY_START_INDEX . $playerId;
|
||||
}
|
||||
|
||||
/** 从 Redis 加载或根据玩家与 DiceLotteryConfig 创建并保存 */
|
||||
/** 从 Redis 加载或根据玩家与 DiceLotteryPoolConfig 创建并保存 */
|
||||
public static function getOrCreate(int $playerId): self
|
||||
{
|
||||
$key = self::getRedisKey($playerId);
|
||||
@@ -56,8 +56,8 @@ class LotteryService
|
||||
if (!$player) {
|
||||
throw new \RuntimeException('玩家不存在');
|
||||
}
|
||||
$config0 = DiceLotteryConfig::where('type', 0)->find();
|
||||
$config1 = DiceLotteryConfig::where('type', 1)->find();
|
||||
$config0 = DiceLotteryPoolConfig::where('type', 0)->find();
|
||||
$config1 = DiceLotteryPoolConfig::where('type', 1)->find();
|
||||
$s = new self($playerId);
|
||||
$s->configType0Id = $config0 ? (int) $config0->id : null;
|
||||
$s->configType1Id = $config1 ? (int) $config1->id : null;
|
||||
@@ -84,7 +84,7 @@ class LotteryService
|
||||
}
|
||||
|
||||
/** 根据奖池配置的 t1_weight..t5_weight 权重随机抽取档位 T1-T5 */
|
||||
public static function drawTierByWeights(DiceLotteryConfig $config): string
|
||||
public static function drawTierByWeights(DiceLotteryPoolConfig $config): string
|
||||
{
|
||||
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];
|
||||
$weights = [
|
||||
|
||||
Reference in New Issue
Block a user