回退import('../library/index.js').GameEvent的写法,格式化部分文件
This commit is contained in:
parent
862cc16cd6
commit
72481e7193
|
@ -557,8 +557,8 @@ export class Game {
|
||||||
/**
|
/**
|
||||||
* @template { keyof GameHistory } T
|
* @template { keyof GameHistory } 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 }
|
||||||
*/
|
*/
|
||||||
hasGlobalHistory(key, filter, last) {
|
hasGlobalHistory(key, filter, last) {
|
||||||
|
@ -580,8 +580,8 @@ export class Game {
|
||||||
/**
|
/**
|
||||||
* @template { keyof GameHistory } T
|
* @template { keyof GameHistory } 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 }
|
||||||
*/
|
*/
|
||||||
checkGlobalHistory(key, filter, last) {
|
checkGlobalHistory(key, filter, last) {
|
||||||
|
@ -608,8 +608,8 @@ export class Game {
|
||||||
* @template { keyof GameHistory } T
|
* @template { keyof GameHistory } 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 { GameHistory[T] }
|
* @returns { GameHistory[T] }
|
||||||
*/
|
*/
|
||||||
getGlobalHistory(key, filter, last) {
|
getGlobalHistory(key, filter, last) {
|
||||||
|
@ -630,8 +630,8 @@ export class Game {
|
||||||
/**
|
/**
|
||||||
* @template { keyof GameHistory } T
|
* @template { keyof GameHistory } 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 }
|
||||||
*/
|
*/
|
||||||
hasAllGlobalHistory(key, filter, last) {
|
hasAllGlobalHistory(key, filter, last) {
|
||||||
|
@ -656,8 +656,8 @@ export class Game {
|
||||||
/**
|
/**
|
||||||
* @template { keyof GameHistory } T
|
* @template { keyof GameHistory } 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 }
|
||||||
*/
|
*/
|
||||||
checkAllGlobalHistory(key, filter, last) {
|
checkAllGlobalHistory(key, filter, last) {
|
||||||
|
@ -686,8 +686,8 @@ export class Game {
|
||||||
* @template { keyof GameHistory } T
|
* @template { keyof GameHistory } 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 { GameHistory[T] }
|
* @returns { GameHistory[T] }
|
||||||
*/
|
*/
|
||||||
getAllGlobalHistory(key, filter, last) {
|
getAllGlobalHistory(key, filter, last) {
|
||||||
|
@ -718,12 +718,12 @@ export class Game {
|
||||||
/**
|
/**
|
||||||
* @overload
|
* @overload
|
||||||
* @param { Card } cards
|
* @param { Card } cards
|
||||||
* @returns { import('../library/index.js').GameEventPromise }
|
* @returns { GameEventPromise }
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @overload
|
* @overload
|
||||||
* @param {Card[]} cards
|
* @param {Card[]} cards
|
||||||
* @returns { import('../library/index.js').GameEventPromise }
|
* @returns { GameEventPromise }
|
||||||
*/
|
*/
|
||||||
cardsDiscard(cards) {
|
cardsDiscard(cards) {
|
||||||
/** @type { 'cards' | 'card' | void } */
|
/** @type { 'cards' | 'card' | void } */
|
||||||
|
@ -746,12 +746,12 @@ export class Game {
|
||||||
/**
|
/**
|
||||||
* @overload
|
* @overload
|
||||||
* @param { Card } cards
|
* @param { Card } cards
|
||||||
* @returns { import('../library/index.js').GameEventPromise }
|
* @returns { GameEventPromise }
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @overload
|
* @overload
|
||||||
* @param {Card[]} cards
|
* @param {Card[]} cards
|
||||||
* @returns { import('../library/index.js').GameEventPromise }
|
* @returns { GameEventPromise }
|
||||||
*/
|
*/
|
||||||
cardsGotoOrdering(cards) {
|
cardsGotoOrdering(cards) {
|
||||||
/** @type { 'cards' | 'card' | void } */
|
/** @type { 'cards' | 'card' | void } */
|
||||||
|
@ -771,13 +771,13 @@ export class Game {
|
||||||
* @overload
|
* @overload
|
||||||
* @param { 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 {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 }
|
||||||
*/
|
*/
|
||||||
cardsGotoSpecial(cards, bool) {
|
cardsGotoSpecial(cards, bool) {
|
||||||
/** @type { 'cards' | 'card' | void } */
|
/** @type { 'cards' | 'card' | void } */
|
||||||
|
@ -836,7 +836,7 @@ export class Game {
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param { import('../library/index.js').GameEventPromise } event
|
* @param { GameEventPromise } event
|
||||||
*/
|
*/
|
||||||
$cardsGotoPile(event) {
|
$cardsGotoPile(event) {
|
||||||
const cards = event.cards;
|
const cards = event.cards;
|
||||||
|
@ -4651,8 +4651,8 @@ export class Game {
|
||||||
* @param { string } name
|
* @param { string } name
|
||||||
* @param { string } skill
|
* @param { string } skill
|
||||||
* @param { Player } player
|
* @param { Player } player
|
||||||
* @param { import('../library/index.js').GameEventPromise } event
|
* @param { GameEventPromise } event
|
||||||
* @returns { import('../library/index.js').GameEventPromise }
|
* @returns { GameEventPromise }
|
||||||
*/
|
*/
|
||||||
createTrigger(name, skill, player, event, indexedData) {
|
createTrigger(name, skill, player, event, indexedData) {
|
||||||
let info = get.info(skill);
|
let info = get.info(skill);
|
||||||
|
@ -4675,7 +4675,7 @@ export class Game {
|
||||||
*
|
*
|
||||||
* @param { string } name
|
* @param { string } name
|
||||||
* @param { false } [trigger]
|
* @param { false } [trigger]
|
||||||
* @param { import('../library/index.js').GameEventPromise } [triggerEvent]
|
* @param { GameEventPromise } [triggerEvent]
|
||||||
*/
|
*/
|
||||||
createEvent(name, trigger, triggerEvent) {
|
createEvent(name, trigger, triggerEvent) {
|
||||||
const next = new lib.element.GameEvent(name, trigger).toPromise();
|
const next = new lib.element.GameEvent(name, trigger).toPromise();
|
||||||
|
@ -5832,11 +5832,11 @@ export class Game {
|
||||||
*/
|
*/
|
||||||
executingAsyncEventMap = new Map();
|
executingAsyncEventMap = new Map();
|
||||||
/**
|
/**
|
||||||
* @type { import('../library/index.js').GameEventPromise[] }
|
* @type { GameEventPromise[] }
|
||||||
*/
|
*/
|
||||||
belongAsyncEventList = [];
|
belongAsyncEventList = [];
|
||||||
/**
|
/**
|
||||||
* @param { import('../library/index.js').GameEventPromise } [belongAsyncEvent]
|
* @param { GameEventPromise } [belongAsyncEvent]
|
||||||
*/
|
*/
|
||||||
async loop(belongAsyncEvent) {
|
async loop(belongAsyncEvent) {
|
||||||
if (belongAsyncEvent) {
|
if (belongAsyncEvent) {
|
||||||
|
@ -6017,7 +6017,7 @@ export class Game {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param { import('../library/index.js').GameEventPromise } [belongAsyncEvent]
|
* @param { GameEventPromise } [belongAsyncEvent]
|
||||||
*/
|
*/
|
||||||
runContent(belongAsyncEvent) {
|
runContent(belongAsyncEvent) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
@ -6331,7 +6331,7 @@ export class Game {
|
||||||
return game.asyncDelay(time, time2);
|
return game.asyncDelay(time, time2);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param { import('../library/index.js').GameEventPromise } [event]
|
* @param { GameEventPromise } [event]
|
||||||
*/
|
*/
|
||||||
check(event = _status.event) {
|
check(event = _status.event) {
|
||||||
game.callHook("checkBegin", [event]);
|
game.callHook("checkBegin", [event]);
|
||||||
|
@ -7936,7 +7936,7 @@ export class Game {
|
||||||
* @param { Player } player
|
* @param { Player } player
|
||||||
* @param { string | Card[] } card
|
* @param { string | Card[] } card
|
||||||
* @param { 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]
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -916,23 +916,32 @@ export class Get {
|
||||||
"[object Date]": true,
|
"[object Date]": true,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof obj !== "object" || obj === null || !canTranverse[getType(obj)]) return obj;
|
if (
|
||||||
|
typeof obj !== "object" ||
|
||||||
|
obj === null ||
|
||||||
|
!canTranverse[getType(obj)]
|
||||||
|
)
|
||||||
|
return obj;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (map.has(obj)) return map.get(obj);
|
if (map.has(obj)) return map.get(obj);
|
||||||
|
|
||||||
const constructor = obj.constructor;
|
const constructor = obj.constructor;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
// 这四类数据处理单独处理
|
||||||
|
// (实际上需要处理的只有Map和Set)
|
||||||
|
// 除此之外的就只能祝愿有拷贝构造函数了
|
||||||
const target = constructor
|
const target = constructor
|
||||||
? // 这四类数据处理单独处理
|
? Array.isArray(obj) ||
|
||||||
// (实际上需要处理的只有Map和Set)
|
obj instanceof Map ||
|
||||||
// 除此之外的就只能祝愿有拷贝构造函数了
|
obj instanceof Set ||
|
||||||
Array.isArray(obj) || obj instanceof Map || obj instanceof Set || constructor === Object
|
constructor === Object
|
||||||
? // @ts-ignore
|
? // @ts-ignore
|
||||||
new constructor()
|
new constructor()
|
||||||
: constructor.name in window && /\[native code\]/.test(constructor.toString())
|
: constructor.name in window &&
|
||||||
|
/\[native code\]/.test(constructor.toString())
|
||||||
? // @ts-ignore
|
? // @ts-ignore
|
||||||
new constructor(obj)
|
new constructor(obj)
|
||||||
: obj
|
: obj
|
||||||
: Object.create(null);
|
: Object.create(null);
|
||||||
if (target === obj) return target;
|
if (target === obj) return target;
|
||||||
|
@ -959,7 +968,11 @@ export class Get {
|
||||||
if (obj.hasOwnProperty(key)) {
|
if (obj.hasOwnProperty(key)) {
|
||||||
const result = { enumerable, configurable };
|
const result = { enumerable, configurable };
|
||||||
if (descriptor.hasOwnProperty("value")) {
|
if (descriptor.hasOwnProperty("value")) {
|
||||||
result.value = get.copy(descriptor.value, copyKeyDeep, map);
|
result.value = get.copy(
|
||||||
|
descriptor.value,
|
||||||
|
copyKeyDeep,
|
||||||
|
map
|
||||||
|
);
|
||||||
result.writable = descriptor.writable;
|
result.writable = descriptor.writable;
|
||||||
} else {
|
} else {
|
||||||
const { get, set } = descriptor;
|
const { get, set } = descriptor;
|
||||||
|
|
|
@ -6,6 +6,7 @@ export class Button extends HTMLDivElement {
|
||||||
/**
|
/**
|
||||||
* @type { string | undefined }
|
* @type { string | undefined }
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line no-unreachable
|
||||||
buttonid;
|
buttonid;
|
||||||
/**
|
/**
|
||||||
* @param {{}} item
|
* @param {{}} item
|
||||||
|
@ -21,13 +22,26 @@ export class Button extends HTMLDivElement {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
[item, type, position, noClick, button] = other._args;
|
[item, type, position, noClick, button] = other._args;
|
||||||
}
|
}
|
||||||
if (typeof type == "function") button = type(item, type, position, noClick, button);
|
if (typeof type == "function")
|
||||||
|
button = type(item, type, position, noClick, button);
|
||||||
else if (ui.create.buttonPresets[type])
|
else if (ui.create.buttonPresets[type])
|
||||||
button = ui.create.buttonPresets[type](item, type, position, noClick, button);
|
button = ui.create.buttonPresets[type](
|
||||||
|
item,
|
||||||
|
type,
|
||||||
|
position,
|
||||||
|
noClick,
|
||||||
|
button
|
||||||
|
);
|
||||||
if (button) {
|
if (button) {
|
||||||
Object.setPrototypeOf(button, (lib.element.Button || Button).prototype);
|
Object.setPrototypeOf(
|
||||||
|
button,
|
||||||
|
(lib.element.Button || Button).prototype
|
||||||
|
);
|
||||||
if (!noClick)
|
if (!noClick)
|
||||||
button.addEventListener(lib.config.touchscreen ? "touchend" : "click", ui.click.button);
|
button.addEventListener(
|
||||||
|
lib.config.touchscreen ? "touchend" : "click",
|
||||||
|
ui.click.button
|
||||||
|
);
|
||||||
else {
|
else {
|
||||||
button.classList.add("noclick");
|
button.classList.add("noclick");
|
||||||
const intro = button.querySelector(".intro");
|
const intro = button.querySelector(".intro");
|
||||||
|
|
|
@ -40,7 +40,10 @@ export class Card extends HTMLDivElement {
|
||||||
buildEventListener(info) {
|
buildEventListener(info) {
|
||||||
let card = this;
|
let card = this;
|
||||||
if (info != "noclick") {
|
if (info != "noclick") {
|
||||||
card.addEventListener(lib.config.touchscreen ? "touchend" : "click", ui.click.card);
|
card.addEventListener(
|
||||||
|
lib.config.touchscreen ? "touchend" : "click",
|
||||||
|
ui.click.card
|
||||||
|
);
|
||||||
if (lib.config.touchscreen) {
|
if (lib.config.touchscreen) {
|
||||||
card.addEventListener("touchstart", ui.click.cardtouchstart);
|
card.addEventListener("touchstart", ui.click.cardtouchstart);
|
||||||
card.addEventListener("touchmove", ui.click.cardtouchmove);
|
card.addEventListener("touchmove", ui.click.cardtouchmove);
|
||||||
|
@ -75,6 +78,7 @@ export class Card extends HTMLDivElement {
|
||||||
if (!noclick) lib.setIntro(this);
|
if (!noclick) lib.setIntro(this);
|
||||||
}
|
}
|
||||||
/** @type { SMap<HTMLDivElement> } */
|
/** @type { SMap<HTMLDivElement> } */
|
||||||
|
// eslint-disable-next-line no-unreachable
|
||||||
node;
|
node;
|
||||||
/**
|
/**
|
||||||
* @type { string }
|
* @type { string }
|
||||||
|
@ -192,7 +196,10 @@ export class Card extends HTMLDivElement {
|
||||||
}
|
}
|
||||||
removeGaintag(tag) {
|
removeGaintag(tag) {
|
||||||
if (tag === true) {
|
if (tag === true) {
|
||||||
if ((this.gaintag && this.gaintag.length) || this.node.gaintag.innerHTML.length)
|
if (
|
||||||
|
(this.gaintag && this.gaintag.length) ||
|
||||||
|
this.node.gaintag.innerHTML.length
|
||||||
|
)
|
||||||
this.addGaintag([]);
|
this.addGaintag([]);
|
||||||
} else if (this.hasGaintag(tag)) {
|
} else if (this.hasGaintag(tag)) {
|
||||||
this.gaintag.remove(tag);
|
this.gaintag.remove(tag);
|
||||||
|
@ -260,7 +267,11 @@ export class Card extends HTMLDivElement {
|
||||||
this.number = parseInt(card[1]) || 0;
|
this.number = parseInt(card[1]) || 0;
|
||||||
this.name = card[2];
|
this.name = card[2];
|
||||||
|
|
||||||
if (info.destroy && typeof info.destroy != "boolean" && !lib.skill[info.destroy]) {
|
if (
|
||||||
|
info.destroy &&
|
||||||
|
typeof info.destroy != "boolean" &&
|
||||||
|
!lib.skill[info.destroy]
|
||||||
|
) {
|
||||||
this.destroyed = info.destroy;
|
this.destroyed = info.destroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +302,21 @@ export class Card extends HTMLDivElement {
|
||||||
var cardnum = card[1] || "";
|
var cardnum = card[1] || "";
|
||||||
if (parseInt(cardnum) == cardnum) cardnum = parseInt(cardnum);
|
if (parseInt(cardnum) == cardnum) cardnum = parseInt(cardnum);
|
||||||
if (cardnum > 0 && cardnum < 14) {
|
if (cardnum > 0 && cardnum < 14) {
|
||||||
cardnum = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"][cardnum - 1];
|
cardnum = [
|
||||||
|
"A",
|
||||||
|
"2",
|
||||||
|
"3",
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6",
|
||||||
|
"7",
|
||||||
|
"8",
|
||||||
|
"9",
|
||||||
|
"10",
|
||||||
|
"J",
|
||||||
|
"Q",
|
||||||
|
"K",
|
||||||
|
][cardnum - 1];
|
||||||
}
|
}
|
||||||
if (this.name) {
|
if (this.name) {
|
||||||
this.classList.remove("epic");
|
this.classList.remove("epic");
|
||||||
|
@ -338,14 +363,20 @@ export class Card extends HTMLDivElement {
|
||||||
this.classList.add("fullskin");
|
this.classList.add("fullskin");
|
||||||
if (img) {
|
if (img) {
|
||||||
if (img.startsWith("ext:")) {
|
if (img.startsWith("ext:")) {
|
||||||
this.node.image.setBackgroundImage(img.replace(/^ext:/, "extension/"));
|
this.node.image.setBackgroundImage(
|
||||||
|
img.replace(/^ext:/, "extension/")
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.node.image.setBackgroundDB(img);
|
this.node.image.setBackgroundDB(img);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (lib.card[bg].modeimage) {
|
if (lib.card[bg].modeimage) {
|
||||||
this.node.image.setBackgroundImage(
|
this.node.image.setBackgroundImage(
|
||||||
"image/mode/" + lib.card[bg].modeimage + "/card/" + bg + ".png"
|
"image/mode/" +
|
||||||
|
lib.card[bg].modeimage +
|
||||||
|
"/card/" +
|
||||||
|
bg +
|
||||||
|
".png"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
|
@ -353,18 +384,29 @@ export class Card extends HTMLDivElement {
|
||||||
if (bg == "sha" && typeof nature == "string") {
|
if (bg == "sha" && typeof nature == "string") {
|
||||||
let natures = get.natureList(nature),
|
let natures = get.natureList(nature),
|
||||||
_bg;
|
_bg;
|
||||||
for (const n of natures) if (lib.natureBg.has(n)) _bg = n;
|
for (const n of natures)
|
||||||
|
if (lib.natureBg.has(n)) _bg = n;
|
||||||
if (_bg) {
|
if (_bg) {
|
||||||
this.node.image.setBackgroundImage(lib.natureBg.get(_bg));
|
this.node.image.setBackgroundImage(
|
||||||
|
lib.natureBg.get(_bg)
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.node.image.setBackgroundImage("image/card/" + bg + ".png");
|
this.node.image.setBackgroundImage(
|
||||||
|
"image/card/" + bg + ".png"
|
||||||
|
);
|
||||||
} while (0);
|
} while (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (get.dynamicVariable(lib.card[bg].image, this) == "background") {
|
} else if (
|
||||||
if (card[3]) this.node.background.setBackground(bg + "_" + get.natureList(card[3])[0], "card");
|
get.dynamicVariable(lib.card[bg].image, this) == "background"
|
||||||
|
) {
|
||||||
|
if (card[3])
|
||||||
|
this.node.background.setBackground(
|
||||||
|
bg + "_" + get.natureList(card[3])[0],
|
||||||
|
"card"
|
||||||
|
);
|
||||||
else this.node.background.setBackground(bg, "card");
|
else this.node.background.setBackground(bg, "card");
|
||||||
} else if (lib.card[bg].fullimage) {
|
} else if (lib.card[bg].fullimage) {
|
||||||
this.classList.add("fullimage");
|
this.classList.add("fullimage");
|
||||||
|
@ -376,10 +418,19 @@ export class Card extends HTMLDivElement {
|
||||||
this.setBackgroundDB(img);
|
this.setBackgroundDB(img);
|
||||||
}
|
}
|
||||||
} else if (get.dynamicVariable(lib.card[bg].image, this)) {
|
} else if (get.dynamicVariable(lib.card[bg].image, this)) {
|
||||||
if (get.dynamicVariable(lib.card[bg].image, this).startsWith("character:")) {
|
if (
|
||||||
this.setBackground(get.dynamicVariable(lib.card[bg].image, this).slice(10), "character");
|
get
|
||||||
|
.dynamicVariable(lib.card[bg].image, this)
|
||||||
|
.startsWith("character:")
|
||||||
|
) {
|
||||||
|
this.setBackground(
|
||||||
|
get.dynamicVariable(lib.card[bg].image, this).slice(10),
|
||||||
|
"character"
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.setBackground(get.dynamicVariable(lib.card[bg].image, this));
|
this.setBackground(
|
||||||
|
get.dynamicVariable(lib.card[bg].image, this)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var cardPack = lib.cardPack["mode_" + get.mode()];
|
var cardPack = lib.cardPack["mode_" + get.mode()];
|
||||||
|
@ -407,30 +458,44 @@ export class Card extends HTMLDivElement {
|
||||||
}
|
}
|
||||||
if (img) {
|
if (img) {
|
||||||
if (img.startsWith("ext:")) {
|
if (img.startsWith("ext:")) {
|
||||||
this.node.avatar.setBackgroundImage(img.replace(/^ext:/, "extension/"));
|
this.node.avatar.setBackgroundImage(
|
||||||
|
img.replace(/^ext:/, "extension/")
|
||||||
|
);
|
||||||
this.node.avatar.style.backgroundSize = "cover";
|
this.node.avatar.style.backgroundSize = "cover";
|
||||||
} else {
|
} else {
|
||||||
this.node.avatar.setBackgroundDB(img);
|
this.node.avatar.setBackgroundDB(img);
|
||||||
}
|
}
|
||||||
} else if (get.dynamicVariable(lib.card[bg].image, this)) {
|
} else if (get.dynamicVariable(lib.card[bg].image, this)) {
|
||||||
if (get.dynamicVariable(lib.card[bg].image, this).startsWith("character:")) {
|
if (
|
||||||
|
get
|
||||||
|
.dynamicVariable(lib.card[bg].image, this)
|
||||||
|
.startsWith("character:")
|
||||||
|
) {
|
||||||
this.node.avatar.setBackground(
|
this.node.avatar.setBackground(
|
||||||
get.dynamicVariable(lib.card[bg].image, this).slice(10),
|
get.dynamicVariable(lib.card[bg].image, this).slice(10),
|
||||||
"character"
|
"character"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.node.avatar.setBackground(get.dynamicVariable(lib.card[bg].image, this));
|
this.node.avatar.setBackground(
|
||||||
|
get.dynamicVariable(lib.card[bg].image, this)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var cardPack = lib.cardPack["mode_" + get.mode()];
|
var cardPack = lib.cardPack["mode_" + get.mode()];
|
||||||
if (Array.isArray(cardPack) && cardPack.includes(bg)) {
|
if (Array.isArray(cardPack) && cardPack.includes(bg)) {
|
||||||
this.node.avatar.setBackground("mode/" + get.mode() + "/card/" + bg);
|
this.node.avatar.setBackground(
|
||||||
|
"mode/" + get.mode() + "/card/" + bg
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.node.avatar.setBackground("card/" + bg);
|
this.node.avatar.setBackground("card/" + bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (get.dynamicVariable(lib.card[bg].image, this) == "card") {
|
} else if (get.dynamicVariable(lib.card[bg].image, this) == "card") {
|
||||||
if (card[3]) this.setBackground(bg + "_" + get.natureList(card[3])[0], "card");
|
if (card[3])
|
||||||
|
this.setBackground(
|
||||||
|
bg + "_" + get.natureList(card[3])[0],
|
||||||
|
"card"
|
||||||
|
);
|
||||||
else this.setBackground(bg, "card");
|
else this.setBackground(bg, "card");
|
||||||
} else if (
|
} else if (
|
||||||
typeof get.dynamicVariable(lib.card[bg].image, this) == "string" &&
|
typeof get.dynamicVariable(lib.card[bg].image, this) == "string" &&
|
||||||
|
@ -444,13 +509,18 @@ export class Card extends HTMLDivElement {
|
||||||
this.setBackgroundDB(img);
|
this.setBackgroundDB(img);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.setBackground(get.dynamicVariable(lib.card[bg].image, this));
|
this.setBackground(
|
||||||
|
get.dynamicVariable(lib.card[bg].image, this)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.node.background.innerHTML =
|
this.node.background.innerHTML =
|
||||||
lib.translate[bg + "_cbg"] || lib.translate[bg + "_bg"] || get.translation(bg)[0];
|
lib.translate[bg + "_cbg"] ||
|
||||||
|
lib.translate[bg + "_bg"] ||
|
||||||
|
get.translation(bg)[0];
|
||||||
// this.node.background.style.fontFamily=lib.config.card_font;
|
// this.node.background.style.fontFamily=lib.config.card_font;
|
||||||
if (this.node.background.innerHTML.length > 1) this.node.background.classList.add("tight");
|
if (this.node.background.innerHTML.length > 1)
|
||||||
|
this.node.background.classList.add("tight");
|
||||||
else this.node.background.classList.remove("tight");
|
else this.node.background.classList.remove("tight");
|
||||||
}
|
}
|
||||||
if (!lib.card[bg].fullborder && this.node.avatar && this.node.framebg) {
|
if (!lib.card[bg].fullborder && this.node.avatar && this.node.framebg) {
|
||||||
|
@ -502,7 +572,10 @@ export class Card extends HTMLDivElement {
|
||||||
let natures = get.natureList(nature);
|
let natures = get.natureList(nature);
|
||||||
natures.sort(lib.sort.nature);
|
natures.sort(lib.sort.nature);
|
||||||
for (let nature of natures) {
|
for (let nature of natures) {
|
||||||
name += lib.translate["nature_" + nature] || lib.translate[nature] || "";
|
name +=
|
||||||
|
lib.translate["nature_" + nature] ||
|
||||||
|
lib.translate[nature] ||
|
||||||
|
"";
|
||||||
if (nature != "stab") this.node.image.classList.add(nature);
|
if (nature != "stab") this.node.image.classList.add(nature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,7 +588,8 @@ export class Card extends HTMLDivElement {
|
||||||
this.node.name.classList.add("longlong");
|
this.node.name.classList.add("longlong");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.node.name2.innerHTML = get.translation(card[0]) + cardnum + " " + name;
|
this.node.name2.innerHTML =
|
||||||
|
get.translation(card[0]) + cardnum + " " + name;
|
||||||
this.classList.add("card");
|
this.classList.add("card");
|
||||||
if (card[3]) {
|
if (card[3]) {
|
||||||
let natures = get.natureList(card[3]);
|
let natures = get.natureList(card[3]);
|
||||||
|
@ -539,7 +613,8 @@ export class Card extends HTMLDivElement {
|
||||||
var dist = lib.card[this.name].distance;
|
var dist = lib.card[this.name].distance;
|
||||||
if (dist.attackFrom) {
|
if (dist.attackFrom) {
|
||||||
added = true;
|
added = true;
|
||||||
this.node.range.innerHTML = "范围: " + (-dist.attackFrom + 1);
|
this.node.range.innerHTML =
|
||||||
|
"范围: " + (-dist.attackFrom + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!added) {
|
if (!added) {
|
||||||
|
@ -548,13 +623,15 @@ export class Card extends HTMLDivElement {
|
||||||
break;
|
break;
|
||||||
case "equip3":
|
case "equip3":
|
||||||
if (info.distance && info.distance.globalTo) {
|
if (info.distance && info.distance.globalTo) {
|
||||||
this.node.range.innerHTML = "防御: " + info.distance.globalTo;
|
this.node.range.innerHTML =
|
||||||
|
"防御: " + info.distance.globalTo;
|
||||||
this.node.name2.innerHTML += "+";
|
this.node.name2.innerHTML += "+";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "equip4":
|
case "equip4":
|
||||||
if (info.distance && info.distance.globalFrom) {
|
if (info.distance && info.distance.globalFrom) {
|
||||||
this.node.range.innerHTML = "进攻: " + -info.distance.globalFrom;
|
this.node.range.innerHTML =
|
||||||
|
"进攻: " + -info.distance.globalFrom;
|
||||||
this.node.name2.innerHTML += "-";
|
this.node.name2.innerHTML += "-";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -608,7 +685,8 @@ export class Card extends HTMLDivElement {
|
||||||
game.layout == "nova")
|
game.layout == "nova")
|
||||||
) {
|
) {
|
||||||
if (bool) {
|
if (bool) {
|
||||||
this.style.transform = this._transform + " translateY(-20px)";
|
this.style.transform =
|
||||||
|
this._transform + " translateY(-20px)";
|
||||||
} else {
|
} else {
|
||||||
this.style.transform = this._transform || "";
|
this.style.transform = this._transform || "";
|
||||||
}
|
}
|
||||||
|
@ -659,12 +737,16 @@ export class Card extends HTMLDivElement {
|
||||||
let owner = get.owner(this);
|
let owner = get.owner(this);
|
||||||
if (owner) {
|
if (owner) {
|
||||||
if (owner == player) return true; //是牌主,必知情。
|
if (owner == player) return true; //是牌主,必知情。
|
||||||
if (player.hasSkillTag("viewHandcard", null, owner, true)) return true; //有viewHandcard标签,必知情。
|
if (player.hasSkillTag("viewHandcard", null, owner, true))
|
||||||
|
return true; //有viewHandcard标签,必知情。
|
||||||
if (owner.isUnderControl(true, player)) return true; //被操控,必知情。
|
if (owner.isUnderControl(true, player)) return true; //被操控,必知情。
|
||||||
}
|
}
|
||||||
if (get.is.shownCard(this)) return true; //此牌是明置牌,必知情。
|
if (get.is.shownCard(this)) return true; //此牌是明置牌,必知情。
|
||||||
if (this._knowers) {
|
if (this._knowers) {
|
||||||
return this._knowers.includes("everyone") || this._knowers.includes(player.playerid);
|
return (
|
||||||
|
this._knowers.includes("everyone") ||
|
||||||
|
this._knowers.includes(player.playerid)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -702,8 +784,13 @@ export class Card extends HTMLDivElement {
|
||||||
this.style.left = this.offsetLeft + "px";
|
this.style.left = this.offsetLeft + "px";
|
||||||
this.style.top = this.offsetTop + "px";
|
this.style.top = this.offsetTop + "px";
|
||||||
|
|
||||||
dx = player.getLeft() + player.offsetWidth / 2 - 52 - this.offsetLeft;
|
dx =
|
||||||
dy = player.getTop() + player.offsetHeight / 2 - 52 - this.offsetTop;
|
player.getLeft() +
|
||||||
|
player.offsetWidth / 2 -
|
||||||
|
52 -
|
||||||
|
this.offsetLeft;
|
||||||
|
dy =
|
||||||
|
player.getTop() + player.offsetHeight / 2 - 52 - this.offsetTop;
|
||||||
}
|
}
|
||||||
if (get.is.mobileMe(player)) {
|
if (get.is.mobileMe(player)) {
|
||||||
dx += get.cardOffset();
|
dx += get.cardOffset();
|
||||||
|
@ -753,8 +840,10 @@ export class Card extends HTMLDivElement {
|
||||||
var clone = true;
|
var clone = true;
|
||||||
var position;
|
var position;
|
||||||
for (var i = 0; i < arguments.length; i++) {
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
if (typeof arguments[i] == "string") node.classList.add(arguments[i]);
|
if (typeof arguments[i] == "string")
|
||||||
else if (["div", "fragment"].includes(get.objtype(arguments[i]))) position = arguments[i];
|
node.classList.add(arguments[i]);
|
||||||
|
else if (["div", "fragment"].includes(get.objtype(arguments[i])))
|
||||||
|
position = arguments[i];
|
||||||
else if (typeof arguments[i] == "boolean") clone = arguments[i];
|
else if (typeof arguments[i] == "boolean") clone = arguments[i];
|
||||||
}
|
}
|
||||||
node.moveTo = lib.element.Card.prototype.moveTo;
|
node.moveTo = lib.element.Card.prototype.moveTo;
|
||||||
|
@ -780,7 +869,9 @@ export class Card extends HTMLDivElement {
|
||||||
* @returns {boolean} 是否包含class
|
* @returns {boolean} 是否包含class
|
||||||
*/
|
*/
|
||||||
classListContains(className) {
|
classListContains(className) {
|
||||||
return Array.from(arguments).some((name) => this.classList.contains(className));
|
return Array.from(arguments).some((name) =>
|
||||||
|
this.classList.contains(className)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 判断此牌是否包含class样式,参数有多个时,需全部满足。
|
* 判断此牌是否包含class样式,参数有多个时,需全部满足。
|
||||||
|
@ -790,7 +881,9 @@ export class Card extends HTMLDivElement {
|
||||||
* @returns {boolean} 是否包含class
|
* @returns {boolean} 是否包含class
|
||||||
*/
|
*/
|
||||||
classListContainsAll() {
|
classListContainsAll() {
|
||||||
return Array.from(arguments).every((name) => this.classList.contains(this.className));
|
return Array.from(arguments).every((name) =>
|
||||||
|
this.classList.contains(this.className)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 返回一个键值,用于在缓存中作为键名。
|
* 返回一个键值,用于在缓存中作为键名。
|
||||||
|
@ -809,7 +902,9 @@ export class Card extends HTMLDivElement {
|
||||||
if (bool === false) {
|
if (bool === false) {
|
||||||
ui.cardPile.insertBefore(
|
ui.cardPile.insertBefore(
|
||||||
this,
|
this,
|
||||||
ui.cardPile.childNodes[Math.floor(Math.random() * ui.cardPile.childNodes.length)]
|
ui.cardPile.childNodes[
|
||||||
|
Math.floor(Math.random() * ui.cardPile.childNodes.length)
|
||||||
|
]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (_status.discarded) {
|
if (_status.discarded) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { ui } from "../../ui/index.js";
|
||||||
|
|
||||||
export class Dialog extends HTMLDivElement {
|
export class Dialog extends HTMLDivElement {
|
||||||
/** @type { HTMLDivElement } */
|
/** @type { HTMLDivElement } */
|
||||||
|
// eslint-disable-next-line no-unreachable
|
||||||
contentContainer;
|
contentContainer;
|
||||||
/** @type { HTMLDivElement } */
|
/** @type { HTMLDivElement } */
|
||||||
content;
|
content;
|
||||||
|
@ -51,7 +52,8 @@ export class Dialog extends HTMLDivElement {
|
||||||
else dialog.add(argument);
|
else dialog.add(argument);
|
||||||
});
|
});
|
||||||
//if (!hidden) dialog.open();
|
//if (!hidden) dialog.open();
|
||||||
if (!lib.config.touchscreen) dialog.contentContainer.onscroll = ui.update;
|
if (!lib.config.touchscreen)
|
||||||
|
dialog.contentContainer.onscroll = ui.update;
|
||||||
if (!noTouchScroll) {
|
if (!noTouchScroll) {
|
||||||
dialog.contentContainer.ontouchstart = ui.click.dialogtouchStart;
|
dialog.contentContainer.ontouchstart = ui.click.dialogtouchStart;
|
||||||
dialog.contentContainer.ontouchmove = ui.click.touchScroll;
|
dialog.contentContainer.ontouchmove = ui.click.touchScroll;
|
||||||
|
@ -98,21 +100,27 @@ export class Dialog extends HTMLDivElement {
|
||||||
const buttons = ui.create.div(".buttons", this.content);
|
const buttons = ui.create.div(".buttons", this.content);
|
||||||
if (zoom) buttons.classList.add("smallzoom");
|
if (zoom) buttons.classList.add("smallzoom");
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.buttons = this.buttons.concat(ui.create.buttons(item, "card", buttons, noclick));
|
this.buttons = this.buttons.concat(
|
||||||
|
ui.create.buttons(item, "card", buttons, noclick)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
else if (get.itemtype(item) == "players") {
|
else if (get.itemtype(item) == "players") {
|
||||||
var buttons = ui.create.div(".buttons", this.content);
|
var buttons = ui.create.div(".buttons", this.content);
|
||||||
if (zoom) buttons.classList.add("smallzoom");
|
if (zoom) buttons.classList.add("smallzoom");
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.buttons = this.buttons.concat(ui.create.buttons(item, "player", buttons, noclick));
|
this.buttons = this.buttons.concat(
|
||||||
|
ui.create.buttons(item, "player", buttons, noclick)
|
||||||
|
);
|
||||||
} else if (item[1] == "textbutton") {
|
} else if (item[1] == "textbutton") {
|
||||||
ui.create.textbuttons(item[0], this, noclick);
|
ui.create.textbuttons(item[0], this, noclick);
|
||||||
} else {
|
} else {
|
||||||
var buttons = ui.create.div(".buttons", this.content);
|
var buttons = ui.create.div(".buttons", this.content);
|
||||||
if (zoom) buttons.classList.add("smallzoom");
|
if (zoom) buttons.classList.add("smallzoom");
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.buttons = this.buttons.concat(ui.create.buttons(item[0], item[1], buttons, noclick));
|
this.buttons = this.buttons.concat(
|
||||||
|
ui.create.buttons(item[0], item[1], buttons, noclick)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (this.buttons.length) {
|
if (this.buttons.length) {
|
||||||
if (this.forcebutton !== false) this.forcebutton = true;
|
if (this.forcebutton !== false) this.forcebutton = true;
|
||||||
|
@ -166,10 +174,19 @@ export class Dialog extends HTMLDivElement {
|
||||||
}
|
}
|
||||||
ui.dialog = this;
|
ui.dialog = this;
|
||||||
let translate;
|
let translate;
|
||||||
if (lib.config.remember_dialog && lib.config.dialog_transform && !this.classList.contains("fixed")) {
|
if (
|
||||||
|
lib.config.remember_dialog &&
|
||||||
|
lib.config.dialog_transform &&
|
||||||
|
!this.classList.contains("fixed")
|
||||||
|
) {
|
||||||
translate = lib.config.dialog_transform;
|
translate = lib.config.dialog_transform;
|
||||||
this._dragtransform = translate;
|
this._dragtransform = translate;
|
||||||
this.style.transform = "translate(" + translate[0] + "px," + translate[1] + "px) scale(0.8)";
|
this.style.transform =
|
||||||
|
"translate(" +
|
||||||
|
translate[0] +
|
||||||
|
"px," +
|
||||||
|
translate[1] +
|
||||||
|
"px) scale(0.8)";
|
||||||
} else {
|
} else {
|
||||||
this.style.transform = "scale(0.8)";
|
this.style.transform = "scale(0.8)";
|
||||||
}
|
}
|
||||||
|
@ -179,8 +196,17 @@ export class Dialog extends HTMLDivElement {
|
||||||
ui.dialogs.unshift(this);
|
ui.dialogs.unshift(this);
|
||||||
ui.update();
|
ui.update();
|
||||||
ui.refresh(this);
|
ui.refresh(this);
|
||||||
if (lib.config.remember_dialog && lib.config.dialog_transform && !this.classList.contains("fixed")) {
|
if (
|
||||||
this.style.transform = "translate(" + translate[0] + "px," + translate[1] + "px) scale(1)";
|
lib.config.remember_dialog &&
|
||||||
|
lib.config.dialog_transform &&
|
||||||
|
!this.classList.contains("fixed")
|
||||||
|
) {
|
||||||
|
this.style.transform =
|
||||||
|
"translate(" +
|
||||||
|
translate[0] +
|
||||||
|
"px," +
|
||||||
|
translate[1] +
|
||||||
|
"px) scale(1)";
|
||||||
} else {
|
} else {
|
||||||
this.style.transform = "scale(1)";
|
this.style.transform = "scale(1)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,6 +165,7 @@ export class Player extends HTMLDivElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** @type { SMap<HTMLDivElement> } */
|
/** @type { SMap<HTMLDivElement> } */
|
||||||
|
// eslint-disable-next-line no-unreachable
|
||||||
node;
|
node;
|
||||||
/**
|
/**
|
||||||
* @type { number }
|
* @type { number }
|
||||||
|
|
Loading…
Reference in New Issue