From 02b03b1ca545bfd69726328f2ddfcef4c59ecf56 Mon Sep 17 00:00:00 2001 From: libccy Date: Tue, 12 May 2015 17:51:40 +0800 Subject: [PATCH] boss --- card/qimou.js | 2 +- card/refresh.js | 2 +- card/yibao.js | 2 + character/extra.js | 10 +- character/fire.js | 3 +- character/sp.js | 4 +- character/xianjian.js | 1 + character/yxs.js | 1 + character/zhuogui.js | 9 + game/config.js | 1 + game/game.js | 120 ++--- layout/mode/boss.css | 111 +++-- layout/newlayout/layout.css | 4 + mode/boss.js | 891 ++++++++++++++++++++++++++++++++++-- mode/chess.js | 4 +- mode/versus.js | 6 +- 16 files changed, 1045 insertions(+), 126 deletions(-) diff --git a/card/qimou.js b/card/qimou.js index 20fade592..d4e5953f7 100644 --- a/card/qimou.js +++ b/card/qimou.js @@ -251,7 +251,7 @@ card.qimou={ ai:{ order:6.5, tag:{ - discard:1, + loseCard:1, multitarget:1, multineg:1 }, diff --git a/card/refresh.js b/card/refresh.js index 8cb04f2c0..b8dc27320 100644 --- a/card/refresh.js +++ b/card/refresh.js @@ -164,7 +164,7 @@ card.refresh={ order:4, result:{ player:function(player){ - if(player.tempSkills['muniu_skill8']) return 0; + if(player.skills.contains('muniu_skill8')) return 0; if(_status.dying) return ai.get.attitude(player,_status.dying); return 1; } diff --git a/card/yibao.js b/card/yibao.js index d8e745356..8a1def314 100644 --- a/card/yibao.js +++ b/card/yibao.js @@ -266,6 +266,8 @@ card.yibao={ player.$compare(event.card1,target,event.card2); game.delay(4); "step 3" + game.log(get.translation(player)+'展示了'+get.translation(event.card1)); + game.log(get.translation(target)+'展示了'+get.translation(event.card2)); if(get.color(event.card2)==get.color(event.card1)){ player.discard(event.card1).animate=false; target.$gain2(event.card2); diff --git a/character/extra.js b/character/extra.js index dc2d3b989..b9278078a 100644 --- a/character/extra.js +++ b/character/extra.js @@ -490,7 +490,7 @@ character.extra={ intro:{ mark:function(dialog,content,player){ if(content&&content.length){ - if(player==game.me){ + if(player==game.me||player.isUnderControl()){ dialog.add(content); } else{ @@ -500,7 +500,7 @@ character.extra={ }, content:function(content,player){ if(content&&content.length){ - if(player==game.me){ + if(player==game.me||player.isUnderControl()){ return get.translation(content); } return '共有'+get.cnNumber(content.length)+'张星'; @@ -590,6 +590,9 @@ character.extra={ for(var i=0;i=position){ + return players[i]; + } + } + return players[0]; + }, phaseLoop:function(player){ var next=game.createEvent('phaseLoop'); next.player=player; @@ -5969,19 +5979,8 @@ window.play={}; "step 0" player.phase(); "step 1" - var players,i; - if(game.players.contains(event.player.next)==false){ - players=get.players(lib.sort.position); - if(parseInt(players[players.length-1].dataset.position)=parseInt(event.player.dataset.position)){ - event.player=game.players[i];break; - } - } - } + if(!game.players.contains(event.player.next)){ + event.player=game.findNext(event.player.next); } else{ event.player=event.player.next; @@ -7099,6 +7098,9 @@ window.play={}; else if(typeof lib.config.current_mode[i]==='function'){ modeconfig.push(lib.config.current_mode[i](game,lib,get,ui)); } + else{ + modeconfig.push(ui.create.div('.placeholder')); + } } } } @@ -8768,14 +8770,14 @@ window.play={}; player:function(){ return ui.click.target.apply(this,arguments); }, - target:function(){ + target:function(e){ if(_status.dragged) return; if(_status.clicked) return; if(ui.intro) return; _status.clicked=true; var custom=_status.event.custom; if(custom.replace.target){ - custom.replace.target(this); + custom.replace.target(this,e); return; } if(this.classList.contains('selectable')==false) return; @@ -8792,28 +8794,30 @@ window.play={}; } else{ ui.selected.targets.add(this); - var targetprompt=null; - if(_status.event.targetprompt){ - targetprompt=_status.event.targetprompt; - } - else if(_status.event.skill&&!get.info(_status.event.skill).viewAs){ - targetprompt=get.info(_status.event.skill).targetprompt; - } - else{ - var currentcard=get.card(); - if(currentcard){ - targetprompt=get.info(currentcard).targetprompt; + if(_status.event.name=='chooseToUse'){ + var targetprompt=null; + if(_status.event.targetprompt){ + targetprompt=_status.event.targetprompt; } - } - if(targetprompt){ - if(Array.isArray(targetprompt)){ - targetprompt=targetprompt[Math.min(targetprompt.length-1,ui.selected.targets.indexOf(this))]; + else if(_status.event.skill&&!get.info(_status.event.skill).viewAs){ + targetprompt=get.info(_status.event.skill).targetprompt; } - else if(typeof targetprompt=='function'){ - targetprompt=targetprompt(this); + else{ + var currentcard=get.card(); + if(currentcard){ + targetprompt=get.info(currentcard).targetprompt; + } } - if(targetprompt&&typeof targetprompt=='string'){ - this.prompt(targetprompt); + if(targetprompt){ + if(Array.isArray(targetprompt)){ + targetprompt=targetprompt[Math.min(targetprompt.length-1,ui.selected.targets.indexOf(this))]; + } + else if(typeof targetprompt=='function'){ + targetprompt=targetprompt(this); + } + if(targetprompt&&typeof targetprompt=='string'){ + this.prompt(targetprompt); + } } } this.classList.add('selected'); @@ -9911,7 +9915,7 @@ window.play={}; 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()){ + else if(to.isMin(true)||from.isMin(true)){ if(method=='raw'||method=='pure'||method=='absolute') return 1; } else{ @@ -9920,14 +9924,14 @@ window.play={}; for(var iwhile=0;iwhile#bosslist, -.bosspaused>#control{ +.bosspaused>#control, +.bosspaused>.dialog.bosscharacter{ opacity:0.2 !important; } -#bosslist>.player.bossshow{ - opacity:1; - -webkit-animation:boss_start 0.5s; - -webkit-transform:none; -} -#bosslist>.player{ - position:relative; - margin:10px; - left:0; - top:0; - width:180px; - height:216px; - opacity: 0; - transition: all 0.3s; - -webkit-transform:translateY(-200px); -} -#bosslist>.player:hover{ - -webkit-transform:scale(1.1); +#bosslist.hidden>.player{ + transition:all 0s; } #bosslist>div:first-child, #bosslist>div:last-child{ width:20px; position:relative; } -#bosslist>.player>div:not(.hp):not(.identity):not(.avatar){ + +.player.bossplayer.bossing{ + position:absolute; +} +.player.bossing .avatar{ + transition:all 0.5s; +} +.player.bossplayer.highlight{ + -webkit-transform:scale(1.1); + opacity:1; +} +#bosslist.removing>.player.bossplayer.highlight{ + transition:all 0s; + opacity:0; +} +.player.bossplayer{ + position:relative; + margin:10px; + left:0; + top:0; + width:180px; + height:216px; + transition: all 0.3s; + opacity:0.6; + -webkit-animation:game_start 0.5s; +} +.player.bossplayer>div:not(.hp):not(.identity):not(.avatar){ display:none !important; } -#bosslist>.player>.identity{ +.player.bossplayer>.identity{ left:16px; top:20px; line-height:24px; white-space:normal; } -#bosslist>.player>.hp{ +.player.bossplayer>.hp{ top:22px; left:144px; } -#bosslist>.player>.avatar{ +.player.bossplayer>.avatar{ width:156px; height:192px; } #control.bosslist{ - top:calc(50% + 100px); -} -#control.bosslist>div{ - transition:opacity 0.5s; + top:calc(100% - 50px); + position:fixed; } -@-webkit-keyframes boss_start{from {opacity: 0;-webkit-transform:translateY(-200px);}} +.dialog.bosscharacter{ + top:auto; + bottom:65px; + height:calc(100% - 383px); + background: rgba(0,0,0,0.2); + box-shadow: rgba(0, 0, 0, 0.3) 0 0 0 1px; + border-radius:8px; +} + +.bosschongzheng{ + width:calc(100% - 20px); + white-space:nowrap; + position:relative; +} +.bosschongzheng div{ + position:relative; +} +.bosschongzheng>div{ + width:100%; + display:block; + margin-bottom:5px; +} +.bosschongzheng>div>div:first-child{ + text-align:left; + width:30%; +} +.bosschongzheng>div>div:last-child{ + text-align:right; + width:70%; +} + +@media screen and (min-height: 800px) { + .dialog.bosscharacter{ + height:417px; + bottom:calc(50% - 335px); + } + #control.bosslist{ + top:calc(50% + 350px); + + } + #bosslist{ + top:calc(40% - 260px); + } +} diff --git a/layout/newlayout/layout.css b/layout/newlayout/layout.css index 867a06224..160bf8186 100644 --- a/layout/newlayout/layout.css +++ b/layout/newlayout/layout.css @@ -463,6 +463,10 @@ width: 630px; left: calc(50% - 315px); } + .dialog.bosscharacter{ + width: 735px; + left: calc(50% - 367.5px); + } #arena.stone .dialog{ width: calc(90% - 440px); left: calc(5% + 220px); diff --git a/mode/boss.js b/mode/boss.js index 7b4691f60..7328882f8 100644 --- a/mode/boss.js +++ b/mode/boss.js @@ -1,7 +1,27 @@ 'use strict'; mode.boss={ + element:{ + player:{ + dieAfter:function(){ + if(this!=game.boss){ + this.storage.boss_chongzheng=0; + } + if(this==game.boss||game.players.length==1){ + game.checkResult(); + } + } + } + }, game:{ reserveDead:true, + checkResult:function(){ + if(game.boss==game.me){ + game.over(game.boss.isAlive()); + } + else{ + game.over(!game.boss.isAlive()); + } + }, start:function(){ var next=game.createEvent('game',false); next.content=function(){ @@ -15,7 +35,10 @@ mode.boss={ } } lib.init.css('layout/mode','boss'); - var bosslist=ui.create.div('#bosslist'); + game.delay(0.1); + "step 1" + var bosslist=ui.create.div('#bosslist.hidden'); + event.bosslist=bosslist; if(!lib.config.touchscreen&&lib.config.mousewheel){ bosslist._scrollspeed=30; bosslist._scrollnum=10; @@ -44,6 +67,7 @@ mode.boss={ game.onresume2=onresume; ui.create.div(bosslist); + event.current=null; var list=[]; for(var i in lib.character){ var info=lib.character[i]; @@ -62,6 +86,12 @@ mode.boss={ player.setIdentity(player.name); player.node.identity.dataset.color=info[5]; bosslistlinks[cfg]=player; + player.classList.add('bossplayer'); + + if(lib.storage.current==i){ + event.current=player; + player.classList.add('highlight'); + } if(!get.config(cfg)){ player.style.display='none'; @@ -71,52 +101,843 @@ mode.boss={ ui.create.div(bosslist); lib.translate.boss_pangtong='涅槃凤雏'; ui.create.arena(); - var time=(ui.window.offsetWidth-30)/200; - ui.window.appendChild(ui.control); + ui.create.cards(); + game.finishCards(); + ui.arena.dataset.number=8; ui.control.classList.add('bosslist'); ui.window.appendChild(bosslist); - var interval=setInterval(function(){ - if(list.length){ - list.shift().classList.add('bossshow'); + + setTimeout(function(){ + if(event.current){ + var left=event.current.offsetLeft-(ui.window.offsetWidth-180)/2; + if(bosslist.scrollLeft(无重整角色)'); + uiintro.add(ui.create.div('.placeholder.slim')) + } + else{ + uiintro.add(table); + } + + return uiintro; + },180); + + ui.arena.appendChild(boss); + ui.refresh(boss); + boss.classList.remove('highlight'); + boss.classList.remove('bossplayer'); + boss.style.left=''; + boss.style.top=''; + boss.style.position=''; + + event.bosslist.delete(); + + game.arrangePlayers(); + "step 3" + game.gameDraw(game.boss); + game.bossPhaseLoop(); } - } + }, + bossPhaseLoop:function(){ + var next=game.createEvent('phaseLoop'); + next.player=game.boss; + _status.looped=true; + next.content=function(){ + "step 0" + if(player.chongzheng){ + player.chongzheng=false; + } + else if(player.isDead()){ + if(player.hp<0) player.hp=0; + player.storage.boss_chongzheng++; + if(player.hp0?player.node.handcards1:player.node.handcards2; + card.fix(); + card.animate('start'); + position.insertBefore(card,position.firstChild); + player.$draw(); + game.log(get.translation(player)+'摸了一张牌'); + } + player.update(); + + if(player.storage.boss_chongzheng>=game.bossinfo.chongzheng){ + player.revive(); + } + if(game.bossinfo.loopType==2){ + game.boss.chongzheng=true; + } + } + else{ + player.phase(); + } + "step 1" + if(game.bossinfo.loopType==2){ + if(event.player==game.boss){ + if(!_status.last||_status.last.nextSeat==game.boss){ + event.player=game.boss.nextSeat; + } + else{ + event.player=_status.last.nextSeat; + } + } + else{ + _status.last=player; + event.player=game.boss; + } + } + else{ + event.player=event.player.nextSeat; + } + event.goto(0); + } + }, + onSwapControl:function(){ + if(game.me==game.boss) return; + var name=game.me.name; + if(ui.fakeme&&ui.fakeme.current!=name){ + ui.fakeme.current=name; + if(ui.versushighlight&&ui.versushighlight!=game.me){ + ui.versushighlight.node.avatar.classList.remove('glow2'); + } + ui.versushighlight=game.me; + game.me.node.avatar.classList.add('glow2'); + game.me.line(ui.fakeme,{opacity:0.5,dashed:true}); + + ui.fakemebg.style.backgroundImage=game.me.node.avatar.style.backgroundImage; + ui.fakemebg.style.backgroundSize='cover'; + } + }, + modeSwapPlayer:function(player){ + game.swapControl(player); + game.onSwapControl(); + }, + chooseCharacter:function(func){ + var next=game.createEvent('chooseCharacter',false); + next.showConfig=true; + next.customreplacetarget=func; + next.ai=function(player,list){ + if(get.config('double_character')){ + player.init(list[0],list[1]); + } + else{ + player.init(list[0]); + } + } + next.content=function(){ + "step 0" + var i; + var list=[]; + event.list=list; + for(i in lib.character){ + if(lib.character[i][4].contains('minskin')) continue; + if(lib.character[i][4].contains('boss')) continue; + if(lib.character[i][4].contains('hiddenboss')) continue; + if(lib.config.forbidai.contains(i)) continue; + if(lib.config.forbidall.contains(i)) continue; + if(lib.config.forbidboss.contains(i)) continue; + if(get.config('ban_weak')&&lib.config.forbidsingle.contains(i)) continue; + list.push(i); + } + list.randomSort(); + var dialog=ui.create.dialog('选择参战角色','hidden'); + ui.window.appendChild(dialog); + dialog.classList.add('bosscharacter'); + dialog.add('0/3'); + dialog.add([list.slice(0,20),'character']); + dialog.noopen=true; + + var next=game.me.chooseButton(dialog,true); + next._triggered=null; + next.custom.replace.target=event.customreplacetarget; + next.selectButton=[3,3]; + next.custom.add.button=function(){ + if(ui.cheat2&&ui.cheat2.backup) return; + _status.event.dialog.content.childNodes[1].innerHTML= + ui.selected.buttons.length+'/3'; + }; + event.changeDialog=function(){ + if(ui.cheat2&&ui.cheat2.dialog==_status.event.dialog){ + return; + } + list.randomSort(); + _status.event.dialog.close(); + _status.event.dialog=ui.create.dialog('选择参战角色','hidden'); + ui.window.appendChild(_status.event.dialog); + _status.event.dialog.classList.add('bosscharacter'); + _status.event.dialog.add('0/3'); + _status.event.dialog.add([list.slice(0,20),'character']); + game.uncheck(); + game.check(); + }; + event.asboss=ui.create.control('应战',function(){ + event.boss=true; + event.enemy=[]; + for(var i=0;i1; + }, + content:function(){ + "step 0" + event.players=get.players(player); + event.num=0; + "step 1" + if(event.players.length){ + event.players.shift().loseHp(); + event.redo(); + } + } + }, + wuxin:{ + inherit:'miles_xueyi', + group:'swd_wuxie' + }, + shenwei:{ + unique:true, + trigger:{player:'phaseDrawBegin'}, + forced:true, + content:function(){ + trigger.num+=Math.max(2,game.players.length-1); + }, + mod:{ + maxHandcard:function(player,current){ + return current+Math.max(2,game.players.length-1); + } + } + }, + shenji:{ + unique:true, + mod:{ + selectTarget:function(card,player,range){ + if(card.name=='sha'||card.name=='juedou') range[1]=3; + }, + } + }, + boss_baonu:{ + unique:true, + group:'boss_baonu2', + trigger:{player:'changeHp'}, + forced:true, + priority:100, + filter:function(event,player){ + return player.hp<=4 + }, + content:function(){ + player.init('boss_lvbu2'); + player.update(); + ui.clear(); + while(_status.event.name!='phaseLoop'){ + _status.event=_status.event.parent; + } + for(var i=0;i1) return [0,2]; + if(num&&Math.random()<0.7) return [0,1]; + } + } + } + } + } + }, + boss_baonu2:{ + trigger:{player:'gameDrawBegin'}, + forced:true, + popup:false, + content:function(){ + player.draw(4,false); + } + }, + _bossswap:{ + 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 player.isUnderControl(); + }, + content:function(){ + game.modeSwapPlayer(player); + }, + }, }, translate:{ + tinqin:'听琴', + boss_guihan:'归汉', + boss_guihan_info:'觉醒技,当所有敌人失去技能后,你摸两张牌并将体力回复至体力上限,然后令所有敌人将体力上限减至1', + boss_hujia:'胡笳', + boss_hujia_info:'回合结束阶段,若你已受伤,可以弃置一张牌令一名其他角色的所有技能失效,若其所有技能已失效,改为令其失去所有技能', + boss_honglian:'红莲', + boss_honglian_info:'锁定技,回合结束阶段,你摸两张牌,并对所有敌人造成一点火焰伤害', + huoshen:'火神', + huoshen_info:'锁定技,你防止即将受到的火焰伤害,改为回复1点体力', + boss_xianyin:'仙音', + boss_xianyin_info:'每当你于回合外失去牌,你可以进行一次判定,若为红色,你令一名敌人失去一点体力', + + boss_yuhuo:'浴火', + boss_yuhuo_info:'觉醒技,在你涅槃后,你获得技能【神威】、【朱羽】', + boss_tianyu:'天狱', + + boss_jizhi:'集智', + boss_jizhi_info:'每当你使用一张锦囊牌或装备牌,你可以摸一张牌并展示之', + boss_guiyin:'归隐', + boss_guiyin_info:'锁定技,体力值比你多的角色无法在回合内对你使用卡牌', + boss_gongshen:'工神', + boss_gongshen_info:'锁定技,除你之外的角色没有装备区,也不能重铸卡牌', + + fanghua:'芳华', + fanghua_info:'回合结束阶段,你可以令所有已翻面角色流失一点体力', + tashui:'踏水', + tashui_info:'每当你使用或打出一张黑色牌,你可以令一名其他角色翻面', + + wuxin:'无心', + wuxin_info:'锁定技,你防止即将受到的伤害,改为流失一点体力;你不能成为其他角色的延时锦囊的目标', + shangshix:'伤逝', + shangshix2:'伤逝', + shangshix_info:'锁定技,你的手牌数至少为4,回合结束阶段,若你的体力值大于1,你令场上所有角色流失一点体力', + + shenwei:'神威', + shenwei_info:'锁定技,摸牌阶段,你额外摸X张牌,你的手牌上限+X,X为敌方存活角色个数且至少为2', + shenji:'神戟', + shenji:'你使用的杀或决斗可指定至多3名角色为目标', + + zhu:'神', + cai:'盟', boss_shuijing:'水镜先生', boss_huangyueying:'奇智女杰', boss_zhangchunhua:'冷血皇后', @@ -136,5 +957,13 @@ mode.boss={ boss_luxun:'蹁跹君子', boss_zhenji:'洛水仙子', boss_diaochan:'绝代妖姬', - } + }, + ai:{ + get:{ + attitude:function(from,to){ + return 6*(from.side===to.side?1:-1); + } + } + }, + config:['ban_weak','change_choice','free_choose',''] } diff --git a/mode/chess.js b/mode/chess.js index d0d2bd16d..fe47957b9 100644 --- a/mode/chess.js +++ b/mode/chess.js @@ -780,6 +780,7 @@ mode.chess={ game.finishCards(); game.arrangePlayers(); "step 2" + ui.control.style.display=''; var p; for(var i=0;i