`;
ads.images.slice(0, 3).forEach((image, index) => {
if (image && image.img_url && image.link) {
imagesHTML += `
`;
} else {
// 如果数据不完整,使用占位符
imagesHTML += `
`;
}
});
imagesHTML += `
`;
}
// 生成入口广告HTML
let entriesHTML = '';
if (ads && ads.entries && Array.isArray(ads.entries)) {
const colors = [
'linear-gradient(135deg,#4cd964,#5ac8fa)',
'linear-gradient(135deg,#ff9500,#ff5e3a)',
'linear-gradient(135deg,#5856d6,#af52de)'
];
entriesHTML = ``;
ads.entries.slice(0, 3).forEach((entry, index) => {
if (entry && entry.url && entry.name) {
entriesHTML += `
${entry.name}
`;
} else {
// 如果数据不完整,使用占位符
entriesHTML += `
入口${index + 1}
`;
}
});
entriesHTML += `
`;
}
addMessage('robot', `
${username} ${new Date().toTimeString().substr(0,8)}
${content}
`;
chat.appendChild(div);
if(isNearBottom || who === 'self') chat.scrollTop = chat.scrollHeight;
}
function showToast(msg, duration = 2000) {
const el = document.getElementById('toast');
el.textContent = msg;
el.classList.add('show');
setTimeout(() => el.classList.remove('show'), duration);
}
const BOT_NAMES = ['闪电⚡熊🐻', '孤勇者', '天涯', '快乐小狗', '在此一位', '赢赢赢', '财神到', '运气爆棚', '小小的愿望', 'MVP', '拓哥'];
const BET_TYPES = ['大', '小', '单', '双', '大单', '小双', '大双', '小单'];
const BET_AMOUNTS = [10, 20, 50, 100, 200, 500, 1000];
function botLoop() {
const delay = Math.random() * (CONFIG.botInterval[1] - CONFIG.botInterval[0]) + CONFIG.botInterval[0];
setTimeout(() => {
if (!isLocked && !isTempLocked) {
let name;
if(Math.random() > 0.2) name = '游客U' + Math.floor(Math.random() * 9000 + 1000);
else name = BOT_NAMES[Math.floor(Math.random() * BOT_NAMES.length)];
if (!botBetCounts[name]) botBetCounts[name] = 0;
if (botBetCounts[name] < 2) {
const type = BET_TYPES[Math.floor(Math.random() * BET_TYPES.length)];
const amount = BET_AMOUNTS[Math.floor(Math.random() * BET_AMOUNTS.length)];
botBetCounts[name]++;
var rk = String(currentPeriod);
if (!botBetsByRound[rk]) botBetsByRound[rk] = [];
botBetsByRound[rk].push({username: name, type: type, amount: amount});
const chat = document.getElementById('chatArea');
const isNearBottom = chat.scrollHeight - chat.scrollTop - chat.clientHeight < 100;
const div = document.createElement('div');
div.className = 'c28-message';
const avatarHtml = `
${name} ${new Date().toTimeString().substr(0,8)}
${type}:${amount}
`;
chat.appendChild(div);
if (isNearBottom) chat.scrollTop = chat.scrollHeight;
}
}
botLoop();
}, delay);
}
botLoop();
function confirmFollow(type, amount) {
if (userBetCount >= 2) { showToast('本期下注次数已达上限'); return; }
document.getElementById('betInput').value = type + amount;
sendBet();
}
function tryRescue() {
$.getJSON(CONFIG.apiUrl + 'action=rescue', function(res){
if(res.success) {
addMessage('system', res.msg);
showToast('💰 ' + res.msg);
userCoins = res.new_coins;
document.getElementById('userBalance').textContent = (parseFloat(userCoins)||0).toFixed(2);
}
});
}
document.addEventListener('DOMContentLoaded', function(){});