修改原有框架中英文映射
This commit is contained in:
@@ -35,7 +35,7 @@ class GameLogic
|
||||
public function buyLotteryTickets(int $playerId, int $count): array
|
||||
{
|
||||
if (!isset(self::PACKAGES[$count])) {
|
||||
throw new ApiException('购买抽奖券错误');
|
||||
throw new ApiException('Invalid lottery ticket purchase');
|
||||
}
|
||||
$pack = self::PACKAGES[$count];
|
||||
$cost = $pack['coin'];
|
||||
@@ -45,11 +45,11 @@ class GameLogic
|
||||
|
||||
$player = DicePlayer::find($playerId);
|
||||
if (!$player) {
|
||||
throw new ApiException('用户不存在');
|
||||
throw new ApiException('User not found');
|
||||
}
|
||||
$coinBefore = (float) $player->coin;
|
||||
if ($coinBefore < $cost) {
|
||||
throw new ApiException('平台币不足');
|
||||
throw new ApiException('Insufficient balance');
|
||||
}
|
||||
|
||||
$coinAfter = $coinBefore - $cost;
|
||||
|
||||
@@ -53,7 +53,7 @@ class PlayStartLogic
|
||||
{
|
||||
$player = DicePlayer::find($playerId);
|
||||
if (!$player) {
|
||||
throw new ApiException('用户不存在');
|
||||
throw new ApiException('User not found');
|
||||
}
|
||||
|
||||
$minEv = DiceRewardConfig::getCachedMinRealEv();
|
||||
@@ -66,7 +66,7 @@ class PlayStartLogic
|
||||
$paid = (int) ($player->paid_ticket_count ?? 0);
|
||||
$free = (int) ($player->free_ticket_count ?? 0);
|
||||
if ($paid + $free <= 0) {
|
||||
throw new ApiException('抽奖券不足');
|
||||
throw new ApiException('Insufficient lottery tickets');
|
||||
}
|
||||
|
||||
$lotteryService = LotteryService::getOrCreate($playerId);
|
||||
@@ -74,7 +74,7 @@ class PlayStartLogic
|
||||
$configType0 = DiceLotteryPoolConfig::where('name', 'default')->find();
|
||||
$configType1 = DiceLotteryPoolConfig::where('name', 'killScore')->find();
|
||||
if (!$configType0) {
|
||||
throw new ApiException('奖池配置不存在(需 name=default)');
|
||||
throw new ApiException('Lottery pool config not found (name=default required)');
|
||||
}
|
||||
|
||||
// 玩家累计盈利:仅统计 lottery_config_id=type=0 的成功对局(中奖金额-100*局数)
|
||||
@@ -119,7 +119,7 @@ class PlayStartLogic
|
||||
}
|
||||
if ($chosen === null) {
|
||||
Log::error("多次摇取档位后仍无有效 DiceReward");
|
||||
throw new ApiException('暂无可用奖励配置');
|
||||
throw new ApiException('No available reward config');
|
||||
}
|
||||
|
||||
$startIndex = (int) ($chosen['start_index'] ?? 0);
|
||||
|
||||
@@ -29,7 +29,7 @@ class UserLogic
|
||||
public static function validatePhone(string $phone): void
|
||||
{
|
||||
if (!preg_match(self::PHONE_REGEX, $phone)) {
|
||||
throw new ApiException('手机号格式错误,仅支持 +60 开头的马来西亚号码(如 +60123456789)');
|
||||
throw new ApiException('Invalid phone format, only +60 Malaysia numbers supported (e.g. +60123456789)');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,17 +52,17 @@ class UserLogic
|
||||
{
|
||||
$username = trim($username);
|
||||
if ($username === '') {
|
||||
throw new ApiException('username 不能为空');
|
||||
throw new ApiException('username is required');
|
||||
}
|
||||
|
||||
$player = DicePlayer::where('username', $username)->find();
|
||||
if ($player) {
|
||||
if ((int) ($player->status ?? 1) === 0) {
|
||||
throw new ApiException('账号已被禁用,无法登录');
|
||||
throw new ApiException('Account is disabled and cannot log in');
|
||||
}
|
||||
$hashed = $this->hashPassword($password);
|
||||
if ($player->password !== $hashed) {
|
||||
throw new ApiException('密码错误');
|
||||
throw new ApiException('Wrong password');
|
||||
}
|
||||
$currentCoin = (float) $player->coin;
|
||||
$player->coin = $currentCoin + $coin;
|
||||
|
||||
Reference in New Issue
Block a user