功能:字体颜色持久化、等级体系升级至99级、钓鱼小游戏、补充系统参数

- 字体颜色:s_color 改为 varchar,发消息时保存颜色,进入聊天室自动恢复
- 等级体系:maxlevel 15→99,superlevel 16→100,99级经验阶梯(幂次曲线)
- 管理权限等级按比例调整:禁言50、踢人60、设公告60、封号80、封IP90
- 钓鱼小游戏:FishingController(抛竿扣金币+收竿随机结果+广播)
- 补充6个缺失的 sysparam 参数 + 4个钓鱼参数
- 用户列表点击用户名后自动聚焦输入框
- Pint 格式化
This commit is contained in:
2026-02-26 21:10:34 +08:00
parent d884853968
commit ea06328885
652 changed files with 5013 additions and 1274 deletions
+57
View File
@@ -0,0 +1,57 @@
<?php
/**
* 文件功能:自动动作事件模型
* 对应原版 ASP 聊天室的 autoact
* 存储系统随机事件(好运/坏运/经验/金币奖惩)
* 管理员可在后台管理这些事件
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Autoact extends Model
{
/** @var string 表名 */
protected $table = 'autoact';
/** @var array 可批量赋值的字段 */
protected $fillable = [
'text_body',
'event_type',
'exp_change',
'jjb_change',
'enabled',
];
/** @var array 类型转换 */
protected $casts = [
'exp_change' => 'integer',
'jjb_change' => 'integer',
'enabled' => 'boolean',
];
/**
* 随机获取一条已启用的事件
*/
public static function randomEvent(): ?self
{
return static::where('enabled', true)->inRandomOrder()->first();
}
/**
* 将事件文本中的变量替换为实际值
*
* @param string $username 当前用户名
* @return string 替换后的文本
*/
public function renderText(string $username): string
{
return str_replace('{username}', $username, $this->text_body);
}
}
+1
View File
@@ -36,6 +36,7 @@ class Room extends Model
'build_time',
'permit_level',
'door_open',
'announcement',
];
/**
+74 -13
View File
@@ -2,28 +2,89 @@
/**
* 文件功能:系统参数模型
* 对应原版 ASP 聊天室的 sysparam 配置表
* 管理员可在后台修改等级经验阈值等系统参数
*
* 对应原 ASP 文件:sysparam
*
* @author ChatRoom Laravel
*
* @version 1.0.0
* @package App\Models
* @author ChatRoom Laravel
* @version 1.0.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class SysParam extends Model
class Sysparam extends Model
{
/** @var string 表名 */
protected $table = 'sysparam';
/** @var array 可批量赋值的字段 */
protected $fillable = ['alias', 'body', 'guidetxt'];
/**
* The attributes that are mass assignable.
* 获取指定参数的值
* 带缓存,避免频繁查库
*
* @var array<int, string>
* @param string $alias 参数别名
* @param string $default 默认值
* @return string
*/
protected $fillable = [
'alias',
'guidetxt',
'body',
];
public static function getValue(string $alias, string $default = ''): string
{
return Cache::remember("sysparam:{$alias}", 300, function () use ($alias, $default) {
$param = static::where('alias', $alias)->first();
return $param ? ($param->body ?? $default) : $default;
});
}
/**
* 获取等级经验阈值数组
* 返回格式:[0 => 10, 1 => 50, 2 => 150, ...] 索引即为目标等级-1
*
* @return array<int, int>
*/
public static function getLevelExpThresholds(): array
{
$str = static::getValue('levelexp', '10,50,150,400,800,1500,3000,5000,8000,12000,18000,25000,35000,50000,80000');
return array_map('intval', explode(',', $str));
}
/**
* 根据经验值计算应该达到的等级
*
* @param int $expNum 当前经验值
* @return int 对应的等级
*/
public static function calculateLevel(int $expNum): int
{
$thresholds = static::getLevelExpThresholds();
$level = 0;
foreach ($thresholds as $threshold) {
if ($expNum >= $threshold) {
$level++;
} else {
break;
}
}
// 不超过最大等级
$maxLevel = (int) static::getValue('maxlevel', '99');
return min($level, $maxLevel);
}
/**
* 清除指定参数的缓存
*
* @param string $alias 参数别名
*/
public static function clearCache(string $alias): void
{
Cache::forget("sysparam:{$alias}");
}
}
+16
View File
@@ -12,6 +12,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@@ -34,6 +35,7 @@ class User extends Authenticatable
'room_id',
'first_ip',
'last_ip',
'usersf',
];
/**
@@ -69,4 +71,18 @@ class User extends Authenticatable
'q3_time' => 'datetime',
];
}
/**
* 头像文件名访问器
*
* ASP 系统的头像文件名存储在 usersf 字段中(如 "75.GIF"),
* 但项目中各处通过 $user->headface 来引用头像。
* accessor headface 属性映射到 usersf 字段,保持代码一致性。
*/
protected function headface(): Attribute
{
return Attribute::make(
get: fn () => $this->usersf ?: '1.GIF',
);
}
}