优化代码提示
This commit is contained in:
parent
931c9a5dda
commit
5b445350be
|
@ -4537,7 +4537,7 @@ export class Game extends Uninstantable {
|
|||
*
|
||||
* @param { string } name
|
||||
* @param { false } [trigger]
|
||||
* @param { import('../library/index.js').GameEventPromise } triggerEvent
|
||||
* @param { import('../library/index.js').GameEventPromise } [triggerEvent]
|
||||
*/
|
||||
static createEvent(name, trigger, triggerEvent) {
|
||||
const next = (new lib.element.GameEvent(name, trigger)).toPromise();
|
||||
|
@ -4783,7 +4783,7 @@ export class Game extends Uninstantable {
|
|||
}
|
||||
/**
|
||||
* @param { string } skill
|
||||
* @param { import('../library/index.js').Player } player
|
||||
* @param { import('../library/index.js').Player } [player]
|
||||
*/
|
||||
static addGlobalSkill(skill, player) {
|
||||
let info = lib.skill[skill];
|
||||
|
@ -5701,10 +5701,10 @@ export class Game extends Uninstantable {
|
|||
}
|
||||
if (event.next.length > 0) {
|
||||
var next = event.next.shift();
|
||||
if (next.player && next.player.skipList.contains(next.name)) {
|
||||
if (next.player && next.player.skipList.includes(next.name)) {
|
||||
event.trigger(next.name + 'Skipped');
|
||||
next.player.skipList.remove(next.name);
|
||||
if (lib.phaseName.contains(next.name)) next.player.getHistory('skipped').add(next.name);
|
||||
if (lib.phaseName.includes(next.name)) next.player.getHistory('skipped').add(next.name);
|
||||
}
|
||||
else {
|
||||
next.parent = event;
|
||||
|
@ -5868,6 +5868,7 @@ export class Game extends Uninstantable {
|
|||
};
|
||||
|
||||
run(event).then(() => {
|
||||
// 其实这个if几乎一定执行了
|
||||
if (game.executingAsyncEventMap.has(event.toEvent())) {
|
||||
game.executingAsyncEventMap.set(_status.event.toEvent(), game.executingAsyncEventMap.get(_status.event.toEvent()).then(() => {
|
||||
event.finish();
|
||||
|
@ -5909,6 +5910,7 @@ export class Game extends Uninstantable {
|
|||
else if (event.content instanceof AsyncFunction) {
|
||||
// _status,lib,game,ui,get,ai六个变量由game.import提供
|
||||
event.content(event, trigger, player).then(() => {
|
||||
// 其实这个if几乎一定执行了
|
||||
if (game.executingAsyncEventMap.has(event.toEvent())) {
|
||||
game.executingAsyncEventMap.set(_status.event.toEvent(), game.executingAsyncEventMap.get(_status.event.toEvent()).then(() => {
|
||||
event.finish();
|
||||
|
@ -7711,7 +7713,7 @@ export class Game extends Uninstantable {
|
|||
Object.keys(lib.skill).forEach(value => game.finishSkill(value));
|
||||
}
|
||||
/**
|
||||
* 这玩意至少19中重载了吧
|
||||
* 这玩意至少19种重载了吧
|
||||
*/
|
||||
static checkMod() {
|
||||
const argumentArray = Array.from(arguments), name = argumentArray[argumentArray.length - 2];
|
||||
|
|
|
@ -9,8 +9,8 @@ import { GNC as gnc } from '../gnc/index.js';
|
|||
export class Is extends Uninstantable {
|
||||
/**
|
||||
* 判断是否为进攻坐骑
|
||||
* @param {Card | VCard} card
|
||||
* @param {false | Player} [player]
|
||||
* @param {import("../library/index.js").Card | import("../library/index.js").VCard} card
|
||||
* @param {false | import("../library/index.js").Player} [player]
|
||||
* @returns {boolean}
|
||||
*/
|
||||
static attackingMount(card, player) {
|
||||
|
@ -25,8 +25,8 @@ export class Is extends Uninstantable {
|
|||
}
|
||||
/**
|
||||
* 判断是否为防御坐骑
|
||||
* @param {Card | VCard} card
|
||||
* @param {false | Player} [player]
|
||||
* @param {import("../library/index.js").Card | import("../library/index.js").VCard} card
|
||||
* @param {false | import("../library/index.js").Player} [player]
|
||||
* @returns {boolean}
|
||||
*/
|
||||
static defendingMount(card, player) {
|
||||
|
@ -257,14 +257,14 @@ export class Is extends Uninstantable {
|
|||
};
|
||||
configs[name] = item;
|
||||
if (!configs.phonelayout) return false;
|
||||
if (configs.show_round_menu && menus.contains(configs.round_menu_func)) {
|
||||
if (configs.show_round_menu && menus.includes(configs.round_menu_func)) {
|
||||
return false;
|
||||
}
|
||||
if (configs.touchscreen) {
|
||||
if (menus.contains(configs.swipe_up)) return false;
|
||||
if (menus.contains(configs.swipe_down)) return false;
|
||||
if (menus.contains(configs.swipe_left)) return false;
|
||||
if (menus.contains(configs.swipe_right)) return false;
|
||||
if (menus.includes(configs.swipe_up)) return false;
|
||||
if (menus.includes(configs.swipe_down)) return false;
|
||||
if (menus.includes(configs.swipe_left)) return false;
|
||||
if (menus.includes(configs.swipe_right)) return false;
|
||||
}
|
||||
else {
|
||||
if (configs.right_click == 'config') return false;
|
||||
|
@ -1131,7 +1131,7 @@ export class Get extends Uninstantable {
|
|||
for (var i in lib.cardPile) {
|
||||
for (var j = 0; j < lib.cardPile[i].length; j++) {
|
||||
var info = lib.cardPile[i][j];
|
||||
if (lib.inpile.contains(info[2]) && get.type(info[2]) == type) {
|
||||
if (lib.inpile.includes(info[2]) && get.type(info[2]) == type) {
|
||||
list.push({
|
||||
name: info[2],
|
||||
suit: info[0],
|
||||
|
@ -1273,7 +1273,7 @@ export class Get extends Uninstantable {
|
|||
var pack = lib.characterPack[lib.configOL.characterPack[i]];
|
||||
for (var j in pack) {
|
||||
if (typeof func == 'function' && func(j)) continue;
|
||||
if (lib.connectBanned.contains(j)) continue;
|
||||
if (lib.connectBanned.includes(j)) continue;
|
||||
if (lib.character[j]) libCharacter[j] = pack[j];
|
||||
}
|
||||
}
|
||||
|
@ -1954,8 +1954,8 @@ export class Get extends Uninstantable {
|
|||
}
|
||||
/**
|
||||
*
|
||||
* @param {Card | VCard} card
|
||||
* @param {false | Player} [player]
|
||||
* @param {import("../library/index.js").Card | import("../library/index.js").VCard} card
|
||||
* @param {false | import("../library/index.js").Player} [player]
|
||||
* @returns {string}
|
||||
*/
|
||||
static name(card, player) {
|
||||
|
@ -1968,8 +1968,8 @@ export class Get extends Uninstantable {
|
|||
return card.name;
|
||||
}
|
||||
/**
|
||||
* @param {Card | VCard | Card[] | VCard[]} card
|
||||
* @param {false | Player} [player]
|
||||
* @param {import("../library/index.js").Card | import("../library/index.js").VCard | Card[] | VCard[]} card
|
||||
* @param {false | import("../library/index.js").Player} [player]
|
||||
* @returns {string}
|
||||
*/
|
||||
static suit(card, player) {
|
||||
|
@ -1988,13 +1988,13 @@ export class Get extends Uninstantable {
|
|||
return game.checkMod(card, owner, game.checkMod(card, card.suit, 'suit', owner), 'cardsuit', owner);
|
||||
}
|
||||
}
|
||||
if (lib.suits.contains(card.suit)) return card.suit;
|
||||
if (lib.suits.includes(card.suit)) return card.suit;
|
||||
return 'none';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param {Card | VCard | Card[] | VCard[]} card
|
||||
* @param {false | Player} [player]
|
||||
* @param {import("../library/index.js").Card | import("../library/index.js").VCard | Card[] | VCard[]} card
|
||||
* @param {false | import("../library/index.js").Player} [player]
|
||||
* @returns {string}
|
||||
*/
|
||||
static color(card, player) {
|
||||
|
@ -2022,8 +2022,8 @@ export class Get extends Uninstantable {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* @param {Card | VCard} card
|
||||
* @param {false | Player} [player]
|
||||
* @param {import("../library/index.js").Card | import("../library/index.js").VCard} card
|
||||
* @param {false | import("../library/index.js").Player} [player]
|
||||
* @returns {number}
|
||||
*/
|
||||
static number(card, player) {
|
||||
|
@ -2047,8 +2047,8 @@ export class Get extends Uninstantable {
|
|||
}
|
||||
/**
|
||||
* 返回一张杀的属性。如有多种属性则用`lib.natureSeparator`分割开来。例:火雷【杀】的返回值为`fire|thunder`
|
||||
* @param {string | string[] | Card | VCard} card
|
||||
* @param {false | Player} [player]
|
||||
* @param {string | string[] | import("../library/index.js").Card | import("../library/index.js").VCard} card
|
||||
* @param {false | import("../library/index.js").Player} [player]
|
||||
* @returns {string}
|
||||
*/
|
||||
static nature(card, player) {
|
||||
|
@ -2066,7 +2066,7 @@ export class Get extends Uninstantable {
|
|||
/**
|
||||
* 返回包含所有属性的数组
|
||||
* @param {string[] | string} card
|
||||
* @param {false | Player} [player]
|
||||
* @param {false | import("../library/index.js").Player} [player]
|
||||
* @returns {string[]}
|
||||
*/
|
||||
static natureList(card, player) {
|
||||
|
@ -4539,12 +4539,12 @@ export class Get extends Uninstantable {
|
|||
if (!isLink && get.tag(card, 'natureDamage') && !zerotarget) {
|
||||
var info = get.info(card);
|
||||
if (!info || !info.ai || !info.ai.canLink) {
|
||||
if (target.isLinked()) game.countPlayer(function (current) {
|
||||
if (target.isLinked()) game.players.forEach(function (current) {
|
||||
if (current != target && current.isLinked()) final += get.effect(current, card, player, player2, true);
|
||||
});
|
||||
}
|
||||
else if (info.ai.canLink(player, target, card)) {
|
||||
game.countPlayer(function (current) {
|
||||
game.players.forEach(function (current) {
|
||||
if (current != target && current.isLinked()) final += get.effect(current, card, player, player2, true);
|
||||
});
|
||||
}
|
||||
|
@ -4713,12 +4713,12 @@ export class Get extends Uninstantable {
|
|||
if (!isLink && get.tag(card, 'natureDamage') && !zerotarget) {
|
||||
var info = get.info(card);
|
||||
if (!info || !info.ai || !info.ai.canLink) {
|
||||
if (target.isLinked()) game.countPlayer(function (current) {
|
||||
if (target.isLinked()) game.players.forEach(function (current) {
|
||||
if (current != target && current.isLinked()) final += get.effect(current, card, player, player2, true);
|
||||
});
|
||||
}
|
||||
else if (info.ai.canLink(player, target, card)) {
|
||||
game.countPlayer(function (current) {
|
||||
game.players.forEach(function (current) {
|
||||
if (current != target && current.isLinked()) final += get.effect(current, card, player, player2, true);
|
||||
});
|
||||
}
|
||||
|
@ -4764,7 +4764,7 @@ export class Get extends Uninstantable {
|
|||
var card = button.link;
|
||||
var player = get.owner(card);
|
||||
if (!player) player = _status.event.player;
|
||||
if (player.getCards('j').contains(card)) {
|
||||
if (player.getCards('j').includes(card)) {
|
||||
var efff = get.effect(player, {
|
||||
name: card.viewAs || card.name,
|
||||
cards: [card],
|
||||
|
@ -4773,7 +4773,7 @@ export class Get extends Uninstantable {
|
|||
if (efff == 0) return 0;
|
||||
return -1.5;
|
||||
}
|
||||
if (player.getCards('e').contains(card)) {
|
||||
if (player.getCards('e').includes(card)) {
|
||||
var evalue = get.value(card, player);
|
||||
if (player.hasSkillTag('noe')) {
|
||||
if (evalue >= 7) {
|
||||
|
|
|
@ -8,27 +8,28 @@ import { UI as ui } from '../../ui/index.js';
|
|||
export class Button extends HTMLDivElement {
|
||||
/**
|
||||
* @param {{}} item
|
||||
* @param {keyof typeof ui.create.buttonPresets | ((item: {}, type: Function, position?: HTMLDivElement | DocumentFragment, noClick?: true, button?: typeof Button) => typeof Button)} type
|
||||
* @param {keyof typeof ui.create.buttonPresets | ((item: {}, type: Function, position?: HTMLDivElement | DocumentFragment, noClick?: true, button?: Button) => Button)} type
|
||||
* @param {HTMLDivElement|DocumentFragment} [position]
|
||||
* @param {true} [noClick]
|
||||
* @param { typeof Button } [button]
|
||||
* @param { Button } [button]
|
||||
*/
|
||||
// @ts-ignore
|
||||
constructor(item, type, position, noClick, button) {
|
||||
if (ui.create.buttonPresets[type]) button = ui.create.buttonPresets[type](item, type, position, noClick, button);
|
||||
else if (typeof type == 'function') button = type(item, type, position, noClick, button);
|
||||
Object.setPrototypeOf(button, Button.prototype);
|
||||
// @ts-ignore
|
||||
if (!noClick) button.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', ui.click.button);
|
||||
else {
|
||||
// @ts-ignore
|
||||
button.classList.add('noclick');
|
||||
// @ts-ignore
|
||||
const intro = button.querySelector('.intro');
|
||||
if (intro) intro.remove();
|
||||
if (typeof type == 'function') button = type(item, type, position, noClick, button);
|
||||
else if (ui.create.buttonPresets[type]) button = ui.create.buttonPresets[type](item, type, position, noClick, button);
|
||||
if (button) {
|
||||
Object.setPrototypeOf(button, Button.prototype);
|
||||
if (!noClick) button.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', ui.click.button);
|
||||
else {
|
||||
button.classList.add('noclick');
|
||||
const intro = button.querySelector('.intro');
|
||||
if (intro) intro.remove();
|
||||
}
|
||||
return button;
|
||||
} else {
|
||||
console.error([item, type, position, noClick, button]);
|
||||
throw 'button不合法';
|
||||
}
|
||||
// @ts-ignore
|
||||
return button;
|
||||
}
|
||||
exclude() {
|
||||
if (_status.event.excludeButton == undefined) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { UI as ui } from '../../ui/index.js';
|
|||
import { AsyncFunction } from '../../util/index.js';
|
||||
|
||||
export class GameEvent {
|
||||
/** @type { import('./gameEventPromise.js').default } */
|
||||
/** @type { import('../index.js').GameEventPromise } */
|
||||
#promise;
|
||||
/**
|
||||
* @param {string} [name]
|
||||
|
@ -26,11 +26,11 @@ export class GameEvent {
|
|||
this.step = 0;
|
||||
this.finished = false;
|
||||
/**
|
||||
* @type {(import('./GameEventPromise.js').default)[]}
|
||||
* @type {(import('../index.js').GameEventPromise)[]}
|
||||
*/
|
||||
this.next = [];
|
||||
/**
|
||||
* @type {(import('./GameEventPromise.js').default)[]}
|
||||
* @type {(import('../index.js').GameEventPromise)[]}
|
||||
*/
|
||||
this.after = [];
|
||||
this.custom = {
|
||||
|
|
|
@ -37,8 +37,7 @@ export class GameEventPromise extends Promise {
|
|||
}
|
||||
#event;
|
||||
/**
|
||||
* @param { import('./gameEvent.js').default } event
|
||||
* @returns { Promise<import('./gameEvent.js').default> & import('./gameEvent.js').default }
|
||||
* @param { import('./gameEvent.js').GameEvent } event
|
||||
*/
|
||||
constructor(event) {
|
||||
super(resolve => {
|
||||
|
|
|
@ -1400,13 +1400,19 @@ export class Player extends HTMLDivElement {
|
|||
inRangeOf(source) {
|
||||
return source.inRange(this);
|
||||
}
|
||||
//Get the player's HP not less than 0. Set “raw” to true to get the player's raw HP instead.
|
||||
//获取角色的体力值。设置“raw”为true以获取角色的体力。
|
||||
/**
|
||||
* Get the player's HP not less than 0. Set “raw” to true to get the player's raw HP instead.
|
||||
*
|
||||
* 获取角色的体力值。设置“raw”为true以获取角色的体力。
|
||||
*/
|
||||
getHp(raw) {
|
||||
return raw ? this.hp : Math.max(0, this.hp);
|
||||
}
|
||||
//Set “raw” to true to get the player's raw damaged HP instead.
|
||||
//设置“raw”为true以获取角色已损失的体力。
|
||||
/**
|
||||
* Set “raw” to true to get the player's raw damaged HP instead.
|
||||
*
|
||||
* 设置“raw”为true以获取角色已损失的体力。
|
||||
*/
|
||||
getDamagedHp(raw) {
|
||||
return this.maxHp - this.getHp(raw);
|
||||
}
|
||||
|
@ -2701,8 +2707,8 @@ export class Player extends HTMLDivElement {
|
|||
}
|
||||
/**
|
||||
* @param {string} [arg1='h']
|
||||
* @param {string | Record<string, any> | (card: Card) => boolean} [arg2]
|
||||
* @returns {Card[]}
|
||||
* @param {string | Record<string, any> | ((card: import('../index.js').Card) => boolean)} [arg2]
|
||||
* @returns {import('../index.js').Card[]}
|
||||
*/
|
||||
getCards(arg1, arg2) {
|
||||
if (typeof arg1 != 'string') {
|
||||
|
|
|
@ -8,7 +8,7 @@ import { UI as ui } from '../../ui/index.js';
|
|||
export class VCard {
|
||||
/**
|
||||
* @param {any} [suitOrCard]
|
||||
* @param {number | Card[]} [numberOrCards]
|
||||
* @param {number | import('./card.js').Card[]} [numberOrCards]
|
||||
* @param {string} [name]
|
||||
* @param {string} [nature]
|
||||
*/
|
||||
|
@ -31,6 +31,7 @@ export class VCard {
|
|||
*/
|
||||
this.nature = suitOrCard[3];
|
||||
}
|
||||
// @ts-ignore
|
||||
else if (get.itemtype(suitOrCard) == 'card') {
|
||||
this.name = get.name(suitOrCard);
|
||||
this.suit = get.suit(suitOrCard);
|
||||
|
@ -54,6 +55,10 @@ export class VCard {
|
|||
}
|
||||
else if (suitOrCard && typeof suitOrCard != 'string') {
|
||||
Object.keys(suitOrCard).forEach(key => {
|
||||
/**
|
||||
* @type { PropertyDescriptor }
|
||||
*/
|
||||
// @ts-ignore
|
||||
const propertyDescriptor = Object.getOwnPropertyDescriptor(suitOrCard, key), value = propertyDescriptor.value;
|
||||
if (Array.isArray(value)) this[key] = value.slice();
|
||||
else Object.defineProperty(this, key, propertyDescriptor);
|
||||
|
@ -61,7 +66,7 @@ export class VCard {
|
|||
if (Array.isArray(numberOrCards)) {
|
||||
const noCards = !this.cards;
|
||||
/**
|
||||
* @type {Card[]}
|
||||
* @type {import('./card.js').Card[]}
|
||||
*/
|
||||
this.cards = numberOrCards.slice();
|
||||
if (noCards) {
|
||||
|
|
|
@ -9590,6 +9590,9 @@ class Create extends Uninstantable {
|
|||
return node;
|
||||
}
|
||||
static buttonPresets = {
|
||||
/**
|
||||
* @returns { import("../library/index.js").Button }
|
||||
*/
|
||||
tdnodes: (item, type, position, noclick, node) => {
|
||||
node = ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode.tdnodes', position);
|
||||
if (Array.isArray(item)) {
|
||||
|
@ -9602,11 +9605,17 @@ class Create extends Uninstantable {
|
|||
}
|
||||
return node;
|
||||
},
|
||||
/**
|
||||
* @returns { import("../library/index.js").Button }
|
||||
*/
|
||||
blank: (item, type, position, noclick, node) => {
|
||||
node = ui.create.div('.button.card', position);
|
||||
node.link = item;
|
||||
return node;
|
||||
},
|
||||
/**
|
||||
* @returns { import("../library/index.js").Button }
|
||||
*/
|
||||
card: (item, type, position, noclick, node) => {
|
||||
if (typeof item.copy == 'function') {
|
||||
node = item.copy(false);
|
||||
|
@ -9636,6 +9645,9 @@ class Create extends Uninstantable {
|
|||
}
|
||||
return node;
|
||||
},
|
||||
/**
|
||||
* @returns { import("../library/index.js").Button }
|
||||
*/
|
||||
vcard: (item, type, position, noclick, node) => {
|
||||
if (typeof item == 'string') {
|
||||
item = [get.type(item), '', item];
|
||||
|
@ -9646,6 +9658,9 @@ class Create extends Uninstantable {
|
|||
node.link = item;
|
||||
return node;
|
||||
},
|
||||
/**
|
||||
* @returns { import("../library/index.js").Button }
|
||||
*/
|
||||
character: (item, type, position, noclick, node) => {
|
||||
if (node) {
|
||||
node.classList.add('button');
|
||||
|
@ -9790,9 +9805,15 @@ class Create extends Uninstantable {
|
|||
|
||||
return node;
|
||||
},
|
||||
/**
|
||||
* @returns { import("../library/index.js").Button }
|
||||
*/
|
||||
characterx: (item, type, position, noclick, node) => {
|
||||
return ui.create.buttonPresets.character(item, type, position, noclick, node);
|
||||
},
|
||||
/**
|
||||
* @returns { import("../library/index.js").Button }
|
||||
*/
|
||||
player: (item, type, position, noclick, node) => {
|
||||
if (node) {
|
||||
node.classList.add('button');
|
||||
|
|
Loading…
Reference in New Issue