From b8d8deb5cf40e9e8ea3a49f285eb4afbe656adae Mon Sep 17 00:00:00 2001 From: Curpond <1713610444@qq.name> Date: Sun, 14 Jan 2024 21:40:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E7=94=B1?= =?UTF-8?q?=E9=80=89=E5=B0=86=E6=97=B6=EF=BC=8C=E8=87=AA=E7=94=B1=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/ui/index.js | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/noname/ui/index.js b/noname/ui/index.js index 705e91cde..1f2fc20dd 100644 --- a/noname/ui/index.js +++ b/noname/ui/index.js @@ -8652,6 +8652,48 @@ class Create extends Uninstantable { clickCapt.call(node[lib.config.character_dialog_tool]); } } + + //仅仅下面是新加的,by Curpond + + let container = dialog.querySelector('.content-container>.content') + let Searcher = ui.create.div('.searcher.caption') + let input = document.createElement('input') + input.style.textAlign = 'center' + input.style.border = 'solid 2px #294510' + input.style.borderRadius = '6px' + input.style.fontWeight = 'bold' + input.style.fontSize = '21px' + let find = ui.create.button(['find', '搜索'], 'tdnodes') + find.style.display = 'inline' + let clickfind = function (e) { + e.stopPropagation() + let value = input.value + if (value == '') { + game.alert('搜索不能为空') + input.focus() + return + } + let list = [] + for (let btn of dialog.buttons) { + + if ((new RegExp(value, 'g').test(get.translation(btn.link)))) { + btn.classList.remove('nodisplay') + } else { + btn.classList.add('nodisplay') + } + } + + } + input.addEventListener('keyup', (e) => { + + if (e.key == 'Enter') clickfind(e) + }) + find.listen(clickfind) + Searcher.appendChild(input) + Searcher.appendChild(find) + container.prepend(Searcher) + + return dialog; } static dialog() { @@ -9624,8 +9666,8 @@ class Create extends Uninstantable { if (get.position(item) == 'j' && item.viewAs && lib.config.cardtempname != 'off') { node.classList.add('infoflip'); node.classList.add('infohidden') - ui.create.cardTempName(item, node).style.setProperty('display','block','important') - + ui.create.cardTempName(item, node).style.setProperty('display', 'block', 'important') + } return node; }, From 826391ebba3290fb7afe3d76573fd94e8328efcb Mon Sep 17 00:00:00 2001 From: Ansolve Date: Mon, 15 Jan 2024 13:33:53 +0800 Subject: [PATCH 2/5] fix: cannot edit the character. --- noname/ui/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noname/ui/index.js b/noname/ui/index.js index 705e91cde..ea01b714e 100644 --- a/noname/ui/index.js +++ b/noname/ui/index.js @@ -4190,7 +4190,7 @@ class Create extends Uninstantable { } editnode.classList.remove('disabled'); }; - var clickButton = async () => { + var clickButton = async function () { if (currentButton == this) { resetEditor(); return; From 514751d3719eabe0b94b6df1cbc7041dc8baa879 Mon Sep 17 00:00:00 2001 From: Ansolve Date: Mon, 15 Jan 2024 14:27:34 +0800 Subject: [PATCH 3/5] fix: ext loaded failed. --- noname/init/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/noname/init/index.js b/noname/init/index.js index 1cc23525d..13b8b327b 100644 --- a/noname/init/index.js +++ b/noname/init/index.js @@ -468,6 +468,7 @@ export async function boot() { if (extensionlist.length && (config.get('mode') != 'connect' || show_splash)) { _status.extensionLoading = []; + _status.extensionLoaded = []; const bannedExtensions = Reflect.get(window, 'bannedExtensions'); From 2190dfe083779f962eec6abd96947e0a99b669ab Mon Sep 17 00:00:00 2001 From: Ansolve Date: Mon, 15 Jan 2024 14:27:59 +0800 Subject: [PATCH 4/5] fix: get copy. --- noname/get/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/noname/get/index.js b/noname/get/index.js index 955765fc9..f38faf096 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -814,6 +814,7 @@ export class Get extends Uninstantable { "[object Object]": true, "[object Array]": true, "[object Arguments]": true, + "[object Date]": true }; if (typeof obj !== "object" || obj === null || !canTranverse[getType(obj)]) @@ -827,16 +828,22 @@ export class Get extends Uninstantable { const target = constructor ? ( - // 这三类数据处理单独处理 + // 这四类数据处理单独处理 // (实际上需要处理的只有Map和Set) // 除此之外的就只能祝愿有拷贝构造函数了 - (Array.isArray(obj) || obj instanceof Map || obj instanceof Set) + (Array.isArray(obj) || obj instanceof Map || obj instanceof Set || constructor === Object) // @ts-ignore ? new constructor() - // @ts-ignore - : new constructor(obj) + : ( + (constructor.name in window && /\[native code\]/.test(constructor.toString())) + // @ts-ignore + ? new constructor(obj) + : obj + ) ) : Object.create(null); + if (target === obj) return target; + map.set(obj, target); if (obj instanceof Map) { From 8b80deb3b3ae2c11ca751703b2f379fa9918a6fa Mon Sep 17 00:00:00 2001 From: Ansolve Date: Mon, 15 Jan 2024 14:29:33 +0800 Subject: [PATCH 5/5] fix: vcard without args. --- noname/library/element/vcard.js | 253 ++++++++++++++++---------------- 1 file changed, 125 insertions(+), 128 deletions(-) diff --git a/noname/library/element/vcard.js b/noname/library/element/vcard.js index deca706e7..30b4d58b6 100644 --- a/noname/library/element/vcard.js +++ b/noname/library/element/vcard.js @@ -1,128 +1,125 @@ -import { AI as ai } from '../../ai/index.js'; -import { Get as get } from '../../get/index.js'; -import { Game as game } from '../../game/index.js'; -import { Library as lib } from "../index.js"; -import { status as _status } from '../../status/index.js'; -import { UI as ui } from '../../ui/index.js'; - -export class VCard { - /** - * @param { any } [suitOrCard] - * @param { number | Card[] } [numberOrCards] - * @param { string } [name] - * @param { string } [nature] - */ - constructor(suitOrCard, numberOrCards, name, nature) { - - if (Array.isArray(suitOrCard)) { - /** - * @type {string} - */ - this.suit = suitOrCard[0]; - /** - * @type {number} - */ - this.number = suitOrCard[1]; - /** - * @type {string} - */ - this.name = suitOrCard[2]; - /** - * @type {string} - */ - this.nature = suitOrCard[3]; - } - // @ts-ignore - else if (get.itemtype(suitOrCard) == 'card') { - this.name = get.name(suitOrCard); - this.suit = get.suit(suitOrCard); - this.color = get.color(suitOrCard); - this.number = get.number(suitOrCard); - this.nature = get.nature(suitOrCard); - /** - * @type { boolean } - */ - this.isCard = true; - this.cardid = suitOrCard.cardid; - this.wunature = suitOrCard.wunature; - /** - * @type {Record} - */ - this.storage = get.copy(suitOrCard.storage); - if (Array.isArray(numberOrCards)) this.cards = numberOrCards.slice(); - else this.cards = [suitOrCard]; - const info = get.info(this, false); - if (info) { - const autoViewAs = info.autoViewAs; - if (typeof autoViewAs == 'string') this.name = autoViewAs; - } - } - else if (suitOrCard && typeof suitOrCard != 'string') { - Object.keys(suitOrCard).forEach(key => { - /** - * @type { PropertyDescriptor } - */ - // @ts-ignore - const propertyDescriptor = Object.getOwnPropertyDescriptor(suitOrCard, key), value = propertyDescriptor.value; - if (Array.isArray(value)) this[key] = value.slice(); - else Object.defineProperty(this, key, propertyDescriptor); - }); - if (Array.isArray(numberOrCards)) { - const noCards = !this.cards; - /** - * @type { Card[] } - */ - this.cards = numberOrCards.slice(); - if (noCards) { - if (!lib.suits.includes(this.suit)) this.suit = get.suit(this); - if (!Object.keys(lib.color).includes(this.color)) this.color = get.color(this); - if (typeof this.number != 'number') this.number = get.number(this); - if (!this.nature) this.nature = get.nature(this); - } - } - const info = get.info(this, false); - if (info) { - const autoViewAs = info.autoViewAs; - if (typeof autoViewAs == 'string') this.name = autoViewAs; - } - } - if (typeof suitOrCard == 'string') this.suit = suitOrCard; - if (typeof numberOrCards == 'number') this.number = numberOrCards; - if (typeof name == 'string') this.name = name; - if (typeof nature == 'string') this.nature = nature; - if (!this.storage) this.storage = {}; - if (!this.cards) this.cards = []; - - this._args = [suitOrCard, numberOrCards, name, nature]; - } - sameSuitAs(card) { - return get.suit(this) == get.suit(card); - } - differentSuitFrom(card) { - return get.suit(this) != get.suit(card); - } - sameNumberAs(card) { - return get.number(this) == get.number(card); - } - differentNumberFrom(card) { - return get.number(this) != get.number(card); - } - sameNameAs(card) { - return get.name(this) == get.name(card); - } - differentNameFrom(card) { - return get.name(this) != get.name(card); - } - /** - * @param { Player } player - */ - hasNature(nature, player) { - const natures = get.natureList(this, player); - if (!nature) return natures.length > 0; - if (nature == 'linked') return natures.some(n => lib.linked.includes(n)); - return get.is.sameNature(natures, nature); - } - hasGaintag(tag) { - return this.gaintag && this.gaintag.includes(tag); - } -} +import { AI as ai } from '../../ai/index.js'; +import { Get as get } from '../../get/index.js'; +import { Game as game } from '../../game/index.js'; +import { Library as lib } from "../index.js"; +import { status as _status } from '../../status/index.js'; +import { UI as ui } from '../../ui/index.js'; + +export class VCard { + /** + * @param { any } [suitOrCard] + * @param { number | Card[] } [numberOrCards] + * @param { string } [name] + * @param { string } [nature] + */ + constructor(suitOrCard, numberOrCards, name, nature) { + if (Array.isArray(suitOrCard)) { + /** + * @type {string} + */ + this.suit = suitOrCard[0]; + /** + * @type {number} + */ + this.number = suitOrCard[1]; + /** + * @type {string} + */ + this.name = suitOrCard[2]; + /** + * @type {string} + */ + this.nature = suitOrCard[3]; + } + // @ts-ignore + else if (get.itemtype(suitOrCard) == 'card') { + this.name = get.name(suitOrCard); + this.suit = get.suit(suitOrCard); + this.color = get.color(suitOrCard); + this.number = get.number(suitOrCard); + this.nature = get.nature(suitOrCard); + /** + * @type { boolean } + */ + this.isCard = true; + this.cardid = suitOrCard.cardid; + this.wunature = suitOrCard.wunature; + /** + * @type {Record} + */ + this.storage = get.copy(suitOrCard.storage); + if (Array.isArray(numberOrCards)) this.cards = numberOrCards.slice(); + else this.cards = [suitOrCard]; + const info = get.info(this, false); + if (info) { + const autoViewAs = info.autoViewAs; + if (typeof autoViewAs == 'string') this.name = autoViewAs; + } + } + else if (suitOrCard && typeof suitOrCard != 'string') { + Object.keys(suitOrCard).forEach(key => { + /** + * @type { PropertyDescriptor } + */ + // @ts-ignore + const propertyDescriptor = Object.getOwnPropertyDescriptor(suitOrCard, key), value = propertyDescriptor.value; + if (Array.isArray(value)) this[key] = value.slice(); + else Object.defineProperty(this, key, propertyDescriptor); + }); + if (Array.isArray(numberOrCards)) { + const noCards = !this.cards; + /** + * @type { Card[] } + */ + this.cards = numberOrCards.slice(); + if (noCards) { + if (!lib.suits.includes(this.suit)) this.suit = get.suit(this); + if (!Object.keys(lib.color).includes(this.color)) this.color = get.color(this); + if (typeof this.number != 'number') this.number = get.number(this); + if (!this.nature) this.nature = get.nature(this); + } + } + const info = get.info(this, false); + if (info) { + const autoViewAs = info.autoViewAs; + if (typeof autoViewAs == 'string') this.name = autoViewAs; + } + } + if (typeof suitOrCard == 'string') this.suit = suitOrCard; + if (typeof numberOrCards == 'number') this.number = numberOrCards; + if (typeof name == 'string') this.name = name; + if (typeof nature == 'string') this.nature = nature; + if (!this.storage) this.storage = {}; + if (!this.cards) this.cards = []; + } + sameSuitAs(card) { + return get.suit(this) == get.suit(card); + } + differentSuitFrom(card) { + return get.suit(this) != get.suit(card); + } + sameNumberAs(card) { + return get.number(this) == get.number(card); + } + differentNumberFrom(card) { + return get.number(this) != get.number(card); + } + sameNameAs(card) { + return get.name(this) == get.name(card); + } + differentNameFrom(card) { + return get.name(this) != get.name(card); + } + /** + * @param { Player } player + */ + hasNature(nature, player) { + const natures = get.natureList(this, player); + if (!nature) return natures.length > 0; + if (nature == 'linked') return natures.some(n => lib.linked.includes(n)); + return get.is.sameNature(natures, nature); + } + hasGaintag(tag) { + return this.gaintag && this.gaintag.includes(tag); + } +}