兼容帽子和棒子

master
yin5th 2021-12-08 17:46:32 +08:00
parent cd1cea890e
commit c45b31da3b
2 changed files with 100 additions and 7 deletions

View File

@ -114,7 +114,7 @@ function exitEv(id){
$(`${id}`).remove(); $(`${id}`).remove();
} }
// 进入广场 // 进入广场
function peopleObj(name,uid,say,action,active_time, is_admin){ function peopleObj(name,uid,say,action,active_time, is_admin, decoration){
// console.log(name + ' ' + uid + ' ' + say + ' ' + action + ' ' + active_time + ' ' + is_admin, 'sssss') // console.log(name + ' ' + uid + ' ' + say + ' ' + action + ' ' + active_time + ' ' + is_admin, 'sssss')
let yspHtml = ''; let yspHtml = '';
let yspData = [ let yspData = [
@ -132,13 +132,42 @@ function peopleObj(name,uid,say,action,active_time, is_admin){
is_admin: is_admin is_admin: is_admin
} }
] ]
let decorationHat = ''
let decorationStick = ''
let decorationWing = ''
if (decoration != undefined && decoration.length > 0) {
// console.log(decoration, '装饰品')
// console.log(decoration.indexOf('people-hat'), '是否有帽子')
// 添加帽子
if (decoration.indexOf('people-hat') != -1) {
decorationHat = 'people-hat'
// console.log(decorationHat, '我的帽子')
}
// 添加棒子
if (decoration.indexOf('stick-christmas') != -1) {
decorationStick = 'stick-christmas'
// console.log(decorationStick, '我的棒子')
}
// 添加翅膀
if (decoration.indexOf('big-wing') != -1) {
decorationWing = 'big-wing'
// console.log(decorationWing, '我的翅膀')
}
}
$.each(yspData, function (commentIndex, comment) { $.each(yspData, function (commentIndex, comment) {
let bigStick = comment.is_admin == 1 ? 'stick-swing-big-tow' : '' let bigStick = comment.is_admin == 1 ? 'stick-swing-big-tow' : ''
if (decorationStick != '') {
bigStick = ''
}
yspHtml += ` yspHtml += `
<div id="${comment.uid}" data-time="${comment.active_time}" class="dance-people data${peopleId}" style="top: ${comment.top}; left: ${comment.left};"> <div id="${comment.uid}" data-time="${comment.active_time}" class="dance-people ${decorationWing} data${peopleId}" style="top: ${comment.top}; left: ${comment.left};">
<div class="speak ">${comment.say}</div> <div class="speak ">${comment.say}</div>
<div class="people-img ${comment.peopleImg} ${comment.dancin} "> <div class="people-img ${comment.peopleImg} ${comment.dancin} ${decorationHat} ">
<div class="stick stick-swing ${bigStick} ${comment.ying_guang}"></div> <div class="stick stick-swing ${decorationStick} ${bigStick} ${comment.ying_guang}"></div>
<div class="people-name ">${comment.name}</div> <div class="people-name ">${comment.name}</div>
</div> </div>
</div>` </div>`

View File

@ -28,8 +28,8 @@ let virtualList = ['一只小绵飏','未来狗头耀武扬威什么','大牛逼
let virtualWordList = ['哈哈哈', '我又来了!', '大爷闪亮登场', '真会玩 哈哈'] let virtualWordList = ['哈哈哈', '我又来了!', '大爷闪亮登场', '真会玩 哈哈']
// 礼物所需电池列表 // 礼物所需电池
let giftList = { let giftObj = {
'粉丝团灯牌': 1, '粉丝团灯牌': 1,
'牛哇牛哇': 1, '牛哇牛哇': 1,
'白银宝盒': 10, '白银宝盒': 10,
@ -223,6 +223,14 @@ function receiveMessage(event)
// 高能榜top3 // 高能榜top3
let highList = dataList.high let highList = dataList.high
// 送礼物列表
let giftList = dataList.gift
if (giftList.length > 0) {
updateUserCell(giftList)
// console.log(userCell, '用户礼物记录')
}
// console.log(adminList, '舰长列表') // console.log(adminList, '舰长列表')
// console.log(highList, '高能榜列表') // console.log(highList, '高能榜列表')
@ -279,10 +287,32 @@ function receiveMessage(event)
leader.text = dm.text leader.text = dm.text
leader.event = eventName ? eventName : leaderEvent leader.event = eventName ? eventName : leaderEvent
} }
let decoration = []
let userCellNum = userCell[dm.uname]
// userCell['yin5th'] = 99
// userCell['未来狗头耀武扬威什么'] = 1
if (userCellNum != undefined) {
// 1个电池送圣诞帽
if (userCellNum >= 1) {
decoration.push('people-hat')
}
// 10个电池送圣诞树光棒子
if (userCellNum >= 10) {
decoration.push('stick-christmas')
}
// 99个电池送大翅膀一对
if (userCellNum >= 99) {
decoration.push('big-wing')
}
}
// 新用户 // 新用户
if(dm.is_new==1){ if(dm.is_new==1){
// if(dm.uname!=leader.uname){//如果弹幕的人的名字不等于领舞者的名字,就创建一个人物 // if(dm.uname!=leader.uname){//如果弹幕的人的名字不等于领舞者的名字,就创建一个人物
peopleObj(dm.uname,dm.uid,dm.text,dm.event,dm.active_time,dm.is_admin); peopleObj(dm.uname,dm.uid,dm.text,dm.event,dm.active_time,dm.is_admin, decoration);
// } // }
} else { } else {
// 老用户 // 老用户
@ -294,6 +324,24 @@ function receiveMessage(event)
// 舰长添加大宝剑 // 舰长添加大宝剑
$(`#${dm.uid} .stick`).addClass("stick-swing-big-tow"); $(`#${dm.uid} .stick`).addClass("stick-swing-big-tow");
} }
if (decoration.length > 0) {
// 添加帽子
if (decoration.indexOf('people-hat') != -1) {
$(`#${dm.uid} .people-img`).removeClass("people-hat").addClass('people-hat');
}
// 添加棒子
if (decoration.indexOf('stick-christmas') != -1) {
$(`#${dm.uid} .stick`).removeClass("stick-christmas").removeClass('stick-swing-big-tow').addClass('stick-christmas');
}
// 添加翅膀
if (decoration.indexOf('big-wing') != -1) {
$(`#${dm.uid} .dance-people`).removeClass("big-wing").addClass('big-wing');
}
}
setTimeout(()=>{//关闭当前说话 setTimeout(()=>{//关闭当前说话
$(`#${dm.uid} .speak`).addClass("dn"); $(`#${dm.uid} .speak`).addClass("dn");
},3000) },3000)
@ -421,6 +469,22 @@ function createVirtual() {
} }
} }
function updateUserCell(list) {
$.each(list, function (index, item) {
let cell = 0
if (giftObj[item.gift] != undefined) {
cell = giftObj[item.gift] * item.num
}
if (cell > 0) {
if (userCell[item.uname] == undefined) {
userCell[item.uname] = cell
} else {
userCell[item.uname] = userCell[item.uname] + cell
}
}
})
}
// music(); // music();
// 清理缓存 // 清理缓存
sessionStorage.clear() sessionStorage.clear()