From 60a1d59aa4f29bae56a3fc5dd571fa714fd2cf29 Mon Sep 17 00:00:00 2001 From: Tipx-L <138244655+Tipx-L@users.noreply.github.com> Date: Thu, 24 Aug 2023 06:34:39 -0700 Subject: [PATCH] Optimize game.findCards. (cherry picked from commit 7a80e7ed521bf8f54df35e715f026e91682e3164) --- game/game.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/game/game.js b/game/game.js index dcb7e96c9..bb6c35aad 100644 --- a/game/game.js +++ b/game/game.js @@ -38803,18 +38803,12 @@ } return null; }, - findCards:function(func,all){ - var cards=[]; - for(var i in lib.card){ - if(!lib.translate[i+'_info']) continue; - if(lib.card[i].mode&&lib.card[i].mode.contains(lib.config.mode)==false) continue; - if(!all&&!lib.inpile.contains(i)) continue; - if(func(i,lib.card[i])){ - cards.push(i); - } - } - return cards; - }, + findCards:(func,all)=>Object.keys(lib.card).filter(value=>{ + if(!lib.translate[`${value}_info`]) return false; + if(lib.card[value].mode&&lib.card[value].mode.includes(lib.config.mode)==false) return false; + if(!all&&!lib.inpile.includes(value)) return false; + return func(value,lib.card[value]); + }), countGroup:()=>{ const list=lib.group.slice(0); return game.countPlayer(current=>{