This commit is contained in:
libccy 2017-04-19 11:28:14 +08:00
parent bf8474d7ee
commit eaceb797d6
2 changed files with 78 additions and 41 deletions

View File

@ -19701,7 +19701,7 @@
alert('请稍后再试'); alert('请稍后再试');
_status.enteringroom=false; _status.enteringroom=false;
}, },
roomlist:function(list,events,clients){ roomlist:function(list,events,clients,wsid){
game.online=true; game.online=true;
game.onlinehall=true; game.onlinehall=true;
lib.config.recentIP.remove(_status.ip); lib.config.recentIP.remove(_status.ip);
@ -19740,7 +19740,9 @@
ui.connectEventsCount.show(); ui.connectEventsCount.show();
} }
} }
lib.message.client.updaterooms(list,events,clients); game.wsid=wsid;
lib.message.client.updaterooms(list,clients);
lib.message.client.updateevents(events);
ui.exitroom=ui.create.system('退出房间',function(){ ui.exitroom=ui.create.system('退出房间',function(){
if(ui.rooms){ if(ui.rooms){
game.saveConfig('reconnect_info'); game.saveConfig('reconnect_info');
@ -19784,7 +19786,7 @@
proceed(); proceed();
} }
}, },
updaterooms:function(list,events,clients){ updaterooms:function(list,clients){
if(ui.rooms){ if(ui.rooms){
ui.window.classList.add('more_room'); ui.window.classList.add('more_room');
var list2=['re_caocao','re_liubei','sunquan','sp_zhangjiao','re_yuanshao','dongzhuo']; var list2=['re_caocao','re_liubei','sunquan','sp_zhangjiao','re_yuanshao','dongzhuo'];
@ -19792,6 +19794,15 @@
ui.rooms[i].initRoom(list[i],list2[i]); ui.rooms[i].initRoom(list[i],list2[i]);
} }
} }
lib.message.client.updateclients(clients,true);
},
updateclients:function(clients,bool){
if(clients&&ui.connectClients){
ui.connectClients.info=clients;
ui.connectClientsCount.innerHTML=clients.length;
}
},
updateevents:function(events){
if(events&&ui.connectEvents){ if(events&&ui.connectEvents){
ui.connectEvents.info=events; ui.connectEvents.info=events;
if(events.length){ if(events.length){
@ -19805,13 +19816,6 @@
_status.connectEventsCallback(); _status.connectEventsCallback();
} }
} }
if(clients&&ui.connectClients){
ui.connectClients.info=clients;
ui.connectClientsCount.innerHTML=clients.length;
}
},
eventsaccepted:function(){
}, },
eventsdenied:function(reason){ eventsdenied:function(reason){
var str='创建约战失败'; var str='创建约战失败';
@ -26283,10 +26287,7 @@
config[key]=value; config[key]=value;
} }
config.version=lib.version; config.version=lib.version;
console.log(key,value); game.putDB('data',mode,config);
game.putDB('data',mode,config,function(){
console.log(key,value,2);
});
}); });
} }
else{ else{
@ -35718,7 +35719,29 @@
else{ else{
str+=get.cnNumber(button.info[i].day,true); str+=get.cnNumber(button.info[i].day,true);
} }
str+=' '+button.info[i].hour+'点'; str+=' ';
var hour=button.info[i].hour;
if(hour<=12){
if(hour<=5){
str+='凌晨';
}
else if(hour<12){
str+='上午';
}
else{
str+='中午';
}
str+=button.info[i].hour+'点';
}
else{
if(hour<=17){
str+='下午';
}
else{
str+='晚上';
}
str+=(button.info[i].hour-12)+'点';
}
ui.create.div('','已有'+(button.info[i].members.length)+'人加入',eventnode); ui.create.div('','已有'+(button.info[i].members.length)+'人加入',eventnode);
ui.create.div('','时间:'+str,eventnode); ui.create.div('','时间:'+str,eventnode);
if(button.info[i].members.contains(game.onlineKey)){ if(button.info[i].members.contains(game.onlineKey)){
@ -35828,10 +35851,14 @@
for(var i=0;i<this.info.length;i++){ for(var i=0;i<this.info.length;i++){
var node=ui.create.div('.menubutton.videonode.pointerdiv',uiintro.content); var node=ui.create.div('.menubutton.videonode.pointerdiv',uiintro.content);
ui.create.div('.menubutton.videoavatar',node).setBackground(this.info[i][1]||'caocao','character'); ui.create.div('.menubutton.videoavatar',node).setBackground(this.info[i][1]||'caocao','character');
switch(this.info[i][2]){ if(this.info[i][4]==game.wsid){
case 0:ui.create.div('.name','<span class="thundertext thunderauto">'+(this.info[i][0]||'无名玩家'),node);node.isme=true;break; ui.create.div('.name','<span class="thundertext thunderauto">'+(this.info[i][0]||'无名玩家'),node);node.isme=true;break;
case 1:ui.create.div('.name','<span style="opacity:0.6">'+(this.info[i][0]||'无名玩家'),node);break; }
case 2:ui.create.div('.name',(this.info[i][0]||'无名玩家'),node);break; else if(this.info[i][2]){
ui.create.div('.name',(this.info[i][0]||'无名玩家'),node);
}
else{
ui.create.div('.name','<span style="opacity:0.6">'+(this.info[i][0]||'无名玩家'),node);break;
} }
if(this.info[i][3]){ if(this.info[i][3]){
ui.create.div('.menubutton.videotext',uiintro.content,this.info[i][3]); ui.create.div('.menubutton.videotext',uiintro.content,this.info[i][3]);

View File

@ -39,7 +39,7 @@
changeAvatar:function(nickname,avatar){ changeAvatar:function(nickname,avatar){
this.nickname=nickname; this.nickname=nickname;
this.avatar=avatar; this.avatar=avatar;
util.updaterooms(); util.updateclients();
}, },
server:function(cfg){ server:function(cfg){
if(cfg){ if(cfg){
@ -109,16 +109,15 @@
cfg.nickname=cfg.nickname||'无名玩家'; cfg.nickname=cfg.nickname||'无名玩家';
cfg.avatar=cfg.nickname||'caocao'; cfg.avatar=cfg.nickname||'caocao';
cfg.creator=id; cfg.creator=id;
cfg.id=(Math.floor(1000000+9000000*Math.random())).toString(); cfg.id=util.getid();
cfg.members=[id]; cfg.members=[id];
events.unshift(cfg); events.unshift(cfg);
changed=true; changed=true;
this.sendl('eventsaccepted');
} }
} }
} }
if(changed){ if(changed){
util.updaterooms(); util.updateevents();
} }
}, },
config:function(config){ config:function(config){
@ -145,7 +144,7 @@
else{ else{
delete this.status; delete this.status;
} }
util.updaterooms(); util.updateclients();
}, },
send:function(id,message){ send:function(id,message){
if(clients[id]&&clients[id].owner==this){ if(clients[id]&&clients[id].owner==this){
@ -207,24 +206,31 @@
} }
return roomlist; return roomlist;
}, },
getclientlist:function(me){ getclientlist:function(){
var clientlist=[]; var clientlist=[];
for(var i in clients){ for(var i in clients){
var num; clientlist.push([clients[i].nickname,clients[i].avatar,!clients[i].room,clients[i].status,clients[i].wsid]);
if(clients[i]==me){
num=0;
}
else if(clients[i].room){
num=1;
}
else{
num=2;
}
clientlist.push([clients[i].nickname,clients[i].avatar,num,clients[i].status]);
} }
return clientlist; return clientlist;
}, },
updaterooms:function(){ updaterooms:function(){
var roomlist=util.getroomlist();
var clientlist=util.getclientlist();
for(var i in clients){
if(!clients[i].room){
clients[i].sendl('updaterooms',roomlist,clientlist);
}
}
},
updateclients:function(){
var clientlist=util.getclientlist();
for(var i in clients){
if(!clients[i].room){
clients[i].sendl('updateclients',clientlist);
}
}
},
checkevents:function(){
if(events.length){ if(events.length){
var time=(new Date()).getTime(); var time=(new Date()).getTime();
for(var i=0;i<events.length;i++){ for(var i=0;i<events.length;i++){
@ -233,19 +239,22 @@
} }
} }
} }
var roomlist=util.getroomlist(); return events;
},
updateevents:function(){
util.checkevents();
for(var i in clients){ for(var i in clients){
if(!clients[i].room){ if(!clients[i].room){
clients[i].sendl('updaterooms',roomlist,events,util.getclientlist(clients[i])); clients[i].sendl('updateevents',events);
} }
} }
}, }
}; };
wss.on('connection',function(ws){ wss.on('connection',function(ws){
ws.sendl=util.sendl; ws.sendl=util.sendl;
ws.wsid=util.getid(); ws.wsid=util.getid();
clients[ws.wsid]=ws; clients[ws.wsid]=ws;
ws.sendl('roomlist',util.getroomlist(),events,util.getclientlist(ws)); ws.sendl('roomlist',util.getroomlist(),util.checkevents(),util.getclientlist(ws),ws.wsid);
ws.heartbeat=setInterval(function(){ ws.heartbeat=setInterval(function(){
if(ws.beat){ if(ws.beat){
ws.close(); ws.close();
@ -309,7 +318,8 @@
} }
delete clients[this.wsid]; delete clients[this.wsid];
} }
util.updaterooms(); if(this.room) util.updaterooms();
else util.updateclients();
}); });
}); });
}()); }());