diff --git a/game/game.js b/game/game.js index 5633b5b97..0097ebaec 100644 --- a/game/game.js +++ b/game/game.js @@ -19701,7 +19701,7 @@ alert('请稍后再试'); _status.enteringroom=false; }, - roomlist:function(list,events,clients){ + roomlist:function(list,events,clients,wsid){ game.online=true; game.onlinehall=true; lib.config.recentIP.remove(_status.ip); @@ -19740,7 +19740,9 @@ 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(){ if(ui.rooms){ game.saveConfig('reconnect_info'); @@ -19784,7 +19786,7 @@ proceed(); } }, - updaterooms:function(list,events,clients){ + updaterooms:function(list,clients){ if(ui.rooms){ ui.window.classList.add('more_room'); var list2=['re_caocao','re_liubei','sunquan','sp_zhangjiao','re_yuanshao','dongzhuo']; @@ -19792,6 +19794,15 @@ 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){ ui.connectEvents.info=events; if(events.length){ @@ -19805,13 +19816,6 @@ _status.connectEventsCallback(); } } - if(clients&&ui.connectClients){ - ui.connectClients.info=clients; - ui.connectClientsCount.innerHTML=clients.length; - } - }, - eventsaccepted:function(){ - }, eventsdenied:function(reason){ var str='创建约战失败'; @@ -26283,10 +26287,7 @@ config[key]=value; } config.version=lib.version; - console.log(key,value); - game.putDB('data',mode,config,function(){ - console.log(key,value,2); - }); + game.putDB('data',mode,config); }); } else{ @@ -35718,7 +35719,29 @@ else{ 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('','时间:'+str,eventnode); if(button.info[i].members.contains(game.onlineKey)){ @@ -35828,10 +35851,14 @@ for(var i=0;i'+(this.info[i][0]||'无名玩家'),node);node.isme=true;break; - case 1:ui.create.div('.name',''+(this.info[i][0]||'无名玩家'),node);break; - case 2:ui.create.div('.name',(this.info[i][0]||'无名玩家'),node);break; + if(this.info[i][4]==game.wsid){ + ui.create.div('.name',''+(this.info[i][0]||'无名玩家'),node);node.isme=true;break; + } + else if(this.info[i][2]){ + ui.create.div('.name',(this.info[i][0]||'无名玩家'),node); + } + else{ + ui.create.div('.name',''+(this.info[i][0]||'无名玩家'),node);break; } if(this.info[i][3]){ ui.create.div('.menubutton.videotext',uiintro.content,this.info[i][3]); diff --git a/game/server.js b/game/server.js index b4cb8d387..d98fab21d 100644 --- a/game/server.js +++ b/game/server.js @@ -39,7 +39,7 @@ changeAvatar:function(nickname,avatar){ this.nickname=nickname; this.avatar=avatar; - util.updaterooms(); + util.updateclients(); }, server:function(cfg){ if(cfg){ @@ -109,16 +109,15 @@ cfg.nickname=cfg.nickname||'无名玩家'; cfg.avatar=cfg.nickname||'caocao'; cfg.creator=id; - cfg.id=(Math.floor(1000000+9000000*Math.random())).toString(); + cfg.id=util.getid(); cfg.members=[id]; events.unshift(cfg); changed=true; - this.sendl('eventsaccepted'); } } } if(changed){ - util.updaterooms(); + util.updateevents(); } }, config:function(config){ @@ -145,7 +144,7 @@ else{ delete this.status; } - util.updaterooms(); + util.updateclients(); }, send:function(id,message){ if(clients[id]&&clients[id].owner==this){ @@ -207,24 +206,31 @@ } return roomlist; }, - getclientlist:function(me){ + getclientlist:function(){ var clientlist=[]; for(var i in clients){ - var num; - 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]); + clientlist.push([clients[i].nickname,clients[i].avatar,!clients[i].room,clients[i].status,clients[i].wsid]); } return clientlist; }, 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){ var time=(new Date()).getTime(); for(var i=0;i