Merge branch 'libccy:PR-Branch' into PR-Branch

This commit is contained in:
157 2024-01-15 20:54:50 +08:00 committed by GitHub
commit 55913de845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 182 additions and 135 deletions

View File

@ -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) {

View File

@ -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');

View File

@ -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<string, any>}
*/
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<string, any>}
*/
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);
}
}

View File

@ -4190,7 +4190,7 @@ class Create extends Uninstantable {
}
editnode.classList.remove('disabled');
};
var clickButton = async () => {
var clickButton = async function () {
if (currentButton == this) {
resetEditor();
return;
@ -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;
},