优化代码提示,codeMirror修改为esmodule

This commit is contained in:
shijian 2023-12-31 23:26:10 +08:00
parent 26cd6fae95
commit 9fdf573bc7
15 changed files with 10354 additions and 10324 deletions

View File

@ -1,68 +1,67 @@
(() => {
function getDocumentZoom() { function getDocumentZoom() {
//一般body的缩放是xy同步的 //一般body的缩放是xy同步的
var transform = getComputedStyle(document.body).transform; var transform = getComputedStyle(document.body).transform;
// @ts-ignore
if (transform == 'none') transform = 1; if (transform == 'none') transform = 1;
// @ts-ignore
else transform = +transform.slice(7, -1).split(',')[0]; else transform = +transform.slice(7, -1).split(',')[0];
return +transform; return +transform;
} }
// BROWSER SNIFFING // BROWSER SNIFFING
// Kludges for bugs and behavior differences that can't be feature // Kludges for bugs and behavior differences that can't be feature
// detected are enabled based on userAgent etc sniffing. // detected are enabled based on userAgent etc sniffing.
var userAgent = navigator.userAgent; var userAgent = navigator.userAgent;
var platform = navigator.platform; var platform = navigator.platform;
var gecko = /gecko\/\d/i.test(userAgent); var gecko = /gecko\/\d/i.test(userAgent);
var ie_upto10 = /MSIE \d/.test(userAgent); var ie_upto10 = /MSIE \d/.test(userAgent);
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent); var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
var ie = ie_upto10 || ie_11up; var ie = ie_upto10 || ie_11up;
var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]); // @ts-ignore
var webkit = /WebKit\//.test(userAgent); var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent); var webkit = /WebKit\//.test(userAgent);
var chrome = /Chrome\//.test(userAgent); var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
var presto = /Opera\//.test(userAgent); var chrome = /Chrome\//.test(userAgent);
var safari = /Apple Computer/.test(navigator.vendor); var presto = /Opera\//.test(userAgent);
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent); var safari = /Apple Computer/.test(navigator.vendor);
var phantom = /PhantomJS/.test(userAgent); var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
var phantom = /PhantomJS/.test(userAgent);
var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent); var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
// This is woefully incomplete. Suggestions for alternative methods welcome. // This is woefully incomplete. Suggestions for alternative methods welcome.
var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent); var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
var mac = ios || /Mac/.test(platform); var mac = ios || /Mac/.test(platform);
var chromeOS = /\bCrOS\b/.test(userAgent); var chromeOS = /\bCrOS\b/.test(userAgent);
var windows = /win/i.test(platform); var windows = /win/i.test(platform);
var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/); var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
if (presto_version) presto_version = Number(presto_version[1]); // @ts-ignore
if (presto_version && presto_version >= 15) { presto = false; webkit = true; } if (presto_version) presto_version = Number(presto_version[1]);
// Some browsers use the wrong event properties to signal cmd/ctrl on OS X // @ts-ignore
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11)); if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
var captureRightClick = gecko || (ie && ie_version >= 9); // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
// @ts-ignore
var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
var captureRightClick = gecko || (ie && ie_version >= 9);
// Optimize some code when these features are not used. // Optimize some code when these features are not used.
var sawReadOnlySpans = false, sawCollapsedSpans = false; var sawReadOnlySpans = false, sawCollapsedSpans = false;
// EDITOR CONSTRUCTOR // EDITOR CONSTRUCTOR
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: http://codemirror.net/LICENSE
// This is CodeMirror (http://codemirror.net), a code editor // This is CodeMirror (http://codemirror.net), a code editor
// implemented in JavaScript on top of the browser's DOM. // implemented in JavaScript on top of the browser's DOM.
// //
// You can find some technical background for some of the code below // You can find some technical background for some of the code below
// at http://marijnhaverbeke.nl/blog/#cm-internals . // at http://marijnhaverbeke.nl/blog/#cm-internals .
(function (mod) { var CodeMirror = (function () {
if (typeof exports == "object" && typeof module == "object") // CommonJS
module.exports = mod();
else if (typeof define == "function" && define.amd) // AMD
return define([], mod);
else // Plain browser env
(this || window).CodeMirror = mod();
})(function () {
// A CodeMirror instance represents an editor. This is the object // A CodeMirror instance represents an editor. This is the object
// that user code is usually dealing with. // that user code is usually dealing with.
@ -8984,19 +8983,17 @@
CodeMirror.version = "5.17.0"; CodeMirror.version = "5.17.0";
return CodeMirror; return CodeMirror;
}); })();
// @ts-ignore
window.CodeMirror = CodeMirror;
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// CodeMirror, copyright (c) by Marijn Haverbeke and others // TODO actually recognize syntax of TypeScript constructs
// Distributed under an MIT license: http://codemirror.net/LICENSE
// TODO actually recognize syntax of TypeScript constructs (function () {
(function (mod) {
// Plain browser env
mod(CodeMirror);
})(function (CodeMirror) {
"use strict"; "use strict";
function expressionAllowed(stream, state, backUp) { function expressionAllowed(stream, state, backUp) {
@ -9726,15 +9723,12 @@
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
}); })();
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE // Distributed under an MIT license: http://codemirror.net/LICENSE
(function (mod) { (function () {
// Plain browser env
mod(CodeMirror);
})(function (CodeMirror) {
var defaults = { var defaults = {
pairs: "()[]{}''\"\"", pairs: "()[]{}''\"\"",
triples: "", triples: "",
@ -9920,17 +9914,14 @@
stream.start = stream.pos; stream.start = stream.pos;
} }
} }
}); })();
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE // Distributed under an MIT license: https://codemirror.net/LICENSE
// declare global: DOMRect // declare global: DOMRect
(function (mod) { (function () {
// Plain browser env
mod(CodeMirror);
})(function (CodeMirror) {
"use strict"; "use strict";
var HINT_ELEMENT_CLASS = "CodeMirror-hint"; var HINT_ELEMENT_CLASS = "CodeMirror-hint";
@ -10458,5 +10449,6 @@
}; };
CodeMirror.defineOption("hintOptions", null); CodeMirror.defineOption("hintOptions", null);
});
})(); })();
export default CodeMirror;

View File

@ -1,6 +1,6 @@
{ {
"name": "noname-typings", "name": "noname-typings",
"version": "2023.12.30", "version": "2023.12.31",
"description": "Noname typings, mainly for showing type hints when creating extensions of the Sanguosha-like game Noname.", "description": "Noname typings, mainly for showing type hints when creating extensions of the Sanguosha-like game Noname.",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -31,3 +31,9 @@ declare type GameEvent = import('../../noname/library/index.js').GameEvent;
declare type GameEventPromise = import('../../noname/library/index.js').GameEventPromise; declare type GameEventPromise = import('../../noname/library/index.js').GameEventPromise;
declare type Player = import('../../noname/library/index.js').Player; declare type Player = import('../../noname/library/index.js').Player;
declare type VCard = import('../../noname/library/index.js').VCard; declare type VCard = import('../../noname/library/index.js').VCard;
declare type Video = import('../../noname/game/index.js').Video;
declare type Videos = import('../../noname/game/index.js').Videos;
declare type History = import('../../noname/game/index.js').History;
declare type CodeMirror = typeof import('../../game/codemirror.js').default;

View File

@ -7,7 +7,9 @@ declare interface Window {
version: string, version: string,
update: string, update: string,
changeLog: string[], changeLog: string[],
files: string[] files: string[],
players?: string[],
cards?: string[],
} }
/** 游戏配置 */ /** 游戏配置 */
@ -25,7 +27,7 @@ declare interface Window {
noname_skin_list?: SMap<number>; noname_skin_list?: SMap<number>;
/** codeMirror,一个代码编辑器库 */ /** codeMirror,一个代码编辑器库 */
CodeMirror: any; CodeMirror: CodeMirror;
resetGameTimeout: number; resetGameTimeout: number;
@ -66,4 +68,15 @@ declare interface Window {
get: Get; get: Get;
ai: AI; ai: AI;
} }
initReadWriteFunction?(game = ({
download: () => any,
readFile: () => any,
readFileAsText: () => any,
writeFile: () => any,
removeFile: () => any,
getFileList: () => any,
ensureDirectory: () => any,
createDir: () => any,
})): void;
} }

View File

@ -9,8 +9,8 @@ import { Uninstantable } from "../util/index.js";
export class Basic extends Uninstantable { export class Basic extends Uninstantable {
/** /**
* @param { ( * @param { (
* button: import('../library/index.js').Button, * button: Button,
* buttons?: import('../library/index.js').Button[] * buttons?: Button[]
* ) => number } check * ) => number } check
*/ */
static chooseButton(check) { static chooseButton(check) {
@ -65,8 +65,8 @@ export class Basic extends Uninstantable {
} }
/** /**
* @param { ( * @param { (
* card?: import('../library/index.js').Card, * card?: Card,
* cards?: import('../library/index.js').Card[] * cards?: Card[]
* ) => number } check * ) => number } check
* @returns { boolean | undefined } * @returns { boolean | undefined }
*/ */
@ -143,8 +143,8 @@ export class Basic extends Uninstantable {
} }
/** /**
* @param { ( * @param { (
* target?: import('../library/index.js').Player, * target?: Player,
* targets?: import('../library/index.js').Player[] * targets?: Player[]
* ) => number } check * ) => number } check
*/ */
static chooseTarget(check) { static chooseTarget(check) {

View File

@ -1,10 +1,10 @@
/** /**
* @typedef {{ * @typedef {{
* cardMove:(import('../library/index.js').GameEventPromise)[], * cardMove:GameEventPromise[],
* custom: (import('../library/index.js').GameEventPromise)[], * custom: GameEventPromise[],
* useCard: (import('../library/index.js').GameEventPromise)[], * useCard: GameEventPromise[],
* changeHp: (import('../library/index.js').GameEventPromise)[], * changeHp: GameEventPromise[],
* everything: (import('../library/index.js').GameEventPromise)[] * everything: GameEventPromise[]
* }} History * }} History
* @typedef { { type: string, player?: string, content?: string | any[], delay: number } } Video * @typedef { { type: string, player?: string, content?: string | any[], delay: number } } Video
* @typedef { { mode: string, name: string[], name1: string, name2?: string, time: number, video: Video, win: boolean } } Videos * @typedef { { mode: string, name: string[], name1: string, name2?: string, time: number, video: Video, win: boolean } } Videos
@ -23,16 +23,16 @@ export class Game extends Uninstantable {
static onlineID = null; static onlineID = null;
static onlineKey = null; static onlineKey = null;
/** /**
* @type {import('../library/index.js').Player[]} * @type {Player[]}
*/ */
static players = []; static players = [];
/** /**
* @type {import('../library/index.js').Player[]} * @type {Player[]}
*/ */
static dead = []; static dead = [];
static imported = []; static imported = [];
/** /**
* @type { { [key: string]: import('../library/index.js').Player } } * @type { { [key: string]: Player } }
*/ */
static playerMap = {}; static playerMap = {};
static phaseNumber = 0; static phaseNumber = 0;
@ -664,8 +664,8 @@ export class Game extends Uninstantable {
} }
/** /**
* 为牌添加知情者 * 为牌添加知情者
* @param { import('../library/index.js').Card[] | import('../library/index.js').Card } cards * @param { Card[] | Card } cards
* @param { import('../library/index.js').Player[] } players * @param { Player[] } players
*/ */
static addCardKnower(cards, players) { static addCardKnower(cards, players) {
if (get.itemtype(cards) == 'card') { if (get.itemtype(cards) == 'card') {
@ -677,7 +677,7 @@ export class Game extends Uninstantable {
} }
/** /**
* 移除牌的所有知情者 * 移除牌的所有知情者
* @param { import('../library/index.js').Card[] | import('../library/index.js').Card } cards * @param { Card[] | Card } cards
*/ */
static clearCardKnowers(cards) { static clearCardKnowers(cards) {
// @ts-ignore // @ts-ignore
@ -775,8 +775,8 @@ export class Game extends Uninstantable {
/** /**
* @template { keyof History } T * @template { keyof History } T
* @param { T } key * @param { T } key
* @param { (event: import('../library/index.js').GameEventPromise) => boolean } filter * @param { (event: GameEventPromise) => boolean } filter
* @param { import('../library/index.js').GameEventPromise } [last] * @param { GameEventPromise } [last]
* @returns { boolean } * @returns { boolean }
*/ */
static hasGlobalHistory(key, filter, last) { static hasGlobalHistory(key, filter, last) {
@ -799,8 +799,8 @@ export class Game extends Uninstantable {
/** /**
* @template { keyof History } T * @template { keyof History } T
* @param { T } key * @param { T } key
* @param { (event: import('../library/index.js').GameEventPromise) => boolean } filter * @param { (event: GameEventPromise) => boolean } filter
* @param { import('../library/index.js').GameEventPromise } [last] * @param { GameEventPromise } [last]
* @returns { void } * @returns { void }
*/ */
static checkGlobalHistory(key, filter, last) { static checkGlobalHistory(key, filter, last) {
@ -828,8 +828,8 @@ export class Game extends Uninstantable {
* @template { keyof History } T * @template { keyof History } T
* @overload * @overload
* @param { T } key * @param { T } key
* @param { (event: import('../library/index.js').GameEventPromise) => boolean } [filter] * @param { (event: GameEventPromise) => boolean } [filter]
* @param { import('../library/index.js').GameEventPromise } [last] * @param { GameEventPromise } [last]
* @returns { History[T] } * @returns { History[T] }
*/ */
static getGlobalHistory(key, filter, last) { static getGlobalHistory(key, filter, last) {
@ -850,8 +850,8 @@ export class Game extends Uninstantable {
/** /**
* @template { keyof History } T * @template { keyof History } T
* @param { T } key * @param { T } key
* @param { (event: import('../library/index.js').GameEventPromise) => boolean } filter * @param { (event: GameEventPromise) => boolean } filter
* @param { import('../library/index.js').GameEventPromise } [last] * @param { GameEventPromise } [last]
* @returns { boolean } * @returns { boolean }
*/ */
static hasAllGlobalHistory(key, filter, last) { static hasAllGlobalHistory(key, filter, last) {
@ -874,8 +874,8 @@ export class Game extends Uninstantable {
/** /**
* @template { keyof History } T * @template { keyof History } T
* @param { T } key * @param { T } key
* @param { (event: import('../library/index.js').GameEventPromise) => boolean } filter * @param { (event: GameEventPromise) => boolean } filter
* @param { import('../library/index.js').GameEventPromise } [last] * @param { GameEventPromise } [last]
* @returns { void } * @returns { void }
*/ */
static checkAllGlobalHistory(key, filter, last) { static checkAllGlobalHistory(key, filter, last) {
@ -905,8 +905,8 @@ export class Game extends Uninstantable {
* @template { keyof History } T * @template { keyof History } T
* @overload * @overload
* @param { T } key * @param { T } key
* @param { (event: import('../library/index.js').GameEventPromise) => boolean } [filter] * @param { (event: GameEventPromise) => boolean } [filter]
* @param { import('../library/index.js').GameEventPromise } [last] * @param { GameEventPromise } [last]
* @returns { History[T] } * @returns { History[T] }
*/ */
static getAllGlobalHistory(key, filter, last) { static getAllGlobalHistory(key, filter, last) {
@ -937,13 +937,13 @@ export class Game extends Uninstantable {
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Card } cards * @param { Card } cards
* @returns { import('../library/index.js').GameEventPromise } * @returns { GameEventPromise }
*/ */
/** /**
* @overload * @overload
* @param {import('../library/index.js').Card[]} cards * @param {Card[]} cards
* @returns { import('../library/index.js').GameEventPromise } * @returns { GameEventPromise }
*/ */
static cardsDiscard(cards) { static cardsDiscard(cards) {
/** @type { 'cards' | 'card' | void } */ /** @type { 'cards' | 'card' | void } */
@ -965,13 +965,13 @@ export class Game extends Uninstantable {
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Card } cards * @param { Card } cards
* @returns { import('../library/index.js').GameEventPromise } * @returns { GameEventPromise }
*/ */
/** /**
* @overload * @overload
* @param {import('../library/index.js').Card[]} cards * @param {Card[]} cards
* @returns { import('../library/index.js').GameEventPromise } * @returns { GameEventPromise }
*/ */
static cardsGotoOrdering(cards) { static cardsGotoOrdering(cards) {
/** @type { 'cards' | 'card' | void } */ /** @type { 'cards' | 'card' | void } */
@ -989,15 +989,15 @@ export class Game extends Uninstantable {
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Card } cards * @param { Card } cards
* @param { 'toRenku' | false } [bool] 为false时不触发trigger'toRenku'时牌放到仁库 * @param { 'toRenku' | false } [bool] 为false时不触发trigger'toRenku'时牌放到仁库
* @returns { import('../library/index.js').GameEventPromise } * @returns { GameEventPromise }
*/ */
/** /**
* @overload * @overload
* @param {import('../library/index.js').Card[]} cards * @param {Card[]} cards
* @param { 'toRenku' | false } [bool] 为false时不触发trigger'toRenku'时牌放到仁库 * @param { 'toRenku' | false } [bool] 为false时不触发trigger'toRenku'时牌放到仁库
* @returns { import('../library/index.js').GameEventPromise } * @returns { GameEventPromise }
*/ */
static cardsGotoSpecial(cards, bool) { static cardsGotoSpecial(cards, bool) {
/** @type { 'cards' | 'card' | void } */ /** @type { 'cards' | 'card' | void } */
@ -1014,8 +1014,8 @@ export class Game extends Uninstantable {
/** /**
* *
* @param {...( * @param {...(
* import('../library/index.js').Card[] | * Card[] |
* import('../library/index.js').Card | * Card |
* Function | * Function |
* 'insert' | 'washCard' | 'triggeronly' | * 'insert' | 'washCard' | 'triggeronly' |
* [string, any] * [string, any]
@ -1024,7 +1024,7 @@ export class Game extends Uninstantable {
*/ */
static cardsGotoPile(...args) { static cardsGotoPile(...args) {
/** /**
* @type { import('../library/index.js').Card[] } * @type { Card[] }
*/ */
const cards = []; const cards = [];
const next = game.createEvent('cardsGotoPile'); const next = game.createEvent('cardsGotoPile');
@ -1060,7 +1060,7 @@ export class Game extends Uninstantable {
return next; return next;
} }
/** /**
* @param { import('../library/index.js').GameEventPromise } event * @param { GameEventPromise } event
*/ */
static $cardsGotoPile(event) { static $cardsGotoPile(event) {
const cards = event.cards; const cards = event.cards;
@ -1115,7 +1115,7 @@ export class Game extends Uninstantable {
/** /**
* *
* @param { string } url * @param { string } url
* @param { import('../library/index.js').Player } [player] * @param { Player } [player]
*/ */
static changeLand(url, player) { static changeLand(url, player) {
game.addVideo('changeLand', player, url); game.addVideo('changeLand', player, url);
@ -1219,7 +1219,7 @@ export class Game extends Uninstantable {
} }
} }
/** /**
* @param {...(import('../library/index.js').Player[] | import('../library/index.js').Player)} args * @param {...(Player[] | Player)} args
*/ */
static replaceHandcards(...args) { static replaceHandcards(...args) {
var next = game.createEvent('replaceHandcards'); var next = game.createEvent('replaceHandcards');
@ -1696,7 +1696,7 @@ export class Game extends Uninstantable {
* @typedef {[string,number]|string|number|boolean} audioInfo * @typedef {[string,number]|string|number|boolean} audioInfo
* @typedef {{audio: audioInfo, audioname?:string[], audioname2?:{[playerName: string]: audioInfo}}} skillInfo * @typedef {{audio: audioInfo, audioname?:string[], audioname2?:{[playerName: string]: audioInfo}}} skillInfo
* @param { string } skill 技能名 * @param { string } skill 技能名
* @param { import('../library/index.js').Player | string } [player] 角色/角色名 * @param { Player | string } [player] 角色/角色名
* @param { skillInfo | audioInfo } [skillInfo] 预设的skillInfo/audioInfo(转为skillInfo)覆盖lib.skill[skill] * @param { skillInfo | audioInfo } [skillInfo] 预设的skillInfo/audioInfo(转为skillInfo)覆盖lib.skill[skill]
* @returns { string[] } 语音地址列表 * @returns { string[] } 语音地址列表
* @example * @example
@ -1829,10 +1829,10 @@ export class Game extends Uninstantable {
/** /**
* *
* @param { string } skill * @param { string } skill
* @param { import('../library/index.js').Player | string } player * @param { Player | string } player
* @param { boolean } [directaudio] * @param { boolean } [directaudio]
* @param { boolean } [nobroadcast] * @param { boolean } [nobroadcast]
* @param { import('../library/index.js').['lib']['skill'] } [skillInfo] * @param { ['lib']['skill'] } [skillInfo]
* @returns * @returns
*/ */
static trySkillAudio(skill, player, directaudio, nobroadcast, skillInfo) { static trySkillAudio(skill, player, directaudio, nobroadcast, skillInfo) {
@ -1907,8 +1907,8 @@ export class Game extends Uninstantable {
ui.window.appendChild(audio); ui.window.appendChild(audio);
} }
/** /**
* @param { string | import('../library/index.js').Card } card * @param { string | Card } card
* @param { import('../library/index.js').Player | import('../library/index.js').Sex } sex * @param { Player | Sex } sex
*/ */
static playCardAudio(card, sex) { static playCardAudio(card, sex) {
if (typeof card === 'string') { if (typeof card === 'string') {
@ -1978,12 +1978,12 @@ export class Game extends Uninstantable {
/** /**
* @param { string } type * @param { string } type
* @param {( * @param {(
* lib: import('../library/index.js')['Library'], * lib: Library,
* game: typeof Game, * game: typeof Game,
* ui: import('../ui/index.js')['UI'], * ui: UI,
* get: import('../get/index.js')['Get'], * get: Get,
* ai: import('../ai/index.js')['AI'], * ai: AI,
* _status: import('../status/index.js')['_status'] * _status: Status
* ) => any } content * ) => any } content
* @param {*} [url] * @param {*} [url]
* @returns * @returns
@ -4515,8 +4515,8 @@ export class Game extends Uninstantable {
/** /**
* @param { string } name * @param { string } name
* @param { string } skill * @param { string } skill
* @param { import('../library/index.js').Player } player * @param { Player } player
* @param { import('../library/index.js').GameEventPromise } event * @param { GameEventPromise } event
*/ */
static createTrigger(name, skill, player, event) { static createTrigger(name, skill, player, event) {
let info = get.info(skill); let info = get.info(skill);
@ -4537,7 +4537,7 @@ export class Game extends Uninstantable {
* *
* @param { string } name * @param { string } name
* @param { false } [trigger] * @param { false } [trigger]
* @param { import('../library/index.js').GameEventPromise } [triggerEvent] * @param { GameEventPromise } [triggerEvent]
*/ */
static createEvent(name, trigger, triggerEvent) { static createEvent(name, trigger, triggerEvent) {
const next = (new lib.element.GameEvent(name, trigger)).toPromise(); const next = (new lib.element.GameEvent(name, trigger)).toPromise();
@ -4546,7 +4546,7 @@ export class Game extends Uninstantable {
} }
/** /**
* @param { string } name * @param { string } name
* @param { { extension: string, sex: import('../library/index.js').Sex, group: string, hp: string | number, skills?: string[], tags?: any[], translate: string } } information * @param { { extension: string, sex: Sex, group: string, hp: string | number, skills?: string[], tags?: any[], translate: string } } information
*/ */
static addCharacter(name, information) { static addCharacter(name, information) {
const extensionName = _status.extension || information.extension, character = [ const extensionName = _status.extension || information.extension, character = [
@ -4568,7 +4568,7 @@ export class Game extends Uninstantable {
lib.translate[`${packName}_character_config`] = extensionName; lib.translate[`${packName}_character_config`] = extensionName;
} }
/** /**
* @param { { mode?: string, forbid?: any, character: { [key: string]: import('../library/index.js').Character }, skill: { [key: string]: object }, [key: string]: any } } pack * @param { { mode?: string, forbid?: any, character: { [key: string]: Character }, skill: { [key: string]: object }, [key: string]: any } } pack
* @param { string } [packagename] * @param { string } [packagename]
*/ */
static addCharacterPack(pack, packagename) { static addCharacterPack(pack, packagename) {
@ -4624,7 +4624,7 @@ export class Game extends Uninstantable {
} }
/** /**
* @param { string } name * @param { string } name
* @param { import('../library/index.js').Card } info * @param { Card } info
* @param { { extension: string, translate: string, description: string, number?: number, color?: string } } info2 * @param { { extension: string, translate: string, description: string, number?: number, color?: string } } info2
*/ */
static addCard(name, info, info2) { static addCard(name, info, info2) {
@ -4671,7 +4671,7 @@ export class Game extends Uninstantable {
lib.cardPack[packname].push(name); lib.cardPack[packname].push(name);
} }
/** /**
* @param { { extension: string, mode?: string[], forbid?: string[], list: any[], card: {[key: string]: import('../library/index.js').Card}, skill: { [key: string]: object } } } pack * @param { { extension: string, mode?: string[], forbid?: string[], list: any[], card: {[key: string]: Card}, skill: { [key: string]: object } } } pack
* @param { string } [packagename] * @param { string } [packagename]
*/ */
static addCardPack(pack, packagename) { static addCardPack(pack, packagename) {
@ -4783,7 +4783,7 @@ export class Game extends Uninstantable {
} }
/** /**
* @param { string } skill * @param { string } skill
* @param { import('../library/index.js').Player } [player] * @param { Player } [player]
*/ */
static addGlobalSkill(skill, player) { static addGlobalSkill(skill, player) {
let info = lib.skill[skill]; let info = lib.skill[skill];
@ -4930,11 +4930,11 @@ export class Game extends Uninstantable {
} }
/** /**
* @overload * @overload
* @returns { import('../library/index.js').Card } * @returns { Card }
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Card | string } name * @param { Card | string } name
* @param { string } suit * @param { string } suit
* @param { number } number * @param { number } number
* @param { string } nature * @param { string } nature
@ -4984,11 +4984,11 @@ export class Game extends Uninstantable {
} }
/** /**
* @overload * @overload
* @returns { import('../library/index.js').Card } * @returns { Card }
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Card | string } name * @param { Card | string } name
* @param { string } suit * @param { string } suit
* @param { number } number * @param { number } number
* @param { string } nature * @param { string } nature
@ -5655,7 +5655,7 @@ export class Game extends Uninstantable {
} }
} }
/** /**
* @type { Map<import('../library/index.js').GameEvent, Promise<any>> } * @type { Map<GameEvent, Promise<any>> }
* *
* 以Promise储存异步事件的执行链使async content调用事件时无需必须使用await * 以Promise储存异步事件的执行链使async content调用事件时无需必须使用await
* *
@ -5663,7 +5663,7 @@ export class Game extends Uninstantable {
*/ */
static executingAsyncEventMap = new Map(); static executingAsyncEventMap = new Map();
/** /**
* @param { import('../library/index.js').GameEventPromise } [belongAsyncEvent] * @param { GameEventPromise } [belongAsyncEvent]
*/ */
static async loop(belongAsyncEvent) { static async loop(belongAsyncEvent) {
if (belongAsyncEvent) { if (belongAsyncEvent) {
@ -5828,7 +5828,7 @@ export class Game extends Uninstantable {
} }
} }
/** /**
* @param { import('../library/index.js').GameEventPromise } [belongAsyncEvent] * @param { GameEventPromise } [belongAsyncEvent]
*/ */
static runContent(belongAsyncEvent) { static runContent(belongAsyncEvent) {
return new Promise(resolve => { return new Promise(resolve => {
@ -6033,7 +6033,7 @@ export class Game extends Uninstantable {
return game.asyncDelay(time, time2); return game.asyncDelay(time, time2);
} }
/** /**
* @param { import('../library/index.js').GameEventPromise } event * @param { GameEventPromise } [event]
*/ */
static check(event) { static check(event) {
let i, j, range; let i, j, range;
@ -6520,8 +6520,8 @@ export class Game extends Uninstantable {
_status.dragline.length = 0; _status.dragline.length = 0;
} }
/** /**
* @param { import('../library/index.js').Player } player1 * @param { Player } player1
* @param { import('../library/index.js').Player } player2 * @param { Player } player2
* @param { boolean } [prompt] * @param { boolean } [prompt]
* @param { boolean } [behind] * @param { boolean } [behind]
* @param { boolean } [noanimate] * @param { boolean } [noanimate]
@ -6585,8 +6585,8 @@ export class Game extends Uninstantable {
} }
} }
/** /**
* @param { import('../library/index.js').Player } player1 * @param { Player } player1
* @param { import('../library/index.js').Player } [player2] * @param { Player } [player2]
*/ */
static swapPlayer(player, player2) { static swapPlayer(player, player2) {
let players = game.players.concat(game.dead) let players = game.players.concat(game.dead)
@ -6655,7 +6655,7 @@ export class Game extends Uninstantable {
}, 100, players); }, 100, players);
} }
/** /**
* @param { import('../library/index.js').Player } player * @param { Player } player
*/ */
static swapControl(player) { static swapControl(player) {
if (player == game.me) return; if (player == game.me) return;
@ -6701,7 +6701,7 @@ export class Game extends Uninstantable {
} }
} }
/** /**
* @param { import('../library/index.js').Player } player * @param { Player } player
*/ */
static findNext(player) { static findNext(player) {
let players = get.players(lib.sort.position); let players = get.players(lib.sort.position);
@ -6943,7 +6943,7 @@ export class Game extends Uninstantable {
next.setContent('loadPackage'); next.setContent('loadPackage');
} }
/** /**
* @param { import('../library/index.js').Player } player * @param { Player } player
*/ */
static phaseLoop(player) { static phaseLoop(player) {
let next = game.createEvent('phaseLoop'); let next = game.createEvent('phaseLoop');
@ -6952,7 +6952,7 @@ export class Game extends Uninstantable {
next.setContent('phaseLoop'); next.setContent('phaseLoop');
} }
/** /**
* @param { import('../library/index.js').Player } [player] * @param { Player } [player]
*/ */
static gameDraw(player, num = 4) { static gameDraw(player, num = 4) {
let next = game.createEvent('gameDraw'); let next = game.createEvent('gameDraw');
@ -7488,8 +7488,8 @@ export class Game extends Uninstantable {
}, game.roundNumber, ui.cardPile.firstChild, ui.cardPile.childElementCount); }, game.roundNumber, ui.cardPile.firstChild, ui.cardPile.childElementCount);
} }
/** /**
* @param { import('../library/index.js').Player[] } players * @param { Player[] } players
* @param { number | number[] | (player: import('../library/index.js').Player) => number } num * @param { number | number[] | (player: Player) => number } num
* @param { { drawDeck: boolean } } [drawDeck] * @param { { drawDeck: boolean } } [drawDeck]
* @param { boolean } [bottom] * @param { boolean } [bottom]
*/ */
@ -7505,8 +7505,8 @@ export class Game extends Uninstantable {
}) })
} }
/** /**
* @param { import('../library/index.js').Player[] } players * @param { Player[] } players
* @param { number | number[] | (player: import('../library/index.js').Player) => number } num * @param { number | number[] | (player: Player) => number } num
* @param { { drawDeck: boolean } } [drawDeck] * @param { { drawDeck: boolean } } [drawDeck]
*/ */
static asyncDrawAuto(players, num, drawDeck) { static asyncDrawAuto(players, num, drawDeck) {
@ -7889,10 +7889,10 @@ export class Game extends Uninstantable {
}); });
} }
/** /**
* @param { import('../library/index.js').Player } player * @param { Player } player
* @param { string | import('../library/index.js').Card[] } card * @param { string | Card[] } card
* @param { import('../library/index.js').Player[] } [targets] * @param { Player[] } [targets]
* @param { import('../library/index.js').GameEventPromise } [event] * @param { GameEventPromise } [event]
* @param { boolean } [forced] * @param { boolean } [forced]
* @param { string } [logvid] * @param { string } [logvid]
*/ */
@ -8454,7 +8454,7 @@ export class Game extends Uninstantable {
return player; return player;
} }
/** /**
* @param { import('../library/index.js').Player } player * @param { Player } player
*/ */
static triggerEnter(player) { static triggerEnter(player) {
const next = game.createEvent('enterGame', false); const next = game.createEvent('enterGame', false);
@ -8465,7 +8465,7 @@ export class Game extends Uninstantable {
return next; return next;
} }
/** /**
* @param { import('../library/index.js').Player } player * @param { Player } player
*/ */
static restorePlayer(player) { static restorePlayer(player) {
if (game.players.includes(player) || game.dead.includes(player)) return; if (game.players.includes(player) || game.dead.includes(player)) return;
@ -8485,7 +8485,7 @@ export class Game extends Uninstantable {
return player; return player;
} }
/** /**
* @param { import('../library/index.js').Player } player * @param { Player } player
*/ */
static removePlayer(player) { static removePlayer(player) {
if (_status.roundStart == player) _status.roundStart = player.next || player.getNext() || game.players[0]; if (_status.roundStart == player) _status.roundStart = player.next || player.getNext() || game.players[0];
@ -8517,7 +8517,7 @@ export class Game extends Uninstantable {
return player; return player;
} }
/** /**
* @param { import('../library/index.js').Player } player * @param { Player } player
* @param { string } [character] * @param { string } [character]
* @param { string } [character2] * @param { string } [character2]
*/ */
@ -8587,7 +8587,7 @@ export class Game extends Uninstantable {
} }
/** /**
* @param { string[] } skills * @param { string[] } skills
* @param { import('../library/index.js').Player } player * @param { Player } player
* @param { string[] } exclude * @param { string[] } exclude
*/ */
static filterSkills(skills, player, exclude) { static filterSkills(skills, player, exclude) {
@ -8623,17 +8623,17 @@ export class Game extends Uninstantable {
}) })
} }
/** /**
* @param { (player: import('../library/index.js').Player) => boolean } func * @param { (player: Player) => boolean } func
* @param { boolean } [includeOut] * @param { boolean } [includeOut]
*/ */
static hasPlayer(func, includeOut) { return game.players.some(value => (includeOut || !value.isOut()) && func(value)) } static hasPlayer(func, includeOut) { return game.players.some(value => (includeOut || !value.isOut()) && func(value)) }
/** /**
* @param { (player: import('../library/index.js').Player) => boolean } func * @param { (player: Player) => boolean } func
* @param { boolean } [includeOut] * @param { boolean } [includeOut]
*/ */
static hasPlayer2(func, includeOut) { return game.players.concat(game.dead).some(value => (includeOut || !value.isOut()) && func(value)) } static hasPlayer2(func, includeOut) { return game.players.concat(game.dead).some(value => (includeOut || !value.isOut()) && func(value)) }
/** /**
* @param { (player: import('../library/index.js').Player) => boolean } func * @param { (player: Player) => boolean } func
* @param { boolean } [includeOut] * @param { boolean } [includeOut]
*/ */
static countPlayer(func, includeOut) { static countPlayer(func, includeOut) {
@ -8647,7 +8647,7 @@ export class Game extends Uninstantable {
}, 0); }, 0);
} }
/** /**
* @param { (player: import('../library/index.js').Player) => boolean } func * @param { (player: Player) => boolean } func
* @param { boolean } [includeOut] * @param { boolean } [includeOut]
*/ */
static countPlayer2(func, includeOut) { static countPlayer2(func, includeOut) {
@ -8662,14 +8662,14 @@ export class Game extends Uninstantable {
} }
/** /**
* @overload * @overload
* @returns { import('../library/index.js').Player[] } * @returns { Player[] }
*/ */
/** /**
* @overload * @overload
* @param { (player: import('../library/index.js').Player) => boolean } func * @param { (player: Player) => boolean } func
* @param { import('../library/index.js').Player[] } [list] * @param { Player[] } [list]
* @param { boolean } [includeOut] * @param { boolean } [includeOut]
* @returns { import('../library/index.js').Player[] } * @returns { Player[] }
*/ */
static filterPlayer(func, list, includeOut) { static filterPlayer(func, list, includeOut) {
if (!Array.isArray(list)) list = []; if (!Array.isArray(list)) list = [];
@ -8678,14 +8678,14 @@ export class Game extends Uninstantable {
} }
/** /**
* @overload * @overload
* @returns { import('../library/index.js').Player[] } * @returns { Player[] }
*/ */
/** /**
* @overload * @overload
* @param { (player: import('../library/index.js').Player) => boolean } func * @param { (player: Player) => boolean } func
* @param { import('../library/index.js').Player[] } [list] * @param { Player[] } [list]
* @param { boolean } [includeOut] * @param { boolean } [includeOut]
* @returns { import('../library/index.js').Player[] } * @returns { Player[] }
*/ */
static filterPlayer2(func, list, includeOut) { static filterPlayer2(func, list, includeOut) {
if (!Array.isArray(list)) list = []; if (!Array.isArray(list)) list = [];
@ -8693,17 +8693,17 @@ export class Game extends Uninstantable {
return list.addArray(game.players.concat(game.dead).filter(value => (includeOut || !value.isOut()) && func(value))); return list.addArray(game.players.concat(game.dead).filter(value => (includeOut || !value.isOut()) && func(value)));
} }
/** /**
* @param { (player: import('../library/index.js').Player) => boolean } func * @param { (player: Player) => boolean } func
* @param { boolean } [includeOut] * @param { boolean } [includeOut]
*/ */
static findPlayer(func, includeOut) { return game.players.find(value => (includeOut || !value.isOut()) && func(value)) || null } static findPlayer(func, includeOut) { return game.players.find(value => (includeOut || !value.isOut()) && func(value)) || null }
/** /**
* @param { (player: import('../library/index.js').Player) => boolean } func * @param { (player: Player) => boolean } func
* @param { boolean } [includeOut] * @param { boolean } [includeOut]
*/ */
static findPlayer2(func, includeOut) { return game.players.concat(game.dead).find(value => (includeOut || !value.isOut()) && func(value)) || null } static findPlayer2(func, includeOut) { return game.players.concat(game.dead).find(value => (includeOut || !value.isOut()) && func(value)) || null }
/** /**
* @param { (player: import('../library/index.js').Player) => boolean } func * @param { (player: Player) => boolean } func
* @param { boolean } [all] * @param { boolean } [all]
*/ */
static findCards(func, all) { static findCards(func, all) {

View File

@ -9,8 +9,8 @@ import { GNC as gnc } from '../gnc/index.js';
export class Is extends Uninstantable { export class Is extends Uninstantable {
/** /**
* 判断是否为进攻坐骑 * 判断是否为进攻坐骑
* @param {import("../library/index.js").Card | import("../library/index.js").VCard} card * @param {Card | VCard} card
* @param {false | import("../library/index.js").Player} [player] * @param {false | Player} [player]
* @returns {boolean} * @returns {boolean}
*/ */
static attackingMount(card, player) { static attackingMount(card, player) {
@ -25,8 +25,8 @@ export class Is extends Uninstantable {
} }
/** /**
* 判断是否为防御坐骑 * 判断是否为防御坐骑
* @param {import("../library/index.js").Card | import("../library/index.js").VCard} card * @param {Card | VCard} card
* @param {false | import("../library/index.js").Player} [player] * @param {false | Player} [player]
* @returns {boolean} * @returns {boolean}
*/ */
static defendingMount(card, player) { static defendingMount(card, player) {
@ -1833,12 +1833,12 @@ export class Get extends Uninstantable {
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Player[] } obj * @param { Player[] } obj
* @returns { 'players' } * @returns { 'players' }
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Card[] } obj * @param { Card[] } obj
* @returns { 'cards' } * @returns { 'cards' }
*/ */
/** /**
@ -1853,27 +1853,27 @@ export class Get extends Uninstantable {
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Button } obj * @param { Button } obj
* @returns { 'button' } * @returns { 'button' }
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Card } obj * @param { Card } obj
* @returns { 'card' } * @returns { 'card' }
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Player } obj * @param { Player } obj
* @returns { 'player' } * @returns { 'player' }
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').Dialog } obj * @param { Dialog } obj
* @returns { 'dialog' } * @returns { 'dialog' }
*/ */
/** /**
* @overload * @overload
* @param { import('../library/index.js').GameEvent | import('../library/index.js').GameEventPromise } obj * @param { GameEvent | GameEventPromise } obj
* @returns { 'event' } * @returns { 'event' }
*/ */
static itemtype(obj) { static itemtype(obj) {
@ -1954,8 +1954,8 @@ export class Get extends Uninstantable {
} }
/** /**
* *
* @param {import("../library/index.js").Card | import("../library/index.js").VCard} card * @param {Card | VCard} card
* @param {false | import("../library/index.js").Player} [player] * @param {false | Player} [player]
* @returns {string} * @returns {string}
*/ */
static name(card, player) { static name(card, player) {
@ -1968,8 +1968,8 @@ export class Get extends Uninstantable {
return card.name; return card.name;
} }
/** /**
* @param {import("../library/index.js").Card | import("../library/index.js").VCard | Card[] | VCard[]} card * @param {Card | VCard | Card[] | VCard[]} card
* @param {false | import("../library/index.js").Player} [player] * @param {false | Player} [player]
* @returns {string} * @returns {string}
*/ */
static suit(card, player) { static suit(card, player) {
@ -1993,8 +1993,8 @@ export class Get extends Uninstantable {
} }
} }
/** /**
* @param {import("../library/index.js").Card | import("../library/index.js").VCard | Card[] | VCard[]} card * @param {Card | VCard | Card[] | VCard[]} card
* @param {false | import("../library/index.js").Player} [player] * @param {false | Player} [player]
* @returns {string} * @returns {string}
*/ */
static color(card, player) { static color(card, player) {
@ -2022,8 +2022,8 @@ export class Get extends Uninstantable {
} }
} }
/** /**
* @param {import("../library/index.js").Card | import("../library/index.js").VCard} card * @param {Card | VCard} card
* @param {false | import("../library/index.js").Player} [player] * @param {false | Player} [player]
* @returns {number} * @returns {number}
*/ */
static number(card, player) { static number(card, player) {
@ -2047,8 +2047,8 @@ export class Get extends Uninstantable {
} }
/** /**
* 返回一张杀的属性如有多种属性则用`lib.natureSeparator`分割开来火雷的返回值为`fire|thunder` * 返回一张杀的属性如有多种属性则用`lib.natureSeparator`分割开来火雷的返回值为`fire|thunder`
* @param {string | string[] | import("../library/index.js").Card | import("../library/index.js").VCard} card * @param {string | string[] | Card | VCard} card
* @param {false | import("../library/index.js").Player} [player] * @param {false | Player} [player]
* @returns {string} * @returns {string}
*/ */
static nature(card, player) { static nature(card, player) {
@ -2066,7 +2066,7 @@ export class Get extends Uninstantable {
/** /**
* 返回包含所有属性的数组 * 返回包含所有属性的数组
* @param {string[] | string} card * @param {string[] | string} card
* @param {false | import("../library/index.js").Player} [player] * @param {false | Player} [player]
* @returns {string[]} * @returns {string[]}
*/ */
static natureList(card, player) { static natureList(card, player) {
@ -2231,11 +2231,11 @@ export class Get extends Uninstantable {
* @template T * @template T
* @overload * @overload
* @param {T} key * @param {T} key
* @returns {import("../library/index.js").GameEvent[T]} * @returns {GameEvent[T]}
*/ */
/** /**
* @overload * @overload
* @returns {import("../library/index.js").GameEvent} * @returns {GameEvent}
*/ */
static event(key) { return key ? _status.event[key] : _status.event } static event(key) { return key ? _status.event[key] : _status.event }
static player() { return _status.event.player } static player() { return _status.event.player }
@ -2463,8 +2463,8 @@ export class Get extends Uninstantable {
return result; return result;
} }
/** /**
* @param {((a: import('../library/index.js').Button, b: import('../library/index.js').Button) => number)} [sort] 排序函数 * @param {((a: Button, b: Button) => number)} [sort] 排序函数
* @returns { import('../library/index.js').Button[] } * @returns { Button[] }
*/ */
static selectableButtons(sort) { static selectableButtons(sort) {
if (!_status.event.player) return []; if (!_status.event.player) return [];
@ -2482,8 +2482,8 @@ export class Get extends Uninstantable {
return selectable; return selectable;
} }
/** /**
* @param {((a: import('../library/index.js').Card, b: import('../library/index.js').Card) => number)} [sort] 排序函数 * @param {((a: Card, b: Card) => number)} [sort] 排序函数
* @returns { import('../library/index.js').Card[] } * @returns { Card[] }
*/ */
static selectableCards(sort) { static selectableCards(sort) {
if (!_status.event.player) return []; if (!_status.event.player) return [];
@ -2578,8 +2578,8 @@ export class Get extends Uninstantable {
return list; return list;
} }
/** /**
* @param {((a: import('../library/index.js').Player, b: import('../library/index.js').Player) => number)} [sort] 排序函数 * @param {((a: Player, b: Player) => number)} [sort] 排序函数
* @returns { import('../library/index.js').Player[] } * @returns { Player[] }
*/ */
static selectableTargets(sort) { static selectableTargets(sort) {
var selectable = []; var selectable = [];

View File

@ -59,16 +59,16 @@ export async function boot() {
setWindowListener(); setWindowListener();
// 无名杀更新日志 // 无名杀更新日志
if (Reflect.has(window, 'noname_update')) { if (window.noname_update) {
Reflect.set(lib, 'version', Reflect.get(window, 'noname_update').version); Reflect.set(lib, 'version', window.noname_update.version);
lib.changeLog = Reflect.get(window, 'noname_update').changeLog; lib.changeLog = window.noname_update.changeLog;
if (Reflect.get(window, 'noname_update').players) { if (window.noname_update.players) {
lib.changeLog.push('players://' + JSON.stringify(Reflect.get(window, 'noname_update').players)); lib.changeLog.push('players://' + JSON.stringify(window.noname_update.players));
} }
if (Reflect.get(window, 'noname_update').cards) { if (window.noname_update.cards) {
lib.changeLog.push('cards://' + JSON.stringify(Reflect.get(window, 'noname_update').cards)); lib.changeLog.push('cards://' + JSON.stringify(window.noname_update.cards));
} }
Reflect.deleteProperty(window, 'noname_update'); delete window.noname_update;
} }
// 确认手机端平台 // 确认手机端平台
const noname_inited = localStorage.getItem('noname_inited'); const noname_inited = localStorage.getItem('noname_inited');
@ -105,7 +105,7 @@ export async function boot() {
Reflect.set(lib, 'path', (await import('../library/path.js')).default); Reflect.set(lib, 'path', (await import('../library/path.js')).default);
//为其他自定义平台提供文件读写函数赋值的一种方式。 //为其他自定义平台提供文件读写函数赋值的一种方式。
//但这种方式只能修改game的文件读写函数。 //但这种方式只能修改game的文件读写函数。
if (Reflect.has(window, 'initReadWriteFunction')) { if (typeof window.initReadWriteFunction == 'function') {
const g = {}; const g = {};
const ReadWriteFunctionName = ['download', 'readFile', 'readFileAsText', 'writeFile', 'removeFile', 'getFileList', 'ensureDirectory', 'createDir']; const ReadWriteFunctionName = ['download', 'readFile', 'readFileAsText', 'writeFile', 'removeFile', 'getFileList', 'ensureDirectory', 'createDir'];
ReadWriteFunctionName.forEach(prop => { ReadWriteFunctionName.forEach(prop => {
@ -120,7 +120,8 @@ export async function boot() {
} }
}); });
}); });
Reflect.get(window, 'initReadWriteFunction')(g); // @ts-ignore
window.initReadWriteFunction(g);
} }
window.onbeforeunload = function () { window.onbeforeunload = function () {
if (config.get('confirm_exit') && !_status.reloading) { if (config.get('confirm_exit') && !_status.reloading) {
@ -177,9 +178,11 @@ export async function boot() {
if (config.get('debug')) { if (config.get('debug')) {
await lib.init.promises.js(`${lib.assetURL}game`, 'asset'); await lib.init.promises.js(`${lib.assetURL}game`, 'asset');
lib.skin = Reflect.get(window, 'noname_skin_list'); if (window.noname_skin_list) {
Reflect.deleteProperty(window, 'noname_skin_list'); lib.skin = window.noname_skin_list;
Reflect.deleteProperty(window, 'noname_asset_list'); delete window.noname_skin_list;
delete window.noname_asset_list;
}
} }
if (Reflect.get(window, 'isNonameServer')) if (Reflect.get(window, 'isNonameServer'))

View File

@ -7,7 +7,7 @@ import { UI as ui } from '../../ui/index.js';
import { AsyncFunction } from '../../util/index.js'; import { AsyncFunction } from '../../util/index.js';
export class GameEvent { export class GameEvent {
/** @type { import('../index.js').GameEventPromise } */ /** @type { GameEventPromise } */
#promise; #promise;
/** /**
* @param {string} [name] * @param {string} [name]
@ -26,11 +26,11 @@ export class GameEvent {
this.step = 0; this.step = 0;
this.finished = false; this.finished = false;
/** /**
* @type {(import('../index.js').GameEventPromise)[]} * @type {GameEventPromise[]}
*/ */
this.next = []; this.next = [];
/** /**
* @type {(import('../index.js').GameEventPromise)[]} * @type {GameEventPromise[]}
*/ */
this.after = []; this.after = [];
this.custom = { this.custom = {
@ -301,7 +301,7 @@ export class GameEvent {
/** /**
* *
* @param {import("../util/index.js").AsyncFunction[] | keyof typeof lib.element.contents} contents * @param {Function | keyof typeof lib.element.contents} contents
* @returns {GameEvent} * @returns {GameEvent}
*/ */
setContents(contents) { setContents(contents) {
@ -747,7 +747,7 @@ export class GameEvent {
/** /**
* 事件转为Promise化 * 事件转为Promise化
* *
* @returns { import('../index.js').GameEventPromise } * @returns { GameEventPromise }
*/ */
toPromise() { toPromise() {
if (!this.#promise) { if (!this.#promise) {
@ -760,93 +760,93 @@ export class GameEvent {
*/ */
typeAnnotation() { typeAnnotation() {
/** /**
* @type {import('../index.js').Player} * @type { Player }
*/ */
// @ts-ignore // @ts-ignore
this.source; this.source;
/** /**
* @type {import('../index.js').Player} * @type { Player }
*/ */
// @ts-ignore // @ts-ignore
this.player; this.player;
/** /**
* @type {import('../index.js').Player} * @type { Player }
*/ */
// @ts-ignore // @ts-ignore
this.target; this.target;
/** /**
* @type {import('../index.js').Player[]} * @type { Player[] }
*/ */
// @ts-ignore // @ts-ignore
this.targets; this.targets;
/** /**
* @type {import('../index.js').Card} * @type { Card }
*/ */
// @ts-ignore // @ts-ignore
this.card; this.card;
/** /**
* @type {import('../index.js').Card[]} * @type { Card[] }
*/ */
// @ts-ignore // @ts-ignore
this.cards; this.cards;
/** /**
* @type {string} * @type { string }
*/ */
this.skill; this.skill;
/** /**
* @type {boolean} * @type { boolean }
*/ */
this.forced; this.forced;
/** /**
* @type {number} * @type { number }
*/ */
this.num; this.num;
/** /**
* @type {GameEvent} * @type { GameEvent }
*/ */
// @ts-ignore // @ts-ignore
this._trigger; this._trigger;
/** /**
* @type {Record<string, any>} * @type { Record<string, any> }
*/ */
this._result; this._result;
/** /**
* @type {number} * @type { number }
*/ */
// @ts-ignore // @ts-ignore
this.baseDamage; this.baseDamage;
/** /**
* @type {import('../index.js').Player} * @type { Player }
*/ */
// @ts-ignore // @ts-ignore
this.customSource; this.customSource;
/** /**
* @type {number} * @type { number }
*/ */
// @ts-ignore // @ts-ignore
this.extraDamage; this.extraDamage;
/** /**
* @type {string} * @type { string }
*/ */
// @ts-ignore // @ts-ignore
this.nature; this.nature;
/** /**
* @type {boolean} * @type { boolean }
*/ */
// @ts-ignore // @ts-ignore
this.notrigger; this.notrigger;
/** /**
* @type {number} * @type { number }
*/ */
// @ts-ignore // @ts-ignore
this.original_num; this.original_num;
/** /**
* @type {boolean} * @type { boolean }
*/ */
// @ts-ignore // @ts-ignore
this.unreal; this.unreal;
/** /**
* @type { import('../index.js').Button[] } * @type { Button[] }
*/ */
// @ts-ignore // @ts-ignore
this.excludeButton; this.excludeButton;

View File

@ -37,7 +37,7 @@ export class GameEventPromise extends Promise {
} }
#event; #event;
/** /**
* @param { import('./gameEvent.js').GameEvent } event * @param { GameEvent } event
*/ */
constructor(event) { constructor(event) {
super(resolve => { super(resolve => {

View File

@ -2706,9 +2706,9 @@ export class Player extends HTMLDivElement {
return list; return list;
} }
/** /**
* @param {string} [arg1='h'] * @param { string } [arg1='h']
* @param {string | Record<string, any> | ((card: import('../index.js').Card) => boolean)} [arg2] * @param { string | Record<string, any> | ((card: Card) => boolean) } [arg2]
* @returns {import('../index.js').Card[]} * @returns { Card[] }
*/ */
getCards(arg1, arg2) { getCards(arg1, arg2) {
if (typeof arg1 != 'string') { if (typeof arg1 != 'string') {

View File

@ -7,10 +7,10 @@ import { UI as ui } from '../../ui/index.js';
export class VCard { export class VCard {
/** /**
* @param {any} [suitOrCard] * @param { any } [suitOrCard]
* @param {number | import('./card.js').Card[]} [numberOrCards] * @param { number | Card[] } [numberOrCards]
* @param {string} [name] * @param { string } [name]
* @param {string} [nature] * @param { string } [nature]
*/ */
constructor(suitOrCard, numberOrCards, name, nature) { constructor(suitOrCard, numberOrCards, name, nature) {
if (Array.isArray(suitOrCard)) { if (Array.isArray(suitOrCard)) {
@ -66,7 +66,7 @@ export class VCard {
if (Array.isArray(numberOrCards)) { if (Array.isArray(numberOrCards)) {
const noCards = !this.cards; const noCards = !this.cards;
/** /**
* @type {import('./card.js').Card[]} * @type { Card[] }
*/ */
this.cards = numberOrCards.slice(); this.cards = numberOrCards.slice();
if (noCards) { if (noCards) {
@ -108,7 +108,7 @@ export class VCard {
return get.name(this) != get.name(card); return get.name(this) != get.name(card);
} }
/** /**
* @param {Player} player * @param { Player } player
*/ */
hasNature(nature, player) { hasNature(nature, player) {
const natures = get.natureList(this, player); const natures = get.natureList(this, player);

View File

@ -40,7 +40,7 @@ export class Library extends Uninstantable {
static updates = []; static updates = [];
static canvasUpdates = []; static canvasUpdates = [];
/** /**
* @type { import('../game/index.js').Video[] } * @type { Video[] }
*/ */
static video = []; static video = [];
static skilllist = []; static skilllist = [];
@ -54,6 +54,9 @@ export class Library extends Uninstantable {
static characterGuozhanFilter = ["mode_guozhan"]; static characterGuozhanFilter = ["mode_guozhan"];
static dynamicTranslate = {}; static dynamicTranslate = {};
static cardPack = {}; static cardPack = {};
/**
* @type { SMap<number> }
*/
static skin = {}; static skin = {};
static onresize = []; static onresize = [];
static onphase = []; static onphase = [];
@ -88,11 +91,11 @@ export class Library extends Uninstantable {
static cardType = {}; static cardType = {};
static hook = { globalskill: {} }; static hook = { globalskill: {} };
/** /**
* @returns {never} * @returns { never }
*/ */
static typeAnnotation() { static typeAnnotation() {
/** /**
* @type { import('../game/index.js').Videos[] } * @type { Videos[] }
*/ */
// @ts-ignore // @ts-ignore
this.videos; this.videos;
@ -6550,7 +6553,9 @@ export class Library extends Uninstantable {
} }
else { else {
if (!window.CodeMirror) { if (!window.CodeMirror) {
lib.init.js(lib.assetURL + 'game', 'codemirror', () => lib.codeMirrorReady(node, editor)); import('../../game/codemirror.js').then(() => {
lib.codeMirrorReady(node, editor);
});
lib.init.css(lib.assetURL + 'layout/default', 'codemirror'); lib.init.css(lib.assetURL + 'layout/default', 'codemirror');
} }
else { else {
@ -6642,7 +6647,9 @@ export class Library extends Uninstantable {
} }
else { else {
if (!window.CodeMirror) { if (!window.CodeMirror) {
lib.init.js(lib.assetURL + 'game', 'codemirror', () => lib.codeMirrorReady(node, editor)); import('../../game/codemirror.js').then(() => {
lib.codeMirrorReady(node, editor);
});
lib.init.css(lib.assetURL + 'layout/default', 'codemirror'); lib.init.css(lib.assetURL + 'layout/default', 'codemirror');
} }
else { else {
@ -7102,7 +7109,9 @@ export class Library extends Uninstantable {
} }
else { else {
if (!window.CodeMirror) { if (!window.CodeMirror) {
lib.init.js(lib.assetURL + 'game', 'codemirror', () => lib.codeMirrorReady(node, editor)); import('../../game/codemirror.js').then(() => {
lib.codeMirrorReady(node, editor);
});
lib.init.css(lib.assetURL + 'layout/default', 'codemirror'); lib.init.css(lib.assetURL + 'layout/default', 'codemirror');
} }
else { else {
@ -8632,16 +8641,16 @@ export class Library extends Uninstantable {
/** /**
* @overload * @overload
* @description 指定的玩家或自己装备指定的牌 * @description 指定的玩家或自己装备指定的牌
* @param {...Element.Player | string} args 玩家或卡牌名 * @param {...Player | string} args 玩家或卡牌名
* @returns { void } * @returns { void }
*/ */
e(...args) { e(...args) {
/** /**
* @type { Element.Card[] } * @type { Card[] }
*/ */
let cards = []; let cards = [];
/** /**
* @type { Element.Player } * @type { Player }
*/ */
let target; let target;
for (let i = 0; i < arguments.length; i++) { for (let i = 0; i < arguments.length; i++) {
@ -8889,7 +8898,7 @@ export class Library extends Uninstantable {
}, },
/** /**
* 下家对你使用一张牌 * 下家对你使用一张牌
* @param {...Element.Player | Element.Player[] | string | Element.VCard } args * @param {...Player | Player[] | string | VCard } args
* *
* @example * @example
* ```js * ```js
@ -8973,7 +8982,7 @@ export class Library extends Uninstantable {
}, },
/** /**
* 打印目标玩家的手牌 * 打印目标玩家的手牌
* @param { Element.Player } player * @param { Player } player
*/ */
h(player) { h(player) {
console.log(get.translation(player.getCards('h'))); console.log(get.translation(player.getCards('h')));
@ -9032,7 +9041,7 @@ export class Library extends Uninstantable {
/** /**
* 给目标立即添加一张手牌 * 给目标立即添加一张手牌
* @param { string } name * @param { string } name
* @param { Element.Player } target * @param { Player } target
*/ */
gx(name, target = game.me) { gx(name, target = game.me) {
const card = lib.cheat.gn(name); const card = lib.cheat.gn(name);
@ -9051,7 +9060,7 @@ export class Library extends Uninstantable {
* 如果lib.card里没有对应卡牌名返回null * 如果lib.card里没有对应卡牌名返回null
* *
* @param { string } name * @param { string } name
* @returns { Element.Card } * @returns { Card }
* @example * @example
* ```js * ```js
* // 创建一个梅花杀 * // 创建一个梅花杀
@ -9102,7 +9111,7 @@ export class Library extends Uninstantable {
}, },
/** /**
* 指定的玩家或自己立即获得诸葛连弩青龙刀八卦阵的卢赤兔木牛 * 指定的玩家或自己立即获得诸葛连弩青龙刀八卦阵的卢赤兔木牛
* @param {Element.Player} [target] * @param { Player } [target]
*/ */
ge(target) { ge(target) {
if (target) { if (target) {
@ -9146,7 +9155,7 @@ export class Library extends Uninstantable {
/** /**
* 自己立刻获取牌堆顶num张牌 * 自己立刻获取牌堆顶num张牌
* @param { number } [num] * @param { number } [num]
* @param { Element.Player } [target] * @param { Player } [target]
*/ */
d(num = 1, target) { d(num = 1, target) {
const cards = get.cards(num); const cards = get.cards(num);
@ -9179,7 +9188,7 @@ export class Library extends Uninstantable {
* *
* 不传入num默认为弃置所有玩家的所有牌 * 不传入num默认为弃置所有玩家的所有牌
* *
* @param { number | Element.Player } [num] * @param { number | Player } [num]
*/ */
t(num) { t(num) {
if (game.players.includes(num)) { if (game.players.includes(num)) {

View File

@ -6,7 +6,7 @@ export const status = {
clicked: false, clicked: false,
auto: false, auto: false,
/** /**
* @type {import('../library/index.js').GameEventPromise} * @type { GameEventPromise }
*/ */
// @ts-ignore // @ts-ignore
event: null, event: null,
@ -17,9 +17,10 @@ export const status = {
dragline: [], dragline: [],
dying: [], dying: [],
/** /**
* @type { import('../game/index.js').History[] } * @type { History[] }
*/ */
globalHistory: [{ globalHistory: [{
// @ts-ignore
cardMove: [], cardMove: [],
custom: [], custom: [],
useCard: [], useCard: [],
@ -39,7 +40,7 @@ export const status = {
/** /**
* @type { string | void } * @type { string | void }
*/ */
extension:undefined, extension: undefined,
}; };
export const _status = status; export const _status = status;

View File

@ -5081,7 +5081,9 @@ class Create extends Uninstantable {
} }
else { else {
if (!window.CodeMirror) { if (!window.CodeMirror) {
lib.init.js(lib.assetURL + 'game', 'codemirror', () => lib.codeMirrorReady(node, editor)); import('../../game/codemirror.js').then(() => {
lib.codeMirrorReady(node, editor);
});
lib.init.css(lib.assetURL + 'layout/default', 'codemirror'); lib.init.css(lib.assetURL + 'layout/default', 'codemirror');
} }
else { else {
@ -5517,7 +5519,9 @@ class Create extends Uninstantable {
} }
else { else {
if (!window.CodeMirror) { if (!window.CodeMirror) {
lib.init.js(lib.assetURL + 'game', 'codemirror', () => lib.codeMirrorReady(node, editor)); import('../../game/codemirror.js').then(() => {
lib.codeMirrorReady(node, editor);
});
lib.init.css(lib.assetURL + 'layout/default', 'codemirror'); lib.init.css(lib.assetURL + 'layout/default', 'codemirror');
} }
else { else {
@ -5895,7 +5899,9 @@ class Create extends Uninstantable {
} }
else { else {
if (!window.CodeMirror) { if (!window.CodeMirror) {
lib.init.js(lib.assetURL + 'game', 'codemirror', () => lib.codeMirrorReady(node, this.editor)); import('../../game/codemirror.js').then(() => {
lib.codeMirrorReady(node, editor);
});
lib.init.css(lib.assetURL + 'layout/default', 'codemirror'); lib.init.css(lib.assetURL + 'layout/default', 'codemirror');
} }
else { else {