Compare commits

..

4 Commits

Author SHA1 Message Date
yin5th 7bb5537109 Merge branch 'master' of http://git.scdxtc.com/chen/squareDancing 2021-12-08 17:46:34 +08:00
yin5th c45b31da3b 兼容帽子和棒子 2021-12-08 17:46:32 +08:00
yin5th cd1cea890e Merge branch 'master' of http://git.scdxtc.com/chen/squareDancing 2021-12-08 16:27:17 +08:00
yin5th 9ef9c15f37 礼物 2021-12-08 16:27:13 +08:00
2 changed files with 139 additions and 5 deletions

View File

@ -114,7 +114,7 @@ function exitEv(id){
$(`${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')
let yspHtml = '';
let yspData = [
@ -132,13 +132,42 @@ function peopleObj(name,uid,say,action,active_time, 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) {
let bigStick = comment.is_admin == 1 ? 'stick-swing-big-tow' : ''
if (decorationStick != '') {
bigStick = ''
}
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="people-img ${comment.peopleImg} ${comment.dancin} ">
<div class="stick stick-swing ${bigStick} ${comment.ying_guang}"></div>
<div class="people-img ${comment.peopleImg} ${comment.dancin} ${decorationHat} ">
<div class="stick stick-swing ${decorationStick} ${bigStick} ${comment.ying_guang}"></div>
<div class="people-name ">${comment.name}</div>
</div>
</div>`

View File

@ -28,6 +28,47 @@ let virtualList = ['一只小绵飏','未来狗头耀武扬威什么','大牛逼
let virtualWordList = ['哈哈哈', '我又来了!', '大爷闪亮登场', '真会玩 哈哈']
// 礼物所需电池
let giftObj = {
'粉丝团灯牌': 1,
'牛哇牛哇': 1,
'白银宝盒': 10,
'紫金宝盒': 100,
'D言D语': 330,
'星愿水晶球': 1000,
'为你加冕': 4500,
'探索者启航': 23330,
'小花花': 1,
'这个好诶': 10,
'盛典门票': 20,
'庆典礼花': 880,
'告白花束': 220,
'疯狂心动': 520,
'守护之翼': 2000,
'次元之城': 12450,
'i了i了': 1,
'打call': 5,
'情书': 52,
'干杯': 66,
'B坷垃': 99,
'撒花': 660,
'节奏风暴': 1000,
'心动卡': 1,
'泡泡机': 50,
'爱之魔力': 280,
'摩天轮': 1000,
'转运锦鲤': 6660,
'领航者飞船': 12450,
'友谊的小船': 52,
'冲浪': 1000,
'奈斯': 20,
'变身话筒': 20,
'喵娘': 52
}
// 用户消费电池 姓名: 电池量
let userCell = {}
// 多少秒不说话删除
let speakExpireTime = 10*60
// 歌曲列表
@ -182,6 +223,14 @@ function receiveMessage(event)
// 高能榜top3
let highList = dataList.high
// 送礼物列表
let giftList = dataList.gift
if (giftList.length > 0) {
updateUserCell(giftList)
// console.log(userCell, '用户礼物记录')
}
// console.log(adminList, '舰长列表')
// console.log(highList, '高能榜列表')
@ -238,10 +287,32 @@ function receiveMessage(event)
leader.text = dm.text
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.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 {
// 老用户
@ -253,6 +324,24 @@ function receiveMessage(event)
// 舰长添加大宝剑
$(`#${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(()=>{//关闭当前说话
$(`#${dm.uid} .speak`).addClass("dn");
},3000)
@ -380,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();
// 清理缓存
sessionStorage.clear()