feat: 在后台管理添加AI小班长钓鱼触发概率配置
This commit is contained in:
@@ -130,7 +130,7 @@ class AiHeartbeatCommand extends Command
|
|||||||
|
|
||||||
// 7. 钓鱼小游戏随机参与逻辑
|
// 7. 钓鱼小游戏随机参与逻辑
|
||||||
$fishingEnabled = Sysparam::getValue('chatbot_fishing_enabled', '0') === '1';
|
$fishingEnabled = Sysparam::getValue('chatbot_fishing_enabled', '0') === '1';
|
||||||
$fishingChance = (int) Sysparam::getValue('chatbot_fishing_chance', '5'); // 默认 5% 概率
|
$fishingChance = (int) Sysparam::getValue('chatbot_fishing_chance', '100'); // 默认 5% 概率
|
||||||
if ($fishingEnabled && $fishingChance > 0 && rand(1, 100) <= $fishingChance && \App\Models\GameConfig::isEnabled('fishing')) {
|
if ($fishingEnabled && $fishingChance > 0 && rand(1, 100) <= $fishingChance && \App\Models\GameConfig::isEnabled('fishing')) {
|
||||||
$cost = (int) (\App\Models\GameConfig::param('fishing', 'fishing_cost') ?? Sysparam::getValue('fishing_cost', '5'));
|
$cost = (int) (\App\Models\GameConfig::param('fishing', 'fishing_cost') ?? Sysparam::getValue('fishing_cost', '5'));
|
||||||
if ($user->jjb >= $cost) {
|
if ($user->jjb >= $cost) {
|
||||||
|
|||||||
@@ -49,11 +49,12 @@ class AiProviderController extends Controller
|
|||||||
$chatbotMaxGold = Sysparam::getValue('chatbot_max_gold', '5000');
|
$chatbotMaxGold = Sysparam::getValue('chatbot_max_gold', '5000');
|
||||||
$chatbotMaxDailyRewards = Sysparam::getValue('chatbot_max_daily_rewards', '1');
|
$chatbotMaxDailyRewards = Sysparam::getValue('chatbot_max_daily_rewards', '1');
|
||||||
$chatbotFishingEnabled = Sysparam::getValue('chatbot_fishing_enabled', '0') === '1';
|
$chatbotFishingEnabled = Sysparam::getValue('chatbot_fishing_enabled', '0') === '1';
|
||||||
|
$chatbotFishingChance = Sysparam::getValue('chatbot_fishing_chance', '5');
|
||||||
$chatbotBaccaratEnabled = Sysparam::getValue('chatbot_baccarat_enabled', '0') === '1';
|
$chatbotBaccaratEnabled = Sysparam::getValue('chatbot_baccarat_enabled', '0') === '1';
|
||||||
|
|
||||||
return view('admin.ai-providers.index', compact(
|
return view('admin.ai-providers.index', compact(
|
||||||
'providers', 'chatbotEnabled', 'chatbotMaxGold',
|
'providers', 'chatbotEnabled', 'chatbotMaxGold',
|
||||||
'chatbotMaxDailyRewards', 'chatbotFishingEnabled', 'chatbotBaccaratEnabled'
|
'chatbotMaxDailyRewards', 'chatbotFishingEnabled', 'chatbotFishingChance', 'chatbotBaccaratEnabled'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ class AiProviderController extends Controller
|
|||||||
'chatbot_max_gold' => 'required|integer|min:1',
|
'chatbot_max_gold' => 'required|integer|min:1',
|
||||||
'chatbot_max_daily_rewards' => 'required|integer|min:1',
|
'chatbot_max_daily_rewards' => 'required|integer|min:1',
|
||||||
'chatbot_fishing_enabled' => 'required|in:0,1',
|
'chatbot_fishing_enabled' => 'required|in:0,1',
|
||||||
|
'chatbot_fishing_chance' => 'required|integer|min:1|max:100',
|
||||||
'chatbot_baccarat_enabled' => 'required|in:0,1',
|
'chatbot_baccarat_enabled' => 'required|in:0,1',
|
||||||
]);
|
]);
|
||||||
Sysparam::updateOrCreate(
|
Sysparam::updateOrCreate(
|
||||||
@@ -95,6 +97,15 @@ class AiProviderController extends Controller
|
|||||||
);
|
);
|
||||||
Sysparam::clearCache('chatbot_fishing_enabled');
|
Sysparam::clearCache('chatbot_fishing_enabled');
|
||||||
|
|
||||||
|
Sysparam::updateOrCreate(
|
||||||
|
['alias' => 'chatbot_fishing_chance'],
|
||||||
|
[
|
||||||
|
'body' => (string) $data['chatbot_fishing_chance'],
|
||||||
|
'guidetxt' => 'AI 钓鱼抛竿概率 (每分钟)',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
Sysparam::clearCache('chatbot_fishing_chance');
|
||||||
|
|
||||||
Sysparam::updateOrCreate(
|
Sysparam::updateOrCreate(
|
||||||
['alias' => 'chatbot_baccarat_enabled'],
|
['alias' => 'chatbot_baccarat_enabled'],
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -120,6 +120,14 @@
|
|||||||
<option value="0" {{ !$chatbotFishingEnabled ? 'selected' : '' }}>⛔ 关闭</option>
|
<option value="0" {{ !$chatbotFishingEnabled ? 'selected' : '' }}>⛔ 关闭</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-bold text-gray-700 mb-1">钓鱼触发概率 (每分钟)</label>
|
||||||
|
<div class="relative">
|
||||||
|
<input type="number" name="chatbot_fishing_chance" value="{{ $chatbotFishingChance }}" min="1" max="100" required
|
||||||
|
class="w-48 border border-gray-300 rounded-md p-2 pl-3 pr-8 text-sm focus:ring-indigo-500 focus:border-indigo-500">
|
||||||
|
<span class="absolute right-3 top-2.5 text-gray-400 text-sm">%</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-bold text-gray-700 mb-1">AI 参与百家乐</label>
|
<label class="block text-sm font-bold text-gray-700 mb-1">AI 参与百家乐</label>
|
||||||
<select name="chatbot_baccarat_enabled"
|
<select name="chatbot_baccarat_enabled"
|
||||||
|
|||||||
Reference in New Issue
Block a user