From c34bd7fb331a67ca3c576ed6f916d8f182b04d95 Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Wed, 13 Mar 2024 22:44:16 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9C=E9=87=8E=E7=BE=8E=E5=87=AA=EF=BD=9E?= =?UTF-8?q?=E4=B8=AD=E6=B4=A5=E9=9D=99=E6=B5=81=20cost=E5=88=86=E7=A6=BB?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- character/diy.js | 970 +++++++++++++--------------- noname/library/element/content.js | 10 +- noname/library/element/gameEvent.js | 4 +- noname/library/element/player.js | 25 +- 4 files changed, 486 insertions(+), 523 deletions(-) diff --git a/character/diy.js b/character/diy.js index 53dc12a36..754cec9ff 100755 --- a/character/diy.js +++ b/character/diy.js @@ -1486,8 +1486,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, content(){ 'step 0' - var target=result.targets[0]; - player.logSkill('minagi_huanliu',target); + var target=targets[0]; player.chooseCooperationFor(target,'minagi_huanliu').set('ai',function(button){ var base=0; switch(button.link){ @@ -1885,7 +1884,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player:['phaseUseAfter'], global:['roundStart'], }); - game.asyncDelayx(); + await game.asyncDelayx(); }, subSkill:{ round:{charlotte:true}, @@ -2706,7 +2705,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, nsxiaoye:{ trigger:{global:'phaseJieshuBegin'}, - direct:true, filter(event,player){ return player.hasHistory('useCard',function(evt){ return evt.card.name=='jiu'; @@ -2718,29 +2716,34 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }); }) }, - content(){ - 'step 0' - var list=[]; + async cost(event,trigger,player){ + const list=[]; trigger.player.getHistory('useCard',function(evt){ if(evt.card.name!='sha'&&get.type(evt.card)!='trick') return; if(evt.card.name=='sha'&&evt.card.nature) list.add('sha:'+evt.card.nature); else list.add(evt.card.name); }); - for(var i=0;i0))&& @@ -3024,22 +3023,21 @@ game.import('character',function(lib,game,ui,get,ai,_status){ intro:{ content:'已保护$', }, - content(){ - 'step 0' - var num=(player.countMark('erika_yousheng_ruka')+1); - player.chooseToDiscard('he',num,get.prompt('erika_yousheng',trigger.target),'弃置'+(num)+'张牌,并转移'+get.translation(trigger.card)).logSkill=['erika_yousheng',trigger.target]; - 'step 1' - if(result.bool){ - var ruka=trigger.target,evt=trigger.getParent(); - evt.targets.remove(ruka); - evt.triggeredTargets2.remove(ruka); - evt.targets.push(player); - evt.triggeredTargets2.push(player); - player.addTempSkill('erika_yousheng_ruka'); - var str='erika_yousheng_'+player.playerid; - if(!evt[str]) evt[str]=[]; - evt[str].add(ruka); - } + async cost(event, trigger, player){ + const num=(player.countMark('erika_yousheng_ruka')+1); + event.result = await player.chooseToDiscard('he',num,get.prompt('erika_yousheng',trigger.target),'弃置'+(num)+'张牌,并转移'+get.translation(trigger.card)).forResult(); + }, + async content(event, trigger, player){ + player.discard(event.cards); + var ruka=trigger.target,evt=trigger.getParent(); + evt.targets.remove(ruka); + evt.triggeredTargets2.remove(ruka); + evt.targets.push(player); + evt.triggeredTargets2.push(player); + player.addTempSkill('erika_yousheng_ruka'); + var str='erika_yousheng_'+player.playerid; + if(!evt[str]) evt[str]=[]; + evt[str].add(ruka); }, subSkill:{ achieve:{ @@ -3086,40 +3084,33 @@ game.import('character',function(lib,game,ui,get,ai,_status){ trigger:{global:'roundStart'}, skillAnimation:true, animationColor:'wood', - direct:true, - content(){ - 'step 0' - player.chooseTarget(get.prompt('erika_yousheng'),[1,2],lib.filter.notMe,'选择至多两名其他角色。你减2点体力上限并获得3点护甲。').set('ai',function(ruka){ + async cost(event, trigger, player){ + event.result = await player.chooseTarget(get.prompt('erika_yousheng'),[1,2],lib.filter.notMe,'选择至多两名其他角色。你减2点体力上限并获得3点护甲。').set('ai',function(ruka){ return -1; - }); - 'step 1' - if(result.bool){ - player.logSkill('erika_yousheng_mamori',result.targets); - player.awakenSkill('erika_yousheng_mamori'); - player.markAuto('erika_yousheng',result.targets); - player.loseMaxHp(2); - player.changeHujia(3); - } + }).forResult(); + }, + async content(event, trigger, player){ + player.awakenSkill('erika_yousheng_mamori'); + player.markAuto('erika_yousheng', event.targets); + await player.loseMaxHp(2); + await player.changeHujia(3); }, }, ruka:{ trigger:{global:'useCardAfter'}, - direct:true, charlotte:true, filter(event,player){ return event['erika_yousheng_'+player.playerid]&&event.cards.filterInD().length>0; }, - content(){ - 'step 0' - player.chooseTarget('是否令一名原目标角色获得'+get.translation(trigger.cards.filterInD())+'?',function(card,player,target){ + async cost(event, trigger, player){ + event.result = await player.chooseTarget('是否令一名原目标角色获得'+get.translation(trigger.cards.filterInD())+'?',function(card,player,target){ return _status.event.targets.includes(target); - }).set('targets',trigger['erika_yousheng_'+player.playerid]); - 'step 1' - if(result.bool){ - var ruka=result.targets[0]; - player.line(ruka,'green'); - ruka.gain(trigger.cards.filterInD(),'gain2'); - } + }).set('targets',trigger['erika_yousheng_'+player.playerid]).forResult(); + }, + async content(event, trigger, player){ + const ruka = event.targets[0]; + player.line(ruka,'green'); + ruka.gain(trigger.cards.filterInD(),'gain2'); }, }, }, @@ -3156,25 +3147,19 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, liyingxia_zhenjun:{ trigger:{player:'phaseJieshuBegin'}, - direct:true, filter(event,player){ return player.group=='key'; }, - content(){ - 'step 0' - var num=player.getHistory('useCard',function(evt){ + async cost(event, trigger, player){ + const num=player.getHistory('useCard',function(evt){ return evt.card.name=='sha'||(get.type(evt.card)=='trick'&&get.tag(evt.card,'damage')>0); }).length+1; - player.chooseTarget(get.prompt('liyingxia_zhenjun'),[1,num],'令至多'+get.cnNumber(num)+'名角色各摸一张牌').set('ai',(serafu)=>get.attitude(_status.event.player,serafu)); - 'step 1' - if(result.bool){ - var targets=result.targets.sortBySeat(); - player.logSkill('liyingxia_zhenjun',targets); - game.asyncDraw(targets); - for(var i of targets) i.addTempSkill('liyingxia_zhenjun_enhance',{player:player==i?'phaseJieshuBegin':'phaseAfter'}); - } - else event.finish(); - 'step 2' + event.result = await player.chooseTarget(get.prompt('liyingxia_zhenjun'),[1,num],'令至多'+get.cnNumber(num)+'名角色各摸一张牌').set('ai',(serafu)=>get.attitude(_status.event.player,serafu)).forResult(); + }, + content(){ + targets.sortBySeat(); + game.asyncDraw(targets); + for(var i of targets) i.addTempSkill('liyingxia_zhenjun_enhance',{player:player==i?'phaseJieshuBegin':'phaseAfter'}); game.delayx(); }, subSkill:{ @@ -3194,34 +3179,46 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, liyingxia_wumai:{ trigger:{global:'roundStart'}, - direct:true, filter(event,player){ return player.group=='shu'&&(player.getStorage('liyingxia_wumai').length<4||game.hasPlayer((current)=>current.isDamaged())); }, - content(){ - 'step 0' + async cost(event, trigger, player){ var list=lib.skill.liyingxia_wumai.derivation.slice(0); list.removeArray(player.getStorage('liyingxia_wumai')); if(list.length){ - player.chooseControl(list,'cancel2').set('prompt',get.prompt('liyingxia_wumai')).set('prompt2','获得一个技能直到本轮结束'); + const {result} = await player.chooseControl(list,'cancel2').set('prompt',get.prompt('liyingxia_wumai')).set('prompt2','获得一个技能直到本轮结束'); + if (result.control !== 'cancel2') { + event.result = { + bool: true, + cost_data: { + type: 'addSkill', + skill: result.control, + }, + } + } } else{ - event.num=Math.min(3,game.countPlayer((current)=>current.isDamaged())); - player.chooseBool(get.prompt('liyingxia_wumai')+'(可摸'+get.cnNumber(event.num)+'张牌)') - event.goto(2); + const num=Math.min(3,game.countPlayer((current)=>current.isDamaged())); + const {result} = await player.chooseBool(get.prompt('liyingxia_wumai')+'(可摸'+get.cnNumber(num)+'张牌)'); + if (result.bool) { + event.result = { + bool: true, + cost_data: { + type: 'drawCards', + num, + }, + } + } } - 'step 1' - if(result.control!='cancel2'){ - player.logSkill('liyingxia_wumai'); - player.markAuto('liyingxia_wumai',[result.control]); - player.addTempSkill(result.control,'roundStart'); - game.log(player,'获得了技能','#g【'+get.translation(result.control)+'】') + }, + async content(event, trigger, player){ + const result = event.cost_data; + if(result.type === 'addSkill'){ + player.markAuto('liyingxia_wumai',[result.skill]); + player.addTempSkills(result.skill, 'roundStart'); } - event.finish(); - 'step 2' - if(result.bool){ - player.logSkill('liyingxia_wumai'); - player.draw(num); + else if(result.type === 'drawCards'){ + player.draw(result.num); } }, derivation:['bazhen','rejizhi','reguanxing','youlong'], @@ -3231,40 +3228,45 @@ game.import('character',function(lib,game,ui,get,ai,_status){ filter(event,player){ return player.getHistory('useCard').length>0; }, - direct:true, frequent:true, - content(){ - 'step 0' + async cost(event,trigger,player){ var history=player.getHistory('useCard'); if(history.length>1){ var type=get.type2(history[0].card,false); for(var i=1;i0; }); }, - content(){ - 'step 0' - event.num=player.getHistory('custom',function(evt){ + async cost(event, trigger, player){ + const num = player.getHistory('custom',function(evt){ return evt.kyouko_gongmian==true; }).length; - player.chooseTarget(get.prompt('kyouko_gongmian'),'获得一名其他角色的至多'+get.cnNumber(event.num)+'张牌,然后交给其等量的牌',function(card,player,target){ + event.result = await player.chooseTarget(get.prompt('kyouko_gongmian'),'获得一名其他角色的至多'+get.cnNumber(num)+'张牌,然后交给其等量的牌',function(card,player,target){ return target!=player&&target.countGainableCards(player,'hej')>0; }).set('ai',function(target){ var player=_status.event.player,att=get.attitude(player,target); @@ -4043,31 +4040,27 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return get.value(card,player); })); return 0; - }); - 'step 1' - if(result.bool){ - var target=result.targets[0]; - event.target=target; - player.logSkill('kyouko_gongmian',target); - player.gainPlayerCard(target,'hej',true,[1,num]); - } - else event.finish(); - 'step 2' + }).forResult(); + }, + async content(event, trigger, player){ + const num = player.getHistory('custom',function(evt){ + return evt.kyouko_gongmian==true; + }).length, target = event.targets[0]; + let result = await player.gainPlayerCard(target,'hej',true,[1,num]).forResult(); if(target.isIn()&&result.bool&&result.cards&&result.cards.length&&player.countCards('he')>0){ - var num=result.cards.length,hs=player.getCards('he'); - if(hs.length<=num) event._result={bool:true,cards:hs}; - else player.chooseCard('he',true,num,'交给'+get.translation(target)+get.cnNumber(num)+'张牌'); - } - else event.finish(); - 'step 3' - if(result.bool&&result.cards&&result.cards.length){ - player.give(result.cards,target); + const num = result.cards.length, hs = player.getCards('he'); + if(hs.length<=num) result = {bool:true,cards:hs}; + else{ + result = await player.chooseCard('he',true,num,'交给'+get.translation(target)+get.cnNumber(num)+'张牌').forResult(); + } + if(result.bool&&result.cards&&result.cards.length){ + player.give(result.cards,target); + } } }, }, kyouko_gongmian_discard:{ trigger:{player:'phaseDiscardBegin'}, - direct:true, filter(event,player){ var hs=player.countCards('h'); return hs>0&&player.getHistory('custom',function(evt){ @@ -4076,28 +4069,25 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return current!=player&¤t.countCards('h')0) player.gain(hs,target,'giveAuto','bySelf'); 'step 1' - if(result.bool){ - var target=result.targets[0]; - event.target=target; - player.logSkill('kyouko_gongmian',target); - var hs=target.getCards('h'); - if(hs.length>0) player.gain(hs,target,'giveAuto','bySelf'); - } - else event.finish(); - 'step 2' if(target.isIn()&&player.countCards('h')>0){ var hs=player.getCards('h'),num=Math.ceil(hs.length/2); if(hs.length<=num) event._result={bool:true,cards:hs}; else player.chooseCard('he',true,num,'交给'+get.translation(target)+get.cnNumber(num)+'张牌'); } else event.finish(); - 'step 3' + 'step 2' if(result.bool&&result.cards&&result.cards.length){ player.give(result.cards,target); } @@ -4281,6 +4271,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ filter(event,player){ return player.hasUseTarget('wanjian'); }, + //chooseUseTarget也不好改 先放着 direct:true, content(){ player.addTempSkill('kotomi_qinji2'); @@ -4652,8 +4643,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){ trigger:{player:'judge'}, skillAnimation:true, animationColor:'key', - direct:true, - content(){ + logTarget:'player', + cost(){ 'step 0' var str='你的'+(trigger.judgestr||'')+'判定为'+ get.translation(trigger.player.judging[0])+',是否发动【终愿】修改判定结果?'; @@ -4775,18 +4766,24 @@ game.import('character',function(lib,game,ui,get,ai,_status){ 'step 1' var map=event.result||result; if(map.bool){ - player.awakenSkill('misuzu_zhongyuan'); - player.logSkill('misuzu_zhongyuan',player); - game.log(player,'将判定结果修改为了','#g'+get.translation(result.suit+2)+get.strNumber(result.number)); - trigger.fixedResult={ - suit:result.suit, - color:get.color({suit:result.suit}), - number:result.number, - }; - player.popup(get.translation(result.suit+2)+get.strNumber(result.number),'thunder'); - event.getParent('arrangeTrigger').finish(); + event.result = { + bool: true, + cost_data: map, + } } }, + async content(event, trigger, player){ + var map = event.cost_data; + player.awakenSkill('misuzu_zhongyuan'); + game.log(player,'将判定结果修改为了','#g'+get.translation(map.suit+2)+get.strNumber(map.number)); + trigger.fixedResult={ + suit:map.suit, + color:get.color({suit:map.suit}), + number:map.number, + }; + player.popup(get.translation(map.suit+2)+get.strNumber(map.number),'thunder'); + event.getParent('arrangeTrigger').finish(); + }, }, chihaya_liewu:{ derivation:'chihaya_huairou', @@ -4799,7 +4796,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, }, trigger:{player:'useCard2'}, - direct:true, filter(event,player){ var card=event.card; var info=get.info(card); @@ -4813,30 +4809,21 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } return false; }, - content(){ - 'step 0' + async cost(event, trigger, player){ var prompt2='为'+get.translation(trigger.card)+'增加一个目标'; - player.chooseTarget(get.prompt('chihaya_liewu'),function(card,player,target){ + event.result = await player.chooseTarget(get.prompt('chihaya_liewu'),function(card,player,target){ var player=_status.event.player; return !_status.event.targets.includes(target)&&lib.filter.targetEnabled2(_status.event.card,player,target); }).set('prompt2',prompt2).set('ai',function(target){ var trigger=_status.event.getTrigger(); var player=_status.event.player; return get.effect(target,trigger.card,player,player); - }).set('card',trigger.card).set('targets',trigger.targets); - 'step 1' - if(result.bool){ - if(!event.isMine()) game.delayx(); - event.targets=result.targets; - } - else{ - event.finish(); - } - 'step 2' - if(event.targets){ - player.logSkill('chihaya_liewu',event.targets); - trigger.targets.addArray(event.targets); - } + }).set('card',trigger.card).set('targets',trigger.targets).forResult(); + }, + autodelay:true, + async content(event, trigger, player){ + trigger.targets.addArray(event.targets); + game.log(event.targets, '也成为了', trigger.card, '的目标'); }, group:'chihaya_liewu2', }, @@ -5062,7 +5049,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, }, trigger:{player:'useCard2'}, - direct:true, filter(event,player){ var card=event.card; var info=get.info(card); @@ -5076,10 +5062,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } return false; }, - content(){ - 'step 0' + autodelay:true, + async cost(event, trigger, player){ var prompt2='为'+get.translation(trigger.card)+'增加一个目标'; - player.chooseTarget(get.prompt('rumi_shuwu'),function(card,player,target){ + const {result} = await player.chooseTarget(get.prompt('rumi_shuwu'),function(card,player,target){ var player=_status.event.player; return !_status.event.targets.includes(target)&&lib.filter.targetEnabled2(_status.event.card,player,target); }).set('prompt2',prompt2).set('ai',function(target){ @@ -5087,19 +5073,11 @@ game.import('character',function(lib,game,ui,get,ai,_status){ var player=_status.event.player; return get.effect(target,trigger.card,player,player); }).set('card',trigger.card).set('targets',trigger.targets); - 'step 1' - if(result.bool){ - if(!event.isMine()) game.delayx(); - event.targets=result.targets; - } - else{ - event.finish(); - } - 'step 2' - if(event.targets){ - player.logSkill('rumi_shuwu',event.targets); - trigger.targets.addArray(event.targets); - } + event.result = result; + }, + content(){ + trigger.targets.addArray(event.targets); + game.log(event.targets, '也成为了', trigger.card, '的目标'); }, group:'rumi_shuwu2', }, @@ -5148,7 +5126,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, }, trigger:{player:'useCard2'}, - direct:true, filter(event,player){ if(player.countDisabledSlot()>=4) return true; return lib.skill.sakuya_junbu.filter2.apply(this,arguments); @@ -5167,17 +5144,17 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } return false; }, - content(){ - 'step 0' + async cost(event, trigger, player){ + const result = {bool:false}; + event.result = result; if(player.countDisabledSlot()>=4){ - trigger.directHit.addArray(game.players); + result.bool = true; if(!lib.skill.sakuya_junbu.filter2(trigger,player)){ - event.finish(); return; } } var prompt2='为'+get.translation(trigger.card)+'增加一个目标'; - player.chooseTarget(get.prompt('sakuya_junbu'),function(card,player,target){ + const {result:result2} = await player.chooseTarget(get.prompt('sakuya_junbu'),function(card,player,target){ var player=_status.event.player; return !_status.event.targets.includes(target)&&lib.filter.targetEnabled2(_status.event.card,player,target); }).set('prompt2',prompt2).set('ai',function(target){ @@ -5185,18 +5162,19 @@ game.import('character',function(lib,game,ui,get,ai,_status){ var player=_status.event.player; return get.effect(target,trigger.card,player,player); }).set('card',trigger.card).set('targets',trigger.targets); - 'step 1' - if(result.bool){ - if(!event.isMine()) game.delayx(); - event.targets=result.targets; + if(result2.bool){ + result.bool = true; + result.targets = result2.targets; } - else{ - event.finish(); + }, + async content(event, trigger, player){ + if(player.countDisabledSlot()>=4){ + trigger.directHit.addArray(game.players); + game.log(trigger.card, '不可被响应'); } - 'step 2' - if(event.targets){ - player.logSkill('sakuya_junbu',event.targets); + if(event.targets && event.targets.length>0){ trigger.targets.addArray(event.targets); + game.log(event.targets, '也成为了', trigger.card, '的目标'); } }, group:'sakuya_junbu_damage', @@ -5218,30 +5196,26 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, hiroto_huyu:{ trigger:{global:'phaseUseEnd'}, - direct:true, noHidden:true, filter(event,player){ return player!=event.player&&player.hasSkill('hiroto_huyu')&&!player.hasSkill('hiroto_zonglve')&&event.player.countCards('h')>0; }, - content(){ - 'step 0' - trigger.player.chooseCard(2,'h','是否对'+get.translation(player)+'发动【虎驭】?','将两张手牌交给该角色,然后令其获得〖纵略〗并于下回合获得该角色得到的所有牌').set('goon',function(){ + async cost(event, trigger, player){ + event.result = await trigger.player.chooseCard(2,'h','是否对'+get.translation(player)+'发动【虎驭】?','将两张手牌交给该角色,然后令其获得〖纵略〗并于下回合获得该角色得到的所有牌').set('goon',function(){ var source=trigger.player; if(get.attitude(source,player)>0) return 7; if(source.hp>2) return 4; return 0; }()).set('ai',function(card){ return _status.event.goon-get.value(card); - }); - 'step 1' - if(result.bool){ - var target=trigger.player; - player.logSkill('hiroto_huyu',target); - target.give(result.cards,player); - player.storage.hiroto_huyu2=target; - player.addSkills('hiroto_zonglve'); - player.addSkill('hiroto_huyu2'); - } + }).forResult(); + }, + content(){ + var target=trigger.player; + target.give(cards,player); + player.storage.hiroto_huyu2=target; + player.addSkills('hiroto_zonglve'); + player.addSkill('hiroto_huyu2'); }, derivation:'hiroto_zonglve', }, @@ -5498,30 +5472,26 @@ game.import('character',function(lib,game,ui,get,ai,_status){ forceDie:true, skillAnimation:true, animationColor:'thunder', - direct:true, - content(){ - 'step 0' - player.chooseTarget(get.prompt2('shizuku_sanhua'),lib.filter.notMe).set('ai',function(target){ + async cost(event, trigger, player){ + event.result = await player.chooseTarget(get.prompt2('shizuku_sanhua'),lib.filter.notMe).set('ai',function(target){ return get.attitude(_status.event.player,target); - }); - 'step 1' - if(result.bool){ - var target=result.targets[0]; - player.logSkill('shizuku_sanhua',target); - var names=[]; - var cards=[]; - while(cards.length<4){ - var card=get.cardPile2(function(card){ - return !cards.includes(card)&&!names.includes(card.name)&&get.type(card)=='basic'; - }); - if(card){ - cards.push(card); - names.push(card.name); - } - else break; + }).forResult(); + }, + async content(event, trigger, player){ + var target = event.targets[0]; + var names = []; + var cards = []; + while (cards.length < 4) { + var card=get.cardPile2(function(card){ + return !cards.includes(card)&&!names.includes(card.name)&&get.type(card)=='basic'; + }); + if(card){ + cards.push(card); + names.push(card.name); } - if(cards.length) target.gain(cards,'gain2'); + else break; } + if(cards.length) await target.gain(cards,'gain2'); }, }, shiroha_yuzhao:{ @@ -5607,7 +5577,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player:'damageBegin3', source:'damageBegin1', }, - direct:true, filter(event,player,name){ if(!player.storage.shiroha_jiezhao&&player.hasSkill('shiroha_guying_temp')) return false; if(name=='damageBegin3') return true; @@ -5617,40 +5586,40 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(!player||!player.storage.shiroha_jiezhao) return true; return false; }, - content(){ + cost(){ 'step 0' var num=event.triggername=='damageBegin3'?-1:1; - event.num=num; if(player.storage.shiroha_jiezhao||!player.hasSkill('shiroha_guying')){ if(num>0) player.chooseBool(get.prompt('shiroha_guying',trigger.player),'进行判定。若判定结果为黑色,则即将对其造成的伤害+1'); else player.chooseBool(get.prompt('shiroha_guying'),'进行判定。若判定结果为红色,则即将受到的伤害-1'); } else event._result={bool:true}; 'step 1' - if(result.bool){ - player.addTempSkill('shiroha_guying_temp'); - player.judge(function(card){ - return (get.color(card)==(_status.event.getParent('shiroha_guying').num>0?'black':'red'))?2:0; - }).judge2=function(result){ - return result.bool?true:false; - }; - } - else event.finish(); - 'step 2' + event.result = result; + }, + content(){ + 'step 0' + var num=event.triggername=='damageBegin3'?-1:1; + event.num=num; + player.addTempSkill('shiroha_guying_temp'); + player.judge(function(card){ + return (get.color(card)==(_status.event.getParent('shiroha_guying').num>0?'black':'red'))?2:0; + }).judge2=function(result){ + return result.bool?true:false; + }; + 'step 1' if(result.bool) trigger.num+=num; }, }, shiroha_guying_temp:{charlotte:true}, shiroha_jiezhao:{ trigger:{global:'judge'}, - direct:true, filter(event,player){ return player.getExpansions('shiroha_yuzhao').length&&event.player.isIn(); }, - content(){ - "step 0" - var list=player.getExpansions('shiroha_yuzhao'); - player.chooseButton([get.translation(trigger.player)+'的'+(trigger.judgestr||'')+'判定为'+get.translation(trigger.player.judging[0])+ + async cost(event, trigger, player){ + const list = player.getExpansions('shiroha_yuzhao'); + const {result} = await player.chooseButton([get.translation(trigger.player)+'的'+(trigger.judgestr||'')+'判定为'+get.translation(trigger.player.judging[0])+ ','+get.prompt('shiroha_jiezhao'),list,'hidden'],function(button){ var card=button.link; var trigger=_status.event.getTrigger(); @@ -5668,41 +5637,38 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(mod!='unchanged') return mod; return true; }); - "step 1" if(result.bool){ - event.forceDie=true; - player.respond(result.links,'shiroha_jiezhao','highlight','noOrdering'); - result.cards=result.links; + event.result = {bool:true, cards:result.links}; } - else{ - event.finish(); + }, + //logSkill留给respond + popup:false, + async content(event, trigger, player){ + const cards = event.cards; + await player.respond(cards, 'shiroha_jiezhao','highlight','noOrdering'); + if(trigger.player.judging[0].clone){ + trigger.player.judging[0].clone.classList.remove('thrownhighlight'); + game.broadcast(function(card){ + if(card.clone){ + card.clone.classList.remove('thrownhighlight'); + } + },trigger.player.judging[0]); + game.addVideo('deletenode',player,get.cardsInfo([trigger.player.judging[0].clone])); } - "step 2" - if(result.bool){ - if(trigger.player.judging[0].clone){ - trigger.player.judging[0].clone.classList.remove('thrownhighlight'); - game.broadcast(function(card){ - if(card.clone){ - card.clone.classList.remove('thrownhighlight'); - } - },trigger.player.judging[0]); - game.addVideo('deletenode',player,get.cardsInfo([trigger.player.judging[0].clone])); - } - game.cardsDiscard(trigger.player.judging[0]); - trigger.player.judging[0]=result.cards[0]; - trigger.orderingCards.addArray(result.cards); - game.log(trigger.player,'的判定牌改为',result.cards[0]); - game.delay(2); - } - "step 3" + const oldJudgeCard = trigger.player.judging[0]; + trigger.player.judging[0] = cards[0]; + trigger.orderingCards.addArray(cards); + game.log(trigger.player,'的判定牌改为',cards[0]); + await game.cardsDiscard(oldJudgeCard); + await game.asyncDelay(2); if(!player.getExpansions('shiroha_yuzhao').length){ player.storage.shiroha_jiezhao=true; player.gainMaxHp(); player.recover(); var list=['umi_chaofan','ao_xishi','tsumugi_mugyu','kamome_jieban']; var skill=list.randomGet(); - player.addSkills(skill); player.flashAvatar('shiroha_jiezhao','key_'+skill.split('_')[0]); + await player.addSkills(skill); } }, ai:{ @@ -5719,36 +5685,30 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, jojiro_shensu1:{ trigger:{player:'phaseJudgeBefore'}, - direct:true, - content(){ - "step 0" - var check= player.countCards('h')>2; - player.chooseTarget(get.prompt("jojiro_shensu"),"跳过判定阶段和摸牌阶段,视为对一名其他角色使用一张【杀】",function(card,player,target){ + async cost(event,trigger,player){ + const check = player.countCards('h')>2; + event.result = await player.chooseTarget(get.prompt("jojiro_shensu"),"跳过判定阶段和摸牌阶段,视为对一名其他角色使用一张【杀】",function(card,player,target){ if(player==target) return false; return player.canUse({name:'sha'},target,false); }).set('check',check).set('ai',function(target){ if(!_status.event.check) return 0; return get.effect(target,{name:'sha'},_status.event.player); - }); - "step 1" - if(result.bool){ - player.logSkill('jojiro_shensu',result.targets); - player.useCard({name:'sha',isCard:true},result.targets[0],false); - trigger.cancel(); - player.skip('phaseDraw'); - } + }).forResult(); + }, + async content(event,trigger,player){ + await trigger.cancel(); + player.skip('phaseDraw'); + await player.useCard({name:'sha',isCard:true},event.targets[0],false); } }, jojiro_shensu2:{ trigger:{player:'phaseUseBefore'}, - direct:true, filter(event,player){ return player.countCards('he',{type:'equip'})>0; }, - content(){ - "step 0" - var check=player.needsToDiscard(); - player.chooseCardTarget({ + async cost(event,trigger,player){ + const check = player.needsToDiscard(); + event.result = await player.chooseCardTarget({ prompt:get.prompt('jojiro_shensu'), prompt2:"弃置一张装备牌并跳过出牌阶段,视为对一名其他角色使用一张【杀】", filterCard(card,player){ @@ -5768,36 +5728,30 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return get.effect(target,{name:'sha'},_status.event.player); }, check:check - }); - "step 1" - if(result.bool){ - player.logSkill('jojiro_shensu',result.targets); - player.discard(result.cards[0]); - player.useCard({name:'sha',isCard:true},result.targets[0]); - trigger.cancel(); - } + }).forResult(); + }, + async content(event,trigger,player){ + await trigger.cancel(); + await player.discard(event.cards[0]); + await player.useCard({name:'sha',isCard:true}, event.targets[0]); } }, jojiro_shensu4:{ trigger:{player:'phaseDiscardBefore'}, - direct:true, - content(){ - "step 0" + async cost(event, trigger, player){ var check=player.needsToDiscard()||player.isTurnedOver()||(player.hasSkill('shebian')&&player.canMoveCard(true,true)); - player.chooseTarget(get.prompt('jojiro_shensu'),"跳过弃牌阶段并将武将牌翻面,视为对一名其他角色使用一张【杀】",function(card,player,target){ + event.result = await player.chooseTarget(get.prompt('jojiro_shensu'),"跳过弃牌阶段并将武将牌翻面,视为对一名其他角色使用一张【杀】",function(card,player,target){ if(player==target) return false; return player.canUse({name:'sha'},target,false); }).set('check',check).set('ai',function(target){ if(!_status.event.check) return 0; return get.effect(target,{name:'sha'},_status.event.player,_status.event.player); - }); - "step 1" - if(result.bool){ - player.logSkill('jojiro_shensu',result.targets); - player.turnOver(); - player.useCard({name:'sha',isCard:true},result.targets[0],false); - trigger.cancel(); - } + }).forResult(); + }, + async content(event, trigger, player){ + await trigger.cancel(); + await player.turnOver(); + await player.useCard({name:'sha',isCard:true}, event.targets[0], false); } }, jojiro_shunying:{ @@ -5856,7 +5810,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, kotori_yumo_gain:{ trigger:{player:'phaseBegin'}, - direct:true, filter(event,player){ var list=['wei','shu','wu','qun','key','jin']; for(var i in list){ @@ -5864,15 +5817,14 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } return false; }, - content(){ - 'step 0' - var list=['wei','shu','wu','qun','key','jin']; - var list2=[]; - for(var i of list){ + async cost(event, trigger, player){ + const list=['wei','shu','wu','qun','key','jin']; + const list2=[]; + for(const i of list){ if(player.hasMark('kotori_yumo_'+i)) list2.push('kotori_skill_'+i); } list2.push('cancel2'); - player.chooseControl(list2).set('prompt','###是否发动【驭魔】?###弃置对应的标记并获得下列技能中的一个,或点取消,不获得技能').set('choice',function(){ + const {control} = await player.chooseControl(list2).set('prompt','###是否发动【驭魔】?###弃置对应的标记并获得下列技能中的一个,或点取消,不获得技能').set('choice',function(){ if(list2.includes('kotori_skill_shu')&&player.countCards('h',function(card){ return get.name(card,player)=='sha'&&player.getUseValue(card)>0; })>1) return 'kotori_skill_shu'; @@ -5881,27 +5833,30 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return 'cancel2'; }()).set('ai',function(){ return _status.event.choice; - }); - 'step 1' + }).forResult(); + event.result = { + bool: control !== 'cancel2', + cost_data: {control}, + } + }, + content(){ + const result = event.cost_data; if(result.control!='cancel2'){ - player.logSkill('kotori_yumo'); var name='kotori_yumo_'+result.control.slice(13); player.removeMark(name,1,false);game.log(player,'移去了一个',lib.translate[name].replace(/魔物/g,'【魔物】')); - player.addTempSkill(result.control); + player.addTempSkills(result.control); game.log(player,'获得了技能',lib.translate[name].replace(/魔物/g,'【'+get.translation(result.control)+'】')); } }, }, kotori_skill_wei:{ trigger:{player:'phaseBegin'}, - direct:true, filter(event,player){ return player.countCards('he')>0; }, - content(){ - 'step 0' - player.chooseCardTarget({ - prompt:get.prompt2(event.name), + async cost(event, trigger, player){ + event.result = await player.chooseCardTarget({ + prompt:get.prompt2(event.skill), filterCard:lib.filter.cardDiscardable, filterTarget(card,player,target){ return player!=target; @@ -5913,15 +5868,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){ ai2(target){ return 1/(1+target.countCards('he'))*-get.attitude(_status.event.player,target); }, - }); + }).forResult(); + }, + content(){ + 'step 0' + player.discard(cards); + targets[0].chooseToDiscard('弃置一张牌,或令'+get.translation(player)+'摸一张牌','he').ai=lib.skill.zhiheng.check; 'step 1' - if(result.bool){ - player.logSkill(event.name,result.targets); - player.discard(result.cards); - result.targets[0].chooseToDiscard('弃置一张牌,或令'+get.translation(player)+'摸一张牌','he').ai=lib.skill.zhiheng.check; - } - else event.finish(); - 'step 2' if(!result.bool) player.draw(); }, }, @@ -6495,7 +6448,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, shiori_huijuan:{ trigger:{global:'phaseJieshuBegin'}, - direct:true, locked:true, filter(event,player){ return event.player!=player&&event.player.getHistory('useCard',function(evt){ @@ -6506,9 +6458,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }); }).length>0; }, - content(){ - 'step 0' - var list=[]; + async cost(event, trigger, player){ + const list=[]; trigger.player.getHistory('useCard',function(evt){ if(!evt.isPhaseUsing()||!['basic','trick'].includes(get.type(evt.card))) return; if(evt.card.name=='sha'&&evt.card.nature) list.add('sha:'+evt.card.nature); @@ -6518,18 +6469,24 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(list[i].indexOf('sha:')==0) list[i]=['基本','','sha',list[i].slice(4)]; else list[i]=[get.type(list[i]),'',list[i]]; } - player.chooseButton([get.prompt('shiori_huijuan'),[list,'vcard']]).set('filterButton',function(button){ + const {result} = await player.chooseButton([get.prompt('shiori_huijuan'),[list,'vcard']]).set('filterButton',function(button){ return player.hasUseTarget({name:button.link[2],nature:button.link[3],isCard:true}); }).set('ai',function(button){ return player.getUseValue({name:button.link[2],nature:button.link[3],isCard:true}); }); - 'step 1' if(result.bool){ - player.logSkill('shiori_huijuan'); - player.chooseUseTarget(true,{name:result.links[0][2],nature:result.links[0][3],isCard:true}); - player.getStat('skill').shiori_huijuan=1; + event.result = { + bool: true, + cost_data: { + card: {name:result.links[0][2],nature:result.links[0][3],isCard:true} + }, + } } }, + async content(event, trigger, player){ + player.chooseUseTarget(true, event.cost_data.card); + player.getStat('skill').shiori_huijuan=1; + }, group:'shiori_huijuan_discard', }, shiori_huijuan_discard:{ @@ -6584,19 +6541,22 @@ game.import('character',function(lib,game,ui,get,ai,_status){ filter(event,player){ return !event.player.countCards('e')&&player.inRange(event.player); }, - direct:true, locked:true, - content(){ - 'step 0' - if(!player.canUse('sha',trigger.player,false)) event._result={index:0}; - else player.chooseControl().set('prompt','制裸:请选择一项').set('choiceList',[ - '摸一张牌', - '视为对'+get.translation(trigger.player)+'使用一张【杀】', - ]).set('ai',function(){ - if(get.effect(_status.event.getTrigger().player,{name:'sha'},_status.event.player)>0) return 1; - return 0; - }); - 'step 1' + async cost(event, trigger, player){ + event.result = {bool: true, cost_data: {index:0}}; + if (player.canUse('sha', trigger.player, false)){ + const {index} = await player.chooseControl().set('prompt','制裸:请选择一项').set('choiceList',[ + '摸一张牌', + '视为对'+get.translation(trigger.player)+'使用一张【杀】', + ]).set('ai',function(){ + if(get.effect(_status.event.getTrigger().player,{name:'sha'},_status.event.player)>0) return 1; + return 0; + }).forResult(); + event.result.cost_data.index = index; + } + }, + async content(event, trigger, player){ + const result = event.cost_data; if(result.index==0){ player.logSkill('miki_zhiluo'); player.draw(); @@ -6608,7 +6568,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ trigger:{ source:'damageSource', }, - direct:true, locked:true, popup:'海德洛', filter(event,player){ @@ -6616,7 +6575,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return (current==event.player||current!=player&&get.distance(current,event.player)<=1)&¤t.countDiscardableCards(player,'he')>0; }); }, - content(){ + cost(){ 'step 0' var list=[]; var choiceList=[]; @@ -6645,17 +6604,29 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } 'step 1' if(event.list[result.index]){ - player.logSkill(['miki_hydrogladiator_skill','海德洛'],trigger.player); - player.discardPlayerCard(trigger.player,'he',2,true); - event.finish(); + event.result = { + bool: true, + cost_data:{type: 'single'}, + targets: [trigger.player], + } } else{ - event.targets=game.filterPlayer(function(current){ - return current!=player&&get.distance(current,trigger.player)<=1; - }).sortBySeat(); - player.logSkill(['miki_hydrogladiator_skill','海德洛'],event.targets); + event.result = { + bool: true, + cost_data:{type: 'multiple'}, + targets: game.filterPlayer(function(current){ + return current!=player&&get.distance(current,trigger.player)<=1; + }).sortBySeat(), + } } - 'step 2' + }, + content(){ + 'step 0' + if(event.cost_data.type == 'single'){ + player.discardPlayerCard(targets[0],'he',2,true); + event.finish(); + } + 'step 1' var target=targets.shift(); if(target.countDiscardableCards(player,'he')>0) player.discardPlayerCard(target,'he',true); if(targets.length) event.redo(); @@ -6803,11 +6774,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, kud_qiaoshou_end:{ trigger:{player:'phaseJieshuBegin'}, - direct:true, filter(event,player){ return player.countCards('h')>0&&!player.getExpansions('kud_qiaoshou_equip').length; }, - content(){ + cost(){ 'step 0' var list=[]; var list2=['rewrite_bagua','rewrite_renwang','rewrite_tengjia','rewrite_baiyin']; @@ -6837,24 +6807,32 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }); 'step 1' if(result.bool){ - player.logSkill('kud_qiaoshou'); event.cardname=result.links[0][2]; player.chooseCard('h',true,'将一张手牌置于武将牌上,然后视为装备'+get.translation(event.cardname)); } else event.finish(); 'step 2' - var cards=result.cards; - player.addToExpansion(cards,player,'give').gaintag.add('kud_qiaoshou_equip'); - 'step 3' + if(result.bool){ + event.result = { + bool:true, + cards: result.cards, + cost_data:{ + cardname: event.cardname, + }, + } + } + }, + async content(event, trigger, player){ + await player.addToExpansion(event.cards,player,'give').gaintag.add('kud_qiaoshou_equip'); if(!player.getExpansions('kud_qiaoshou_equip').length) return; player.addTempSkill('kud_qiaoshou_equip',{player:['phaseUseEnd','phaseZhunbeiBegin']}); - var name=event.cardname; + var name=event.cost_data.cardname; player.storage.kud_qiaoshou_equip2=name; player.markAuto('kud_qiaoshou_equip',cards); var info=lib.card[name].skills; if(info&&info.length) player.addAdditionalSkill('kud_qiaoshou_equip',info); - player.draw(); game.log(player,'声明了','#y'+get.translation(name)); + await player.draw(); }, }, kud_buhui:{ @@ -6965,23 +6943,20 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player:'loseAfter', global:['equipAfter','addJudgeAfter','gainAfter','loseAsyncAfter','addToExpansionAfter'], }, - direct:true, filter(event,player){ var evt=event.getl(player); return evt&&evt.js&&evt.js.length>0&&!player.hasSkill('misuzu_zhongxing_haruko'); }, - content(){ - 'step 0' - player.chooseTarget(get.prompt('misuzu_zhongxing'),'令一名角色选择摸两张牌或回复1点体力').set('ai',function(card){ + async cost(event, trigger, player){ + event.result = await player.chooseTarget(get.prompt('misuzu_zhongxing'),'令一名角色选择摸两张牌或回复1点体力').set('ai',function(card){ return get.attitude(_status.event.player,card); - }); - 'step 1' - if(result.bool){ - var target=result.targets[0]; - player.logSkill('misuzu_zhongxing',target); - player.addTempSkill('misuzu_zhongxing_haruko'); - target.chooseDrawRecover(2,true); - } + }).forResult(); + }, + async content(event, trigger, player){ + var target=event.targets[0]; + player.logSkill('misuzu_zhongxing',target); + player.addTempSkill('misuzu_zhongxing_haruko'); + target.chooseDrawRecover(2,true); }, }, misuzu_zhongxing_haruko:{charlotte:true}, @@ -7089,7 +7064,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player:'damageEnd', source:'damageSource', }, - direct:true, zhuanhuanji:true, marktext:'☯', mark:true, @@ -7102,10 +7076,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){ var num=player.storage.kamome_jieban?1:2; return player.countCards('he')>=num&&!player.hasSkill('kamome_jieban_phase'); }, - content(){ - 'step 0' + async cost(event, trigger, player){ event.num=player.storage.kamome_jieban?1:2; - player.chooseCardTarget({ + event.result = await player.chooseCardTarget({ position:'he', filterCard:true, filterTarget:lib.filter.notMe, @@ -7131,18 +7104,17 @@ game.import('character',function(lib,game,ui,get,ai,_status){ if(att<0&&num==1) return -0.7*att; return att; }, - }); + }).forResult(); + }, + content(){ + 'step 0' + event.num=player.storage.kamome_jieban?1:2; + var target=targets[0]; + event.target=target; + player.addTempSkill('kamome_jieban_phase'); + player.give(cards,target); + player.changeZhuanhuanji('kamome_jieban'); 'step 1' - if(result.bool){ - var target=result.targets[0]; - event.target=target; - player.logSkill('kamome_jieban',target); - player.addTempSkill('kamome_jieban_phase'); - player.give(result.cards,target); - player.changeZhuanhuanji('kamome_jieban'); - } - else event.finish(); - 'step 2' var num=3-event.num; var hs=target.getCards('he'); if(hs.length){ @@ -7161,7 +7133,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ } } else event.finish(); - 'step 3' + 'step 2' target.give(result.cards,player); }, }, @@ -7234,33 +7206,23 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return lib.skill.nao_wanxin.hasHistory(current); }); }, - direct:true, - content(){ - 'step 0' - player.chooseTarget(get.prompt2('nao_wanxin'),function(card,player,target){ + async cost(event, trigger, player){ + event.result = await player.chooseTarget(get.prompt2('nao_wanxin'),function(card,player,target){ return _status.event.yuus.includes(target); }).set('yuus',game.filterPlayer(function(current){ return lib.skill.nao_wanxin.hasHistory(current); })).set('ai',function(target){ return get.attitude(_status.event.player,target); - }); - 'step 1' - if(result.bool){ - var target=result.targets[0]; - event.target=target; - player.logSkill('nao_wanxin',target); - target.draw(2); - } - else event.finish(); - 'step 2' - player.turnOver(false); - 'step 3' - player.link(false); - if(target==player) event.finish(); - 'step 4' - target.turnOver(false); - 'step 5' - target.link(false); + }).forResult(); + }, + async content(event, trigger, player){ + const target=event.targets[0]; + await target.draw(2); + await player.turnOver(false); + await player.link(false); + if(target==player) return; + await target.turnOver(false); + await target.link(false); }, }, nao_shouqing:{ @@ -7323,45 +7285,39 @@ game.import('character',function(lib,game,ui,get,ai,_status){ shiorimiyuki_banyin:{ audio:2, trigger:{player:['damageEnd','recoverEnd']}, - direct:true, filter(event,player){ return game.hasPlayer(function(current){ return current!=player&¤t.isDamaged(); }) }, - content(){ - 'step 0' - player.chooseTarget(get.prompt('shiorimiyuki_banyin'),'令一名其他角色回复1点体力',lib.filter.notMe).set('ai',function(target){ + async cost(event, trigger, player){ + event.result = await player.chooseTarget(get.prompt('shiorimiyuki_banyin'),'令一名其他角色回复1点体力',lib.filter.notMe).set('ai',function(target){ var player=_status.event.player; return get.recoverEffect(target,player,player); - }); - 'step 1' - if(result.bool){ - var target=result.targets[0]; - player.logSkill('shiorimiyuki_banyin',target); - target.recover(); - } + }).forResult(); + }, + async content(event, trigger, player){ + const target=event.targets[0]; + target.recover(); }, }, shiorimiyuki_tingxian:{ audio:2, trigger:{player:'phaseUseBegin'}, - direct:true, - content(){ - 'step 0' - player.chooseControl('一张','两张','三张','cancel2').set('prompt',get.prompt2('shiorimiyuki_tingxian')).set('ai',function(){ + async cost(event, trigger, player){ + const {control, index} = await player.chooseControl('一张','两张','三张','cancel2').set('prompt',get.prompt2('shiorimiyuki_tingxian')).set('ai',function(){ var player=_status.event.player; var max=Math.min(player.hp+1,player.maxHp) var min=Math.min(Math.max(max-2,max-player.hp),3); if(min) return min-1; return 3; - }); - 'step 1' - if(result.control=='cancel2') return; - player.logSkill('shiorimiyuki_tingxian1'); - var num=1+result.index; - player.draw(num).gaintag=['shiorimiyuki_tingxian']; - player.recover(); + }).forResult(); + if (control != 'cancel2') event.result = {bool:true, cost_data:index}; + }, + async content(event, trigger, player){ + let num = 1 + event.cost_data; + await player.draw(num).set('gaintag', ['shiorimiyuki_tingxian']); + await player.recover(); player.addTempSkill('shiorimiyuki_tingxian2'); }, group:'shiorimiyuki_tingxian1', @@ -7526,15 +7482,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){ shizuru_benzhan:{ trigger:{global:['useCard','respond']}, usable:1, - direct:true, filter(event,player){ return Array.isArray(event.respondTo)&&event.respondTo[0]!=event.player&&[event.respondTo[0],event.player].includes(player); }, - content(){ - 'step 0' + async cost(event, trigger, player){ event.type=get.type(trigger.card)=='basic'; var prompt=event.type?'令一名角色摸两张牌或弃置两张牌':'令一名角色回复1点体力或对其造成1点伤害'; - player.chooseTarget(get.prompt('shizuru_benzhan'),prompt).set('ai',function(target){ + event.result = await player.chooseTarget(get.prompt('shizuru_benzhan'),prompt).set('ai',function(target){ var player=_status.event.player; if(_status.event.getParent().type){ var att=get.attitude(player,target); @@ -7543,34 +7497,30 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return Math.abs(att)*(1+0.1*(Math.min(0,5-target.countCards('h')))) } return Math.max(get.recoverEffect(target,player,player),get.damageEffect(target,player,player)) - }); - 'step 1' - if(result.bool){ - var target=result.targets[0]; - event.target=target; - player.logSkill('shizuru_benzhan',target,'thunder'); - var trans=get.translation(target); - var list; - if(event.type){ - if(!target.countCards('he')) event._result={index:0}; - else list=['令'+trans+'摸两张牌','令'+trans+'弃置两张牌']; - } - else{ - if(target.isHealthy()) event._result={index:1}; - else list=['令'+trans+'回复1点体力','对'+trans+'造成1点伤害']; - } - player.chooseControl().set('choiceList',list).set('choice',function(){ - if(event.type) return (get.attitude(player,target)>0)?0:1; - return (get.recoverEffect(target,player,player)>get.damageEffect(target,player,player))?0:1; - }()).set('ai',function(){ - return _status.event.choice; - }); + }).forResult(); + }, + content(){ + 'step 0' + event.type=get.type(trigger.card)=='basic'; + var target=event.targets[0]; + event.target=target; + var trans=get.translation(target); + var list; + if(event.type){ + if(!target.countCards('he')) event._result={index:0}; + else list=['令'+trans+'摸两张牌','令'+trans+'弃置两张牌']; } else{ - player.storage.counttrigger[event.name]--; - event.finish(); + if(target.isHealthy()) event._result={index:1}; + else list=['令'+trans+'回复1点体力','对'+trans+'造成1点伤害']; } - 'step 2' + player.chooseControl().set('choiceList',list).set('choice',function(){ + if(event.type) return (get.attitude(player,target)>0)?0:1; + return (get.recoverEffect(target,player,player)>get.damageEffect(target,player,player))?0:1; + }()).set('ai',function(){ + return _status.event.choice; + }); + 'step 1' player.addExpose(0.2); if(event.type){ if(result.index==0) target.draw(2); diff --git a/noname/library/element/content.js b/noname/library/element/content.js index 92d2bddf1..bfeb938ea 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -2306,12 +2306,10 @@ export const Content = { targets = [targets]; } if (info.popup != false && !info.direct) { - if (info.popup) { - player.popup(info.popup); - game.log(player, '发动了', '【' + get.skillTranslation(event.skill, player) + '】'); - } - if (info.logLine === false) player.logSkill(event.skill, false, info.line); - else player.logSkill(event.skill, targets, info.line); + let popup_info = event.skill; + if(typeof info.popup === 'string') popup_info = [event.skill, info.popup]; + if (info.logLine === false) player.logSkill(popup_info, false, info.line); + else player.logSkill(popup_info, targets, info.line); } var next = game.createEvent(event.skill); if (typeof info.usable == 'number') { diff --git a/noname/library/element/gameEvent.js b/noname/library/element/gameEvent.js index 91e694eae..28d9a0649 100644 --- a/noname/library/element/gameEvent.js +++ b/noname/library/element/gameEvent.js @@ -333,10 +333,10 @@ export class GameEvent { this.untrigger(arg1, arg2); this.finish(); if (notrigger != 'notrigger') { - this.trigger(this.name + 'Cancelled'); if (this.player && lib.phaseName.includes(this.name)) this.player.getHistory('skipped').add(this.name); + return this.trigger(this.name + 'Cancelled'); } - return this; + return null; } neutralize(event) { this.untrigger(); diff --git a/noname/library/element/player.js b/noname/library/element/player.js index 0b7229298..8ad82910a 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -371,6 +371,7 @@ export class Player extends HTMLDivElement { * ``` */ when() { + const player = this; if (!_status.postReconnect.player_when) _status.postReconnect.player_when = [ function (map) { "use strict"; @@ -386,7 +387,13 @@ export class Player extends HTMLDivElement { ]; let triggerNames = Array.from(arguments); let trigger; + let instantlyAdd = true; if (triggerNames.length == 0) throw 'player.when的参数数量应大于0'; + //从triggerNames中取出instantlyAdd的部分 + if (triggerNames.includes(false)) { + instantlyAdd = false; + triggerNames.remove(false); + } // add other triggerNames // arguments.length = 1 if (triggerNames.length == 1) { @@ -506,7 +513,7 @@ export class Player extends HTMLDivElement { } }); }, skillName); - this.addSkill(skillName); + if (instantlyAdd !== false) this.addSkill(skillName); _status.postReconnect.player_when[1][skillName] = true; return { /** @@ -603,6 +610,14 @@ export class Player extends HTMLDivElement { if (skill.contentFuns.length > 0) createContent(); return this; }, + /** + * 获得技能 + * 如果instantlyAdd为false,则需要以此法获得技能 + **/ + finish() { + player.addSkill(skillName); + return this; + } }; } /** @@ -7877,14 +7892,14 @@ export class Player extends HTMLDivElement { skillName = 'player_tempSkills_' + Math.random().toString(36).slice(-8); } while (player.additionalSkills[skillName] != null); player.addAdditionalSkill(skillName, skillsToAdd); - player.when(expire).assign({ + player.when(expire,false).assign({ firstDo: true, priority: Infinity, }).vars({ skillName }).then(() => { player.removeAdditionalSkills(skillName); - }); + }).finish(); } }); } @@ -7927,13 +7942,13 @@ export class Player extends HTMLDivElement { if (!expire) expire = { global: ['phaseAfter', 'phaseBeforeStart'] }; else if (typeof expire == 'string' || Array.isArray(expire)) expire = { global: expire }; - this.when(expire).assign({ + this.when(expire,false).assign({ firstDo: true, }).vars({ bannedSkill: skill, }).then(() => { delete player.storage[`temp_ban_${bannedSkill}`]; - }); + }).finish(); } return skill; }