From 35cf886018f219d1e4c05beb3ff308652eb9e8b5 Mon Sep 17 00:00:00 2001 From: nonameShijian <2954700422@qq.com> Date: Mon, 29 Jan 2024 15:13:34 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=8F=82=E6=95=B0=E9=A2=9D?= =?UTF-8?q?=E5=A4=96=E5=8A=A0=E5=85=A5=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- node_modules/noname-typings/Skill.d.ts | 7 +++++- noname/get/index.js | 7 +++++- noname/library/element/player.js | 32 ++++++++++++++++++++++---- noname/library/index.js | 5 +++- noname/util/index.js | 9 +++----- 5 files changed, 47 insertions(+), 13 deletions(-) diff --git a/node_modules/noname-typings/Skill.d.ts b/node_modules/noname-typings/Skill.d.ts index c29c1980f..c0d1b5aef 100644 --- a/node_modules/noname-typings/Skill.d.ts +++ b/node_modules/noname-typings/Skill.d.ts @@ -1384,7 +1384,12 @@ declare interface Skill { /** 规则技能 */ ruleSkill?: boolean; - zhuanhuanji?: 'number' | boolean | ((player: Player, skill: string) => any); + zhuanhuanji?: 'number' | boolean | ((player: Player, skill: string) => any); + + /** + * 手动设置技能的标签 + */ + categories?: (skill: string, player: Player) => string[]; //日后还有很多属性要添加的 [key: string]: any; diff --git a/noname/get/index.js b/noname/get/index.js index 2466172d0..370168280 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -265,8 +265,13 @@ export class Get extends Uninstantable { } return null; } + /** + * @param { string } skill + * @param { Player } player + * @returns { string[] } + */ static skillCategoriesOf(skill, player) { - var list = [], info = get.info(skill); + const list = [], info = get.info(skill); if (!info) return list; if (get.is.locked(skill, player)) list.add('锁定技'); if (info.zhuSkill) list.add('主公技'); diff --git a/noname/library/element/player.js b/noname/library/element/player.js index e5a44d4fa..aaa31db1c 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -654,7 +654,14 @@ export class Player extends HTMLDivElement { * @param { (card: Card) => boolean } [filter] */ getKnownCards(other = _status.event.player, filter = card => true) { - if (!other) other = this; + if (!other) { + if (other === null) console.trace(`getKnownCards的other参数不应传入null,可以用void 0或undefined占位`); + other = _status.event.player || this; + } + if (!filter) { + if (other === null) console.trace(`getKnownCards的filter参数不应传入null,可以用void 0或undefined占位`); + filter = card => true; + } return this.getCards('h', card => { return card.isKnownBy(other) && filter(card); }); @@ -664,6 +671,10 @@ export class Player extends HTMLDivElement { * @param { Player } [other] */ isAllCardsKnown(other = _status.event.player) { + if (!other) { + if (other === null) console.trace(`isAllCardsKnown的other参数不应传入null,可以用void 0或undefined占位`); + other = _status.event.player || this; + } if (!other) other = this; return this.countCards('h', card => { return !card.isKnownBy(other); @@ -675,7 +686,14 @@ export class Player extends HTMLDivElement { * @param { (card: Card) => boolean } [filter] */ hasKnownCards(other = _status.event.player, filter = card => true) { - if (!other) other = this; + if (!other) { + if (other === null) console.trace(`hasKnownCards的other参数不应传入null,可以用void 0或undefined占位`); + other = _status.event.player || this; + } + if (!filter) { + if (other === null) console.trace(`hasKnownCards的filter参数不应传入null,可以用void 0或undefined占位`); + filter = card => true; + } return this.countCards('h', card => { return card.isKnownBy(other) && filter(card); }) > 0; @@ -808,10 +826,16 @@ export class Player extends HTMLDivElement { if (cards && !isArray) recast.cards = [cards]; else if (isArray && cards.length) recast.cards = cards; else _status.event.next.remove(recast); - if (typeof recastingLose != 'function') recastingLose = (player, cards) => player.loseToDiscardpile(cards).log = false; + if (typeof recastingLose != 'function') { + if (recastingLose === null) console.trace(`recast的recastingLose参数不应传入null,可以用void 0或undefined占位`); + recastingLose = (player, cards) => player.loseToDiscardpile(cards).log = false; + } recast.recastingLose = recastingLose; recast.recastingLosingEvents = []; - if (typeof recastingGain != 'function') recastingGain = (player, cards) => player.draw(cards.length).log = false; + if (typeof recastingGain != 'function') { + if (recastingLose === null) console.trace(`recast的recastingGain参数不应传入null,可以用void 0或undefined占位`); + recastingGain = (player, cards) => player.draw(cards.length).log = false; + } recast.recastingGain = recastingGain; recast.recastingGainingEvents = []; recast.setContent('recast'); diff --git a/noname/library/index.js b/noname/library/index.js index 6422d05c9..6617e962a 100644 --- a/noname/library/index.js +++ b/noname/library/index.js @@ -9669,7 +9669,10 @@ export class Library extends Uninstantable { * @param { boolean } [strict] */ cardRecastable: (card, player = get.owner(card), source, strict) => { - // if (typeof player == 'undefined') player = get.owner(card); + if (!player) { + if (player === null) console.trace(`cardRecastable的player参数不应传入null,可以用void 0或undefined占位`); + player = get.owner(card); + } const mod = game.checkMod(card, player, source, 'unchanged', 'cardRecastable', player); if (!mod) return false; if (strict && mod == 'unchanged') { diff --git a/noname/util/index.js b/noname/util/index.js index 875385419..a1ac7857f 100644 --- a/noname/util/index.js +++ b/noname/util/index.js @@ -1,14 +1,11 @@ export const nonameInitialized = localStorage.getItem('noname_inited'); export const assetURL = location.protocol.startsWith('http') || typeof nonameInitialized != 'string' || nonameInitialized == 'nodejs' ? '' : nonameInitialized; -export const GeneratorFunction = (function* () { }).constructor; -export const AsyncFunction = (async function () { }).constructor; +export const GeneratorFunction = (function* () {}).constructor; +export const AsyncFunction = (async function () {}).constructor; export const userAgent = navigator.userAgent.toLowerCase(); export { Mutex } from './mutex.js'; export const characterDefaultPicturePath = "image/character/default_silhouette_"; -// 我靠循环引用问题在这? -// export * as config from './config.js' - /** * 不能被new的类 */ @@ -19,7 +16,7 @@ export class Uninstantable { } /** - * + * 暂停x毫秒 * @param { number } ms * @returns { Promise } */