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