From dd1d1ddff4e3f9f8fd9ea5d60f4972e82fda779f Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 28 Sep 2023 18:34:50 +0800 Subject: [PATCH 1/9] all and none filter. --- game/game.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/game/game.js b/game/game.js index 277770392..560fb49dd 100644 --- a/game/game.js +++ b/game/game.js @@ -30476,9 +30476,8 @@ }, }, filter:{ - all:function(){ - return true; - }, + all:()=>true, + none:()=>false, //Check if the card does not count toward the player's hand limit //检测此牌是否不计入此角色的手牌上限 ignoredHandcard:(card,player)=>game.checkMod(card,player,false,'ignoredHandcard',player), From dfa9dc49c7bfadcfe06854814d56ca5d230ea3b7 Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 28 Sep 2023 18:48:55 +0800 Subject: [PATCH 2/9] add `linq.dom.inject`. --- game/game.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/game/game.js b/game/game.js index 560fb49dd..62958d90b 100644 --- a/game/game.js +++ b/game/game.js @@ -7788,6 +7788,39 @@ class:function(){return `.${Array.from(arguments).join(".")}`;}, group:function(){return Array.from(arguments).join(",");}, media:type=>`@media ${type}` + }, + dom:{ + inject(element,options){ + //处理id和class + if(options.identity){ + for(const item of options.identity){ + if (test.indexOf("#")==0) element.id = item.slice(1); + else element.classList.add(item); + } + } + //处理样式 + if(options.style){ + for(const item in options.style) element.style[item] = options.style[item]; + } + //处理内容 + if(options.content){ + element.innerHTML=options.content; + } + //处理位置 + if(options.position){ + if(options.position2){ + options.position.insertBefore(element, options.position.childNodes[options.position2]); + } + else options.position.appendChild(element); + } + //处理子元素 + if(options.childs){ + for(const item of options.childs){ + element.appendChild(item); + } + } + return element; + } } }, init:{ From 54964c8bd47d212a5ec6476ae086889fac0bd4f7 Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 28 Sep 2023 18:57:13 +0800 Subject: [PATCH 3/9] add `linq.dom.generate`. --- game/game.js | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/game/game.js b/game/game.js index 62958d90b..9abfdbbf8 100644 --- a/game/game.js +++ b/game/game.js @@ -7806,13 +7806,6 @@ if(options.content){ element.innerHTML=options.content; } - //处理位置 - if(options.position){ - if(options.position2){ - options.position.insertBefore(element, options.position.childNodes[options.position2]); - } - else options.position.appendChild(element); - } //处理子元素 if(options.childs){ for(const item of options.childs){ @@ -7820,6 +7813,35 @@ } } return element; + }, + generate(){ + let result=lib.creation.nullObject; + const args=Array.from(arguments); + for(const item of args) { + switch(typeof item) { + case "object": + switch (item.constructor) { + case Object: + case null: + result.style=item; + break; + default: + if(!("childs" in result)) result.childs=lib.creation.array; + result.childs.add(item); + break; + } + break; + case "string": + if(/^\.|#/.test(item)){ + if(!("identity" in result)) result.identity=lib.creation.array; + const identities=item.split(".").filter(Boolean); + for(const item of identities) result.identity.add(item); + } + else result.content = item; + break; + } + } + return result; } } }, From b6b4d10befce3bab4d4e88967d8341d6b816de2a Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 28 Sep 2023 19:04:47 +0800 Subject: [PATCH 4/9] add basic div creation. --- game/game.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/game/game.js b/game/game.js index 9abfdbbf8..8bd2c36cf 100644 --- a/game/game.js +++ b/game/game.js @@ -7842,6 +7842,10 @@ } } return result; + }, + div(){ + const dom=lib.linq.dom; + return dom.inject(document.createElement("div"),dom.generate(...arguments)); } } }, From a662ae8afacb220e24a23e33ce8f742e0cbf59de Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 28 Sep 2023 19:10:04 +0800 Subject: [PATCH 5/9] add attr linq generate. --- game/game.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/game/game.js b/game/game.js index 8bd2c36cf..4ea00d510 100644 --- a/game/game.js +++ b/game/game.js @@ -7823,7 +7823,17 @@ switch (item.constructor) { case Object: case null: - result.style=item; + if("_type" in item){ + const type=item["_type"]; + if(!(type in result)) result[type]=lib.creation.nullObject; + result[type][item.name]=item.value; + } + else{ + if(!("style" in result)) result.style=lib.creation.nullObject; + for(const name in item){ + result.style[name]=item[name]; + } + } break; default: if(!("childs" in result)) result.childs=lib.creation.array; @@ -7843,6 +7853,13 @@ } return result; }, + attr(name,value){ + return { + _type:"attributes", + name:name, + value:value + } + }, div(){ const dom=lib.linq.dom; return dom.inject(document.createElement("div"),dom.generate(...arguments)); From b10b449a0d5328063fdbd172c993cd9d1a15ae09 Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 28 Sep 2023 19:12:11 +0800 Subject: [PATCH 6/9] add style linq generate. --- game/game.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/game/game.js b/game/game.js index 4ea00d510..68270e78b 100644 --- a/game/game.js +++ b/game/game.js @@ -7860,6 +7860,13 @@ value:value } }, + stl(name,value){ + return { + _type:"style", + name:name, + value:value + } + }, div(){ const dom=lib.linq.dom; return dom.inject(document.createElement("div"),dom.generate(...arguments)); From e0dd38625b2a6ce0a0648dc2f5ccfca50a17a866 Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 28 Sep 2023 19:13:36 +0800 Subject: [PATCH 7/9] parse attributes in `linq.dom.inject`. --- game/game.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/game/game.js b/game/game.js index 68270e78b..bcac361b6 100644 --- a/game/game.js +++ b/game/game.js @@ -7798,6 +7798,10 @@ else element.classList.add(item); } } + //处理属性 + if(options.attributes){ + for(const item in options.attributes) element.setAttribute(item,options.attributes[item]); + } //处理样式 if(options.style){ for(const item in options.style) element.style[item] = options.style[item]; From 02bd562a45e46df6c88cdcdaab3c8566aaf5a539 Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 28 Sep 2023 19:16:57 +0800 Subject: [PATCH 8/9] fix bug. --- game/game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/game.js b/game/game.js index bcac361b6..829bb9b1e 100644 --- a/game/game.js +++ b/game/game.js @@ -7794,7 +7794,7 @@ //处理id和class if(options.identity){ for(const item of options.identity){ - if (test.indexOf("#")==0) element.id = item.slice(1); + if (item.indexOf("#")==0) element.id = item.slice(1); else element.classList.add(item); } } From 57bfb05ef5c657183df66142f7bd9cc0fc2d2216 Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 28 Sep 2023 20:10:04 +0800 Subject: [PATCH 9/9] change stl position && modify stl name to style. --- game/game.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/game/game.js b/game/game.js index 829bb9b1e..01474270e 100644 --- a/game/game.js +++ b/game/game.js @@ -7790,6 +7790,15 @@ media:type=>`@media ${type}` }, dom:{ + attributes:{ + style(name,value){ + return { + _type:"style", + name:name, + value:value + } + } + }, inject(element,options){ //处理id和class if(options.identity){ @@ -7857,20 +7866,13 @@ } return result; }, - attr(name,value){ + attribute(name,value){ return { _type:"attributes", name:name, value:value } }, - stl(name,value){ - return { - _type:"style", - name:name, - value:value - } - }, div(){ const dom=lib.linq.dom; return dom.inject(document.createElement("div"),dom.generate(...arguments));