功能:随机浮漂钓鱼防挂机 + 商店自动钓鱼卡

核心变更:
1. FishingController 重写
   - cast(): 生成随机浮漂坐标(x/y%) + 一次性 token
   - reel(): 必须携带 token 才能收竿(防脚本绕过)
   - 检测自动钓鱼卡剩余时间并返回给前端

2. 前端钓鱼逻辑重写
   - 抛竿后显示随机位置 🪝 浮漂动画(全屏飘动)
   - 鱼上钩时浮漂「下沉」动画,8秒内点击浮漂才能收竿
   - 超时未点击:鱼跑了,token 也失效
   - 持有自动钓鱼卡:自动点击,紫色提示剩余时间

3. 商店新增「🎣 自动钓鱼卡」分组
   - 3档:2h(800金)/8h(2500金)/24h(6000金)
   - 图标徽章显示剩余有效时间(紫色)
   - 购买后即时激活,无需手动操作

4. 数据库
   - shop_items.type 加 auto_fishing 枚举
   - shop_items.duration_minutes 新字段(分钟精度)
   - Seeder 写入 3 张卡数据

防挂机原理:按钮 → 浮漂随机位置,脚本无法固定坐标点击
This commit is contained in:
2026-03-01 16:19:45 +08:00
parent e0c15b437e
commit 63679a622f
9 changed files with 417 additions and 77 deletions

View File

@@ -2,12 +2,16 @@
/**
* 文件功能:钓鱼小游戏控制器
* 复刻原版 ASP 聊天室 diaoyu/ 目录下的钓鱼功能
* 简化掉鱼竿道具系统,用 Redis 控制冷却,随机奖惩经验/金币
*
* 新增随机浮漂点击防挂机机制:
* - 抛竿时生成一次性 token 和随机浮漂坐标(百分比),返回给前端
* - 前端显示漂浮动画,等待下沉后用户点击,将 token 随收竿请求提交
* - 若持有有效「自动钓鱼卡」,前端直接自动点击,无需手动操作
* - 服务端验证 token 有效性,防止脚本直接调用收竿接口
*
* @author ChatRoom Laravel
*
* @version 1.0.0
* @version 2.0.0
*/
namespace App\Http\Controllers;
@@ -16,12 +20,14 @@ use App\Enums\CurrencySource;
use App\Events\MessageSent;
use App\Models\Sysparam;
use App\Services\ChatStateService;
use App\Services\ShopService;
use App\Services\UserCurrencyService;
use App\Services\VipService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Str;
class FishingController extends Controller
{
@@ -29,10 +35,17 @@ class FishingController extends Controller
private readonly ChatStateService $chatState,
private readonly VipService $vipService,
private readonly UserCurrencyService $currencyService,
private readonly ShopService $shopService,
) {}
/**
* 抛竿 检查冷却和金币,扣除金币,返回随机等待时间
* 抛竿 检查冷却和金币,扣除金币,生成浮漂 token 和随机坐标。
*
* 返回:
* wait_time 等待秒数(前端倒数后触发下沉动画)
* bobber_x/y 浮漂随机位置0-100 百分比)
* token 本次钓鱼唯一令牌(收竿时必须携带)
* auto_fishing 是否持有有效自动钓鱼卡(前端据此自动点击)
*
* @param int $id 房间ID
*/
@@ -64,36 +77,49 @@ class FishingController extends Controller
], 422);
}
// 3. 扣除金币(通过统一积分服务记录流水)
// 3. 扣除金币
$this->currencyService->change(
$user,
'gold',
-$cost,
$user, 'gold', -$cost,
CurrencySource::FISHING_COST,
"钓鱼抛竿消耗 {$cost} 金币",
$id,
);
$user->refresh(); // 刷新本地模型service 已原子更新)
$user->refresh();
// 4. 设置"正在钓鱼"标记防止重复抛竿30秒后自动过期
Redis::setex("fishing:active:{$user->id}", 30, time());
// 5. 计算随机等待时间
// 4. 生成一次性 token存入 RedisTTL = 等待时间 + 收竿窗口 + 缓冲
$waitMin = (int) Sysparam::getValue('fishing_wait_min', '8');
$waitMax = (int) Sysparam::getValue('fishing_wait_max', '15');
$waitTime = rand($waitMin, $waitMax);
$token = Str::random(32);
$tokenKey = "fishing:token:{$user->id}";
// token 有效期 = 等待时间 + 10秒点击窗口 + 5秒缓冲
Redis::setex($tokenKey, $waitTime + 15, $token);
// 5. 生成随机浮漂坐标(百分比,避开边缘)
$bobberX = rand(15, 85); // 左右 15%~85%
$bobberY = rand(20, 65); // 上下 20%~65%
// 6. 检查是否持有有效自动钓鱼卡
$autoFishingMinutes = $this->shopService->getActiveAutoFishingMinutesLeft($user);
return response()->json([
'status' => 'success',
'message' => "已花费 {$cost} 金币,鱼竿已抛出!等待鱼儿上钩...",
'wait_time' => $waitTime,
'bobber_x' => $bobberX,
'bobber_y' => $bobberY,
'token' => $token,
'auto_fishing' => $autoFishingMinutes > 0,
'auto_fishing_minutes_left' => $autoFishingMinutes,
'cost' => $cost,
'jjb' => $user->jjb,
]);
}
/**
* 收竿 随机计算钓鱼结果,更新经验/金币,广播到聊天室
* 收竿 验证浮漂 token随机计算钓鱼结果,更新经验/金币,广播到聊天室
*
* 必须携带 token从抛竿接口获取否则判定为非法收竿。
*
* @param int $id 房间ID
*/
@@ -104,17 +130,20 @@ class FishingController extends Controller
return response()->json(['status' => 'error', 'message' => '请先登录'], 401);
}
// 1. 检查是否有"正在钓鱼"标记
$activeKey = "fishing:active:{$user->id}";
if (! Redis::exists($activeKey)) {
// 1. 验证 token防止脚本绕过浮漂直接收竿
$tokenKey = "fishing:token:{$user->id}";
$storedToken = Redis::get($tokenKey);
$clientToken = $request->input('token', '');
if (! $storedToken || $storedToken !== $clientToken) {
return response()->json([
'status' => 'error',
'message' => '您还没有抛竿,或者鱼已经跑了!',
'message' => '鱼儿跑了!浮漂已超时或令牌无效,请重新抛竿。',
], 422);
}
// 清除钓鱼标记
Redis::del($activeKey);
// 清除 token一次性
Redis::del($tokenKey);
// 2. 设置冷却时间
$cooldown = (int) Sysparam::getValue('fishing_cooldown', '300');
@@ -123,7 +152,7 @@ class FishingController extends Controller
// 3. 随机决定钓鱼结果
$result = $this->randomFishResult();
// 4. 通过统一积分服务更新经验和金币,写入流水
// 4. 通过统一积分服务更新经验和金币
$expMul = $this->vipService->getExpMultiplier($user);
$jjbMul = $this->vipService->getJjbMultiplier($user);
if ($result['exp'] !== 0) {
@@ -140,7 +169,7 @@ class FishingController extends Controller
"钓鱼收竿:{$result['message']}", $id,
);
}
$user->refresh(); // 刷新获取最新余额
$user->refresh();
// 5. 广播钓鱼结果到聊天室
$sysMsg = [
@@ -175,15 +204,6 @@ class FishingController extends Controller
{
$roll = rand(1, 100);
// 概率分布(总计 100%
// 1-15: 大鲨鱼 (+100exp, +20金)
// 16-30: 娃娃鱼 (+0exp, +30金)
// 31-50: 大草鱼 (+50exp)
// 51-70: 小鲤鱼 (+50exp, +10金)
// 71-85: 落水 (-50exp)
// 86-95: 被打 (-20exp, -3金)
// 96-100:大丰收 (+150exp, +50金)
return match (true) {
$roll <= 15 => [
'emoji' => '🦈',

View File

@@ -42,6 +42,7 @@ class ShopController extends Controller
'price' => $item->price,
'type' => $item->type,
'duration_days' => $item->duration_days,
'duration_minutes' => $item->duration_minutes,
'intimacy_bonus' => $item->intimacy_bonus,
'charm_bonus' => $item->charm_bonus,
]);
@@ -61,7 +62,8 @@ class ShopController extends Controller
'user_jjb' => $user->jjb ?? 0,
'active_week_effect' => $this->shopService->getActiveWeekEffect($user),
'has_rename_card' => $this->shopService->hasRenameCard($user),
'ring_counts' => $ringCounts, // [item_id => qty]
'ring_counts' => $ringCounts,
'auto_fishing_minutes_left' => $this->shopService->getActiveAutoFishingMinutesLeft($user),
]);
}

View File

@@ -17,7 +17,8 @@ class ShopItem extends Model
protected $fillable = [
'name', 'slug', 'description', 'icon', 'price',
'type', 'duration_days', 'sort_order', 'is_active',
'type', 'duration_days', 'duration_minutes', 'sort_order', 'is_active',
'intimacy_bonus', 'charm_bonus',
];
protected $casts = [
@@ -32,6 +33,14 @@ class ShopItem extends Model
return $this->hasMany(UserPurchase::class);
}
/**
* 是否为自动钓鱼卡
*/
public function isAutoFishingCard(): bool
{
return $this->type === 'auto_fishing';
}
/**
* 是否为特效类商品instant durationslug once_ week_ 开头)
*/

View File

@@ -33,6 +33,7 @@ class ShopService
'duration' => $this->buyWeekCard($user, $item),
'one_time' => $this->buyRenameCard($user, $item),
'ring' => $this->buyRing($user, $item),
'auto_fishing' => $this->buyAutoFishingCard($user, $item),
default => ['ok' => false, 'message' => '未知商品类型'],
};
}
@@ -245,4 +246,57 @@ class ShopService
->whereHas('shopItem', fn ($q) => $q->where('slug', 'rename_card'))
->exists();
}
/**
* 购买自动钓鱼卡:手刺金币,写入 active 记录,到期时间 = 现在 + duration_minutes。
*
* @return array{ok:bool, message:string}
*/
public function buyAutoFishingCard(User $user, ShopItem $item): array
{
$minutes = (int) $item->duration_minutes;
if ($minutes <= 0) {
return ['ok' => false, 'message' => '该钓鱼卡配置异常,请联系管理员。'];
}
DB::transaction(function () use ($user, $item, $minutes): void {
// 手刺金币
$user->decrement('jjb', $item->price);
// 写入背包active刻起计时
UserPurchase::create([
'user_id' => $user->id,
'shop_item_id' => $item->id,
'status' => 'active',
'price_paid' => $item->price,
'expires_at' => Carbon::now()->addMinutes($minutes),
]);
});
$hours = round($minutes / 60, 1);
return [
'ok' => true,
'message' => "🎣 {$item->name}购买成功!{$hours}小时内鬼鱼自动收篼,尽情摆烂!",
];
}
/**
* 获取用户当前有效的自动钓鱼卡剩余分钟数(没有则返回 0
*/
public function getActiveAutoFishingMinutesLeft(User $user): int
{
$purchase = UserPurchase::where('user_id', $user->id)
->where('status', 'active')
->whereNotNull('expires_at')
->whereHas('shopItem', fn ($q) => $q->where('type', 'auto_fishing'))
->where('expires_at', '>', Carbon::now())
->orderByDesc('expires_at') // 取最晚过期的
->first();
if (! $purchase) {
return 0;
}
return (int) Carbon::now()->diffInMinutes($purchase->expires_at, false);
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* 文件功能:为 shop_items.type 枚举添加 auto_fishing自动钓鱼卡类型
*
* 自动钓鱼卡激活后,钓鱼无需点击随机浮漂,系统自动收竿。
* duration_hours 字段控制有效期(使用 duration_days 字段1day=24h
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
/**
* 添加 auto_fishing 枚举值。
*/
public function up(): void
{
DB::statement("ALTER TABLE `shop_items` MODIFY `type` ENUM('instant','duration','one_time','ring','auto_fishing') NOT NULL COMMENT '道具类型'");
}
/**
* 回滚:先将 auto_fishing 记录改为 one_time再删除枚举值。
*/
public function down(): void
{
DB::statement("UPDATE `shop_items` SET `type` = 'one_time' WHERE `type` = 'auto_fishing'");
DB::statement("ALTER TABLE `shop_items` MODIFY `type` ENUM('instant','duration','one_time','ring') NOT NULL COMMENT '道具类型'");
}
};

View File

@@ -0,0 +1,35 @@
<?php
/**
* 文件功能:为 shop_items 表添加 duration_minutes 字段
*
* 用于自动钓鱼卡等按分钟计算有效期的道具,
* 避免复用 duration_days天级精度不够
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 添加 duration_minutes 字段。
*/
public function up(): void
{
Schema::table('shop_items', function (Blueprint $table): void {
$table->unsignedSmallInteger('duration_minutes')->default(0)->after('duration_days')->comment('道具有效时长分钟0=不适用');
});
}
/**
* 回滚:删除字段。
*/
public function down(): void
{
Schema::table('shop_items', function (Blueprint $table): void {
$table->dropColumn('duration_minutes');
});
}
};

View File

@@ -0,0 +1,68 @@
<?php
/**
* 文件功能:初始化自动钓鱼卡商品数据
*
* 3 2小时卡、8小时卡、24小时卡。
* 激活后钓鱼无需手动点击浮漂,系统自动收竿。
* 可重复运行updateOrCreate 幂等)。
*/
namespace Database\Seeders;
use App\Models\ShopItem;
use Illuminate\Database\Seeder;
class AutoFishingCardSeeder extends Seeder
{
/**
* 写入 3 档自动钓鱼卡数据。
*/
public function run(): void
{
$cards = [
[
'slug' => 'auto_fishing_2h',
'name' => '自动钓鱼卡2小时',
'icon' => '🎣',
'description' => '激活后2小时内钓鱼无需手动点击浮漂系统自动收竿。',
'price' => 800,
'type' => 'auto_fishing',
'duration_minutes' => 120,
'sort_order' => 201,
'is_active' => true,
],
[
'slug' => 'auto_fishing_8h',
'name' => '自动钓鱼卡8小时',
'icon' => '🎣',
'description' => '激活后8小时内钓鱼无需手动点击浮漂系统自动收竿。超值之选',
'price' => 2500,
'type' => 'auto_fishing',
'duration_minutes' => 480,
'sort_order' => 202,
'is_active' => true,
],
[
'slug' => 'auto_fishing_24h',
'name' => '自动钓鱼卡24小时',
'icon' => '🎣',
'description' => '激活后24小时内钓鱼无需手动点击浮漂系统自动收竿。重度钓鱼爱好者必备',
'price' => 6000,
'type' => 'auto_fishing',
'duration_minutes' => 1440,
'sort_order' => 203,
'is_active' => true,
],
];
foreach ($cards as $card) {
ShopItem::updateOrCreate(
['slug' => $card['slug']],
$card
);
}
$this->command->info('✅ 3 张自动钓鱼卡已写入 shop_items。');
}
}

View File

@@ -1619,16 +1619,74 @@
btn.disabled = false;
btn.textContent = '确定更换';
}
// ── 钓鱼小游戏(复刻原版 diaoyu/ 功能)─────────────
// ── 钓鱼小游戏(随机浮漂版)─────────────────────────
let fishingTimer = null;
let fishingReelTimeout = null;
let _fishToken = null; // 当次钓鱼的 token
/**
* 开始钓鱼 调用抛竿 API花费金币显示等待动画
* 创建浮漂 DOM 元素(绝对定位在聊天框上层)
* @param {number} x 水平百分比 0-100
* @param {number} y 垂直百分比 0-100
* @returns {HTMLElement}
*/
function createBobber(x, y) {
const el = document.createElement('div');
el.id = 'fishing-bobber';
el.style.cssText = `
position: fixed;
left: ${x}vw;
top: ${y}vh;
font-size: 28px;
cursor: pointer;
z-index: 9999;
animation: bobberFloat 1.2s ease-in-out infinite;
filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
user-select: none;
transition: transform 0.3s;
`;
el.textContent = '🪝';
el.title = '鱼上钩了!快点击!';
// 注入动画
if (!document.getElementById('bobber-style')) {
const style = document.createElement('style');
style.id = 'bobber-style';
style.textContent = `
@keyframes bobberFloat {
0%,100% { transform: translateY(0) rotate(-8deg); }
50% { transform: translateY(-10px) rotate(8deg); }
}
@keyframes bobberSink {
0% { transform: translateY(0) scale(1); opacity:1; }
30% { transform: translateY(12px) scale(1.3); opacity:1; }
100% { transform: translateY(40px) scale(0.5); opacity:0; }
}
@keyframes bobberPulse {
0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.6); }
50% { box-shadow: 0 0 0 14px rgba(220,38,38,0); }
}
#fishing-bobber.sinking {
animation: bobberSink 0.5s forwards !important;
}
`;
document.head.appendChild(style);
}
return el;
}
/** 移除浮漂 */
function removeBobber() {
const el = document.getElementById('fishing-bobber');
if (el) el.remove();
}
/**
* 开始钓鱼:调用抛竿 API随机显示浮漂位置
*/
async function startFishing() {
const btn = document.getElementById('fishing-btn');
btn.disabled = true;
btn.textContent = '🎣 抛竿中...';
try {
const res = await fetch(window.chatContext.fishCastUrl, {
@@ -1643,85 +1701,124 @@
if (!res.ok || data.status !== 'success') {
window.chatDialog.alert(data.message || '钓鱼失败', '操作失败', '#cc4444');
btn.disabled = false;
btn.textContent = '🎣 钓鱼';
return;
}
// 在包厢窗口显示抛竿消息
const now = new Date();
const timeStr = now.getHours().toString().padStart(2, '0') + ':' +
now.getMinutes().toString().padStart(2, '0') + ':' +
now.getSeconds().toString().padStart(2, '0');
// 保存本次 token收竿时提交
_fishToken = data.token;
// 聊天框提示
const castDiv = document.createElement('div');
castDiv.className = 'msg-line';
const timeStr = new Date().toLocaleTimeString('zh-CN', {
hour12: false
});
castDiv.innerHTML =
`<span style="color: #2563eb; font-weight: bold;">🎣【钓鱼】</span>${data.message}<span class="msg-time">(${timeStr})</span>`;
`<span style="color:#2563eb;font-weight:bold;">🎣【钓鱼】</span>${data.message}<span class="msg-time">(${timeStr})</span>`;
container2.appendChild(castDiv);
if (autoScroll) container2.scrollTop = container2.scrollHeight;
// 等待鱼上钩(后端返回的随机等待秒数)
btn.textContent = '🎣 等待中...';
// 创建浮漂(浮漂在随机位置)
const bobber = createBobber(data.bobber_x, data.bobber_y);
document.body.appendChild(bobber);
// 等待 wait_time 秒后浮漂「下沉」
fishingTimer = setTimeout(() => {
// 鱼上钩了!
// 播放下沉动画
bobber.classList.add('sinking');
bobber.textContent = '🐟';
const hookDiv = document.createElement('div');
hookDiv.className = 'msg-line';
hookDiv.innerHTML =
'<span style="color: #d97706; font-weight: bold; font-size: 14px;">🐟 鱼上钩了!快点击 <span onclick="reelFish()" style="text-decoration:underline; cursor:pointer; color:#dc2626;">[拉竿]</span> 按钮!</span>';
container2.appendChild(hookDiv);
if (autoScroll) container2.scrollTop = container2.scrollHeight;
btn.textContent = '🎣 拉竿!';
btn.disabled = false;
btn.onclick = reelFish;
// 15 秒内不拉竿,鱼跑掉
fishingReelTimeout = setTimeout(() => {
const missDiv = document.createElement('div');
missDiv.className = 'msg-line';
missDiv.innerHTML =
'<span style="color: #999;">💨 你反应太慢了,鱼跑掉了...</span>';
container2.appendChild(missDiv);
if (data.auto_fishing) {
// 自动钓鱼卡:在动画结束后自动收竿
hookDiv.innerHTML =
`<span style="color:#7c3aed;font-weight:bold;">🎣 自动钓鱼卡生效!自动收竿中... <span style="font-size:10px;opacity:0.7">(剩余${data.auto_fishing_minutes_left}分钟)</span></span>`;
container2.appendChild(hookDiv);
if (autoScroll) container2.scrollTop = container2.scrollHeight;
resetFishingBtn();
}, 15000);
// 500ms 后自动收竿(等动画)
fishingReelTimeout = setTimeout(() => {
removeBobber();
reelFish();
}, 600);
} else {
// 手动模式:玩家需在 8 秒内点击浮漂
hookDiv.innerHTML =
`<span style="color:#d97706;font-weight:bold;font-size:14px;">🐟 鱼上钩了!快点击屏幕上的浮漂!</span>`;
container2.appendChild(hookDiv);
if (autoScroll) container2.scrollTop = container2.scrollHeight;
btn.textContent = '🎣 点击浮漂!';
// 浮漂点击事件
bobber.onclick = () => {
removeBobber();
if (fishingReelTimeout) {
clearTimeout(fishingReelTimeout);
fishingReelTimeout = null;
}
reelFish();
};
// 8 秒内不点击 → 鱼跑了token 过期服务端也会拒绝)
fishingReelTimeout = setTimeout(() => {
removeBobber();
_fishToken = null;
const missDiv = document.createElement('div');
missDiv.className = 'msg-line';
missDiv.innerHTML = '<span style="color:#999;">💨 你反应太慢了,鱼跑掉了...</span>';
container2.appendChild(missDiv);
if (autoScroll) container2.scrollTop = container2.scrollHeight;
resetFishingBtn();
}, 8000);
}
}, data.wait_time * 1000);
} catch (e) {
window.chatDialog.alert('网络错误:' + e.message, '网络异常', '#cc4444');
removeBobber();
btn.disabled = false;
btn.textContent = '🎣 钓鱼';
}
}
/**
* 竿 调用收竿 API,获取随机结果
* 竿 提交 token 到后端,获取随机结果
*/
async function reelFish() {
const btn = document.getElementById('fishing-btn');
btn.disabled = true;
btn.textContent = '🎣 拉竿中...';
// 取消跑鱼计时器
if (fishingReelTimeout) {
clearTimeout(fishingReelTimeout);
fishingReelTimeout = null;
}
const token = _fishToken;
_fishToken = null;
try {
const res = await fetch(window.chatContext.fishReelUrl, {
method: 'POST',
headers: {
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
'Accept': 'application/json'
}
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
token
})
});
const data = await res.json();
const now = new Date();
const timeStr = now.getHours().toString().padStart(2, '0') + ':' +
now.getMinutes().toString().padStart(2, '0') + ':' +
now.getSeconds().toString().padStart(2, '0');
const timeStr = new Date().toLocaleTimeString('zh-CN', {
hour12: false
});
if (res.ok && data.status === 'success') {
const r = data.result;
@@ -1729,15 +1826,15 @@
const resultDiv = document.createElement('div');
resultDiv.className = 'msg-line';
resultDiv.innerHTML =
`<span style="color: ${color}; font-weight: bold;">${r.emoji}【钓鱼结果】</span>${r.message}` +
` <span style="color: #666; font-size: 11px;">当前经验:${data.exp_num} 金币:${data.jjb}</span>` +
`<span style="color:${color};font-weight:bold;">${r.emoji}【钓鱼结果】</span>${r.message}` +
` <span style="color:#666;font-size:11px;">(经验:${data.exp_num} 金币:${data.jjb}</span>` +
`<span class="msg-time">(${timeStr})</span>`;
container2.appendChild(resultDiv);
} else {
const errDiv = document.createElement('div');
errDiv.className = 'msg-line';
errDiv.innerHTML =
`<span style="color: red;">【钓鱼】${data.message || '操作失败'}</span><span class="msg-time">(${timeStr})</span>`;
`<span style="color:red;">【钓鱼】${data.message || '操作失败'}</span><span class="msg-time">(${timeStr})</span>`;
container2.appendChild(errDiv);
}
if (autoScroll) container2.scrollTop = container2.scrollHeight;
@@ -1758,6 +1855,7 @@
btn.onclick = startFishing;
fishingTimer = null;
fishingReelTimeout = null;
removeBobber();
}
// ── AI 聊天机器人 ──────────────────────────────────

View File

@@ -799,6 +799,11 @@
desc: '存入背包,求婚时消耗(被拒则遗失)',
type: 'ring'
},
{
label: '🎣 自动钓鱼卡',
desc: '激活后自动收篼,无需手动点击浮漂',
type: 'auto_fishing'
},
{
label: '🎭 道具',
desc: '',
@@ -828,13 +833,30 @@
const card = document.createElement('div');
card.className = 'shop-card';
// 顶部:图标 + 名称(戒指加持有数徽章)
const iconHtml = isRing && ownedQty > 0 ?
`<span style="position:relative;display:inline-block;">
// 顶部:图标 + 名称(戒指/自动钓鱼卡加徽章)
const isAutoFishing = item.type === 'auto_fishing';
const autoFishLeft = isAutoFishing ? (data.auto_fishing_minutes_left || 0) : 0;
let iconHtml;
if (isRing && ownedQty > 0) {
iconHtml = `<span style="position:relative;display:inline-block;">
<span class="shop-card-icon">${item.icon}</span>
<span style="position:absolute;top:-4px;right:-6px;background:#f43f5e;color:#fff;font-size:9px;font-weight:800;min-width:15px;height:15px;border-radius:8px;text-align:center;line-height:15px;padding:0 2px;">${ownedQty}</span>
</span>` :
`<span class="shop-card-icon">${item.icon}</span>`;
</span>`;
} else if (isAutoFishing && autoFishLeft > 0) {
const hLeft = autoFishLeft >= 60 ? Math.floor(autoFishLeft / 60) + 'h' :
autoFishLeft + 'm';
iconHtml = `<span style="position:relative;display:inline-block;">
<span class="shop-card-icon">${item.icon}</span>
<span style="position:absolute;top:-4px;right:-6px;background:#7c3aed;color:#fff;font-size:9px;font-weight:800;min-width:18px;height:15px;border-radius:8px;text-align:center;line-height:15px;padding:0 2px;">${hLeft}</span>
</span>`;
} else {
iconHtml = `<span class="shop-card-icon">${item.icon}</span>`;
}
const durationLabel = isAutoFishing && item.duration_minutes > 0 ?
`<div style="font-size:9px;margin-top:3px;color:#7c3aed;">⏱ 有效期 ${item.duration_minutes >= 60 ? Math.floor(item.duration_minutes / 60) + ' 小时' : item.duration_minutes + ' 分钟'}</div>` :
'';
card.innerHTML = `
<div class="shop-card-top">
@@ -847,6 +869,7 @@
${item.intimacy_bonus > 0 ? `<span style="color:#f43f5e;">💞 亲密 +${item.intimacy_bonus}</span>` : ''}
${item.charm_bonus > 0 ? `<span style="color:#a855f7;">✨ 魅力 +${item.charm_bonus}</span>` : ''}
</div>` : ''}
${durationLabel}
`;
// 按钮