diff --git a/game/game.js b/game/game.js index 0c6dd1f8d..23a517a87 100755 --- a/game/game.js +++ b/game/game.js @@ -374,8 +374,9 @@ }, connect_nickname:{ name:'联机昵称', - clear:true, - unfrequent:true + input:true, + unfrequent:true, + init:'无名玩家' }, connect_avatar:{ name:'联机头像', @@ -2761,11 +2762,14 @@ } node._customintro=func; }, - setPopped:function(node,func,width,height){ + setPopped:function(node,func,width,height,forceclick){ node._poppedfunc=func; node._poppedwidth=width; node._poppedheight=height; - if(lib.config.touchscreen){ + if(forceclick){ + node.forceclick=true; + } + if(lib.config.touchscreen||forceclick){ node.listen(ui.click.hoverpopped); } else{ @@ -4433,6 +4437,10 @@ }, chooseButton:function(){ "step 0" + if(event.createDialog){ + event.dialog=ui.create.dialog.apply(this,event.createDialog); + event.closeDialog=true; + } if(event.dialog==undefined) event.dialog=ui.dialog; if(event.isMine()){ event.dialog.style.display=''; @@ -4442,11 +4450,22 @@ if(event.isMine()){ game.pause(); } + else if(event.isOnline()){ + event.player.send(function(){ + game.me.chooseButton.apply(game.me,arguments); + game.resume(); + },event.createDialog,event.filterButton,event.selectButton,event.forced); + event.player.wait(); + } else{ - if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok(); - else ui.click.cancel(); + event.result='ai'; } "step 1" + if(event.result=='ai'){ + game.check(); + if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok(); + else ui.click.cancel(); + } if(event.closeDialog){ event.dialog.close(); } @@ -6137,6 +6156,19 @@ this.update(); return this; }, + initOL:function(name,character){ + this.node.avatar.setBackground(character,'character'); + this.node.avatar.show(); + this.node.name.innerHTML=get.verticalStr(name); + this.nickname=name; + this.avatar=character; + }, + uninitOL:function(){ + this.node.avatar.hide(); + this.node.name.innerHTML=''; + delete this.nickname; + delete this.avatar; + }, uninit:function(){ this.node.avatar.hide(); this.node.count.hide(); @@ -6180,6 +6212,13 @@ return this; }, + send:function(){ + this.ws.send.apply(this.ws,arguments); + }, + setNameOL:function(str){ + this.node.nameol.innerHTML=str; + return this; + }, update:function(){ if(_status.video&&arguments.length==0) return; if(this.hp>=this.maxHp) this.hp=this.maxHp; @@ -6826,8 +6865,12 @@ if(next.ai) next.filterButton=arguments[i]; else next.ai=arguments[i]; } + else if(Array.isArray(arguments[i])){ + next.createDialog=arguments[i]; + } } next.player=this; + if(typeof next.forced!='boolean') next.forced=false; if(next.isMine()==false&&next.dialog) next.dialog.style.display='none'; if(next.filterButton==undefined) next.filterButton=lib.filter.filterButton; if(next.selectButton==undefined) next.selectButton=[1,1]; @@ -7638,6 +7681,26 @@ skip:function(name){ this.skipList.add(name); }, + wait:function(){ + if(lib.node){ + lib.node.torespond[this.playerid]='_noname_waiting'; + game.pause(); + } + }, + unwait:function(result){ + lib.node.torespond[this.playerid]=result; + if(_status.paused){ + for(var i in lib.node.torespond){ + if(lib.node.torespond[i]=='_noname_waiting'){ + return; + } + } + _status.event.result=result; + _status.event.result2=lib.node.torespond; + lib.node.torespond={}; + game.resume(); + } + }, logSkill:function(name,targets,nature){ if(get.itemtype(targets)=='player') targets=[targets]; var nopop=false; @@ -8150,6 +8213,12 @@ } return false; }, + isOnline:function(){ + if(this.ws&&lib.node&&lib.node.clients.contains(this.ws)){ + return true; + } + return false; + }, hasSkill:function(skill){ return this.get('s').contains(skill); }, @@ -9505,6 +9574,9 @@ isMine:function(){ return (this.player&&this.player==game.me&&!_status.auto&&!this.player.isMad()); }, + isOnline:function(){ + return (this.player&&this.player.isOnline()); + }, notLink:function(){ return this.parent.name!='_lianhuan'&&this.parent.name!='_lianhuan2'; }, @@ -9773,33 +9845,47 @@ }, client:{ send:function(){ - this.ws.send(JSON.stringify(Array.from(arguments))); + var args=Array.from(arguments); + if(typeof args[0]=='function'){ + args.unshift('exec'); + } + for(var i=1;i=lib.configOL.number){ + else if(lib.node.clients.length>=parseInt(lib.configOL.number)){ this.send('denied','number'); } else{ @@ -10326,23 +10411,100 @@ this.avatar=config.avatar; this.nickname=config.nickname; } + for(var i=0;i10){ openMenu(this._link.menu,{ x:pos1.left+pos1.width+5-pos2.left, - y:40 + y:Math.min((ui.window.offsetHeight-400)/2,pos1.top-pos2.top) },function(){ node.classList.remove('on'); }); + lib.setScroll(this._link.menu); } else{ openMenu(this._link.menu,{ @@ -15647,16 +15890,6 @@ } }; var clickContainer=function(){ - // if(this.animating){ - // return; - // } - // this.animating=true; - // menu.classList.add('zoomout'); - // menu.classList.remove('zoomin'); - // setTimeout(function(){ - // menuContainer.classList.add('hidden'); - // menuContainer.animating=false; - // },300); menuContainer.classList.add('hidden'); game.resume2(); @@ -15747,6 +15980,28 @@ else if(config.clear){ node.listen(clickToggle); } + else if(config.input){ + node.classList.add('switcher'); + var input=ui.create.div(node); + input.innerHTML=config.init||'无名玩家'; + input.contentEditable=true; + input.style.webkitUserSelect='text'; + input.style.minWidth='10px'; + input.onkeydown=function(e){ + if(e.keyCode==13){ + e.preventDefault(); + e.stopPropagation(); + input.blur(); + } + }; + input.onblur=function(){ + input.innerHTML=input.innerHTML.replace(/\/g,''); + if(!input.innerHTML){ + input.innerHTML='无名玩家'; + } + game.saveConfig('connect_nickname',input.innerHTML); + } + } else{ node.classList.add('toggle'); node.listen(clickToggle); @@ -17880,7 +18135,14 @@ menuUpdates.push(function(){ if(_status.video||_status.connectMode){ node.classList.add('off'); - node.classList.remove('active'); + if(node.classList.contains('active')){ + node.classList.remove('active'); + node.link.remove(); + active=start.firstChild.lastChild; + active.classList.add('active'); + rightPane.appendChild(active.link); + } + page.remove(); cheatButton.remove(); if(_status.video) node.remove(); @@ -17936,10 +18198,15 @@ if(active==node){ node.classList.remove('active'); node.link.remove(); - active=start.firstChild.firstChild; + if(_status.connectMode){ + active=start.firstChild.lastChild; + } + else{ + active=start.firstChild.firstChild; + cheatButton.style.display=''; + } active.classList.add('active'); rightPane.appendChild(active.link); - cheatButton.style.display=''; } return; } @@ -17981,9 +18248,18 @@ node.type='cmd'; node.link=page; page.classList.add('menu-sym'); - if(_status.connectMode){ - node.classList.add('off'); - } + menuUpdates.push(function(){ + if(_status.connectMode){ + node.classList.add('off'); + if(node.classList.contains('active')){ + node.classList.remove('active'); + node.link.remove(); + active=start.firstChild.lastChild; + active.classList.add('active'); + rightPane.appendChild(active.link); + } + } + }); var text=document.createElement('div'); text.style.width='194px'; text.style.height='104px'; @@ -18817,6 +19093,7 @@ hp:ui.create.div('.hp',node), name:ui.create.div('.name',node), name2:ui.create.div('.name.name2',node), + nameol:ui.create.div('.nameol',node), count:ui.create.div('.count',node).hide(), equips:ui.create.div('.equips',node).hide(), judges:ui.create.div('.judges',node), @@ -18857,6 +19134,32 @@ return node; }, + connectPlayers:function(){ + game.connectPlayers=[]; + for(var i=0;i<8;i++){ + var player=ui.create.player(ui.window); + player.dataset.position=i; + player.classList.add('connect'); + game.connectPlayers.push(player); + if(i>=lib.configOL.number){ + player.classList.add('unselectable2'); + } + } + var button=ui.create.div('.menubutton.large.highlight',game.online?'退出联机':'开始游戏',ui.window,function(){ + if(game.online){ + game.reload(); + } + else{ + game.resume(); + } + button.delete(); + delete ui.connectStartButton; + }); + button.style.top='calc(200% / 3 + 280px / 3 + 6px)'; + button.style.width='130px'; + button.style.left='calc(50% - 65px)'; + ui.connectStartButton=button; + }, players:function(num){ if(num===0){ return; @@ -18970,9 +19273,6 @@ }, }, click:{ - connectButton:function(){ - game.connect('localhost'); - }, favouriteCharacter:function(e){ if(this.innerHTML=='添加收藏'){ this.innerHTML='移除收藏'; @@ -19191,6 +19491,32 @@ } return uiintro; }, + connectconfig:function(){ + if(game.online) return; + var uiintro=ui.create.dialog('hidden'); + uiintro.listen(function(e){ + e.stopPropagation(); + }); + uiintro.add('
输入地址
'); + uiintro.classList.add('noleave'); + var node=uiintro.add(''); + node.style.paddingTop=0; + node.style.marginBottom='16px'; + var input=node.firstChild; + input.style.width='80%'; + input.onkeydown=function(e){ + if(e.keyCode==13&&input.value){ + game.connect(input.value); + } + else{ + e.stopPropagation(); + } + } + setTimeout(function(){ + input.focus(); + },200); + return uiintro; + }, volumn:function(){ var uiintro=ui.create.dialog('hidden'); uiintro.listen(function(e){ @@ -19275,7 +19601,7 @@ // if(this._poppedalready){ // return; // } - if(lib.config.touchscreen){ + if(lib.config.touchscreen||this.forceclick){ _status.touchpopping=true; setTimeout(function(){ _status.touchpopping=false; @@ -21269,6 +21595,9 @@ }, }; var get={ + id:function(){ + return (Math.floor((new Date()).getTime()*Math.random())).toString(); + }, zhu:function(player,skill){ if(typeof player=='string'){ skill=player; @@ -21353,6 +21682,131 @@ } return cards; }, + cardInfoOL:function(card){ + return '_noname_card:'+card.cardid; + }, + infoCardOL:function(info){ + return lib.cardOL[info.slice(13)]; + }, + cardsInfoOL:function(cards){ + var info=[]; + for(var i=0;i.nameol{ + left:0; + top:15px; + width: 100%; + font-size: 12px; + text-align: center; + /*opacity: 0;*/ +} +.player:hover>.nameol{ + opacity: 1; +} .player>.name{left: 16px;top:24px;font-size:20px;font-family: 'xinwei';} .player>.name.name2{left:81px} #arena.slim_player .player>.name{ @@ -979,6 +990,7 @@ margin-bottom: 5px; #arena.selecting:not(.video) .dialog:not(.noselect) .button:not(.selectable):not(.noclick), .dead,.likedead{opacity: 0.6;} .unselectable:not(.selected):not(.removing){opacity: 0.6 !important} +.unselectable2{opacity: 0.4 !important} .mark>.background{opacity: 1 !important;} #arena.selecting:not(.video) #me .card:not(.selectable){ opacity:0.8 diff --git a/layout/mobile/layout.css b/layout/mobile/layout.css index 0bd544f9e..0b3887c39 100644 --- a/layout/mobile/layout.css +++ b/layout/mobile/layout.css @@ -110,6 +110,9 @@ top:10px; transform: none; } +#arena:not(.chess) .player[data-position='0']>.nameol{ + display: none; +} #arena:not(.chess) .player[data-position='0']>.name.name2, #arena:not(.chess) .player[data-position='0'].linked>.name.name2{ left:69px; diff --git a/layout/newlayout/global.css b/layout/newlayout/global.css index 7b2b9f93f..a54db8aa9 100644 --- a/layout/newlayout/global.css +++ b/layout/newlayout/global.css @@ -6,7 +6,7 @@ width:130px; height:160px; } -#arena.slim_player .player:not(.minskin):not(.fakeme) .avatar{ +#window>.player>.avatar,#arena.slim_player .player:not(.minskin):not(.fakeme) .avatar{ width: 136px; height: 166px; left:7px; @@ -351,6 +351,18 @@ [data-number='2']>.popup[data-position='1']{top:190px;left:calc(50% - 61px);} /*--------位置(1人)------*/ .player[data-position='0']{top:calc(100% - 170px);left:calc(50% - 75px);} +/*--------位置(联机)------*/ +#window>.player.connect[data-position='0']{left:calc(200% / 7 - 1200px / 7);top:calc(100% / 3 - 400px / 3 + 12px);} +#window>.player.connect[data-position='1']{left:calc(300% / 7 - 750px / 7);top:calc(100% / 3 - 400px / 3 + 12px);} +#window>.player.connect[data-position='2']{left:calc(400% / 7 - 300px / 7);top:calc(100% / 3 - 400px / 3 + 12px);} +#window>.player.connect[data-position='3']{left:calc(500% / 7 + 150px / 7);top:calc(100% / 3 - 400px / 3 + 12px);} +#window>.player.connect[data-position='4']{left:calc(200% / 7 - 1200px / 7);top:calc(150% / 3 - 20px + 9px);} +#window>.player.connect[data-position='5']{left:calc(300% / 7 - 750px / 7);top:calc(150% / 3 - 20px + 9px);} +#window>.player.connect[data-position='6']{left:calc(400% / 7 - 300px / 7);top:calc(150% / 3 - 20px + 9px);} +#window>.player.connect[data-position='7']{left:calc(500% / 7 + 150px / 7);top:calc(150% / 3 - 20px + 9px);} + + + .card[data-position='0']{top:calc(100% - 130px);left:calc(50% - 52px);} .popup[data-position='0']{top:calc(100% - 206px);left:calc(50% - 61px);} #me,#mebg{top:calc(100% - 150px);} diff --git a/mode/identity.js b/mode/identity.js index 3d94a44a0..3ea2d9e7e 100755 --- a/mode/identity.js +++ b/mode/identity.js @@ -13,9 +13,15 @@ mode.identity={ lib.configOL[i]=get.config(i); } } - lib.configOL.number=lib.configOL.player_number; + if(_status.mode=='zhong'){ + lib.configOL.number=8; + } + else{ + lib.configOL.number=lib.configOL.player_number; + } lib.configOL.characterPack='standard'; lib.configOL.cardPack='standard'; + lib.configOL.mode='identity'; } "step 1" var playback=localStorage.getItem(lib.configprefix+'playback'); @@ -37,7 +43,7 @@ mode.identity={ } event.finish(); } - else{ + else if(!_status.connectMode){ if(_status.mode=='zhong'){ game.prepareArena(8); } @@ -48,6 +54,9 @@ mode.identity={ game.delay(); } } + if(!lib.node){ + game.connect('localhost'); + } "step 2" if(!lib.config.new_tutorial){ game.saveConfig('version',lib.version); @@ -151,12 +160,57 @@ mode.identity={ ui.auto.classList.add('glow'); } if(_status.connectMode){ - game.waitForStart(); + game.waitForPlayer(); + } + "step 4" + if(_status.connectMode){ + game.prepareArena(); + var list=[]; + for(var i=0;i4){ + // game.me.hp++; + // game.me.maxHp++; + // game.me.update(); + // } + // for(var i=0;i