From 585d6dab385d04d832c580f3a816418ba7a2a1db Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Wed, 6 Sep 2023 11:26:37 +0800 Subject: [PATCH] shownCard --- character/ddd.js | 40 +++---- character/diy.js | 78 +++++++------- character/yingbian.js | 42 +++++--- game/game.js | 241 ++++++++++++++++++++++++++++++++++++++---- 4 files changed, 300 insertions(+), 101 deletions(-) diff --git a/character/ddd.js b/character/ddd.js index c830ba442..675fcc53a 100644 --- a/character/ddd.js +++ b/character/ddd.js @@ -1656,14 +1656,14 @@ game.import('character',function(lib,game,ui,get,ai,_status){ direct:true, filter:function (event,player){ return player!=event.player&&event.player.hp>0&&player.countCards('h',function(card){ - return !card.hasGaintag('dddxujing_tag'); + return !get.is.shownCard(card); })>=event.player.hp; }, content:function (){ 'step 0' var target=trigger.player; - player.chooseCard('h',target.hp,get.prompt('dddqiahua',target),'选择'+get.cnNumber(target.hp)+'张手牌作为“明”,然后'+get.translation(target)+'获得技能〖恂恂〗直到本回合结束。',function(card){ - return !card.hasGaintag('dddxujing_tag'); + player.chooseCard('h',target.hp,get.prompt('dddqiahua',target),'选择明置'+get.cnNumber(target.hp)+'张手牌,然后'+get.translation(target)+'获得技能〖恂恂〗直到本回合结束。',function(card){ + return !get.is.shownCard(card); }).set('goon',get.attitude(player,target)>0).set('ai',function(card){ if(_status.event.goon) return 1+Math.random(); return 0; @@ -1673,11 +1673,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){ var target=trigger.player,cards=result.cards; player.logSkill('dddqiahua',target); target.addTempSkill('dddxunxun'); - player.addSkill('dddxujing_tag'); - player.addGaintag(result.cards,'dddxujing_tag'); + player.addShownCards(cards,'visible_dddxianglang'); game.log(player,'选择了',cards,'作为“明”'); player.showCards(cards,get.translation(player)+'对'+get.translation(target)+'发动了【恰化】'); - player.markSkill('dddxujing_tag'); } }, ai:{ @@ -1692,10 +1690,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){ dddfusi:{ mod:{ ignoredHandcard:function (card,player){ - if(card.hasGaintag('dddxujing_tag')) return true; + if(get.is.shownCard(card)) return true; }, cardDiscardable:function (card,player,name){ - if(name=='phaseDiscard'&&card.hasGaintag('dddxujing_tag')) return false; + if(name=='phaseDiscard'&&get.is.shownCard(card)) return false; }, }, global:"dddfusi_global", @@ -1712,10 +1710,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, dddfusi_global:{ mod:{ - "cardEnabled2":function (card,player){ + cardEnabled2:function(card,player){ var source=_status.currentPhase; if(!source||source==player||!source.hasSkill('dddfusi')||source.countCards('h')==0||source.hasCard(function(card){ - return !card.hasGaintag('dddxujing_tag'); + return !get.is.shownCard(card); },'h')) return; if(player.getCards('h').contains(card)) return false; }, @@ -1727,9 +1725,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return current!=player&¤t.hasSkill('dddfusi'); }); for(var source of players){ - var cards=source.getCards('h',function(card){ - return card.hasGaintag('dddxujing_tag'); - }); + var cards=source.getShownCards(); for(var i of cards){ var card=get.autoViewAs(i); if(event.filterCard(card,player,event)) return true; @@ -1743,9 +1739,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return current!=player&¤t.hasSkill('dddfusi'); }); for(var source of players){ - var cards=source.getCards('h',function(card){ - return card.hasGaintag('dddxujing_tag'); - }); + var cards=source.getShownCards(); for(var i of cards){ var card=get.autoViewAs(i); if(name==card.name) return true; @@ -1760,9 +1754,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return current!=player&¤t.hasSkill('dddfusi'); }).sortBySeat(); for(var source of players){ - var cards=source.getCards('h',function(card){ - return card.hasGaintag('dddxujing_tag'); - }); + var cards=source.getShownCards(); if(cards.length){ var str='
'; str+=get.translation(source); @@ -1862,7 +1854,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ frequent:true, filter:function(event,player){ return event.card.storage&&event.card.storage._dddfusi_owner==player&&!player.hasCard(function(card){ - return !card.hasGaintag('dddxujing_tag'); + return !get.is.shownCard(card); },'h'); }, content:function(){ @@ -4231,13 +4223,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){ dddzhijie_info:"你可以将两张颜色相同的“鉴”当做【闪】使用,或将两张颜色不同的“鉴”当做【无懈可击】使用;然后你摸两张牌。", ddd_xianglang:'向朗', dddqiahua:"恰化", - dddqiahua_info:"其他角色的回合开始时,你可选择X张不为“明”的手牌作为“明”(X为其体力值,这些牌对所有角色可见),然后其于本回合内获得〖恂恂〗。", + dddqiahua_info:"其他角色的回合开始时,你可明置X张手牌(X为其体力值),然后其于本回合内获得〖恂恂〗。", dddfusi:"腹笥", - dddfusi_info:"锁定技。①你的“明”不计入手牌上限。②其他角色需要使用牌时,可以改为使用你的“明”(需经过你的确认)。③你的回合内,若你的手牌均为“明”,则其他角色不能使用各自的手牌。", + dddfusi_info:"锁定技。①你的明置手牌不计入手牌上限。②其他角色需要使用牌时,可以改为使用你的明置手牌(需经过你的确认)。③你的回合内,若你的手牌均为明置手牌,则其他角色不能使用各自的手牌。", dddfusi_global:"腹笥", dddtuoji:"拓籍", - dddtuoji_info:"其他角色因〖腹笥〗而使用你的牌后,若你的手牌均为“明”,则你可以摸三张牌。", - dddxujing_tag:"明", + dddtuoji_info:"其他角色因〖腹笥〗而使用你的牌后,若你的手牌均为明置手牌,则你可以摸三张牌。", + visible_dddxianglang:"明", ddd_yujin:'于禁', dddzhengjun:'整军', dddzhengjun_info:'出牌阶段内每项各限一次。当有其他角色的手牌数/体力值/装备区内牌数变化后,若其的对应数值与你相同,则你可以执行对应的选项。体力值:你令一名角色回复1点体力;手牌数:你令一名角色摸一张牌;装备区内牌数:你移动场上的一张装备牌。', diff --git a/character/diy.js b/character/diy.js index 69649956a..27b8e81d7 100755 --- a/character/diy.js +++ b/character/diy.js @@ -12910,9 +12910,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){ var target=result.targets[0]; player.logSkill('nsfengli',target); var cards=player.getCards('h'); - player.addGaintag(cards,'nsfengli2'); + player.addShownCards(cards,'visible_nsfengli'); player.addSkill('nsfengli2'); - player.showHandcards(); target.addSkill('nsfengli_use'); target.storage.nsfengli_use=player; } @@ -12924,26 +12923,39 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, nsfengli_draw:{ trigger:{ - player:['loseAfter','nsfengliClear'], + player:['loseAfter','hideShownCardsAfter'], global:['gainAfter','equipAfter','addJudgeAfter','loseAsyncAfter','addToExpansionAfter'], - target:'nsfengliUse', }, direct:true, charlotte:true, filter:function(event,player,name){ - if(name!='nsfengliUse'&&name!='nsfengliClear'){ - var evt=event.getl(player); - if(!evt||!evt.gaintag_map) return false; - var bool=false; - for(var i in evt.gaintag_map){ - if(evt.gaintag_map[i].contains('nsfengli2')) bool=true;break; - } - if(!bool) return false; + if(event.name=='hideShownCards'){ + const hs=player.countCards('h'); + return game.hasPlayer(current=>current.countCards('h')tag.indexOf('visible_')==0)) num++; + } + if(event.getg){ + if(event.name=='gain'){ + if(event.getlx===false&&event.gaintag.some(tag=>tag.indexOf('visible_')==0)) num-=event.cards.length; + } + else{ + player.checkHistory('gain',function(evt){ + if(evt.parent==event&&evt.gaintag.some(tag=>tag.indexOf('visible_')==0)){ + num-=evt.cards.length; + } + }); + } + } + if(num>0){ + const hs=player.countCards('h'); + return game.hasPlayer(current=>current.countCards('h')0) player.hideShownCards(cards); player.removeSkill('nsfengli2'); }, }, nsfengli2:{ - mark:true, - intro:{ - mark:function(dialog,content,player){ - var hs=player.getCards('h',function(card){ - return card.hasGaintag('nsfengli2'); - }); - if(hs.length) dialog.addAuto(hs); - else dialog.addText('没有“礼”'); - }, - }, onremove:function(player){ player.removeGaintag('nsfengli2'); game.countPlayer(function(current){ @@ -12999,9 +12999,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ hiddenCard:function(player,name){ if(player==_status.currentPhase) return false; var target=player.storage.nsfengli_use; - var cards=target.getCards('h',function(card){ - return card.hasGaintag('nsfengli2'); - }); + var cards=target.getShownCards(); for(var i of cards){ if(get.name(i,target)==name) return true; } @@ -13013,9 +13011,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ filter:function(event,player){ if(player==_status.currentPhase) return false; var target=player.storage.nsfengli_use; - var cards=target.getCards('h',function(card){ - return card.hasGaintag('nsfengli2'); - }); + var cards=target.getShownCards(); for(var i of cards){ if(event.filterCard({ name:get.name(i,target), @@ -13028,9 +13024,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ chooseButton:{ dialog:function(event,player){ var target=player.storage.nsfengli_use; - var cards=target.getCards('h',function(card){ - return card.hasGaintag('nsfengli2'); - }); + var cards=target.getShownCards(); return ui.create.dialog('奉礼',cards); }, filter:function(button,player){ @@ -13066,8 +13060,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ player.logSkill('nsfengli',target); delete event.result.skill; player.showCards(card,get.translation(player)+'发动了【奉礼】'); - card.removeGaintag('nsfengli2'); - event.trigger('nsfengliUse'); + target.hideShownCards(card); }, }; }, @@ -18674,7 +18667,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){ nsfengli_draw:'奉礼', nsfengli_clear:'奉礼', nsfengli_use:'奉礼', - nsfengli_info:'回合结束时,你可以选择一名其他角色并展示所有手牌。你将所有手牌标记为“礼”。你的“礼”对所有角色可见。当该角色于回合外需要使用或打出牌时,其可移去一张“礼”的标记,然后视为使用或打出一张与此牌名称相同的牌。当你的“礼”减少时,你可令一名手牌数小于你的角色摸一张牌。你的回合开始时,你移去所有“礼”的标记,然后注销该角色对“礼”的操作权限。', + visible_nsfengli:'奉礼', + nsfengli_info:'回合结束时,你可以选择一名其他角色并展示所有手牌直到你的下回合开始。当该角色于回合外需要使用或打出牌时,其可暗置你的一张明置手牌,然后视为使用或打出之。当你的明置手牌减少时,你可令一名手牌数小于你的角色摸一张牌。', nsqiyue:'骑钺', nsqiyue_info:'锁定技,当有角色的武将牌状态改变后,你摸一张牌。', nsxuezhu:'血逐', diff --git a/character/yingbian.js b/character/yingbian.js index c9660b7be..d152bd0e0 100644 --- a/character/yingbian.js +++ b/character/yingbian.js @@ -2984,23 +2984,27 @@ game.import('character',function(lib,game,ui,get,ai,_status){ trigger:{player:'phaseUseBegin'}, preHidden:true, content:function(){ - player.addTempSkill('zhaoran2','phaseUseEnd'); + player.addTempSkill('zhaoran2','phaseUseAfter'); + var cards=player.getCards('h'); + if(cards.length>0) player.addShownCards(cards,'visible_zhaoran'); }, }, zhaoran2:{ audio:'zhaoran', - global:'zhaoran3', + group:'zhaoran3', + init:(player,skill)=>{ + if(!player.storage[skill]) player.storage[skill]=[]; + }, + onremove:true, trigger:{ player:'loseAfter', global:['equipAfter','addJudgeAfter','gainAfter','loseAsyncAfter','addToExpansionAfter'], }, forced:true, charlotte:true, - init:function(player,skill){ - if(!player.storage[skill]) player.storage[skill]=[]; - }, - onremove:true, - filter:function(event,player){ + popup:false, + filter:function(event,player,name){ + if(name=='gainBegin') return true; var evt=event.getl(player); if(!evt||!evt.hs||!evt.hs.length) return false; var list=player.getStorage('zhaoran2'); @@ -3013,6 +3017,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ content:function(){ 'step 0' if(trigger.delay===false) game.delayx(); + 'step 1' var list=[]; var suits=get.copy(player.storage.zhaoran2); suits.addArray(player.getCards('h').map(function(card){ @@ -3042,10 +3047,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){ return 0; }); 'step 2' - if(!result.bool) player.draw(); + if(!result.bool){ + player.logSkill('zhaoran2'); + player.draw(); + } else{ var target=result.targets[0]; - player.line(target,'green'); + player.logSkill('zhaoran2',target); player.discardPlayerCard(target,true,'he'); } if(event.count>0) event.goto(1); @@ -3055,10 +3063,17 @@ game.import('character',function(lib,game,ui,get,ai,_status){ }, }, zhaoran3:{ - ai:{ - viewHandcard:true, - skillTagFilter:function(player,arg,target){ - return target!=player&&target.hasSkill('zhaoran2'); + trigger:{player:['phaseUseEnd','gainBegin']}, + forced:true, + charlotte:true, + firstDo:true, + silent:true, + content:function(){ + if(event.triggername=='gainBegin'){ + trigger.gaintag.add('visible_zhaoran'); + } + else{ + player.hideShownCards(player.getCards('h'),'visible_zhaoran'); } }, }, @@ -3644,6 +3659,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){ zhaoran:'昭然', zhaoran2:'昭然', zhaoran_info:'出牌阶段开始时,你可令你的手牌对其他角色可见直到出牌阶段结束。若如此做,当你于此阶段内失去一张手牌后,若你的手牌里没有与此牌花色相同的牌且你本回合内未因该花色的牌触发过此效果,则你选择一项:①摸一张牌。②弃置一名其他角色的一张牌。', + visible_zhaoran:'invisible', chengwu:'成务', chengwu_info:'主公技,锁定技,其他晋势力角色攻击范围内的角色视为在你的攻击范围内。', jin_xiahouhui:'晋夏侯徽', diff --git a/game/game.js b/game/game.js index 82a0bbbea..f740aca62 100644 --- a/game/game.js +++ b/game/game.js @@ -10960,6 +10960,49 @@ emptyEvent:function(){ event.trigger(event.name); }, + //增加明置手牌 + addShownCards:function(){ + var hs=player.getCards('h'),cards=event._cards.filter(card=>hs.includes(card)); + var shown=player.getShownCards(); + for(var tag of event.gaintag) player.addGaintag(cards,tag); + event.cards=cards.filter(card=>!shown.includes(card)); + if(event.cards.length>0){ + game.log(player,'明置了',event.cards); + event.trigger('addShownCardsAfter') + } + }, + //隐藏明置手牌 + hideShownCards:function(){ + var shown=player.getShownCards(),cards=event._cards.filter(card=>shown.includes(card)); + if(cards.length>0){ + if(!event.gaintag.length){ + var map={}; + cards.forEach(card=>{ + var tags=card.gaintag.filter(tag=>tag.indexOf('visible_')==0) + if(tags.length){ + tags.forEach(tag=>{ + if(!map[tag]) map[tag]=[]; + map[tag].push(card); + }) + } + }); + for(var i in map){ + player.removeGaintag(i,map[i]) + } + } + else{ + event.gaintag.forEach(tag=>{ + player.removeGaintag(tag,cards); + }) + } + cards.removeArray(player.getShownCards()); + if(cards.length>0){ + event.cards=cards; + game.log(player,'取消明置了',cards); + event.trigger('hideShownCardsAfter'); + } + } + }, //Execute the delay card effect //执行延时锦囊牌效果 executeDelayCardEffect:()=>{ @@ -15774,7 +15817,23 @@ directh=false; } else{ - event.dialog.add([hs,'blank']); + var shown=hs.filter(card=>get.is.shownCard(card)); + if(shown.length){ + var hidden=hs.filter(card=>!shown.includes(card)); + var buttons=ui.create.div('.buttons',event.dialog.content); + event.dialog.buttons=event.dialog.buttons.concat(ui.create.buttons(shown,'card',buttons)); + event.dialog.buttons=event.dialog.buttons.concat(ui.create.buttons(hidden,'blank',buttons)); + if(event.dialog.forcebutton!==false) event.dialog.forcebutton=true; + if(event.dialog.buttons.length>3||(zoom&&event.dialog.buttons.length>5)){ + event.dialog.classList.remove('forcebutton-auto'); + } + else if(!event.dialog.noforcebutton){ + event.dialog.classList.add('forcebutton-auto'); + } + } + else{ + event.dialog.add([hs,'blank']); + } } } } @@ -15902,8 +15961,8 @@ for(var i=0;i手牌区
'); title.style.margin='0px'; title.style.padding='0px'; @@ -15913,7 +15972,23 @@ directh=false; } else{ - event.dialog.add([hs,'blank']); + var shown=hs.filter(card=>get.is.shownCard(card)); + if(shown.length){ + var hidden=hs.filter(card=>!shown.includes(card)); + var buttons=ui.create.div('.buttons',event.dialog.content); + event.dialog.buttons=event.dialog.buttons.concat(ui.create.buttons(shown,'card',buttons)); + event.dialog.buttons=event.dialog.buttons.concat(ui.create.buttons(hidden,'blank',buttons)); + if(event.dialog.forcebutton!==false) event.dialog.forcebutton=true; + if(event.dialog.buttons.length>3||(zoom&&event.dialog.buttons.length>5)){ + event.dialog.classList.remove('forcebutton-auto'); + } + else if(!event.dialog.noforcebutton){ + event.dialog.classList.add('forcebutton-auto'); + } + } + else{ + event.dialog.add([hs,'blank']); + } } } } @@ -16076,7 +16151,23 @@ directh=false; } else{ - event.dialog.add([hs,'blank']); + var shown=hs.filter(card=>get.is.shownCard(card)); + if(shown.length){ + var hidden=hs.filter(card=>!shown.includes(card)); + var buttons=ui.create.div('.buttons',event.dialog.content); + event.dialog.buttons=event.dialog.buttons.concat(ui.create.buttons(shown,'card',buttons)); + event.dialog.buttons=event.dialog.buttons.concat(ui.create.buttons(hidden,'blank',buttons)); + if(event.dialog.forcebutton!==false) event.dialog.forcebutton=true; + if(event.dialog.buttons.length>3||(zoom&&event.dialog.buttons.length>5)){ + event.dialog.classList.remove('forcebutton-auto'); + } + else if(!event.dialog.noforcebutton){ + event.dialog.classList.add('forcebutton-auto'); + } + } + else{ + event.dialog.add([hs,'blank']); + } } } } @@ -18795,6 +18886,61 @@ }, player:{ //新函数 + //让一名角色明置一些手牌 + addShownCards:function(){ + const cards=[]; + const tags=[]; + for(let i=0;itag.indexOf('visible_')==0) + } + return false; + }, + //押韵判断 yayun:function(str1,str2){ if(str1==str2) return true; var pinyin1=get.pinyin(str1,false),pinyin2=get.pinyin(str2,false); @@ -56041,11 +56222,27 @@ uiintro.addText(get.colorspan(lib.characterTitle[node.name])); } - if(!node.noclick&&(node.isUnderControl()||(!game.observe&&game.me&&game.me.hasSkillTag('viewHandcard',null,node,true)))){ - var hs=node.getCards('h'); - if(hs.length){ - uiintro.add('
手牌
'); - uiintro.addSmall(node.getCards('h')); + if(!node.noclick){ + const allShown=(node.isUnderControl()||(!game.observe&&game.me&&game.me.hasSkillTag('viewHandcard',null,node,true))); + const shownHs=node.getShownCards(); + if(shownHs.length){ + uiintro.add('
明置的手牌
'); + uiintro.addSmall(shownHs); + if(allShown){ + var hs=node.getCards('h'); + hs.removeArray(shownHs) + if(hs.length){ + uiintro.add('
其他手牌
'); + uiintro.addSmall(hs); + } + } + } + else if(allShown){ + var hs=node.getCards('h'); + if(hs.length){ + uiintro.add('
手牌
'); + uiintro.addSmall(hs); + } } }