diff --git a/game/game.js b/game/game.js index f2c328d43..d80ee3d35 100644 --- a/game/game.js +++ b/game/game.js @@ -1,12 +1,12 @@ "use strict"; { + const userAgent=navigator.userAgent.toLowerCase(); if(!localStorage.getItem('gplv3_noname_alerted')){ if(confirm('①无名杀是一款基于GPLv3协议的开源软件!\n你可以在遵守GPLv3协议的基础上任意使用,修改并转发《无名杀》,以及所有基于《无名杀》开发的拓展。\n点击“确定”即代表您认可并接受GPLv3协议↓️\nhttps://www.gnu.org/licenses/gpl-3.0.html\n②无名杀官方发布地址仅有GitHub仓库!\n其他所有的所谓“无名杀”社群(包括但不限于绝大多数“官方”QQ群、QQ频道等)均为玩家自发组织,与无名杀官方无关!')){ localStorage.setItem('gplv3_noname_alerted',true); } else{ - const ua=navigator.userAgent.toLowerCase(); - const ios=ua.includes('iphone')||ua.includes('ipad')||ua.includes('macintosh'); + const ios=userAgent.includes('iphone')||userAgent.includes('ipad')||userAgent.includes('macintosh'); //electron if(typeof window.process=='object'&&typeof window.require=='function'){ const versions=window.process.versions; @@ -117,6 +117,7 @@ mirrorURL:'https://raw.fgit.cf/libccy/noname', hallURL:'47.99.105.222', assetURL:typeof nonameInitialized!='string'||nonameInitialized=='nodejs'?'':nonameInitialized, + userAgent:userAgent, compatibleEdition:Boolean(typeof nonameInitialized=='string'&&nonameInitialized.match(/\/(?:com\.widget|yuri\.nakamura)\.noname\//)), changeLog:[], updates:[], @@ -8875,7 +8876,7 @@ } var noname_inited=localStorage.getItem('noname_inited'); if(noname_inited&&noname_inited!=='nodejs'){ - var ua=navigator.userAgent.toLowerCase(); + var ua=userAgent; if(ua.includes('android')){ lib.device='android'; } @@ -9041,7 +9042,7 @@ appearenceConfig.global_font.item.default='默认'; } - var ua=navigator.userAgent.toLowerCase(); + var ua=userAgent; if('ontouchstart' in document){ if(!lib.config.totouched){ game.saveConfig('totouched',true); @@ -10520,7 +10521,8 @@ game.addSkill(j,lib.extensions[i][4].skill.skill[j], lib.extensions[i][4].skill.translate[j], lib.extensions[i][4].skill.translate[j+'_info'], - lib.extensions[i][4].skill.translate[j+'_append']); + lib.extensions[i][4].skill.translate[j+'_append'], + lib.extensions[i][4].skill.translate[j+'_ab']); } } } @@ -37326,7 +37328,7 @@ delete _status.waitingToReload; }, exit:function(){ - var ua=navigator.userAgent.toLowerCase(); + var ua=userAgent; var ios=ua.includes('iphone')||ua.includes('ipad')||ua.includes('macintosh'); //electron if(typeof window.process=='object'&&typeof window.require=='function'){ @@ -38148,7 +38150,7 @@ } } }, - addSkill:function(name,info,translate,description,appendInfo){ + addSkill:function(name,info,translate,description,appendInfo,abInfo){ if(lib.skill[name]){ return false; } @@ -38159,6 +38161,7 @@ lib.translate[name]=translate; lib.translate[name+'_info']=description; lib.translate[name+'_append']=appendInfo; + lib.translate[`${name}_ab`]=abInfo; return true; }, addMode:function(name,info,info2){ @@ -56516,7 +56519,7 @@ return info&&info.defaultYingbianEffect||null; }, //优先度判断 - priority:function(skill){ + priority:skill=>{ const info=get.info(skill); if(!info) return 0; if(info.hasOwnProperty('_priority')) return info._priority; @@ -56536,7 +56539,7 @@ //新装备栏相关 //获取一张装备牌实际占用的装备栏(君曹操六龙) //用法同get.subtype,返回数组 - subtypes:function(obj,player){ + subtypes:(obj,player)=>{ if(typeof obj=='string') obj={name:obj}; if(typeof obj!='object') return; var name=get.name(obj,player); @@ -56556,7 +56559,7 @@ } return pinyinUtilx.getPinyin(chinese,null,withTone,true); }, - yunmu:function(str){ + yunmu:str=>{ //部分整体认读音节特化处理 const util=window.pinyinUtilx; if(util&&lib.pinyins._metadata.zhengtirendu.contains(util.removeTone(str))){ @@ -56586,7 +56589,7 @@ return str; }, //用于将参数转换为字符串,作为缓存的key。 - paramToCacheKey:function(){ + paramToCacheKey(){ var str = ""; for(var arg of arguments){ if(arg === null || arg === undefined){ @@ -56606,7 +56609,7 @@ } return str; }, - yunjiao:function(str){ + yunjiao:str=>{ const util=window.pinyinUtilx; if(util) str=util.removeTone(str) if(lib.pinyins._metadata.zhengtirendu.contains(str)){ @@ -56626,7 +56629,7 @@ } return null; }, - skillCategoriesOf:function(skill,player){ + skillCategoriesOf:(skill,player)=>{ var list=[],info=get.info(skill); if(!info) return list; if(get.is.locked(skill,player)) list.add('锁定技'); @@ -56649,54 +56652,44 @@ if(info.categories) list.addArray(info.categories(skill,player)); return list; }, - numOf:function(obj,item){ - var num=0; - for(var i=0;iobj.filter(element=>element==item).length, + connectNickname:()=>typeof lib.config.connect_nickname=='string'?(lib.config.connect_nickname.slice(0,12)):"无名玩家", + zhinangs:filter=>{ var list=(_status.connectMode?lib.configOL:lib.config).zhinang_tricks; if(!list||!list.filter||!list.length) return get.inpile('trick','trick').randomGets(3); if(filter===false) return list.slice(0); - list=list.filter(function(i){ - return lib.inpile.contains(i); - }); + list=list.filter(card=>lib.inpile.includes(card)); if(list.length) return list; return get.inpile('trick','trick').randomGets(3); }, - sourceCharacter:function(str){ + sourceCharacter:str=>{ if(str){ for(var i in lib.characterReplace){ - if(lib.characterReplace[i].contains(str)) return i; + if(lib.characterReplace[i].includes(str)) return i; } } return str; }, - isLuckyStar:function(player){ + isLuckyStar:player=>{ if(player&&player.hasSkillTag('luckyStar')) return true; if(_status.connectMode) return false; return (!player||player==game.me||player.isUnderControl())&&lib.config.lucky_star==true; }, - infoHp:function(hp){ + infoHp:hp=>{ if(typeof hp=='number') return hp; else if(typeof hp=='string'&&hp.includes('/')){ return parseInt(hp.split('/')[0]); } return 0; }, - infoMaxHp:function(hp){ + infoMaxHp:hp=>{ if(typeof hp=='number') return hp; else if(typeof hp=='string'&&hp.includes('/')){ return parseInt(hp.split('/')[1]); } return 0; }, - infoHujia:function(hp){ + infoHujia:hp=>{ if(typeof hp=='string'&&hp.includes('/')){ var splited=hp.split('/'); if(splited.length>2) return parseInt(splited[2]); @@ -56709,7 +56702,7 @@ * @param ...infos 要判断的属性列表 * @param every {boolean} 是否判断每一个传入的属性是否完全相同而不是存在部分相同 */ - sameNature:function(){ + sameNature(){ let processedArguments=[],every=false; Array.from(arguments).forEach(argument=>{ if(typeof argument=='boolean') every=argument; @@ -56740,7 +56733,7 @@ * @param ...infos 要判断的属性列表 * @param every {boolean} 是否判断每一个传入的属性是否完全不同而不是存在部分不同 */ - differentNature:function(){ + differentNature(){ let processedArguments=[],every=false; Array.from(arguments).forEach(argument=>{ if(typeof argument=='boolean') every=argument; @@ -56779,7 +56772,7 @@ //是否是实体牌 ordinaryCard:card=>card.isCard&&("cards" in card)&&Array.isArray(card.cards)&&card.cards.length==1, //押韵判断 - yayun:function(str1,str2){ + yayun:(str1,str2)=>{ if(str1==str2) return true; var pinyin1=get.pinyin(str1,false),pinyin2=get.pinyin(str2,false); if(!pinyin1.length||!pinyin2.length) return false; @@ -56787,7 +56780,7 @@ if(pron1==pron2) return true; return get.yunjiao(pron1)==get.yunjiao(pron2); }, - blocked:function(skill,player){ + blocked:(skill,player)=>{ if(!player.storage.skill_blocker||!player.storage.skill_blocker.length) return false; for(var i of player.storage.skill_blocker){ if(lib.skill[i]&&lib.skill[i].skillBlocker&&lib.skill[i].skillBlocker(skill,player)) return true; @@ -56827,7 +56820,7 @@ return false; }, yingbian:card=>get.is.yingbianConditional(card)||get.is.yingbianEffective(card), - emoji:function(substring){ + emoji:substring=>{ if(substring){ var reg=new RegExp("[~#^$@%&!?%*]",'g'); if(substring.match(reg)){ @@ -56873,28 +56866,11 @@ } return false; }, - banWords:function(str){ - if(get.is.emoji(str)) return true; - for(var i of window.bannedKeyWords){ - if(str.includes(i)) return true; - } - return false; - }, - converted:function(event){ - return !(event.card&&event.card.isCard); - }, - safari:function(){ - var ua=navigator.userAgent.toLowerCase(); - return ua.indexOf('safari'!=-1)&&ua.indexOf('chrome')==-1; - }, - freePosition:function(cards){ - for(var i=0;iget.is.emoji(str)||window.bannedKeyWords.some(item=>str.includes(item)), + converted:event=>!(event.card&&event.card.isCard), + safari:()=>userAgent.indexOf('safari'!=-1)&&userAgent.indexOf('chrome')==-1, + freePosition:cards=>!cards.some(card=>!card.hasPosition||card.hasPosition()), + nomenu:(name,item)=>{ var menus=['system','menu']; var configs={ show_round_menu:lib.config.show_round_menu, @@ -56928,34 +56904,29 @@ } return true; }, - altered:function(skill){ + altered:lib.filter.none, + /* + skill=>{ return false; // if(_status.connectMode) return true; // return !lib.config.vintageSkills.contains(skill); }, - node:function(obj){ + */ + node:obj=>{ var str=Object.prototype.toString.call(obj); if(str&&str.indexOf('[object HTML')) return true; return false; }, - div:function(obj){ - return Object.prototype.toString.call(obj) === '[object HTMLDivElement]'; - }, - map:function(obj){ - return Object.prototype.toString.call(obj) === '[object Map]'; - }, - set:function(obj){ - return Object.prototype.toString.call(obj) === '[object Set]'; - }, - object:function(obj){ - return Object.prototype.toString.call(obj) === '[object Object]'; - }, - singleSelect:function(func){ + div:obj=>Object.prototype.toString.call(obj) === '[object HTMLDivElement]', + map:obj=>Object.prototype.toString.call(obj) === '[object Map]', + set:obj=>Object.prototype.toString.call(obj) === '[object Set]', + object:obj=>Object.prototype.toString.call(obj) === '[object Object]', + singleSelect:func=>{ if(typeof func=='function') return false; var select=get.select(func); return select[0]==1&&select[1]==1; }, - jun:function(name){ + jun:name=>{ if(get.mode()=='guozhan'){ if(name&&typeof name=='object'){ if(name.isUnseen&&name.isUnseen(0)) return false; @@ -56967,33 +56938,17 @@ } return false; }, - versus:function(){ - return !_status.connectMode&&get.mode()=='versus'&&_status.mode=='three'; - }, - changban:function(){ - return get.mode()=='single'&&_status.mode=='changban'; - }, - single:function(){ - return get.mode()=='single'&&_status.mode=='normal'; - }, - mobileMe:function(player){ - return (game.layout=='mobile'||game.layout=='long')&&!game.chess&&player.dataset.position==0; - }, - newLayout:function(){ - if(game.layout!='default') return true; - return false; - }, - phoneLayout:function(){ + versus:()=>!_status.connectMode&&get.mode()=='versus'&&_status.mode=='three', + changban:()=>get.mode()=='single'&&_status.mode=='changban', + single:()=>get.mode()=='single'&&_status.mode=='normal', + mobileMe:player=>(game.layout=='mobile'||game.layout=='long')&&!game.chess&&player.dataset.position==0, + newLayout:()=>game.layout!='default', + phoneLayout:()=>{ if(!lib.config.phonelayout) return false; return (game.layout=='mobile'||game.layout=='long'||game.layout=='long2'||game.layout=='nova'); }, - singleHandcard:function(){ - if(game.singleHandcard||game.layout=='mobile'||game.layout=='long'||game.layout=='long2'||game.layout=='nova'){ - return true; - } - return false; - }, - linked2:function(player){ + singleHandcard:()=>game.singleHandcard||game.layout=='mobile'||game.layout=='long'||game.layout=='long2'||game.layout=='nova', + linked2:player=>{ if(game.chess) return true; if(lib.config.link_style2!='rotate') return true; // if(game.chess) return false; @@ -57003,14 +56958,9 @@ } return false; }, - empty:function(obj){ - for(var i in obj) return false; - return true; - }, - pos:function(str){ - return (str=='h'||str=='e'||str=='j'||str=='he'||str=='hj'||str=='ej'||str=='hej'); - }, - locked:function(skill,player){ + empty:obj=>Object.keys(obj).length==0, + pos:str=>str=='h'||str=='e'||str=='j'||str=='he'||str=='hj'||str=='ej'||str=='hej', + locked:(skill,player)=>{ var info=lib.skill[skill]; if(typeof info.locked=='function') return info.locked(skill,player); if(info.locked==false) return false; @@ -57020,7 +56970,7 @@ return false; }, }, - bottomCards:function(num,putBack){ + bottomCards:(num,putBack)=>{ if(_status.waitingForCards){ ui.create.cards.apply(ui.create,_status.waitingForCards); delete _status.waitingForCards; @@ -57051,21 +57001,13 @@ if(card) return list[0]; return list; }, - discarded:function(){ - var list=_status.discarded.slice(0); - for(var i=0;i_status.discarded.filter(item=>item.parentNode==ui.discardPile), + cardOffset:()=>{ var x=ui.arena.getBoundingClientRect(); var y=ui.window.getBoundingClientRect(); return -y.width/2+(x.left+x.width/2); }, - colorspan:function(str){ + colorspan:str=>{ if(str[0]=='#'){ var color; switch(str[1]){ @@ -57079,7 +57021,7 @@ } return str; }, - evtprompt:function(next,str){ + evtprompt:(next,str)=>{ if(next.prompt){ next.set('prompt2',str); } @@ -57094,7 +57036,7 @@ } } }, - autoViewAs:function(card,cards){ + autoViewAs:(card,cards)=>{ let _card; if(get.itemtype(card)=='card'){ _card={ @@ -57186,7 +57128,7 @@ return card; } }, - max:function(list,func,type){ + max:(list,func,type)=>{ list=list.slice(0); if(typeof func=='string'){ var key=func; @@ -57213,7 +57155,7 @@ return func(list[0]); } }, - min:function(list,func,type){ + min:(list,func,type)=>{ list=list.slice(0); if(typeof func=='string'){ var key=func; @@ -57240,7 +57182,7 @@ return func(list[0]); } }, - character:function(name,num){ + character:(name,num)=>{ let info=lib.character[name]; if(!info){ const pack=Object.keys(lib.characterPack).find(pack=>lib.characterPack[pack].hasOwnProperty(name)); @@ -57254,7 +57196,7 @@ } return null; }, - characterIntro:function(name){ + characterIntro:name=>{ if(lib.characterIntro[name]) return lib.characterIntro[name]; var tags=get.character(name,4); if(tags){ @@ -57280,7 +57222,7 @@ } return raw?'':info[1]||''; }, - groupnature:function(group,method){ + groupnature:(group,method)=>{ var nature=lib.groupnature[group]; if(!nature) return ''; if(method=='raw'){ @@ -57288,12 +57230,12 @@ } return nature+'mm'; }, - sgn:function(num){ + sgn:num=>{ if(num>0) return 1; if(num<0) return -1; return 0; }, - rand:function(num,num2){ + rand:(num,num2)=>{ if(typeof num2=='number'){ return num+Math.floor(Math.random()*(num2-num+1)); } @@ -57301,23 +57243,9 @@ return Math.floor(Math.random()*num); } }, - sort:function(arr,method){ - switch(method){ - case 'seat':{ - lib.tempSortSeat=arguments[2]; - arr.sort(lib.sort.seat); - delete lib.tempSortSeat; - return arr; - } - } - }, - sortSeat:function(arr,target){ - lib.tempSortSeat=target; - arr.sort(lib.sort.seat); - delete lib.tempSortSeat; - return arr; - }, - zip:function(callback){ + sort:(arr,method,arg)=>method=="seat"?arr.sortBySeat(arg):void 0, + sortSeat:(arr,target)=>arr.sortBySeat(target), + zip:callback=>{ if(!window.JSZip){ lib.init.js(lib.assetURL+'game','jszip',function(){ callback(new JSZip()); @@ -57327,7 +57255,7 @@ callback(new JSZip()); } }, - delayx:function(num,max){ + delayx:(num,max)=>{ if(typeof num!='number') num=1; if(typeof max!='number') max=Infinity; switch(lib.config.game_speed){ @@ -57339,7 +57267,7 @@ default:return Math.min(max,num); } }, - prompt:function(skill,target,player){ + prompt:(skill,target,player)=>{ player=player||_status.event.player; if(target){ var str=get.translation(target); @@ -57352,12 +57280,12 @@ return '是否发动【'+get.skillTranslation(skill,player)+'】?'; } }, - prompt2:function(skill,target,player){ + prompt2(skill,target,player){ var str=get.prompt.apply(this,arguments); if(!lib.translate[skill+'_info']) return str; return '###'+str+'###'+lib.translate[skill+'_info']; }, - url:function(master){ + url:master=>{ var url=lib.config.updateURL||lib.updateURL; if(url[url.length-1]!='/'){ url+='/'; @@ -57369,14 +57297,11 @@ return url+'v'+lib.version+'/'; } }, - round:function(num,f){ - var round=1; - for(var i=0;i{ + var round=10**f; return Math.round(num*round)/round; }, - playerNumber:function(){ + playerNumber:()=>{ var num; if(_status.brawl&&_status.brawl.playerNumber){ num=_status.brawl.playerNumber @@ -57386,7 +57311,7 @@ } return parseInt(num)||2; }, - benchmark:function(func1,func2,iteration,arg){ + benchmark:(func1,func2,iteration,arg)=>{ var tic,toc; var key1,key2; if(!arg) arg=[]; @@ -57428,7 +57353,7 @@ toc=get.utc(); console.log('time2: '+(toc-tic)); }, - stringify:function(obj,level){ + stringify:(obj,level)=>{ level=level||0; var indent=''; var str; @@ -57485,7 +57410,7 @@ return str; } }, - copy:function(obj){ + copy:obj=>{ if(get.objtype(obj)=='object'){ var copy={}; for(var i in obj){ @@ -57504,7 +57429,7 @@ return obj; } }, - inpilefull:function(type){ + inpilefull:(type)=>{ var list=[]; for(var i in lib.cardPile){ for(var j=0;j{ var list=[]; if(filter=='trick'){ for(var i=0;iget.inpile(type,'trick'), + typeCard:(type,filter)=>{ var list=[]; for(var i in lib.card){ if(lib.card[i].mode&&lib.card[i].mode.contains(get.mode())==false) continue; @@ -57571,7 +57494,7 @@ } return list; }, - libCard:function(filter){ + libCard:filter=>{ var list=[]; for(var i in lib.card){ if(lib.card[i].mode&&lib.card[i].mode.contains(get.mode())==false) continue; @@ -57585,7 +57508,7 @@ } return list; }, - ip:function(){ + ip:()=>{ if(!require) return ''; var interfaces = require('os').networkInterfaces(); for(var devName in interfaces){ @@ -57598,7 +57521,7 @@ } } }, - modetrans:function(config,server){ + modetrans:(config,server)=>{ if(config.mode=='doudizhu'){ switch(config.doudizhu_mode){ case 'kaihei':return '开黑斗地主'; @@ -57646,7 +57569,7 @@ } } }, - charactersOL:function(func){ + charactersOL:func=>{ var list=[]; var libCharacter={}; for(var i=0;i{ var len=str.length-5; if(str.lastIndexOf(':8080')==len){ str=str.slice(0,len); @@ -57671,15 +57594,8 @@ return str; }, mode:()=>lib[_status.connectMode?'configOL':'config'].mode, - idDialog:function(id){ - for(var i=0;iui.dialogs.find(dialog=>dialog.videoId==id)||null, + arenaState:()=>{ var state={ number:ui.arena.dataset.number, players:{}, @@ -57697,7 +57613,7 @@ } return state; }, - skillState:function(player){ + skillState:player=>{ var skills={ global:lib.skill.global }; @@ -57724,10 +57640,8 @@ } return skills; }, - id:function(){ - return (Math.floor(1000000+9000000*Math.random())).toString()+(10+lib.status.globalId++); - }, - zhu:function(player,skill,group){ + id:()=>(Math.floor(1000000+9000000*Math.random())).toString()+(10+lib.status.globalId++), + zhu:(player,skill,group)=>{ if(typeof player=='string'){ skill=player; player=null; @@ -57772,12 +57686,12 @@ } return null; }, - config:function(item,mode){ + config:(item,mode)=>{ mode=mode||lib.config.mode; if(!lib.config.mode_config[mode]) return; return lib.config.mode_config[mode][item]; }, - coinCoeff:function(list){ + coinCoeff:list=>{ var num=0; for(var i=0;i{ if(typeof name=='object'&&name.name){ name=name.name; } @@ -57842,7 +57756,7 @@ } return num?Math.round(9*(num-1)/8+1):'x'; }, - skillRank:function(skill,type,grouped){ + skillRank:(skill,type,grouped)=>{ var info=lib.skill[skill]; var player=_status.event.skillRankPlayer||_status.event.player; if(!info) return 0; @@ -57936,48 +57850,26 @@ } return num; }, - targetsInfo:function(targets){ + targetsInfo:targets=>{ var info=[]; for(var i=0;iinfos.map(info=>game.playerMap[info]), + cardInfo:card=>[card.suit,card.number,card.name,card.nature], + cardsInfo:cards=>cards.map(get.cardInfo), + infoCard:info=>{ var card=ui.create.card(); if(info[0]){ card.init(info); } return card; }, - infoCards:function(info){ - var cards=[]; - for(var i=0;iinfos.map(get.infoCard), + cardInfoOL:card=>'_noname_card:'+JSON.stringify([card.cardid,card.suit,card.number,card.name,card.nature]), + infoCardOL:info=>{ if(!lib.cardOL) return info; var card; try{ @@ -58005,42 +57897,13 @@ } return card||info; }, - cardsInfoOL:function(cards){ - var info=[]; - for(var i=0;icards.map(get.cardInfoOL), + infoCardsOL:infos=>infos.map(get.infoCardOL), + playerInfoOL:player=>'_noname_player:'+player.playerid, + infoPlayerOL:info=>lib.playerOL?(lib.playerOL[info.slice(15)]||info):info, + playersInfoOL:players=>players.map(get.playerInfoOL), + infoPlayersOL:infos=>infos.map(get.infoPlayerOL), + funcInfoOL:func=>{ if(typeof func=='function'){ if(func._filter_args){ return '_noname_func:'+JSON.stringify(get.stringifiedResult(func._filter_args,3)); @@ -58049,7 +57912,7 @@ } return ''; }, - infoFuncOL:function(info){ + infoFuncOL:info=>{ var func; try{ eval('func=('+info.slice(13)+');'); @@ -58062,7 +57925,7 @@ } return func; }, - eventInfoOL:function(item,level,nomore){ + eventInfoOL:(item,level,nomore)=>{ if(Object.prototype.toString.call(item)=='[object Object]'){ var item2={}; for(var i in item){ @@ -58079,7 +57942,7 @@ return ''; } }, - infoEventOL:function(item){ + infoEventOL:item=>{ var evt; try{ evt=JSON.parse(item.slice(14)); @@ -58093,7 +57956,7 @@ } return evt||item; }, - stringifiedResult:function(item,level,nomore){ + stringifiedResult:(item,level,nomore)=>{ if(!item) return item; if(typeof item=='function'){ return get.funcInfoOL(item); @@ -58143,7 +58006,7 @@ return item; } }, - parsedResult:function(item){ + parsedResult:item=>{ if(!item) return item; if(typeof item=='string'){ if(item.startsWith('_noname_func:')){ @@ -58183,11 +58046,11 @@ return item; } }, - verticalStr:function(str,sp){ + verticalStr:(str,sp)=>{ if(typeof str!='string') return ''; return Array.from(str).filter(value=>value!='`').join(''); }, - numStr:function(num,method){ + numStr:(num,method)=>{ if(num==Infinity){ if(method=='card') return get.selectableCards().length+ui.selected.cards.length; if(method=='target') return get.selectableTargets().length+ui.selected.targets.length; @@ -58195,7 +58058,7 @@ } return num.toString(); }, - rawName:function(str){ + rawName:str=>{ let str2=lib.translate[str]; if(lib.translate[str+'_ab']) str2=lib.translate[str+'_ab']; if(!str2) return ''; @@ -58205,7 +58068,7 @@ return str2; }, //作用修改:只读前缀 不读_ab - rawName2:function(str){ + rawName2:str=>{ let str2=lib.translate[str]; if(!str2) return ''; if(lib.translate[str+'_prefix']&&str2.startsWith(lib.translate[str+'_prefix'])){ @@ -58242,10 +58105,8 @@ if(config=='simple') return `${prefix}` return `${prefix}` }, - slimName:function(str){ - return get.verticalStr(get.slimNameHorizontal(str),true); - }, - time:function(){ + slimName:str=>get.verticalStr(get.slimNameHorizontal(str),true), + time:()=>{ if(lib.status.dateDelaying){ return lib.getUTC(lib.status.dateDelaying)-lib.getUTC(lib.status.date)-lib.status.dateDelayed; } @@ -58253,18 +58114,14 @@ return lib.getUTC(new Date())-lib.getUTC(lib.status.date)-lib.status.dateDelayed; } }, - utc:function(){ - return (new Date()).getTime(); - }, - evtDistance:function(e1,e2){ + utc:()=>(new Date()).getTime(), + evtDistance:(e1,e2)=>{ var dx=(e1.clientX-e2.clientX)/game.documentZoom; var dy=(e1.clientY-e2.clientY)/game.documentZoom; return Math.sqrt(dx*dx+dy*dy); }, - xyDistance:function(from,to){ - return Math.sqrt((from[0]-to[0])*(from[0]-to[0])+(from[1]-to[1])*(from[1]-to[1])); - }, - itemtype:function(obj){ + xyDistance:(from,to)=>Math.sqrt((from[0]-to[0])*(from[0]-to[0])+(from[1]-to[1])*(from[1]-to[1])), + itemtype:obj=>{ var i,j; if(typeof obj=='string'){ if(obj.length<=5){ @@ -58316,13 +58173,13 @@ if(obj.isMine==lib.element.event.isMine) return 'event'; } }, - equipNum:function(card){ + equipNum:card=>{ if(get.type(card)=='equip'){ return parseInt(get.subtype(card)[5]); } return 0; }, - objtype:function(obj){ + objtype:obj=>{ if(Object.prototype.toString.call(obj) === '[object Array]') return 'array'; if(Object.prototype.toString.call(obj) === '[object Object]') return 'object'; if(Object.prototype.toString.call(obj) === '[object HTMLDivElement]') return 'div'; @@ -58331,7 +58188,7 @@ if(Object.prototype.toString.call(obj) === '[object HTMLTableCellElement]') return 'td'; if(Object.prototype.toString.call(obj) === '[object HTMLBodyElement]') return 'td'; }, - type:function(obj,method,player){ + type:(obj,method,player)=>{ if(typeof obj=='string') obj={name:obj}; if(typeof obj!='object') return; var name=get.name(obj,player); @@ -58339,22 +58196,20 @@ if(method=='trick'&&lib.card[name].type=='delay') return 'trick'; return lib.card[name].type; }, - type2:function(card,player){ - return get.type(card,'trick',player); - }, - subtype:function(obj,player){ + type2:(card,player)=>get.type(card,'trick',player), + subtype:(obj,player)=>{ if(typeof obj=='string') obj={name:obj}; if(typeof obj!='object') return; var name=get.name(obj,player); if(!lib.card[name]) return; return lib.card[name].subtype; }, - equiptype:function(card,player){ + equiptype:(card,player)=>{ var subtype=get.subtype(card,player); if(subtype.startsWith('equip')) return parseInt(subtype[5]); return 0; }, - name:function(card,player){ + name:(card,player)=>{ if(get.itemtype(player)=='player'||(player!==false&&get.position(card)=='h')){ var owner=player||get.owner(card); if(owner){ @@ -58363,7 +58218,7 @@ } return card.name; }, - suit:function(card,player){ + suit:(card,player)=>{ if(!card) return; if(Array.isArray(card)){ if(card.length==1) return get.suit(card[0],player); @@ -58376,14 +58231,14 @@ if(player!==false){ const owner=player||get.owner(card); if(owner){ - return game.checkMod(card,card.suit,'suit',owner); + return game.checkMod(card,owner,game.checkMod(card,card.suit,'suit',owner),'cardsuit',owner); } } if(lib.suits.contains(card.suit)) return card.suit; return 'none'; } }, - color:function(card,player){ + color:(card,player)=>{ if(!card) return; if(Array.isArray(card)){ if(!card.length) return 'none'; @@ -58407,7 +58262,7 @@ return 'none'; } }, - number:function(card,player){ + number:(card,player)=>{ if(!card) return; //狗卡你是真敢出啊 var number=null; @@ -58427,7 +58282,7 @@ return number; }, //返回一张杀的属性。如有多种属性则用 lib.natureSeparator 分割开来。例:火雷【杀】的返回值为 fire|thunder - nature:function(card,player){ + nature:(card,player)=>{ if(typeof card=='string') return card.split(lib.natureSeparator).sort(lib.sort.nature).join(lib.natureSeparator); if(Array.isArray(card)) return card.sort(lib.sort.nature).join(lib.natureSeparator); var nature=card.nature; @@ -58440,7 +58295,7 @@ return nature; }, //返回包含所有属性的数组 - natureList:function(card,player){ + natureList(card,player){ if(!card) return []; if(get.itemtype(card)=='natures') return card.split(lib.natureSeparator); if(get.itemtype(card)=='nature') return [card]; @@ -58448,7 +58303,7 @@ if(typeof natures!='string') return []; return natures.split(lib.natureSeparator); }, - cards:function(num,putBack){ + cards:(num,putBack)=>{ if(_status.waitingForCards){ ui.create.cards.apply(ui.create,_status.waitingForCards); delete _status.waitingForCards; @@ -58479,15 +58334,9 @@ if(card) return list[0]; return list; }, - judge:function(card){ - if(card.viewAs) return lib.card[card.viewAs].judge; - return get.info(card).judge; - }, - judge2:function(card){ - if(card.viewAs) return lib.card[card.viewAs].judge2; - return get.info(card).judge2; - }, - distance:function(from,to,method){ + judge:card=>card.viewAs?lib.card[card.viewAs].judge:get.info(card).judge, + judge2:card=>card.viewAs?lib.card[card.viewAs].judge2:get.info(card).judge2, + distance:(from,to,method)=>{ if(from==to) return 0; if(!game.players.contains(from)&&!game.dead.contains(from)) return Infinity; if(!game.players.contains(to)&&!game.dead.contains(to)) return Infinity; @@ -58566,7 +58415,7 @@ else if(method=='unchecked') return n; return Math.max(1,n); }, - info:function(item,player){ + info:(item,player)=>{ if(typeof item=='string'){ return lib.skill[item]; } @@ -58576,13 +58425,13 @@ return lib.card[name]; } }, - select:function(select){ + select:select=>{ if(typeof select=='number') return [select,select]; if(get.itemtype(select)=='select') return select; if(typeof select=='function') return get.select(select()); return [1,1] }, - card:function(original){ + card:original=>{ if(_status.event.skill){ var card=get.info(_status.event.skill).viewAs; if(typeof card=='function') card=card(ui.selected.cards,_status.event.player); @@ -58600,31 +58449,19 @@ } return card; }, - player:function(){ - return _status.event.player; - }, - players:function(sort,dead,out){ + event:key=>key?_status.event[key]:_status.event, + player:()=>_status.event.player, + players:(sort,dead,out)=>{ var players=game.players.slice(0); if(sort!=false){ - if(typeof sort=='function'){ - players.sort(sort); - } - else{ - if(get.itemtype(sort)!='player') lib.tempSortSeat=_status.event.player; - else lib.tempSortSeat=sort; - players.sort(lib.sort.seat); - delete lib.tempSortSeat; - } + if(typeof sort=='function') players.sort(sort); + else players.sortBySeat(get.itemtype(sort)=="player"?sort:_status.event.player); } if(dead) players=players.concat(game.dead); - if(!out){ - for(var i=0;i!current.isOut()); return players; }, - position:function(card,ordering){ + position:(card,ordering)=>{ if(get.itemtype(card)=='player') return parseInt(card.dataset.position); if(card.timeout&&card.destiny&&card.destiny.classList){ if(card.destiny.classList.contains('equips')) return 'e'; @@ -58648,7 +58485,7 @@ if(card.parentNode.id=='ordering') return ordering?'o':'d'; return null; }, - skillTranslation:function(str,player){ + skillTranslation:(str,player)=>{ var str2; if(str.startsWith('re')){ str2=str.slice(2); @@ -58672,7 +58509,7 @@ } return get.translation(str); }, - skillInfoTranslation:function(name,player){ + skillInfoTranslation:(name,player)=>{ if(player&&lib.dynamicTranslate[name]) return lib.dynamicTranslate[name](player,name); var str=lib.translate[name+'_info']; if(!str) return ''; @@ -58685,7 +58522,7 @@ // replace(/阵法技/g,'阵法技'). // replace(/主公技/g,'主公技'); }, - translation:function(str,arg){ + translation:(str,arg)=>{ if(str&&typeof str=='object'&&(str.name||str._tempTranslate)){ if(str._tempTranslate) return str._tempTranslate; var str2; @@ -58781,7 +58618,7 @@ } return ''; }, - strNumber:function(num){ + strNumber:num=>{ switch(num){ case 1:return 'A'; case 11:return 'J'; @@ -58790,7 +58627,7 @@ default:return num.toString(); } }, - cnNumber:function(num,two){ + cnNumber:(num,two)=>{ if(num==Infinity) return '∞'; if(isNaN(num)) return ''; if(typeof num!='number') return num; @@ -58816,7 +58653,7 @@ var x=Math.floor(num/10); return get.cnNumber(x,true)+'十'+(num>10*x?get.cnNumber(num-10*x,true):''); }, - selectableButtons:function(sort){ + selectableButtons:sort=>{ if(!_status.event.player) return[]; var buttons=_status.event.dialog.buttons; var selectable=[]; @@ -58831,7 +58668,7 @@ } return selectable; }, - selectableCards:function(sort){ + selectableCards:sort=>{ if(!_status.event.player) return[]; var cards=_status.event.player.getCards('hes'); var selectable=[]; @@ -58846,7 +58683,7 @@ } return selectable; }, - skills:function(){ + skills:()=>{ var skills=[]; if(ui.skills){ skills=skills.concat(ui.skills.skills); @@ -58859,7 +58696,7 @@ } return skills; }, - gainableSkills:function(func,player){ + gainableSkills:(func,player)=>{ var list=[]; for(var i in lib.character){ if(lib.filter.characterDisabled(i)) continue; @@ -58881,7 +58718,7 @@ } return list; }, - gainableSkillsName:function(name, func){ + gainableSkillsName:(name,func)=>{ var list=[]; if(name&&lib.character[name]){ if(lib.character[name][4]){ @@ -58900,7 +58737,7 @@ } return list; }, - gainableCharacters:function(func){ + gainableCharacters:func=>{ var list=[]; for(var i in lib.character){ var info=lib.character[i]; @@ -58920,7 +58757,7 @@ } return list; }, - selectableTargets:function(sort){ + selectableTargets:sort=>{ var selectable=[]; var players=game.players.slice(0); if(_status.event.deadTarget) players.addArray(game.dead); @@ -58936,7 +58773,7 @@ } return selectable; }, - filter:function(filter,i){ + filter(filter,i){ if(typeof filter=='function') return filter; if(i==undefined) i=0; var result=function(){ @@ -59033,29 +58870,13 @@ if(num==undefined) return 0; return num; }, - owner:function(card,method){ - var list=game.players.concat(game.dead); - for(var i=0;igame.players.concat(game.dead).find(current=> + current.getCards("hejsx").includes(card)||(current.judging[0]==card&&method!="judge")), + noSelected:()=>ui.selected.buttons.length+ui.selected.cards.length+ui.selected.targets.length==0, + population:identity=>identity==undefined? + game.players.length+game.dead.length: + game.players.filter(current=>current.identity==identity), + totalPopulation:identity=>{ if(identity==undefined) return game.players.length+game.dead.length; var i,players=game.players.concat(game.dead); var num=0; @@ -59064,14 +58885,14 @@ } return num; }, - cardtag:function(item,tag){ + cardtag:(item,tag)=>{ if(item.cardid&&(get.itemtype(item)=='card'||!item.cards||!item.cards.length||item.name==item.cards[0].name)&&_status.cardtag&&_status.cardtag[tag]&&_status.cardtag[tag].contains(item.cardid)){ return true; } if(item.cardtags&&item.cardtags.contains(tag)) return true; return false; }, - tag:function(item,tag,item2,bool){ + tag:(item,tag,item2,bool)=>{ var result; if(get.info(item)&&get.info(item).ai&&get.info(item).ai.tag){ result=get.info(item,bool).ai.tag[tag]; @@ -59079,7 +58900,7 @@ if(typeof result=='function') return result(item,item2); return result; }, - sortCard:function(sort){ + sortCard:sort=>{ var func; if(sort=='type_sort'){ func=function(card){ @@ -59116,7 +58937,7 @@ } return func; }, - difficulty:function(){ + difficulty:()=>{ switch(get.config('difficulty')){ case 'easy':return 1; case 'normal':return 2; @@ -59124,7 +58945,7 @@ default: return 1; } }, - cardPile:function(name,create){ + cardPile:(name,create)=>{ var filter=function(card){ if(typeof name=='string'){ if(card.name==name){ @@ -59175,13 +58996,9 @@ } return null; }, - cardPile2:function(name){ - return get.cardPile(name,'cardPile'); - }, - discardPile:function(name){ - return get.cardPile(name,'discardPile'); - }, - aiStrategy:function(){ + cardPile2:name=>get.cardPile(name,'cardPile'), + discardPile:name=>get.cardPile(name,'discardPile'), + aiStrategy:()=>{ switch(get.config('ai_strategy')){ case 'ai_strategy_1':return 1; case 'ai_strategy_2':return 2; @@ -59192,7 +59009,7 @@ default: return 1; } }, - skillintro:function(name,learn,learn2){ + skillintro:(name,learn,learn2)=>{ var str=''; var infoitem=lib.character[name]; if(!infoitem){ @@ -59220,7 +59037,7 @@ } return str; }, - intro:function(name){ + intro:name=>{ var info=lib.character[name]; var str='性别:'+get.translation(info[0])+'
'; str+='势力:'+get.translation(info[1])+'
'; @@ -59234,7 +59051,7 @@ } return str; }, - storageintro:function(type,content,player,dialog,skill){ + storageintro:(type,content,player,dialog,skill)=>{ switch(type){ case 'mark':{ if(content>0){ @@ -59342,7 +59159,7 @@ } } }, - nodeintro:function(node,simple,evt){ + nodeintro:(node,simple,evt)=>{ var uiintro=ui.create.dialog('hidden','notouchscroll'); if(node.classList.contains('player')&&!node.name){ return uiintro; @@ -60415,7 +60232,7 @@ } return uiintro; }, - linkintro:function(dialog,content,player){ + linkintro:(dialog,content,player)=>{ dialog.content.firstChild.remove(); dialog.add('
已横置
'); var list=[]; @@ -60428,10 +60245,8 @@ dialog.add(list,true,true); } }, - groups:function(){ - return ['wei','shu','wu','qun','jin','western','key']; - }, - types:function(){ + groups:()=>['wei','shu','wu','qun','jin','western','key'], + types:()=>{ var types=[]; for(var i in lib.card){ if(lib.card[i].mode&&lib.card[i].mode.contains(lib.config.mode)==false) continue; @@ -60443,14 +60258,14 @@ } return types; }, - links:function(buttons){ + links:buttons=>{ var links=[]; for(var i=0;i{ var threaten=1; var skills=target.getSkills(); if(!player&&player!==false){ @@ -60482,7 +60297,7 @@ } return threaten; }, - condition:function(player){ + condition:player=>{ var num=player.hp; if(num>4){ num=4+Math.sqrt(num-4); @@ -60507,7 +60322,7 @@ } return num; }, - attitude:function(from,to){ + attitude(from,to){ if(!from||!to) return 0; from=from._trueMe||from; arguments[0]=from; @@ -60533,10 +60348,10 @@ } return att; }, - sgnAttitude:function(){ + sgnAttitude(){ return get.sgn(get.attitude.apply(this,arguments)); }, - useful_raw:function(card,player){ + useful_raw:(card,player)=>{ if(get.position(card)=='j') return -1; if(get.position(card)=='e') return get.equipValue(card); if(card._modUseful){ @@ -60571,23 +60386,19 @@ result=game.checkMod(player,card,result,'aiUseful',player); return result; }, - useful:function(card,player){ + useful:(card,player)=>{ if(_status.event.useCache){ return game.callFuncUseStepCache("get.useful_raw",get.useful_raw,[card,player]); } return get.useful_raw(card,player); }, - unuseful:function(card){ - return -get.useful(card); - }, - unuseful2:function(card){ - return 10-get.useful(card); - }, - unuseful3:function(card){ + unuseful:card=>-get.useful(card), + unuseful2:card=>10-get.useful(card), + unuseful3:card=>{ if(card.name=='du') return 20; return 10-get.useful(card); }, - value:function(card,player,method){ + value:(card,player,method)=>{ var result=0; var value; if(Array.isArray(card)){ @@ -60626,7 +60437,7 @@ result=game.checkMod(player,card,result,'aiValue',player); return result; }, - equipResult:function(player,target,name){ + equipResult:(player,target,name)=>{ var card=get.card(); if(!card||card.name!=name){ card={name:name}; @@ -60645,7 +60456,7 @@ } return Math.max(0,value1-value2)/5; }, - equipValue:function(card,player){ + equipValue:(card,player)=>{ if(player==undefined||get.itemtype(player)!='player') player=get.owner(card); if(player==undefined||get.itemtype(player)!='player') player=_status.event.player; var info=get.info(card); @@ -60661,7 +60472,7 @@ if(typeof value=='function') return value(card,player,null,'raw2'); return 0; }, - equipValueNumber:function(card){ + equipValueNumber:card=>{ var info=get.info(card); if(info.ai){ if(typeof info.ai.equipValue=='number') return info.ai.equipValue; @@ -60669,13 +60480,9 @@ } return 0; }, - disvalue:function(card,player){ - return -get.value(card,player); - }, - disvalue2:function(card,player){ - return -get.value(card,player,'raw'); - }, - skillthreaten:function(skill,player,target){ + disvalue:(card,player)=>-get.value(card,player), + disvalue2:(card,player)=>-get.value(card,player,'raw'), + skillthreaten:(skill,player,target)=>{ if(!lib.skill[skill]) return 1; if(!lib.skill[skill].ai) return 1; var threaten=lib.skill[skill].ai.threaten; @@ -60687,7 +60494,7 @@ } return 1; }, - order:function(item){ + order:item=>{ var info=get.info(item); if(!info) return -1; var aii=info.ai; @@ -60705,7 +60512,7 @@ } return num; }, - result:function(item,skill){ + result:(item,skill)=>{ var result; var info=get.info(item); if(info.ai) result=get.copy(info.ai.result); @@ -60722,7 +60529,7 @@ } return result; }, - effect_use:function(target,card,player,player2,isLink){ + effect_use:(target,card,player,player2,isLink)=>{ var event=_status.event; var eventskill=null; if(player==undefined) player=_status.event.player; @@ -60916,7 +60723,7 @@ } return final; }, - effect:function(target,card,player,player2,isLink){ + effect:(target,card,player,player2,isLink)=>{ var event=_status.event; var eventskill=null; if(player==undefined) player=_status.event.player; @@ -61089,7 +60896,7 @@ } return final; }, - damageEffect:function(target,player,viewer,nature){ + damageEffect:(target,player,viewer,nature)=>{ if(get.itemtype(nature)=='natures'){ var natures=get.natureList(nature); return natures.map(n=>get.damageEffect(target,player,viewer,n)).reduce((p,c)=>p+c,0)/(natures.length||1); @@ -61114,7 +60921,7 @@ if(eff>0&&target.hujia>0) return eff/1.3; return eff; }, - recoverEffect:function(target,player,viewer){ + recoverEffect:(target,player,viewer)=>{ if(target.hp==target.maxHp) return 0; if(!player){ player=target; @@ -61124,7 +60931,7 @@ } return get.effect(target,{name:'recover'},player,viewer); }, - buttonValue:function(button){ + buttonValue:button=>{ var card=button.link; var player=get.owner(card); if(!player) player=_status.event.player; @@ -61158,9 +60965,7 @@ default:return 0.4; } }, - attitude2:function(to){ - return get.attitude(_status.event.player,to); - }, + attitude2:to=>get.attitude(_status.event.player,to) }; const ai={ basic:{