功能:字体颜色持久化、等级体系升级至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:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:为 rooms 表添加 visit_num(人气/访问量)字段
|
||||
* 用于记录房间的总访问人次,每次用户进入房间时递增
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 添加 visit_num 字段到 rooms 表
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('rooms', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('visit_num')->default(0)->after('ooooo')
|
||||
->comment('房间人气(总访问人次)');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚:移除 visit_num 字段
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('rooms', function (Blueprint $table) {
|
||||
$table->dropColumn('visit_num');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:创建系统参数表(sysparam)
|
||||
* 复刻原版 ASP 聊天室的 sysparam 系统配置表
|
||||
* 存储等级-经验阈值、系统开关等管理员可配置项
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 创建 sysparam 表并插入默认等级经验配置
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('sysparam', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('alias', 100)->unique()->comment('参数别名(唯一标识)');
|
||||
$table->text('body')->nullable()->comment('参数值');
|
||||
$table->string('guidetxt', 500)->nullable()->comment('参数说明(后台显示)');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 插入默认的等级经验配置(管理员可在后台修改)
|
||||
// 格式:逗号分隔,每项为"等级所需的累计经验值"
|
||||
// 例如:等级1需要10经验,等级2需要50,等级3需要150...
|
||||
DB::table('sysparam')->insert([
|
||||
[
|
||||
'alias' => 'levelexp',
|
||||
'body' => '10,50,150,400,800,1500,3000,5000,8000,12000,18000,25000,35000,50000,80000',
|
||||
'guidetxt' => '等级经验阈值配置(逗号分隔)。第N个数字表示升到N级所需的累计经验值。例如:10,50,150 表示1级需10经验,2级需50经验,3级需150经验。',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'alias' => 'exp_per_heartbeat',
|
||||
'body' => '1',
|
||||
'guidetxt' => '每次心跳(约60秒)增加的经验值',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'alias' => 'superlevel',
|
||||
'body' => '16',
|
||||
'guidetxt' => '管理员级别(= 最高等级 + 1,拥有最高权限的等级阈值)',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'alias' => 'maxlevel',
|
||||
'body' => '15',
|
||||
'guidetxt' => '用户最高可达等级',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚:删除 sysparam 表
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sysparam');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:创建自动动作事件表(autoact)
|
||||
* 复刻原版 ASP 聊天室的 autoact 表
|
||||
* 存储系统随机事件(好运/坏运/经验/金币奖惩等)
|
||||
* 管理员可在后台增删改这些事件
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 创建 autoact 表并插入默认随机事件
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('autoact', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('text_body', 500)->comment('事件文本内容(支持变量替换)');
|
||||
$table->string('event_type', 20)->default('neutral')->comment('事件类型:good=好运, bad=坏运, neutral=中性');
|
||||
$table->integer('exp_change')->default(0)->comment('经验变化值(正=奖励, 负=惩罚)');
|
||||
$table->integer('jjb_change')->default(0)->comment('金币变化值(正=奖励, 负=惩罚)');
|
||||
$table->boolean('enabled')->default(true)->comment('是否启用');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
// 插入默认随机事件
|
||||
$events = [
|
||||
// 好运事件(奖励经验/金币)
|
||||
['text_body' => '🎉 恭喜【{username}】路遇仙人指点,获得 100 经验值!', 'event_type' => 'good', 'exp_change' => 100, 'jjb_change' => 0],
|
||||
['text_body' => '💰 【{username}】在路边捡到一袋金币,获得 500 金币!', 'event_type' => 'good', 'exp_change' => 0, 'jjb_change' => 500],
|
||||
['text_body' => '🌟 天降祥瑞!【{username}】获得 200 经验 + 200 金币!', 'event_type' => 'good', 'exp_change' => 200, 'jjb_change' => 200],
|
||||
['text_body' => '🎊 【{username}】参加武林大会获胜,奖励 300 经验!', 'event_type' => 'good', 'exp_change' => 300, 'jjb_change' => 0],
|
||||
['text_body' => '🏆 【{username}】完成了一个神秘任务,获得 150 金币!', 'event_type' => 'good', 'exp_change' => 0, 'jjb_change' => 150],
|
||||
['text_body' => '✨ 【{username}】领悟了一招绝学,经验暴增 500!', 'event_type' => 'good', 'exp_change' => 500, 'jjb_change' => 0],
|
||||
['text_body' => '🎁 系统随机赠送【{username}】100 金币,请查收!', 'event_type' => 'good', 'exp_change' => 0, 'jjb_change' => 100],
|
||||
|
||||
// 坏运事件(扣除经验/金币)
|
||||
['text_body' => '💀 【{username}】不小心踩到陷阱,损失 50 经验!', 'event_type' => 'bad', 'exp_change' => -50, 'jjb_change' => 0],
|
||||
['text_body' => '😱 【{username}】遭遇山贼打劫,被抢走 100 金币!', 'event_type' => 'bad', 'exp_change' => 0, 'jjb_change' => -100],
|
||||
['text_body' => '🌧️ 【{username}】在雨中迷路,消耗 80 经验值。', 'event_type' => 'bad', 'exp_change' => -80, 'jjb_change' => 0],
|
||||
['text_body' => '🐍 【{username}】被毒蛇咬了一口,损失 30 经验和 50 金币!', 'event_type' => 'bad', 'exp_change' => -30, 'jjb_change' => -50],
|
||||
|
||||
// 中性事件(纯文字,不奖惩)
|
||||
['text_body' => '🔮 星海小博士:【{username}】今天运势不错,继续加油!', 'event_type' => 'neutral', 'exp_change' => 0, 'jjb_change' => 0],
|
||||
['text_body' => '📜 星海小博士:有人说"坚持就是胜利",【{username}】觉得呢?', 'event_type' => 'neutral', 'exp_change' => 0, 'jjb_change' => 0],
|
||||
['text_body' => '🌈 星海小博士:【{username}】今天心情如何?记得多喝水哦!', 'event_type' => 'neutral', 'exp_change' => 0, 'jjb_change' => 0],
|
||||
['text_body' => '🎵 星海小博士:送给【{username}】一首歌,祝你天天开心!', 'event_type' => 'neutral', 'exp_change' => 0, 'jjb_change' => 0],
|
||||
];
|
||||
|
||||
$now = now();
|
||||
foreach ($events as &$event) {
|
||||
$event['enabled'] = true;
|
||||
$event['created_at'] = $now;
|
||||
$event['updated_at'] = $now;
|
||||
}
|
||||
|
||||
DB::table('autoact')->insert($events);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚:删除 autoact 表
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('autoact');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:为 rooms 表添加 announcement(公告/祝福语)字段
|
||||
* 有权限的用户可以设置房间公告,显示在聊天室顶部滚动条
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 添加 announcement 字段
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('rooms', function (Blueprint $table) {
|
||||
$table->string('announcement', 500)->nullable()->after('room_des')->comment('房间公告/祝福语(滚动显示)');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('rooms', function (Blueprint $table) {
|
||||
$table->dropColumn('announcement');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:将 users 表的 s_color 字段从 integer 改为 varchar
|
||||
* 以便直接存储 hex 颜色字符串(如 #ff0000),与前端颜色选择器格式一致
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 执行迁移:s_color 从 integer 改为 varchar(10)
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('s_color', 10)->nullable()->comment('发言颜色(hex,如 #ff0000)')->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚:s_color 从 varchar 改回 integer
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->integer('s_color')->nullable()->comment('发言颜色')->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:补充缺失的 sysparam 系统参数记录
|
||||
* 代码中引用了多个参数但原始迁移只种子了 4 条,
|
||||
* 此迁移使用 insertOrIgnore 补充缺失的参数配置
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 补充缺失的系统参数记录(使用 insertOrIgnore 避免重复)
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$now = now();
|
||||
|
||||
DB::table('sysparam')->insertOrIgnore([
|
||||
[
|
||||
'alias' => 'level_kick',
|
||||
'body' => '10',
|
||||
'guidetxt' => '踢人所需等级(管理员可在聊天室踢出用户的最低等级)',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
[
|
||||
'alias' => 'level_mute',
|
||||
'body' => '8',
|
||||
'guidetxt' => '禁言所需等级(管理员可在聊天室禁言用户的最低等级)',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
[
|
||||
'alias' => 'level_ban',
|
||||
'body' => '12',
|
||||
'guidetxt' => '封号所需等级(管理员可封禁用户账号的最低等级)',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
[
|
||||
'alias' => 'level_banip',
|
||||
'body' => '14',
|
||||
'guidetxt' => '封IP所需等级(管理员可封禁用户IP地址的最低等级)',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
[
|
||||
'alias' => 'level_announcement',
|
||||
'body' => '10',
|
||||
'guidetxt' => '设置公告所需等级(可修改房间公告/祝福语的最低等级)',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
[
|
||||
'alias' => 'auto_event_chance',
|
||||
'body' => '10',
|
||||
'guidetxt' => '随机事件触发概率(百分比,1-100,每次心跳时按此概率触发随机事件)',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚:删除补充的参数记录
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('sysparam')->whereIn('alias', [
|
||||
'level_kick',
|
||||
'level_mute',
|
||||
'level_ban',
|
||||
'level_banip',
|
||||
'level_announcement',
|
||||
'auto_event_chance',
|
||||
])->delete();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:将等级系统从 15 级扩展到 99 级
|
||||
* - maxlevel: 15 → 99(用户最高等级)
|
||||
* - superlevel: 16 → 100(管理员等级)
|
||||
* - levelexp: 重新生成 99 级的经验阶梯
|
||||
* - 管理权限等级按比例调整到新体系
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 更新等级系统参数至 99 级体系
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// 生成 99 级经验阶梯(使用 level^2.5 的幂次曲线,确保平滑递增)
|
||||
$thresholds = [];
|
||||
for ($level = 1; $level <= 99; $level++) {
|
||||
// 公式:10 * level^2.5,取整到十位数,保持数据整洁
|
||||
$exp = (int) (ceil(10 * pow($level, 2.5) / 10) * 10);
|
||||
$thresholds[] = $exp;
|
||||
}
|
||||
$levelExpStr = implode(',', $thresholds);
|
||||
|
||||
$now = now();
|
||||
|
||||
// 更新核心等级参数
|
||||
DB::table('sysparam')->where('alias', 'maxlevel')
|
||||
->update(['body' => '99', 'guidetxt' => '用户最高可达等级', 'updated_at' => $now]);
|
||||
|
||||
DB::table('sysparam')->where('alias', 'superlevel')
|
||||
->update(['body' => '100', 'guidetxt' => '管理员级别(= 最高等级 + 1,拥有最高权限的等级阈值)', 'updated_at' => $now]);
|
||||
|
||||
DB::table('sysparam')->where('alias', 'levelexp')
|
||||
->update(['body' => $levelExpStr, 'updated_at' => $now]);
|
||||
|
||||
// 按比例调整管理权限等级(原体系 /15,新体系 /99)
|
||||
// 禁言:8/15 ≈ 53% → 50级
|
||||
DB::table('sysparam')->where('alias', 'level_mute')
|
||||
->update(['body' => '50', 'updated_at' => $now]);
|
||||
|
||||
// 踢人:10/15 ≈ 67% → 60级
|
||||
DB::table('sysparam')->where('alias', 'level_kick')
|
||||
->update(['body' => '60', 'updated_at' => $now]);
|
||||
|
||||
// 设公告:10/15 ≈ 67% → 60级
|
||||
DB::table('sysparam')->where('alias', 'level_announcement')
|
||||
->update(['body' => '60', 'updated_at' => $now]);
|
||||
|
||||
// 封号:12/15 = 80% → 80级
|
||||
DB::table('sysparam')->where('alias', 'level_ban')
|
||||
->update(['body' => '80', 'updated_at' => $now]);
|
||||
|
||||
// 封IP:14/15 ≈ 93% → 90级
|
||||
DB::table('sysparam')->where('alias', 'level_banip')
|
||||
->update(['body' => '90', 'updated_at' => $now]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚:恢复到原始 15 级体系
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$now = now();
|
||||
|
||||
DB::table('sysparam')->where('alias', 'maxlevel')
|
||||
->update(['body' => '15', 'updated_at' => $now]);
|
||||
|
||||
DB::table('sysparam')->where('alias', 'superlevel')
|
||||
->update(['body' => '16', 'updated_at' => $now]);
|
||||
|
||||
DB::table('sysparam')->where('alias', 'levelexp')
|
||||
->update(['body' => '10,50,150,400,800,1500,3000,5000,8000,12000,18000,25000,35000,50000,80000', 'updated_at' => $now]);
|
||||
|
||||
DB::table('sysparam')->where('alias', 'level_mute')
|
||||
->update(['body' => '8', 'updated_at' => $now]);
|
||||
|
||||
DB::table('sysparam')->where('alias', 'level_kick')
|
||||
->update(['body' => '10', 'updated_at' => $now]);
|
||||
|
||||
DB::table('sysparam')->where('alias', 'level_announcement')
|
||||
->update(['body' => '10', 'updated_at' => $now]);
|
||||
|
||||
DB::table('sysparam')->where('alias', 'level_ban')
|
||||
->update(['body' => '12', 'updated_at' => $now]);
|
||||
|
||||
DB::table('sysparam')->where('alias', 'level_banip')
|
||||
->update(['body' => '14', 'updated_at' => $now]);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:添加钓鱼系统参数到 sysparam 表
|
||||
* 配置钓鱼花费金币、冷却时间、等待上钩时间范围
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 插入钓鱼相关系统参数
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$now = now();
|
||||
|
||||
DB::table('sysparam')->insertOrIgnore([
|
||||
[
|
||||
'alias' => 'fishing_cost',
|
||||
'body' => '5',
|
||||
'guidetxt' => '每次钓鱼花费金币数量',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
[
|
||||
'alias' => 'fishing_cooldown',
|
||||
'body' => '300',
|
||||
'guidetxt' => '钓鱼冷却时间(秒,默认300秒=5分钟)',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
[
|
||||
'alias' => 'fishing_wait_min',
|
||||
'body' => '8',
|
||||
'guidetxt' => '钓鱼最短等待上钩时间(秒)',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
[
|
||||
'alias' => 'fishing_wait_max',
|
||||
'body' => '15',
|
||||
'guidetxt' => '钓鱼最长等待上钩时间(秒)',
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚:删除钓鱼参数
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('sysparam')->whereIn('alias', [
|
||||
'fishing_cost',
|
||||
'fishing_cooldown',
|
||||
'fishing_wait_min',
|
||||
'fishing_wait_max',
|
||||
])->delete();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user