From 7cbd9ec9ec3a0ec46f6e573927045d5ddcfddd4f Mon Sep 17 00:00:00 2001 From: libccy Date: Fri, 8 May 2015 16:07:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E6=A3=8B=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- card/extra.js | 2 +- character/jiange.js | 9 +- character/yijiang.js | 2 +- game/config.js | 5 +- game/game.js | 478 ++++++++++++------ layout/default/layout.css | 5 +- layout/mode/chess.css | 100 ++++ layout/newlayout/layout.css | 12 +- mode/boss.js | 21 + mode/chess.js | 974 ++++++++++++++++++++++++++++++++++++ mode/guozhan.js | 3 + mode/identity.js | 3 + mode/stone.js | 26 +- mode/versus.js | 8 +- 14 files changed, 1474 insertions(+), 174 deletions(-) create mode 100644 layout/mode/chess.css create mode 100644 mode/boss.js create mode 100644 mode/chess.js diff --git a/card/extra.js b/card/extra.js index b78710e0f..41c7bb94d 100644 --- a/card/extra.js +++ b/card/extra.js @@ -65,7 +65,7 @@ card.extra={ type:'trick', enable:true, filterTarget:function(card,player,target){ - if(player!=game.me&&player.num('h')<3) return false; + if(player!=game.me&&player.num('h')<2) return false; return target.num('h')>0; }, content:function(){ diff --git a/character/jiange.js b/character/jiange.js index f1b5286f8..069367ff8 100644 --- a/character/jiange.js +++ b/character/jiange.js @@ -24,13 +24,16 @@ character.jiange={ trigger:{player:'phaseUseBegin'}, direct:true, filter:function(event,player){ - return player.hp<=Math.floor(game.players.length/3); + if(game.players.length>=6){ + return player.hp<=2; + } + return player.hp<=1; }, content:function(){ "step 0" player.chooseTarget('是否发动【控魂】?',function(card,player,target){ return player!=target; - },[1,Math.floor((game.players.length-1)/2)]).ai=function(target){ + },[1,Math.min(4,Math.floor((game.players.length-1)/2))]).ai=function(target){ return ai.get.damageEffect(target,player,player,'thunder')+1; } "step 1" @@ -559,7 +562,7 @@ character.jiange={ sfanshi:'反噬', sfanshi_info:'锁定技,结束阶段,你失去1点体力', konghun:'控魂', - konghun_info:'出牌阶段开始时,若你的体力值不大于1(场上存活角色数不小于6时改为2),你可以对至多X名角色各造成1点雷电伤害,然后你恢复等量体力,X为场上其他存活角色数的一半(向下取整)', + konghun_info:'出牌阶段开始时,若你的体力值不大于1(场上存活角色数不小于6时改为2),你可以对至多X名角色各造成1点雷电伤害,然后你恢复等量体力,X为场上其他存活角色数的一半(向下取整且至多为4)', jizhen_info:'结束阶段,你可以令所至多两名已受伤角色摸一张牌', // biantian2_info:'已获得大雾标记', // biantian3_info:'已获得狂风标记', diff --git a/character/yijiang.js b/character/yijiang.js index ffb116e4d..e68906910 100644 --- a/character/yijiang.js +++ b/character/yijiang.js @@ -3206,7 +3206,7 @@ character.yijiang={ xinjujian:'举荐', luoying:'落英', luoying1:'落英', - luoying2:'落英', + luoying2:'落英·判定', jiushi:'酒诗', jiushi1:'酒诗', jiushi2:'酒诗', diff --git a/game/config.js b/game/config.js index bede0c6f0..2f1f03c6b 100644 --- a/game/config.js +++ b/game/config.js @@ -6,9 +6,10 @@ window.config={ 'xiahouyuan','huangzhong','weiyan','dianwei','gongsunzan'], forbidversus:['swd_kangnalishi'], forbidstone:['zhugedan','pal_xuanxiao'], + forbidchess:['hetaihou'], forbiddouble:['zhugedan','swd_kangnalishi','swd_nicole','dongzhuo','jg_simayi'], all:{ - mode:['identity','guozhan','versus','stone'], + mode:['identity','guozhan','versus','boss','chess','stone'], characters:['standard','wind','fire','woods','mountain','extra','sp','yijiang','refresh','guozhan','jiange','zhuogui','diy','yxs','swd','xswd','gujian','xianjian'], cards:['standard','ex','extra','refresh','guozhan','zhenfa','qimou','yibao','shenbing','wanxiang','swd','shenqi','compensate'], plays:['character','soldier','wuxing'], @@ -32,6 +33,8 @@ window.config={ stone:'炉石', changjing:'场景', mowang:'魔王', + boss:'挑战', + chess:'战棋', infinity:'无限', qunyingzhuan:'群英', swd:'剧情', diff --git a/game/game.js b/game/game.js index 423219fde..8fd324699 100644 --- a/game/game.js +++ b/game/game.js @@ -175,6 +175,9 @@ window.play={}; lib.init.js('character',lib.config.all.characters); lib.init.js('play',lib.config.plays); ui.css={}; + if(lib.config.mode=='chess'){ + lib.config.layout='newlayout'; + } ui.css.layout=lib.init.css('layout/'+lib.config.layout,'layout'); if(!lib.config.touchscreen){ if(lib.config.show_scrollbar) ui.css.scrollbar=lib.init.css('layout/default','scrollbar'); @@ -350,17 +353,7 @@ window.play={}; if(player.node.judges.childElementCount){ event.card=player.node.judges.firstChild; player.lose(event.card); - var clone=event.card.copy('thrown',ui.arena).animate('judgestart'); - clone.style.opacity=0.6; - clone.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*50+'px)'; - clone.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*40+'px)'; - game.delay(); - game.linexy([ - clone.offsetLeft+clone.offsetWidth/2, - clone.offsetTop+clone.offsetHeight/2, - player.offsetLeft+player.offsetWidth/2, - player.offsetTop+player.offsetHeight/2 - ],{opacity:0.5,dashed:true}); + player.$phaseJudge(event.card); event.cancelled=false; event.trigger('phaseJudge'); } @@ -577,6 +570,7 @@ window.play={}; } } else if(get.itemtype(event.dialog)=='dialog'){ + event.dialog.style.display=''; event.dialog.open(); } } @@ -673,6 +667,7 @@ window.play={}; "step 0" if(event.dialog==undefined) event.dialog=ui.dialog; if(event.isMine()){ + event.dialog.style.display=''; event.dialog.open(); } game.check(); @@ -1133,7 +1128,7 @@ window.play={}; } if(lib.config.background_audio){ var sex=player.sex=='female'?'female':'male'; - if(lib.card[card.name].audio){ + if(lib.card[card.name].audio||lib.config.background_ogg){ if(card.name=='sha'&&(card.nature=='fire'||card.nature=='thunder')){ game.playAudio('card',sex,card.name+'_'+card.nature); } @@ -1142,12 +1137,7 @@ window.play={}; } } else{ - if(lib.config.background_ogg){ - game.playAudioOgg('card',sex,card.name); - } - else{ - game.playAudio('card/default'); - } + game.playAudio('card/default'); } } if(event.animate!=false){ @@ -1290,7 +1280,7 @@ window.play={}; game.playAudio('skill',event.skill,Math.ceil(info.audio*Math.random())); } else if(lib.config.background_ogg){ - game.playAudioOgg('skill',event.skill); + game.playAudio('skill',event.skill); } else{ game.playAudio('skill','default', @@ -1454,13 +1444,10 @@ window.play={}; if(event.parent.parent.parent.name=='useCard'){ if(lib.config.background_audio){ var sex=player.sex=='female'?'female':'male'; - if(lib.card[card.name].audio){ + if(lib.card[card.name].audio||lib.config.background_ogg){ game.playAudio('card',sex,card.name); } else{ - if(lib.config.background_ogg){ - game.playAudioOgg('card',sex,card.name); - } game.playAudio('card/default'); } } @@ -1512,7 +1499,12 @@ window.play={}; cards[num].animate('start'); if(lib.config.strict_sort){ j=0; - position=sort>0?player.node.handcards1:player.node.handcards2; + if(game.singleHandcard){ + position=sort>0?player.node.handcards1:player.node.handcards2; + } + else{ + position=player.node.handcards1; + } for(j=0;j0) frag1.appendChild(cards[num]); + if(game.singleHandcard||sort>0) frag1.appendChild(cards[num]); else frag2.appendChild(cards[num]); } } @@ -1838,7 +1830,7 @@ window.play={}; game.playAudio('die',player.name); } else if(lib.config.background_ogg){ - game.playAudioOgg('die',player.name); + game.playAudio('die',player.name); } } if(lib.config.background_audio){ @@ -1992,7 +1984,7 @@ window.play={}; var info=lib.character[character]; var skills=info[3]; this.skills.length=0; - if(lib.config.layout=='newlayout'&&info[4]&&info[4].contains('fullskin')){ + if(!game.minskin&&lib.config.layout=='newlayout'&&info[4]&&info[4].contains('fullskin')){ this.classList.remove('minskin'); this.classList.add('fullskin'); this.node.avatar.style.backgroundImage='url("image/character/fullskin/'+character+'.jpg")'; @@ -2004,6 +1996,9 @@ window.play={}; if(info[4]&&info[4].contains('minskin')){ this.classList.add('minskin'); } + else if(game.minskin){ + this.classList.add('minskin'); + } } this.node.avatar.show(); @@ -2146,17 +2141,27 @@ window.play={}; hp.childNodes[i].classList.add('lost'); } } - if(this.maxHp>9){ - this.node.hp.classList.add('longlong'); + if(this.classList.contains('minskin')){ + if(this.maxHp>5){ + this.node.hp.classList.add('longlong'); + } + else{ + this.node.hp.classList.remove('longlong'); + } } else{ - this.node.hp.classList.remove('longlong'); - } - if(this.maxHp==9||this.maxHp>=17){ - this.node.hp.classList.add('long'); - } - else{ - this.node.hp.classList.remove('long'); + if(this.maxHp>9){ + this.node.hp.classList.add('longlong'); + } + else{ + this.node.hp.classList.remove('longlong'); + } + if(this.maxHp==9||this.maxHp>=17){ + this.node.hp.classList.add('long'); + } + else{ + this.node.hp.classList.remove('long'); + } } } @@ -2232,7 +2237,7 @@ window.play={}; this.offsetTop+this.offsetHeight/2, target.offsetLeft+target.offsetWidth/2, target.offsetTop+target.offsetHeight/2 - ],config); + ],config,true); } }, line2:function(targets,config){ @@ -3449,11 +3454,16 @@ window.play={}; } else{ if(lib.config.background_ogg){ - game.playAudioOgg('skill',name); + game.playAudio('skill',name); + } + else{ + game.playAudio('skill','default',Math.ceil(Math.random()*5)); } - game.playAudio('skill','default',Math.ceil(Math.random()*5)); } } + if(lib.config.mode=='chess'){ + this.chessFocus(); + } }, unprompt:function(){ if(this.node.prompt){ @@ -3469,7 +3479,7 @@ window.play={}; node.className='popup'; } else{ - node=ui.create.div('.popup',ui.arena); + node=ui.create.div('.popup',this.parentNode); this.node.prompt=node; } node.dataset.position=this.dataset.position; @@ -3488,7 +3498,7 @@ window.play={}; }, popup:function(name,className){ var name2=get.translation(name); - var node=ui.create.div('.popup',ui.arena); + var node=ui.create.div('.popup',this.parentNode); node.dataset.position=this.dataset.position; if(this.dataset.position==0||parseInt(this.dataset.position)==parseInt(ui.arena.dataset.number)/2|| typeof name2=='number'||this.classList.contains('minskin')){ @@ -3792,15 +3802,19 @@ window.play={}; return this.classList.contains('out'); }, isMin:function(){ - return this.classList.contains('minskin'); + return this.classList.contains('minskin')&&lib.config.mode!='chess'; }, isIn:function(){ return this.classList.contains('dead')==false&&this.classList.contains('out')==false&&!this.removed; }, isUnderControl:function(){ + if(this===game.me) return false; if(lib.config.mode=='versus'){ return ui.autoreplace&&ui.autoreplace.classList.contains('on')&& - this!=game.me&&this.side==game.me.side; + this.side==game.me.side; + } + else if(lib.config.mode=='chess'){ + return this.side==game.me.side; } return false; }, @@ -3861,7 +3875,7 @@ window.play={}; } node.fixed=true; node.dataset.position=this.dataset.position; - ui.arena.appendChild(node); + this.parentNode.appendChild(node); setTimeout(function(){ node.remove(); },1000); @@ -3884,7 +3898,6 @@ window.play={}; ); node1.classList.add('infohidden'); node1.style.webkitTransform='perspective(600px) rotateY(180deg) translateX(0)'; - // ui.refresh(node1); setTimeout(function(){ setTimeout(function(){ node1.style.transition='all ease-in 0.3s'; @@ -3903,7 +3916,6 @@ window.play={}; ); node2.classList.add('infohidden'); node2.style.webkitTransform='perspective(600px) rotateY(180deg) translateX(0)'; - // ui.refresh(node2); setTimeout(function(){ node2.style.transition='all ease-in 0.3s'; node2.style.webkitTransform='perspective(600px) rotateY(270deg) translateX(52px)'; @@ -3959,15 +3971,25 @@ window.play={}; } game.log(str); } - for(var i=0;i=0){ if(log!=false){ game.log(get.translation(player)+'从'+get.translation(this)+'获得了'+get.cnNumber(card)+'张牌'); } - while(card--) this.$give('',player,false); + if(this.$givemod){ + this.$givemod(card,player); + } + else{ + while(card--) this.$give('',player,false); + } } else{ if(log!=false){ @@ -3978,31 +4000,36 @@ window.play={}; game.log(get.translation(player)+'从'+get.translation(this)+'获得了一张牌'); } } - var node; - if(get.itemtype(card)=='card'){ - node=card.copy('card','thrown',false); + if(this.$givemod){ + this.$givemod(card,player); } else{ - node=ui.create.div('.card.thrown'); + var node; + if(get.itemtype(card)=='card'){ + node=card.copy('card','thrown',false); + } + else{ + node=ui.create.div('.card.thrown'); + } + node.dataset.position=this.dataset.position; + node.fixed=true; + node.hide(); + node.style.transitionProperty='left,top,opacity'; + + node.style.webkitTransform='rotate('+(Math.random()*16-8)+'deg)'; + + ui.arena.appendChild(node); + ui.refresh(node); + node.show(); + node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)'; + node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*80+'px)'; + + setTimeout(function(){ + node.removeAttribute('style'); + node.dataset.position=player.dataset.position; + node.delete(); + },700); } - node.dataset.position=this.dataset.position; - node.fixed=true; - ui.arena.appendChild(node); - node.hide(); - node.style.transitionProperty='left,top,opacity'; - - node.style.webkitTransform='rotate('+(Math.random()*16-8)+'deg)'; - - ui.arena.appendChild(node); - ui.refresh(node); - node.show(); - node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)'; - node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*80+'px)'; - setTimeout(function(){ - node.removeAttribute('style'); - node.dataset.position=player.dataset.position; - node.delete(); - },700); } }, $gain:function(card,log){ @@ -4014,43 +4041,58 @@ window.play={}; } game.log(str); } - for(var i=0;i1){ if(log!=false){ game.log(get.translation(this)+'获得了'+get.cnNumber(card)+'张牌'); } - for(var i=0;i1) auto=false; for(i=0;i7){ + nochess=false; + } + } if(event.filterTarget(card,player,game.players[i])&& - (game.players[i].isOut()==false||event.includeOutTarget)){ + (game.players[i].isOut()==false||event.includeOutTarget)&&nochess){ if(ui.selected.targets.lengthitem.offsetLeft&&exitem.offsetTop&&ey0){ - game.me.node.handcards1.appendChild(cards[i]); - } - else{ - game.me.node.handcards2.appendChild(cards[i]); + if(!game.singleHandcard){ + for(i=0;i0){ + game.me.node.handcards1.appendChild(cards[i]); + } + else{ + game.me.node.handcards2.appendChild(cards[i]); + } } } }, @@ -9375,13 +9527,15 @@ window.play={}; for(i=0;i=ui.dialog.content.offsetHeight){ ui.dialog.classList.remove('scroll1'); @@ -9656,8 +9819,15 @@ window.play={}; if(!game.players.contains(from)&&!game.dead.contains(from)) return Infinity; if(!game.players.contains(to)&&!game.dead.contains(to)) return Infinity; var player=from,m,n=1,i; - if(to.isMin()||from.isMin()){ - if(method=='raw'||method=='pure') return 1; + var fxy,txy; + if(lib.config.mode=='chess'){ + fxy=from.getXY(); + txy=to.getXY(); + n=Math.abs(fxy[0]-txy[0])+Math.abs(fxy[1]-txy[1]); + if(method=='raw'||method=='pure'||method=='absolute') return n; + } + else if(to.isMin()||from.isMin()){ + if(method=='raw'||method=='pure'||method=='absolute') return 1; } else{ var length=game.players.length; @@ -9678,7 +9848,7 @@ window.play={}; if(from.isDead()) length++; if(to.isDead()) length++; n=Math.min(n,length-n); - if(method=='pure') return n; + if(method=='raw'||method=='pure') return n; } n=game.checkMod(from,to,n,'globalFrom',from.get('s')); diff --git a/layout/default/layout.css b/layout/default/layout.css index 12b91110b..08a79d219 100644 --- a/layout/default/layout.css +++ b/layout/default/layout.css @@ -116,6 +116,7 @@ body>.background{z-index:-2} .dialog{text-align: center;} .dialog{width: calc(90% - 420px);height: calc(100% / 3 - 160px / 3 + 120px);} .dialog.fullheight{height:calc(100% - 80px) !important;top:40px !important} +.dialog.fullwidth{left:calc(5% + 60px) !important;width:calc(90% - 120px) !important} .dialog{top:calc(100% / 3 - 100px / 3);left: calc(5% + 210px);} #window>.dialog.popped{ @@ -171,6 +172,7 @@ margin-bottom: 5px; .toggle{right: 16px;left: auto !important;min-width: 16px;text-align: right !important;} .switcher{width: 88%;position: relative;} .caption{padding-top: 8px;font-size: 20px;display: block;} +.caption:only-child{padding-bottom:8px;} .caption:not(.normal)>div{text-align: left;display: block;width: 100%;} .caption>div{position: relative;} .caption>.text{font-size:16px;text-align:left} @@ -485,7 +487,7 @@ div:hover>.intro{opacity: 1;} } .newgame{ - width:170px; + width:calc(100% - 16px); display:flex; } .newgame>div{ @@ -686,6 +688,7 @@ div[data-nature='soil']{ @-webkit-keyframes replaceme{from {opacity: 0;-webkit-transform:translateY(120px)}} @-webkit-keyframes replaceenemy{from {opacity: 0;-webkit-transform:translateY(-120px)}} @-webkit-keyframes drawing{0% {opacity: 0;left:calc(50% - 52px);top:calc(50% - 52px);}50%{opacity: 1}100%{opacity: 0}} +@-webkit-keyframes drawing2{0% {opacity: 0}50%{opacity: 1}100%{opacity: 0}} @-webkit-keyframes card_start{from {opacity: 0;-webkit-transform:scale(0);}} @-webkit-keyframes card_start2{from {opacity: 0;-webkit-transform:scale(0);margin-left: -52px;margin-right: -52px;}} @-webkit-keyframes card_judgestart{from {opacity: 0;-webkit-transform:scale(0) rotateY(-180deg) perspective(600px);}} diff --git a/layout/mode/chess.css b/layout/mode/chess.css new file mode 100644 index 000000000..2b21cb2a4 --- /dev/null +++ b/layout/mode/chess.css @@ -0,0 +1,100 @@ +#arena.chess{ + width:100%; + height:100%; + left:0; + top:0; + transition:all 0s !important; +} +#arena.chess>#me, +#arena.chess>#mebg{ + bottom:0; + top:auto; + border-radius:0; +} + +#chess-container{ + width:100%; + height :calc(100% - 120px); + left:0; + top:0; + overflow:scroll; + text-align:center; +} +#chess{ + margin-top:36px; + position:relative; +} +#arena .card.thrown{ + z-index:4; +} + +#handcards1{ + height:120px; + padding:0; + top:calc(100% - 120px); + width:calc(100% - 240px); + left:120px; +} +#handcards2{ + display:none; +} +#mebg,#me{ + height:120px; +} + +#system{ + z-index:5; +} +#arena>.dialog{ + width:400px; + height:240px; + left:calc(50% - 200px); + top:calc(50% - 120px); + background: rgba(0,0,0,0.2); + box-shadow: rgba(0, 0, 0, 0.3) 0 0 0 1px; + border-radius:8px; +} +#control{ + top:calc(100% - 155px); +} +.fakeme{ + width:120px; + height:120px; + border-radius:0px; + top:0; +} +.fakeme.avatar{ + left:0; + background-size:cover; +} +.fakeme.player{ + left:calc(100% - 120px); + overflow:scroll; + text-align:center; +} +.fakeme.player>div{ + width:45px; + height:45px; + background-size:cover; + border-radius:4px; + position:relative; + left:0; + top:8px; + margin-left: 4px; + margin-right: 4px; + margin-bottom: 8px; +} +.fakeme.player>.dead{ + -webkit-filter:grayscale(1); + opacity:0.5; +} +.card.drawing{ + -webkit-animation: drawing2 1s; + -webkit-animation-fill-mode: forwards; +} + +.player.playergrid{ + background: rgba(0,0,0,0.2); + box-shadow: rgba(0, 0, 0, 0.3) 0 0 0 1px; + border-radius:8px; +} diff --git a/layout/newlayout/layout.css b/layout/newlayout/layout.css index 551db267c..0c4e74682 100644 --- a/layout/newlayout/layout.css +++ b/layout/newlayout/layout.css @@ -19,6 +19,9 @@ .player.minskin .hp{ left:86px; } +.player.minskin .hp.longlong{ + left:74px; +} .player .avatar2{ width:52px; height:52px; @@ -76,7 +79,7 @@ max-height:148px; left:auto; } -.player.minskin .judges{ +.player.noidentity .judges{ top:14px; } .player .marks>div, @@ -103,6 +106,10 @@ left:12px; text-align:left; } +.player.minskin .equips{ + -webkit-transform:scale(0.73); + -webkit-transform-origin:bottom left; +} .player .equips>.card{ position:relative; width:100%; @@ -282,6 +289,9 @@ -webkit-transform:rotate(90deg) translate(-150px,-6px); -webkit-transform-origin:bottom left; } +.player.minskin.linked .equips{ + -webkit-transform:rotate(90deg) translate(-90px,-6px) scale(0.73); +} .player.linked div:not(.equips) .card, .player.linked .identity{ -webkit-transform:rotate(90deg); diff --git a/mode/boss.js b/mode/boss.js new file mode 100644 index 000000000..271eee9ac --- /dev/null +++ b/mode/boss.js @@ -0,0 +1,21 @@ +'use strict'; +mode.boss={ + game:{ + start:function(){ + var next=game.createEvent('game',false); + next.content=function(){ + "step 0" + ui.create.arena(); + var dialog=ui.create.dialog('还没完工~'); + dialog.style.height='52px'; + dialog.style.background=' rgba(0,0,0,0.2)'; + dialog.style.boxShadow=' rgba(0, 0, 0, 0.3) 0 0 0 1px'; + dialog.style.borderRadius='8px'; + dialog.style.top='calc(50% - 52px)'; + game.pause(); + "step 1" + console.log(1); + } + } + } +} diff --git a/mode/chess.js b/mode/chess.js new file mode 100644 index 000000000..b2a3f0c08 --- /dev/null +++ b/mode/chess.js @@ -0,0 +1,974 @@ +'use strict'; +mode.chess={ + canvasUpdates2:[], + element:{ + card:{ + moveTo:function(player,method){ + this.fixed=true; + if(this.parentNode==ui.arena){ + var rect=player.getBoundingClientRect(); + this.style.left=(rect.left+8)+'px'; + this.style.top=(rect.top+8)+'px'; + } + else{ + this.style.left=''; + this.style.top=''; + this.dataset.position=player.dataset.position; + } + if(method=='flip'){ + this.style.transition='all 0.5s'; + this.style.webkitTransform='rotate'+(Math.random()<0.5?'X':'Y')+'(180deg) perspective(1000px)'; + } + else if(method=='rotate'){ + this.style.transition='all 0.5s'; + this.style.webkitTransform='rotate(180deg)'; + } + return this; + }, + }, + player:{ + chooseToMove:function(num){ + var next=game.createEvent('chooseToMove'); + next.num=num||1; + next.player=this; + next.content=lib.element.playerproto.chooseToMove; + return next; + }, + move:function(x,y){ + var xy=this.getXY(); + return this.moveTo(x+xy[0],y+xy[1]); + }, + moveTo:function(x,y){ + if(x>=ui.chesswidth){ + x=ui.chesswidth-1; + } + if(y>=ui.chessheight){ + y=ui.chessheight-1; + } + // console.log(x,y); + + var pos=y*ui.chesswidth+x; + if(!lib.posmap[pos]){ + delete lib.posmap[this.dataset.position]; + this.dataset.position=pos; + lib.posmap[pos]=this; + this.chessFocus(); + } + return this; + }, + chessFocus:function(){ + if(ui.chess._chessdrag) return; + var player=this; + var dx=0,dy=0; + + if(player.offsetLeft-ui.chessContainer.scrollLeft<14){ + dx=player.offsetLeft-ui.chessContainer.scrollLeft-14; + } + else if(player.offsetLeft-ui.chessContainer.scrollLeft>ui.chessContainer.offsetWidth-134){ + dx=player.offsetLeft-ui.chessContainer.scrollLeft-ui.chessContainer.offsetWidth+134; + } + if(player.offsetTop-ui.chessContainer.scrollTop<14){ + dy=player.offsetTop-ui.chessContainer.scrollTop-14; + } + else if(player.offsetTop+ui.chess.offsetTop-ui.chessContainer.scrollTop>ui.chessContainer.offsetHeight-134){ + dy=player.offsetTop+ui.chess.offsetTop-ui.chessContainer.scrollTop-ui.chessContainer.offsetHeight+134; + } + if(_status.currentChessFocus){ + clearInterval(_status.currentChessFocus); + } + var count=12; + var ddx=Math.floor(dx/12); + var ddy=Math.floor(dy/12); + if(dx||dy){ + _status.currentChessFocus=setInterval(function(){ + if(count--){ + ui.chessContainer.scrollLeft+=ddx; + ui.chessContainer.scrollTop+=ddy; + } + else{ + ui.chessContainer.scrollLeft+=dx%12; + ui.chessContainer.scrollTop+=dy%12; + clearInterval(_status.currentChessFocus); + delete _status.currentChessFocus; + } + },16); + } + }, + getXY:function(){ + var pos=parseInt(this.dataset.position); + var x=pos%ui.chesswidth; + var y=Math.floor(pos/ui.chesswidth); + return [x,y]; + }, + getDataPos:function(x,y){ + var xy=this.getXY(); + if(typeof x!='number') x=0; + if(typeof y!='number') y=0; + x+=xy[0]; + y+=xy[1]; + return x+y*ui.chesswidth; + }, + getNeighbour:function(x,y){ + return lib.posmap[this.getDataPos(x,y)]||null; + }, + movable:function(x,y){ + var xy=this.getXY(); + if(xy[0]+x<0) return false; + if(xy[1]+y<0) return false; + if(xy[0]+x>=ui.chesswidth) return false; + if(xy[1]+y>=ui.chessheight) return false; + return !this.getNeighbour(x,y); + }, + moveRight:function(){ + if(this.movable(1,0)){ + this.move(1,0); + return true; + } + return false; + }, + moveLeft:function(){ + if(this.movable(-1,0)){ + this.move(-1,0); + return true; + } + return false; + }, + moveUp:function(){ + if(this.movable(0,-1)){ + this.move(0,-1); + return true; + } + return false; + }, + moveDown:function(){ + if(this.movable(0,1)){ + this.move(0,1); + return true; + } + return false; + }, + dieAfter:function(){ + var player=this; + delete lib.posmap[player.dataset.position]; + setTimeout(function(){ + player.delete(); + },500); + for(var i=0;i1){ + if(cards){ + that.$draw(cards) + } + else{ + that.$draw(num-1) + } + } + }, + $gainmod:function(num){ + var cards,node; + if(get.itemtype(num)=='cards'){ + cards=num; + num=cards.length; + } + else if(get.itemtype(num)=='card'){ + cards=[num]; + num=1; + } + if(cards){ + cards=cards.slice(0); + node=cards.shift().copy('thrown','hidden'); + } + else{ + node=ui.create.div('.card.thrown.hidden'); + } + node.fixed=true; + game.$randomMove(this,node,100,30); + var ot=node.style.webkitTransform; + node.style.webkitTransform+='scale(0.6)'; + node.dataset.position=this.dataset.position; + this.parentNode.appendChild(node); + ui.refresh(node); + node.show(); + node.style.webkitTransform=ot; + setTimeout(function(){ + node.style.webkitTransform=''; + node.delete(); + },500); + var that=this; + if(num&&num>1){ + if(cards){ + that.$gain(cards) + } + else{ + that.$gain(num-1) + } + } + }, + $throw:function(card,time){ + this.chessFocus(); + if(get.itemtype(card)=='cards'){ + for(var i=0;i=0){ + for(var i=0;ipxy[0]&&randomMove.contains('moveRight')){ + if(player.moveRight()){ + event.moved=true;break; + } + } + else if(txy[0]pxy[1]&&randomMove.contains('moveDown')){ + if(player.moveDown()){ + event.moved=true;break; + } + } + else if(txy[1]pxy[1]&&randomMove.contains('moveDown')){ + if(player.moveDown()){ + event.moved=true;break; + } + } + else if(txy[1]pxy[0]&&randomMove.contains('moveRight')){ + if(player.moveRight()){ + event.moved=true;break; + } + } + else if(txy[0]=ui.chessContainer.offsetWidth){ + tx=-Math.abs(tx); + } + if(rect.top<=80){ + ty=Math.abs(ty); + } + else if(rect.top+rect.height+80>=ui.chessContainer.offsetHeight){ + ty=-Math.abs(ty); + } + node.style.webkitTransform='translate('+tx+'px,'+ty+'px)'; + }, + draw2:function(func){ + lib.canvasUpdates2.push(func); + if(!lib.status.canvas2){ + lib.status.canvas2=true; + game.update(game.updateCanvas2); + } + }, + updateCanvas2:function(time){ + if(lib.canvasUpdates2.length===0){ + lib.status.canvas2=false; + return false; + } + ui.canvas2.width=ui.chess.offsetWidth; + ui.canvas2.height=ui.chess.offsetHeight; + ui.canvas2.style.left=0; + ui.canvas2.style.top=0; + var ctx=ui.ctx2; + ctx.shadowBlur=5; + ctx.shadowColor='rgba(0,0,0,0.3)'; + ctx.fillStyle='white'; + ctx.strokeStyle='white'; + ctx.lineWidth=3; + ctx.save(); + for(var i=0;i.player'+pos+ + '{left:'+(14+i*148)+'px;top:'+(14+j*148)+'px}',0); + ui.chesssheet.sheet.insertRule('#arena.chess #chess>.card'+pos+ + '{left:'+(22+i*148)+'px;top:'+(22+j*148)+'px}',0); + if(j==ui.chessheight-1){ + ui.chesssheet.sheet.insertRule('#arena.chess #chess>.popup'+pos+ + '{left:'+(19+i*148)+'px;top:'+(-19+j*148)+'px}',0); + } + else{ + ui.chesssheet.sheet.insertRule('#arena.chess #chess>.popup'+pos+ + '{left:'+(19+i*148)+'px;top:'+(142+j*148)+'px}',0); + } + } + } + + var grids=[]; + var gridnum=ui.chessheight*ui.chesswidth; + for(var i=0;i1; + var nh=player.num('h'); + if(nh<=Math.min(3,player.hp)) return Math.random()-0.3; + else if(nh<=Math.min(3,player.hp)) return Math.random()-0.4; + if(!player.num('h','sha')&& + !player.num('h','shunshou')&& + !player.num('h','bingliang')) return Math.random()-0.5; + var neighbour; + neighbour=player.getNeighbour(0,1); + if(neighbour&&neighbour.side!=player.side){ + return range?1:0; + } + neighbour=player.getNeighbour(0,-1); + if(neighbour&&neighbour.side!=player.side){ + return range?1:0; + } + neighbour=player.getNeighbour(1,0); + if(neighbour&&neighbour.side!=player.side){ + return range?1:0; + } + neighbour=player.getNeighbour(-1,0); + if(neighbour&&neighbour.side!=player.side){ + return range?1:0; + } + return 1; + } + } + } + }, + _chessswap:{ + trigger:{player:['phaseBegin','chooseToUseBegin','chooseToRespondBegin','chooseToDiscardBegin','chooseToCompareBegin', + 'chooseButtonBegin','chooseCardBegin','chooseTargetBegin','chooseCardTargetBegin','chooseControlBegin', + 'chooseBoolBegin','choosePlayerCardBegin','discardPlayerCardBegin','gainPlayerCardBegin']}, + forced:true, + priority:100, + popup:false, + filter:function(event,player){ + if(event.autochoose&&event.autochoose()) return false; + return !_status.auto&&player.isUnderControl(); + }, + content:function(){ + game.modeSwapPlayer(player); + }, + }, + _chesscenter:{ + trigger:{player:['phaseBegin','useCardBegin','useSkillBegin','respondBegin','damageBegin','loseHpBegin'], + target:'useCardToBegin'}, + forced:true, + priority:100, + popup:false, + content:function(){ + player.chessFocus(); + }, + }, + }, + translate:{ + friend:'友', + enemy:'敌', + trueColor:"zhu", + falseColor:"wei", + _chessmove:'移动', + }, + ui:{ + create:{ + playergrid:function(player,x,y){ + var node=ui.create.div('.player.minskin.playergrid',player.parentNode); + node.listen(ui.click.playergrid); + node.link=player; + node.dataset.position=player.getDataPos(x,y); + return node; + }, + fakeme:function(){ + if(ui.fakeme){ + ui.fakeme.delete(); + } + ui.fakeme=ui.create.div('.fakeme.avatar',ui.me); + ui.fakeme.style.backgroundImage=game.me.node.avatar.style.backgroundImage; + } + }, + click:{ + playergrid:function(){ + if(!_status.paused) return; + delete lib.posmap[this.link.dataset.position]; + this.link.dataset.position=this.dataset.position; + lib.posmap[this.link.dataset.position]=this.link; + if(ui.movegrids){ + while(ui.movegrids.length){ + ui.movegrids.shift().delete(); + } + } + game.resume(); + } + } + }, + ai:{ + get:{ + attitude:function(from,to){ + return (from.side==to.side?1:-1)*5; + } + } + }, + posmap:{}, + config:['battle_number','ban_weak','free_choose','change_choice'], +} diff --git a/mode/guozhan.js b/mode/guozhan.js index 6068f7e93..e97f5bb1c 100644 --- a/mode/guozhan.js +++ b/mode/guozhan.js @@ -204,6 +204,9 @@ mode.guozhan={ } ui.create.cheat=function(){ ui.cheat=ui.create.control('更换',function(){ + if(ui.cheat2&&ui.cheat2.dialog==_status.event.dialog){ + return; + } event.list=event.list.concat(list); event.list.randomSort(); list=event.list.splice(0,7); diff --git a/mode/identity.js b/mode/identity.js index 145f0f0ee..259094ffd 100644 --- a/mode/identity.js +++ b/mode/identity.js @@ -355,6 +355,9 @@ mode.identity={ }; ui.create.cheat=function(){ ui.cheat=ui.create.control('更换',function(){ + if(ui.cheat2&&ui.cheat2.dialog==_status.event.dialog){ + return; + } if(game.zhu!=game.me){ event.list=event.list.concat(list); event.list.randomSort(); diff --git a/mode/stone.js b/mode/stone.js index 4828bd66f..2afecb2cd 100644 --- a/mode/stone.js +++ b/mode/stone.js @@ -106,6 +106,7 @@ mode.stone={ game.additionaldead.push(this); setTimeout(function(){ var player=ui.create.player(); + player.classList.add('noidentity'); player.dataset.position=dead.dataset.position; player.side=dead.side; player.actcharacterlist=dead.actcharacterlist; @@ -140,6 +141,7 @@ mode.stone={ game.additionaldead.push(this); setTimeout(function(){ var player=ui.create.player(); + player.classList.add('noidentity'); player.dataset.position=dead.dataset.position; player.side=dead.side; player.actcharacterlist=dead.actcharacterlist; @@ -179,7 +181,6 @@ mode.stone={ }, game:{ reserveDead:true, - layoutFixed:true, updateStatusCount:function(){ _status.friendCount.innerHTML='我方兵力:'+get.cnNumber(1+_status.mylist.length/(_status.double_character?2:1),true); _status.enemyCount.innerHTML='敌方兵力:'+get.cnNumber(1+_status.enemylist.length/(_status.double_character?2:1),true); @@ -211,7 +212,7 @@ mode.stone={ } }, initStone:function(){ - var list=[]; + var list=[],list2=[]; var i,j,name; for(i in lib.character){ if(lib.character[i][4]&&lib.character[i][4].contains('minskin')&&lib.character[i][4].contains('stone')){ @@ -219,7 +220,12 @@ mode.stone={ lib.character[i][3].add('stoneshan'); lib.character[i][3].add('stonedraw'); name=i+'_stonecharacter'; - list.push(name); + if(lib.character[i][5][0]<3){ + list.push(name); + } + else{ + list2.push(name); + } lib.card[name]={ image:'character/default/'+i, stoneact:lib.character[i][5][0] @@ -231,16 +237,13 @@ mode.stone={ lib.translate[name+'_info']=get.skillintro(i); } } - var totallength=Math.ceil(lib.card.list.length/40); var addedcardcount=Math.ceil(lib.card.list.length/80); var addedcardcount2=Math.ceil(lib.card.list.length/160); var suit=['heart','diamond','club','spade']; - while(totallength--){ + while(addedcardcount--){ for(i=0;i