优化类型提示,消灭shenhua.js中的function关键字

This commit is contained in:
nonameShijian 2024-04-20 17:42:20 +08:00
parent 68bf106ad3
commit 80a0b2df63
16 changed files with 1111 additions and 675 deletions

File diff suppressed because it is too large Load Diff

View File

@ -129,6 +129,7 @@ game.import("character", function () {
ganning: ["lingtong", "xf_sufei"],
guanyu: ["zhangfei", "liaohua"],
},
/** @type { importCharacterConfig['skill'] } */
skill: {
//标准版甘夫人
stdshushen: {
@ -578,7 +579,7 @@ game.import("character", function () {
async cost(event, trigger, player) {
let num = game.countPlayer(
(current) =>
current != player && current.countCards("h") && get.attitude(player, current) <= 0
current != player && current.countCards("h") > 0 && get.attitude(player, current) <= 0
);
let check = num >= 2;
const { result } = await player
@ -2611,7 +2612,7 @@ game.import("character", function () {
global: ["dying", "gainAfter", "loseAsyncAfter"],
},
audio: 2,
getIndex: function (event, player) {
getIndex(event, player) {
if (event.name !== "loseAsync") return [event.player];
else
return game

View File

@ -37,7 +37,12 @@ declare interface Result {
* card参数特供给视为牌cards[0]
* card.isCardfalse为视为牌
*/
card: Card;
card: Card | CardBaseUIData;
cost_data: {
[key: string]: any;
};
[key: string]: any;
}

View File

@ -442,7 +442,7 @@ declare interface Skill {
*
* checkcheck方法检测
*/
frequent?: boolean | string | TwoParmFun<SkillTrigger, Player, number | boolean>;
frequent?: boolean | string | TwoParmFun<GameEventPromise, Player, number | boolean>;
/**
* 2
*
@ -1285,7 +1285,7 @@ declare interface Skill {
*
* @param target v1.10.11
*/
logTarget?: string | ((event?: GameEventPromise, player?: Player, triggername?: string, target?: Player) => string | Player | Player[] | null);
logTarget?: string | ((event?: GameEventPromise, player?: Player, triggername?: string, target?: Player) => string | Player | Player[] | null | undefined);
/**
* logTarget显示触发者的目标日志
*

View File

@ -33,6 +33,10 @@ export class Game {
* @type { boolean }
*/
chess: boolean;
/**
* @type { Player }
*/
zhu: Player;
globalEventHandlers: {
_handlers: {};
getHandler(name: any, type: any): any;
@ -350,7 +354,7 @@ export class Game {
* @param { ...Parameters<typeof lib.message.client[T]> } args
* @returns { void }
*/
broadcast<T_6 extends "cancel" | "onclose" | "init" | "log" | "opened" | "onconnection" | "onmessage" | "selfclose" | "reloadroom" | "createroom" | "enterroomfailed" | "roomlist" | "updaterooms" | "updateclients" | "updateevents" | "eventsdenied" | "reinit" | "exec" | "denied" | "closeDialog" | "createDialog" | "gameStart" | "updateWaiting">(func: T_6, ...args: Parameters<{
broadcast<T_6 extends "cancel" | "onclose" | "init" | "reinit" | "log" | "opened" | "onconnection" | "onmessage" | "selfclose" | "reloadroom" | "createroom" | "enterroomfailed" | "roomlist" | "updaterooms" | "updateclients" | "updateevents" | "eventsdenied" | "exec" | "denied" | "closeDialog" | "createDialog" | "gameStart" | "updateWaiting">(func: T_6, ...args: Parameters<{
log: (arr: any) => void;
opened: () => void;
onconnection: (id: any) => void;
@ -382,7 +386,7 @@ export class Game {
* @param { ...T } args
* @returns { void }
*/
broadcast<T_6 extends "cancel" | "onclose" | "init" | "log" | "opened" | "onconnection" | "onmessage" | "selfclose" | "reloadroom" | "createroom" | "enterroomfailed" | "roomlist" | "updaterooms" | "updateclients" | "updateevents" | "eventsdenied" | "reinit" | "exec" | "denied" | "closeDialog" | "createDialog" | "gameStart" | "updateWaiting">(func: (...args: T_6) => void, ...args: T_6 | undefined): void;
broadcast<T_6 extends "cancel" | "onclose" | "init" | "reinit" | "log" | "opened" | "onconnection" | "onmessage" | "selfclose" | "reloadroom" | "createroom" | "enterroomfailed" | "roomlist" | "updaterooms" | "updateclients" | "updateevents" | "eventsdenied" | "exec" | "denied" | "closeDialog" | "createDialog" | "gameStart" | "updateWaiting">(func: (...args: T_6) => void, ...args: T_6 | undefined): void;
/**
* @template { keyof typeof lib.message.client } T
* @overload
@ -390,7 +394,7 @@ export class Game {
* @param { ...Parameters<typeof lib.message.client[T]> } args
* @returns { void }
*/
broadcastAll<T_7 extends "cancel" | "onclose" | "init" | "log" | "opened" | "onconnection" | "onmessage" | "selfclose" | "reloadroom" | "createroom" | "enterroomfailed" | "roomlist" | "updaterooms" | "updateclients" | "updateevents" | "eventsdenied" | "reinit" | "exec" | "denied" | "closeDialog" | "createDialog" | "gameStart" | "updateWaiting">(func: T_7, ...args: Parameters<{
broadcastAll<T_7 extends "cancel" | "onclose" | "init" | "reinit" | "log" | "opened" | "onconnection" | "onmessage" | "selfclose" | "reloadroom" | "createroom" | "enterroomfailed" | "roomlist" | "updaterooms" | "updateclients" | "updateevents" | "eventsdenied" | "exec" | "denied" | "closeDialog" | "createDialog" | "gameStart" | "updateWaiting">(func: T_7, ...args: Parameters<{
log: (arr: any) => void;
opened: () => void;
onconnection: (id: any) => void;
@ -422,7 +426,7 @@ export class Game {
* @param { ...T } args
* @returns { void }
*/
broadcastAll<T_7 extends "cancel" | "onclose" | "init" | "log" | "opened" | "onconnection" | "onmessage" | "selfclose" | "reloadroom" | "createroom" | "enterroomfailed" | "roomlist" | "updaterooms" | "updateclients" | "updateevents" | "eventsdenied" | "reinit" | "exec" | "denied" | "closeDialog" | "createDialog" | "gameStart" | "updateWaiting">(func: (...args: T_7) => void, ...args: T_7 | undefined): void;
broadcastAll<T_7 extends "cancel" | "onclose" | "init" | "reinit" | "log" | "opened" | "onconnection" | "onmessage" | "selfclose" | "reloadroom" | "createroom" | "enterroomfailed" | "roomlist" | "updaterooms" | "updateclients" | "updateevents" | "eventsdenied" | "exec" | "denied" | "closeDialog" | "createDialog" | "gameStart" | "updateWaiting">(func: (...args: T_7) => void, ...args: T_7 | undefined): void;
syncState(): void;
updateWaiting(): void;
/**
@ -1155,11 +1159,11 @@ export class Game {
updateRoundNumber(): void;
/**
* @param { Player[] } players
* @param { number | number[] | (player: Player) => number } num
* @param { number | number[] | (player: Player) => number } [num]
* @param { { drawDeck: boolean } } [drawDeck]
* @param { boolean } [bottom]
*/
asyncDraw(players: Player[], num: number | number[] | ((player: Player) => number), drawDeck?: {
asyncDraw(players: Player[], num?: number | number[] | ((player: Player) => number) | undefined, drawDeck?: {
drawDeck: boolean;
} | undefined, bottom?: boolean | undefined): void;
/**

View File

@ -99,7 +99,7 @@ export class Get {
infoHp(hp: any): number;
infoMaxHp(hp: any): number;
infoHujia(hp: any): number;
bottomCards(num: any, putBack: any): any;
bottomCards(num: any, putBack: any): Node | Node[];
discarded(): any;
cardOffset(): number;
colorspan(str: any): any;
@ -355,7 +355,7 @@ export class Get {
* @returns {string[]}
*/
natureList(card: string[] | string, player?: false | import("noname-typings/nonameModules/noname/library/element/player.js").Player | undefined): string[];
cards(num: any, putBack: any): any;
cards(num: any, putBack: any): Node | Node[];
judge(card: any): any;
judge2(card: any): any;
distance(from: any, to: any, method: any): number;
@ -390,7 +390,7 @@ export class Get {
* @returns {GameEvent[T]}
*/
event<T_2 extends keyof import("noname-typings/nonameModules/noname/library/element/gameEvent.js").GameEvent>(key: T_2): import("noname-typings/nonameModules/noname/library/element/gameEvent.js").GameEvent[T_2];
player(): any;
player(): import("noname-typings/nonameModules/noname/library/element/player.js").Player;
players(sort: any, dead: any, out: any): import("noname-typings/nonameModules/noname/library/element/player.js").Player[];
position(card: any, ordering: any): number | "e" | "j" | "x" | "s" | "h" | "c" | "d" | "o" | null | undefined;
skillTranslation(str: any, player: any): string;
@ -476,7 +476,7 @@ export class Get {
/**
* @returns { number }
*/
order(item: any, player?: any): number;
order(item: any, player?: import("noname-typings/nonameModules/noname/library/element/player.js").Player): number;
result(item: any, skill: any): any;
cacheEffectUse(target: any, card: any, player: any, player2: any, isLink: any): number;
effect_use(target: any, card: any, player: any, player2: any, isLink: any): number;

View File

@ -49,7 +49,7 @@ export class Is {
*
* @param { Card | VCard } card
*/
ordinaryCard(card: Card | VCard): any;
ordinaryCard(card: Card | VCard): boolean;
/**
*
* @param { string } str1

View File

@ -34,6 +34,10 @@ export class Card extends HTMLDivElement {
* @type { string }
*/
name: string;
/**
* @type { boolean }
*/
isCard: boolean;
selfDestroy(event: any): void;
willBeDestroyed(targetPosition: any, player: any, event: any): any;
hasNature(nature: any, player: any): boolean;

View File

@ -125,9 +125,37 @@ export class GameEvent {
*/
parent: GameEventPromise | void | null;
/**
* @type { Function | void | null }
* @type { (this: GameEventPromise) => any | undefined | void | null }
*/
filterStop: Function | void | null;
filterStop: (this: GameEventPromise) => any | undefined | void | null;
/**
* @type { Result['cost_data'] }
*/
cost_data: Result['cost_data'];
/**
* @type { boolean }
*/
responded: boolean;
/**
* @type { string | undefined }
*/
judgestr: string | undefined;
/**
* @type { boolean }
*/
judging: boolean;
/**
* @type { Function | undefined }
*/
judge2: Function | undefined;
/**
* @type { Card[] }
*/
orderingCards: Card[];
/**
* @type { Function | undefined }
*/
ai: Function | undefined;
/**
* @param {keyof this} key
* @param {number} [value]

View File

@ -69,29 +69,9 @@ export class Player extends HTMLDivElement {
skill: {};
}[];
/**
* @type { {
* useCard: GameEventPromise[],
* respond: GameEventPromise[],
* skipped: GameEventPromise[],
* lose: GameEventPromise[],
* gain: GameEventPromise[],
* sourceDamage: GameEventPromise[],
* damage: GameEventPromise[],
* custom: GameEventPromise[],
* useSkill: GameEventPromise[],
* }[] }
* @type { ActionHistory[] }
*/
actionHistory: {
useCard: GameEventPromise[];
respond: GameEventPromise[];
skipped: GameEventPromise[];
lose: GameEventPromise[];
gain: GameEventPromise[];
sourceDamage: GameEventPromise[];
damage: GameEventPromise[];
custom: GameEventPromise[];
useSkill: GameEventPromise[];
}[];
actionHistory: ActionHistory[];
/**
* @type { SMap<string[]> }
*/
@ -117,7 +97,8 @@ export class Player extends HTMLDivElement {
* friend: [],
* enemy: [],
* neutral: [],
* handcards: {
* shown?: number,
* handcards?: {
* global: [],
* source: [],
* viewed: []
@ -128,7 +109,8 @@ export class Player extends HTMLDivElement {
friend: [];
enemy: [];
neutral: [];
handcards: {
shown?: number;
handcards?: {
global: [];
source: [];
viewed: [];
@ -208,6 +190,18 @@ export class Player extends HTMLDivElement {
* @type { ((player: this) => any)[] }
*/
_inits: ((player: this) => any)[];
/**
* @type { boolean }
*/
isZhu: boolean;
/**
* @type { string }
*/
identity: string;
/**
* @type { boolean | undefined }
*/
identityShown: boolean | undefined;
/**
*
* @param { number } amount
@ -516,10 +510,10 @@ export class Player extends HTMLDivElement {
/**
* target发起协力
* @param { Player } target
* @param {*} type
* @param { string } type
* @param {*} reason
*/
cooperationWith(target: Player, type: any, reason: any): void;
cooperationWith(target: Player, type: string, reason: any): void;
chooseCooperationFor(...args: any[]): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
checkCooperationStatus(target: any, reason: any): boolean;
removeCooperation(info: any): void;
@ -634,8 +628,9 @@ export class Player extends HTMLDivElement {
/**
* @param { string } name
* @param { string } type
* @returns { boolean }
*/
hasUsableCard(name: string, type: string): true | undefined;
hasUsableCard(name: string, type: string): boolean;
/**
* @param { Player } to
* @returns { boolean }
@ -768,9 +763,9 @@ export class Player extends HTMLDivElement {
position: number;
hujia: number;
side: any;
identityShown: any;
identityShown: boolean | undefined;
identityNode: (string | undefined)[];
identity: any;
identity: string;
dead: boolean;
linked: boolean;
turnedover: boolean;
@ -806,7 +801,13 @@ export class Player extends HTMLDivElement {
countUsed(card: any, type: any): number;
getCacheKey(): string;
countSkill(skill: any): any;
getStockSkills(unowned: any, unique: any, hidden: any): any[];
/**
* @param {*} [unowned]
* @param {*} [unique]
* @param {*} [hidden]
* @returns { string[] }
*/
getStockSkills(unowned?: any, unique?: any, hidden?: any): string[];
/**
* @param { string } [arg1='h']
* @param { string | Record<string, any> | ((card: Card) => boolean) } [arg2]
@ -821,16 +822,41 @@ export class Player extends HTMLDivElement {
getCards(arg1?: string | undefined, arg2?: string | Record<string, any> | ((card: Card) => boolean) | undefined): Card[];
iterableGetDiscardableCards(player: any, arg1: any, arg2: any): Generator<import("noname-typings/nonameModules/noname/library/element/card.js").Card, void, unknown>;
getDiscardableCards(player: any, arg1: any, arg2: any): import("noname-typings/nonameModules/noname/library/element/card.js").Card[];
iterableGetGainableCards(player: any, arg1: any, arg2: any): Generator<import("noname-typings/nonameModules/noname/library/element/card.js").Card, void, unknown>;
getGainableCards(player: any, arg1: any, arg2: any): import("noname-typings/nonameModules/noname/library/element/card.js").Card[];
/**
* @param {Parameters<lib['filter']['canBeGained']>[1]} player
* @param {Parameters<this['iterableGetCards']>[0]} arg1
* @param {Parameters<this['iterableGetCards']>[1]} arg2
*/
iterableGetGainableCards(player: [card?: any, player?: any, target?: any, event?: any][1], arg1: Parameters<this['iterableGetCards']>[0], arg2: Parameters<this['iterableGetCards']>[1]): Generator<import("noname-typings/nonameModules/noname/library/element/card.js").Card, void, unknown>;
/**
*
* @param {Parameters<this['iterableGetGainableCards']>[0]} player
* @param {Parameters<this['iterableGetGainableCards']>[1]} [arg1]
* @param {Parameters<this['iterableGetGainableCards']>[2]} [arg2]
*/
getGainableCards(player: Parameters<this['iterableGetGainableCards']>[0], arg1?: Parameters<this["iterableGetGainableCards"]>[1] | undefined, arg2?: Parameters<this["iterableGetGainableCards"]>[2] | undefined): import("noname-typings/nonameModules/noname/library/element/card.js").Card[];
getGainableSkills(func: any): any[];
countCards(arg1: any, arg2: any): number;
/**
* @param { Parameters<typeof this['iterableGetCards']>[0] } [arg1]
* @param { Parameters<typeof this['iterableGetCards']>[1] } [arg2]
*/
countCards(arg1?: Parameters<this["iterableGetCards"]>[0] | undefined, arg2?: Parameters<this["iterableGetCards"]>[1] | undefined): number;
getCardIndex(arg1: any, name: any, card: any, max: any): number;
countDiscardableCards(player: any, arg1: any, arg2: any): number;
countGainableCards(player: any, arg1: any, arg2: any): number;
/**
* @param {Parameters<this['getGainableCards']>[0]} player
* @param {Parameters<this['getGainableCards']>[1]} [arg1]
* @param {Parameters<this['getGainableCards']>[2]} [arg2]
*/
countGainableCards(player: Parameters<this['getGainableCards']>[0], arg1?: Parameters<this["getGainableCards"]>[1] | undefined, arg2?: Parameters<this["getGainableCards"]>[2] | undefined): number;
getOriginalSkills(): any[];
getModableSkills(): any[];
getSkills(arg2: any, arg3: any, arg4: any): any[];
/**
* @param { string | boolean | null } [arg2]
* @param { boolean | null} [arg3]
* @param {boolean} [arg4]
*/
getSkills(arg2?: string | boolean | null | undefined, arg3?: boolean | null | undefined, arg4?: boolean | undefined): any[];
get(arg1: any, arg2: any, arg3: any, arg4: any, ...args: any[]): any[] | ChildNode | undefined;
syncStorage(skill: any): void;
syncSkills(): void;
@ -889,16 +915,30 @@ export class Player extends HTMLDivElement {
$addToExpansion(cards: any, broadcast: any, gaintag: any): this;
directgain(cards: any, broadcast: any, gaintag: any): this;
directgains(cards: any, broadcast: any, gaintag: any): this;
gainMultiple(targets: any, position: any): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
/**
*
* @param { Player[] } targets
* @param { string } [position]
*/
gainMultiple(targets: Player[], position?: string | undefined): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
gain(...args: any[]): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
addToExpansion(...args: any[]): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
give(cards: any, target: any, visible: any): any;
/**
*
* @param { Card | Card[] } cards
* @param { Player } target
* @param { boolean } [visible]
*/
give(cards: Card | Card[], target: Player, visible?: boolean | undefined): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
lose(...args: any[]): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
damage(...args: any[]): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
recover(...args: any[]): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
recoverTo(...args: any[]): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
doubleDraw(): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
loseHp(num: any): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
/**
* @param { number } [num]
*/
loseHp(num?: number | undefined): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
loseMaxHp(...args: any[]): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
gainMaxHp(...args: any[]): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
changeHp(num: any, popup: any): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
@ -930,11 +970,23 @@ export class Player extends HTMLDivElement {
wait(callback: any): void;
unwait(result: any): void;
tempUnwait(result: any): void;
logSkill(name: any, targets: any, nature: any, logv: any): void;
/**
* @param { string | string[] } name
* @param { Player | Player[] } [targets]
* @param { boolean | string } [nature]
* @param { boolean } [logv]
*/
logSkill(name: string | string[], targets?: Player | Player[] | undefined, nature?: string | boolean | undefined, logv?: boolean | undefined): void;
unprompt(): void;
prompt(str: any, nature: any): void;
prompt_old(name2: any, className: any): void;
popup(name: any, className: any, nobroadcast: any): void;
/**
*
* @param { string } name
* @param { string } className
* @param { Parameters<this["damagepop"]>[3] } [nobroadcast]
*/
popup(name: string, className?: string, nobroadcast?: Parameters<this["damagepop"]>[3] | undefined): void;
popup_old(name: any, className: any): HTMLDivElement;
_popup(): void;
showTimer(time: any): void;
@ -961,7 +1013,14 @@ export class Player extends HTMLDivElement {
unmark(name: any, info: any): void;
addLink(): void;
removeLink(): void;
canUse(card: any, target: any, distance: any, includecard: any): any;
/**
* @param { string | Card | VCard } card
* @param { Player } target
* @param { boolean } [distance]
* @param { GameEventPromise | boolean } [includecard]
* @returns { boolean }
*/
canUse(card: string | Card | VCard, target: Player, distance?: boolean | undefined, includecard?: boolean | import("noname-typings/nonameModules/noname/library/index.js").GameEventPromise | undefined): boolean;
hasUseTarget(card: any, distance: any, includecard: any): boolean;
hasValueTarget(card: any, distance: any, includecard: any): boolean;
getUseValue(card: any, distance: any, includecard: any): number;
@ -997,7 +1056,20 @@ export class Player extends HTMLDivElement {
removeSkillTrigger(skills: any, triggeronly: any): this;
removeSkill(skill: any, ...args: any[]): any;
addTempSkills(skillsToAdd: any, expire: any): import("./gameEvent.js").GameEvent & import("./gameEventPromise.js").GameEventPromise;
addTempSkill(skill: any, expire: any, checkConflict: any): any;
/**
* @overload
* @param { string } skill
* @param { SkillTrigger | string } [expire]
* @param { boolean } [checkConflict]
*/
addTempSkill(skill: string, expire?: string | SkillTrigger | undefined, checkConflict?: boolean | undefined): any;
/**
* @overload
* @param { string[] } skill
* @param { SkillTrigger } [expire]
* @param { boolean } [checkConflict]
*/
addTempSkill(skill: string[], expire?: SkillTrigger | undefined, checkConflict?: boolean | undefined): any;
tempBanSkill(skill: any, expire: any, log: any): any;
isTempBanned(skill: any): boolean;
attitudeTo(target: any): any;
@ -1019,14 +1091,68 @@ export class Player extends HTMLDivElement {
* @param { string | function | number | boolean | object } map
*/
getRoundHistory(key: any, filter: any, num: any, keep: any, last: any): any[];
getHistory(key: any, filter: any, last: any): any;
checkHistory(key: any, filter: any, last: any): void;
hasHistory(key: any, filter: any, last: any): any;
getLastHistory(key: any, filter: any, last: any): any;
checkAllHistory(key: any, filter: any, last: any): void;
getAllHistory(key: any, filter: any, last: any): any[];
hasAllHistory(key: any, filter: any, last: any): boolean;
getLastUsed(num: any): any;
/**
* @overload
* @returns { ActionHistory }
*/
getHistory(): ActionHistory;
/**
* @template { keyof ActionHistory } T
* @overload
* @param { T } key
* @param { (event: GameEventPromise) => boolean } [filter]
* @param { GameEventPromise } [last]
* @returns { ActionHistory[T] }
*/
getHistory<T extends keyof ActionHistory>(key: T, filter?: ((event: GameEventPromise) => boolean) | undefined, last?: import("noname-typings/nonameModules/noname/library/index.js").GameEventPromise | undefined): ActionHistory[T];
/**
* @template { keyof ActionHistory } T
* @param { T } key
* @param { (event: GameEventPromise) => boolean } filter
* @param { GameEventPromise } [last]
*/
checkHistory<T_1 extends keyof ActionHistory>(key: T_1, filter: (event: GameEventPromise) => boolean, last?: import("noname-typings/nonameModules/noname/library/index.js").GameEventPromise | undefined): void;
/**
* @template { keyof ActionHistory } T
* @param { T } key
* @param { (event: GameEventPromise) => boolean } [filter]
* @param { GameEventPromise } [last]
* @returns { boolean }
*/
hasHistory<T_2 extends keyof ActionHistory>(key: T_2, filter?: ((event: GameEventPromise) => boolean) | undefined, last?: import("noname-typings/nonameModules/noname/library/index.js").GameEventPromise | undefined): boolean;
/**
* @template { keyof ActionHistory } T
* @overload
* @param { T } [key]
* @param { (event: GameEventPromise) => boolean } [filter]
* @param { GameEventPromise } [last]
* @returns { null | ActionHistory[T] | boolean }
*/
getLastHistory<T_3 extends keyof ActionHistory>(key?: T_3 | undefined, filter?: ((event: GameEventPromise) => boolean) | undefined, last?: import("noname-typings/nonameModules/noname/library/index.js").GameEventPromise | undefined): boolean | ActionHistory[T_3] | null;
/**
* @template { keyof ActionHistory } T
* @param { T } key
* @param { (event: GameEventPromise) => boolean } filter
* @param { GameEventPromise } [last]
*/
checkAllHistory<T_4 extends keyof ActionHistory>(key: T_4, filter: (event: GameEventPromise) => boolean, last?: import("noname-typings/nonameModules/noname/library/index.js").GameEventPromise | undefined): void;
/**
* @template { keyof ActionHistory } T
* @param { T } [key]
* @param { (event: GameEventPromise) => boolean } [filter]
* @param { GameEventPromise } [last]
* @returns { ActionHistory[T] }
*/
getAllHistory<T_5 extends keyof ActionHistory>(key?: T_5 | undefined, filter?: ((event: GameEventPromise) => boolean) | undefined, last?: import("noname-typings/nonameModules/noname/library/index.js").GameEventPromise | undefined): ActionHistory[T_5];
/**
* @template { keyof ActionHistory } T
* @param { T } key
* @param { (event: GameEventPromise) => boolean } filter
* @param { GameEventPromise } [last]
* @returns { boolean }
*/
hasAllHistory<T_6 extends keyof ActionHistory>(key: T_6, filter: (event: GameEventPromise) => boolean, last?: import("noname-typings/nonameModules/noname/library/index.js").GameEventPromise | undefined): boolean;
getLastUsed(num: any): import("noname-typings/nonameModules/noname/library/index.js").GameEventPromise | null;
getStat(key: any): any;
getLastStat(key: any): any;
queue(time: any): void;
@ -1067,23 +1193,59 @@ export class Player extends HTMLDivElement {
isOnline2(): boolean;
isOffline(): boolean;
checkShow(skill: any, showonly: any): false | "main" | "vice";
needsToDiscard(add: any, filter: any, pure: any): number;
/**
*
* @param { number | Card[] | Card } [add]
* @param { (card?: Card, player?: Player) => boolean } [filter]
* @param { boolean } [pure]
*/
needsToDiscard(add?: number | import("noname-typings/nonameModules/noname/library/element/card.js").Card | import("noname-typings/nonameModules/noname/library/element/card.js").Card[] | undefined, filter?: ((card?: Card, player?: Player) => boolean) | undefined, pure?: boolean | undefined): number;
distanceTo(target: any, method: any): number;
distanceFrom(target: any, method: any): number;
hasSkill(skill: any, arg2: any, arg3: any, arg4: any): boolean;
hasStockSkill(skill: any, arg1: any, arg2: any, arg3: any): boolean;
/**
* @param { string } skill
* @param { Parameters<this['getSkills']>[0] } arg2
* @param { Parameters<this['getSkills']>[1] } arg3
* @param { Parameters<this['getSkills']>[2] } arg4
* @returns { boolean }
*/
hasSkill(skill: string, arg2: Parameters<this['getSkills']>[0], arg3: Parameters<this['getSkills']>[1], arg4: Parameters<this['getSkills']>[2]): boolean;
/**
* @param { string } skill
* @param { Parameters<this['getStockSkills']>[0] } arg1
* @param { Parameters<this['getStockSkills']>[1] } arg2
* @param { Parameters<this['getStockSkills']>[2] } arg3
* @returns { boolean }
*/
hasStockSkill(skill: string, arg1: Parameters<this['getStockSkills']>[0], arg2: Parameters<this['getStockSkills']>[1], arg3: Parameters<this['getStockSkills']>[2]): boolean;
isZhu2(): boolean;
isInitFilter(tag: any): boolean;
hasZhuSkill(skill: any, player: any): boolean;
/**
*
* @param {string} skill
* @param {Player} [player]
*/
hasZhuSkill(skill: string, player?: Player | undefined): boolean;
hasGlobalTag(tag: any, arg: any): boolean;
hasSkillTag(tag: any, hidden: any, arg: any, globalskill: any): boolean;
/**
* @param {string} tag
* @param {Parameters<this['getSkills']>[0]} hidden
* @param {Parameters<SkillAI['skillTagFilter']>[2]} arg
* @param {boolean} [globalskill]
*/
hasSkillTag(tag: string, hidden: Parameters<this['getSkills']>[0], arg: [player: import("noname-typings/nonameModules/noname/library/element/player.js").Player, tag: string, arg: any][2], globalskill?: boolean | undefined): boolean;
hasJudge(name: any): boolean;
hasFriend(): boolean;
hasUnknown(num: any): boolean;
isUnknown(player: any): boolean;
hasWuxie(info: any): boolean;
hasSha(respond: any, noauto: any): true | undefined;
hasShan(respond: any): true | undefined;
/**
*
* @param {string|boolean} [respond]
* @param {boolean} [noauto]
*/
hasSha(respond?: string | boolean | undefined, noauto?: boolean | undefined): boolean;
hasShan(respond: any): boolean;
mayHaveSha(viewer: any, type: any, ignore: any, rvt: any): number | boolean;
mayHaveShan(viewer: any, type: any, ignore: any, rvt: any): number | boolean;
hasCard(name: any, position: any): boolean;
@ -1119,9 +1281,27 @@ export class Player extends HTMLDivElement {
$dust(): void;
$recover(): void;
$fullscreenpop(str: any, nature: any, avatar: any, broadcast: any): void;
$damagepop(num: any, nature: any, font: any, nobroadcast: any): void;
/**
*
* @param { number | string } num
* @param { string } [nature]
* @param { boolean } [font]
* @param { boolean } [nobroadcast]
*/
$damagepop(num: number | string, nature?: string | undefined, font?: boolean | undefined, nobroadcast?: boolean | undefined): void;
$damage(source: any, ...args: any[]): void;
$die(): void;
$dieflip(type: any): void;
$phaseJudge(card: any): void;
}
export type ActionHistory = {
useCard: GameEventPromise[];
respond: GameEventPromise[];
skipped: GameEventPromise[];
lose: GameEventPromise[];
gain: GameEventPromise[];
sourceDamage: GameEventPromise[];
damage: GameEventPromise[];
custom: GameEventPromise[];
useSkill: GameEventPromise[];
};

View File

@ -129,6 +129,10 @@ export class UI {
* @type {HTMLDivElement}
*/
tempnowuxie: HTMLDivElement;
/**
* @type {HTMLDivElement}
*/
cardPile: HTMLDivElement;
refresh(node: any): void;
clear(): void;
updatec(): void;

View File

@ -53,18 +53,19 @@ export class Game {
/**
* @type { string }
*/
// @ts-ignore
layout;
/**
* @type { Player }
*/
// @ts-ignore
me;
/**
* @type { boolean }
*/
// @ts-ignore
chess;
/**
* @type { Player }
*/
zhu;
globalEventHandlers = new (class {
constructor() {
this._handlers = {};
@ -7486,7 +7487,7 @@ export class Game {
}
/**
* @param { Player[] } players
* @param { number | number[] | (player: Player) => number } num
* @param { number | number[] | (player: Player) => number } [num]
* @param { { drawDeck: boolean } } [drawDeck]
* @param { boolean } [bottom]
*/

View File

@ -100,6 +100,10 @@ export class Card extends HTMLDivElement {
* @type { any[] }
*/
_uncheck;
/**
* @type { boolean }
*/
isCard;
//执行销毁一张牌的钩子函数
selfDestroy(event) {
if (this._selfDestroyed) return;

View File

@ -67,37 +67,30 @@ export class GameEvent {
/**
* @type { Player }
*/
// @ts-ignore
source;
/**
* @type { Player }
*/
// @ts-ignore
player;
/**
* @type { Player[] }
*/
// @ts-ignore
players;
/**
* @type { Player }
*/
// @ts-ignore
target;
/**
* @type { Player[] }
*/
// @ts-ignore
targets;
/**
* @type { Card }
*/
// @ts-ignore
card;
/**
* @type { Card[] }
*/
// @ts-ignore
cards;
/**
* @type { string }
@ -114,7 +107,6 @@ export class GameEvent {
/**
* @type { GameEvent }
*/
// @ts-ignore
_trigger;
/**
* @type { Result }
@ -123,61 +115,79 @@ export class GameEvent {
/**
* @type { number }
*/
// @ts-ignore
baseDamage;
/**
* @type { Player }
*/
// @ts-ignore
customSource;
/**
* @type { number }
*/
// @ts-ignore
extraDamage;
/**
* @type { string }
*/
// @ts-ignore
nature;
/**
* @type { boolean }
*/
// @ts-ignore
notrigger;
/**
* @type { number }
*/
// @ts-ignore
original_num;
/**
* @type { boolean }
*/
// @ts-ignore
unreal;
/**
* @type { Button[] }
*/
// @ts-ignore
excludeButton;
/**
* @type { Result }
*/
// @ts-ignore
result;
/**
* @type { GameEventPromise | void | null }
*/
// @ts-ignore
parent;
/**
* @type { string }
*/
name;
/**
* @type { Function | void | null }
* @type { (this: GameEventPromise) => any | undefined | void | null }
*/
filterStop;
/**
* @type { Result['cost_data'] }
*/
cost_data;
/**
* @type { boolean }
*/
responded;
/**
* @type { string | undefined }
*/
judgestr;
/**
* @type { boolean }
*/
judging;
/**
* @type { Function | undefined }
*/
judge2;
/**
* @type { Card[] }
*/
orderingCards;
/**
* @type { Function | undefined }
*/
ai;
/**
* @param {keyof this} key
* @param {number} [value]

View File

@ -1,3 +1,17 @@
/**
* @typedef { {
* useCard: GameEventPromise[],
* respond: GameEventPromise[],
* skipped: GameEventPromise[],
* lose: GameEventPromise[],
* gain: GameEventPromise[],
* sourceDamage: GameEventPromise[],
* damage: GameEventPromise[],
* custom: GameEventPromise[],
* useSkill: GameEventPromise[],
* }} ActionHistory
*/
import { ai } from "../../ai/index.js";
import { get } from "../../get/index.js";
import { game } from "../../game/index.js";
@ -224,17 +238,7 @@ export class Player extends HTMLDivElement {
*/
stat;
/**
* @type { {
* useCard: GameEventPromise[],
* respond: GameEventPromise[],
* skipped: GameEventPromise[],
* lose: GameEventPromise[],
* gain: GameEventPromise[],
* sourceDamage: GameEventPromise[],
* damage: GameEventPromise[],
* custom: GameEventPromise[],
* useSkill: GameEventPromise[],
* }[] }
* @type { ActionHistory[] }
*/
actionHistory;
/**
@ -262,7 +266,8 @@ export class Player extends HTMLDivElement {
* friend: [],
* enemy: [],
* neutral: [],
* handcards: {
* shown?: number,
* handcards?: {
* global: [],
* source: [],
* viewed: []
@ -342,6 +347,18 @@ export class Player extends HTMLDivElement {
* @type { ((player: this) => any)[] }
*/
_inits;
/**
* @type { boolean }
*/
isZhu;
/**
* @type { string }
*/
identity;
/**
* @type { boolean | undefined }
*/
identityShown;
//新函数
/**
* 怒气
@ -1402,7 +1419,7 @@ export class Player extends HTMLDivElement {
/**
* 向target发起协力
* @param { Player } target
* @param {*} type
* @param { string } type
* @param {*} reason
*/
cooperationWith(target, type, reason) {
@ -2023,6 +2040,7 @@ export class Player extends HTMLDivElement {
/**
* @param { string } name
* @param { string } type
* @returns { boolean }
*/
hasUsableCard(name, type) {
if (typeof type !== "string") type = type ? "limit" : "all";
@ -3698,6 +3716,12 @@ export class Player extends HTMLDivElement {
if (num == undefined) return 0;
return num;
}
/**
* @param {*} [unowned]
* @param {*} [unique]
* @param {*} [hidden]
* @returns { string[] }
*/
getStockSkills(unowned, unique, hidden) {
var list = [];
if (lib.character[this.name] && (hidden || !this.isUnseen(0))) {
@ -3842,6 +3866,11 @@ export class Player extends HTMLDivElement {
getDiscardableCards(player, arg1, arg2) {
return Array.from(this.iterableGetDiscardableCards(player, arg1, arg2));
}
/**
* @param {Parameters<lib['filter']['canBeGained']>[1]} player
* @param {Parameters<this['iterableGetCards']>[0]} arg1
* @param {Parameters<this['iterableGetCards']>[1]} arg2
*/
*iterableGetGainableCards(player, arg1, arg2) {
for (let card of this.iterableGetCards(arg1, arg2)) {
if (lib.filter.canBeGained(card, player, this)) {
@ -3849,6 +3878,12 @@ export class Player extends HTMLDivElement {
}
}
}
/**
*
* @param {Parameters<this['iterableGetGainableCards']>[0]} player
* @param {Parameters<this['iterableGetGainableCards']>[1]} [arg1]
* @param {Parameters<this['iterableGetGainableCards']>[2]} [arg2]
*/
getGainableCards(player, arg1, arg2) {
return Array.from(this.iterableGetGainableCards(player, arg1, arg2));
}
@ -3860,6 +3895,10 @@ export class Player extends HTMLDivElement {
}
return list;
}
/**
* @param { Parameters<typeof this['iterableGetCards']>[0] } [arg1]
* @param { Parameters<typeof this['iterableGetCards']>[1] } [arg2]
*/
countCards(arg1, arg2) {
let count = 0;
for (let item of this.iterableGetCards(arg1, arg2)) {
@ -3883,6 +3922,11 @@ export class Player extends HTMLDivElement {
countDiscardableCards(player, arg1, arg2) {
return this.getDiscardableCards(player, arg1, arg2).length;
}
/**
* @param {Parameters<this['getGainableCards']>[0]} player
* @param {Parameters<this['getGainableCards']>[1]} [arg1]
* @param {Parameters<this['getGainableCards']>[2]} [arg2]
*/
countGainableCards(player, arg1, arg2) {
return this.getGainableCards(player, arg1, arg2).length;
}
@ -3906,6 +3950,11 @@ export class Player extends HTMLDivElement {
skills.sort((a, b) => get.priority(a) - get.priority(b));
return skills;
}
/**
* @param { string | boolean | null } [arg2]
* @param { boolean | null} [arg3]
* @param {boolean} [arg4]
*/
getSkills(arg2, arg3, arg4) {
var skills = this.skills.slice(0);
var es = [];
@ -5781,7 +5830,12 @@ export class Player extends HTMLDivElement {
);
return this;
}
gainMultiple(targets, position) {
/**
*
* @param { Player[] } targets
* @param { string } [position]
*/
gainMultiple(targets, position = "h") {
var next = game.createEvent("gainMultiple", false);
next.setContent("gainMultiple");
next.player = this;
@ -5945,6 +5999,12 @@ export class Player extends HTMLDivElement {
next.gaintag = [];
return next;
}
/**
*
* @param { Card | Card[] } cards
* @param { Player } target
* @param { boolean } [visible]
*/
give(cards, target, visible) {
var next = target.gain(cards, this);
next.animate = visible ? "give" : "giveAuto";
@ -6136,6 +6196,9 @@ export class Player extends HTMLDivElement {
next.setContent("doubleDraw");
return next;
}
/**
* @param { number } [num]
*/
loseHp(num) {
var next = game.createEvent("loseHp");
next.num = num;
@ -6787,6 +6850,12 @@ export class Player extends HTMLDivElement {
}
if (typeof proceed == "function") proceed();
}
/**
* @param { string | string[] } name
* @param { Player | Player[] } [targets]
* @param { boolean | string } [nature]
* @param { boolean } [logv]
*/
logSkill(name, targets, nature, logv) {
if (get.itemtype(targets) == "player") targets = [targets];
var nopop = false;
@ -6980,7 +7049,13 @@ export class Player extends HTMLDivElement {
node.classList.add(className);
}
}
popup(name, className, nobroadcast) {
/**
*
* @param { string } name
* @param { string } className
* @param { Parameters<this["damagepop"]>[3] } [nobroadcast]
*/
popup(name, className = "water", nobroadcast) {
var name2 = get.translation(name);
if (!name2) return;
this.$damagepop(name2, className || "water", true, nobroadcast);
@ -7403,6 +7478,13 @@ export class Player extends HTMLDivElement {
this.classList.remove("linked");
}
}
/**
* @param { string | Card | VCard } card
* @param { Player } target
* @param { boolean } [distance]
* @param { GameEventPromise | boolean } [includecard]
* @returns { boolean }
*/
canUse(card, target, distance, includecard) {
if (typeof card == "string") card = { name: card, isCard: true };
var info = get.info(card);
@ -8247,6 +8329,18 @@ export class Player extends HTMLDivElement {
}
});
}
/**
* @overload
* @param { string } skill
* @param { SkillTrigger | string } [expire]
* @param { boolean } [checkConflict]
*/
/**
* @overload
* @param { string[] } skill
* @param { SkillTrigger } [expire]
* @param { boolean } [checkConflict]
*/
addTempSkill(skill, expire, checkConflict) {
if (Array.isArray(skill)) {
for (var i = 0; i < skill.length; i++) {
@ -8417,6 +8511,18 @@ export class Player extends HTMLDivElement {
}
return evts;
}
/**
* @overload
* @returns { ActionHistory }
*/
/**
* @template { keyof ActionHistory } T
* @overload
* @param { T } key
* @param { (event: GameEventPromise) => boolean } [filter]
* @param { GameEventPromise } [last]
* @returns { ActionHistory[T] }
*/
getHistory(key, filter, last) {
if (!key) return this.actionHistory[this.actionHistory.length - 1];
if (!filter) return this.actionHistory[this.actionHistory.length - 1][key];
@ -8432,6 +8538,12 @@ export class Player extends HTMLDivElement {
return history.filter(filter);
}
}
/**
* @template { keyof ActionHistory } T
* @param { T } key
* @param { (event: GameEventPromise) => boolean } filter
* @param { GameEventPromise } [last]
*/
checkHistory(key, filter, last) {
if (!key || !filter) return;
else {
@ -8447,7 +8559,14 @@ export class Player extends HTMLDivElement {
}
}
}
hasHistory(key, filter, last) {
/**
* @template { keyof ActionHistory } T
* @param { T } key
* @param { (event: GameEventPromise) => boolean } [filter]
* @param { GameEventPromise } [last]
* @returns { boolean }
*/
hasHistory(key, filter = lib.filter.all, last) {
const history = this.getHistory(key);
if (!filter || typeof filter != "function") filter = lib.filter.all;
if (last) {
@ -8459,6 +8578,14 @@ export class Player extends HTMLDivElement {
}
return history.some(filter);
}
/**
* @template { keyof ActionHistory } T
* @overload
* @param { T } [key]
* @param { (event: GameEventPromise) => boolean } [filter]
* @param { GameEventPromise } [last]
* @returns { null | ActionHistory[T] | boolean }
*/
getLastHistory(key, filter, last) {
let history = false;
for (let i = this.actionHistory.length - 1; i >= 0; i--) {
@ -8481,6 +8608,12 @@ export class Player extends HTMLDivElement {
return history.filter(filter);
}
}
/**
* @template { keyof ActionHistory } T
* @param { T } key
* @param { (event: GameEventPromise) => boolean } filter
* @param { GameEventPromise } [last]
*/
checkAllHistory(key, filter, last) {
if (!key || !filter) return;
this.actionHistory.forEach((value) => {
@ -8496,6 +8629,13 @@ export class Player extends HTMLDivElement {
}
});
}
/**
* @template { keyof ActionHistory } T
* @param { T } [key]
* @param { (event: GameEventPromise) => boolean } [filter]
* @param { GameEventPromise } [last]
* @returns { ActionHistory[T] }
*/
getAllHistory(key, filter, last) {
const history = [];
this.actionHistory.forEach((value) => {
@ -8517,6 +8657,13 @@ export class Player extends HTMLDivElement {
}
return history;
}
/**
* @template { keyof ActionHistory } T
* @param { T } key
* @param { (event: GameEventPromise) => boolean } filter
* @param { GameEventPromise } [last]
* @returns { boolean }
*/
hasAllHistory(key, filter, last) {
return this.actionHistory.some((value) => {
let history = value[key];
@ -9096,6 +9243,12 @@ export class Player extends HTMLDivElement {
}
return false;
}
/**
*
* @param { number | Card[] | Card } [add]
* @param { (card?: Card, player?: Player) => boolean } [filter]
* @param { boolean } [pure]
*/
needsToDiscard(add, filter, pure) {
/**
* add: (逻辑上)同时考虑获得的这张/些牌
@ -9124,9 +9277,23 @@ export class Player extends HTMLDivElement {
distanceFrom(target, method) {
return get.distance(target, this, method);
}
/**
* @param { string } skill
* @param { Parameters<this['getSkills']>[0] } arg2
* @param { Parameters<this['getSkills']>[1] } arg3
* @param { Parameters<this['getSkills']>[2] } arg4
* @returns { boolean }
*/
hasSkill(skill, arg2, arg3, arg4) {
return game.expandSkills(this.getSkills(arg2, arg3, arg4)).includes(skill);
}
/**
* @param { string } skill
* @param { Parameters<this['getStockSkills']>[0] } arg1
* @param { Parameters<this['getStockSkills']>[1] } arg2
* @param { Parameters<this['getStockSkills']>[2] } arg3
* @returns { boolean }
*/
hasStockSkill(skill, arg1, arg2, arg3) {
return game.expandSkills(this.getStockSkills(arg1, arg2, arg3)).includes(skill);
}
@ -9153,6 +9320,11 @@ export class Player extends HTMLDivElement {
}
return false;
}
/**
*
* @param {string} skill
* @param {Player} [player]
*/
hasZhuSkill(skill, player) {
if (!this.hasSkill(skill)) return false;
if (player) {
@ -9187,6 +9359,12 @@ export class Player extends HTMLDivElement {
}
return false;
}
/**
* @param {string} tag
* @param {Parameters<this['getSkills']>[0]} hidden
* @param {Parameters<SkillAI['skillTagFilter']>[2]} arg
* @param {boolean} [globalskill]
*/
hasSkillTag(tag, hidden, arg, globalskill) {
var skills = this.getSkills(hidden);
if (globalskill) {
@ -9281,6 +9459,11 @@ export class Player extends HTMLDivElement {
}
return false;
}
/**
*
* @param {string|boolean} [respond]
* @param {boolean} [noauto]
*/
hasSha(respond, noauto) {
if (this.countCards("hs", "sha")) return true;
if (this.countCards("hs", "hufu")) return true;
@ -10848,7 +11031,14 @@ export class Player extends HTMLDivElement {
avatar ? 1600 : 1000
);
}
$damagepop(num, nature, font, nobroadcast) {
/**
*
* @param { number | string } num
* @param { string } [nature]
* @param { boolean } [font]
* @param { boolean } [nobroadcast]
*/
$damagepop(num, nature = "soil", font, nobroadcast) {
if (typeof num == "number" || typeof num == "string") {
game.addVideo("damagepop", this, [num, nature, font]);
if (nobroadcast !== false)

View File

@ -136,6 +136,10 @@ export class UI {
* @type {HTMLDivElement}
*/
tempnowuxie;
/**
* @type {HTMLDivElement}
*/
cardPile;
refresh(node) {
void window.getComputedStyle(node, null).getPropertyValue("opacity");
}