From 302cebabf35b454fe20a281e26ad01376695a9cc Mon Sep 17 00:00:00 2001 From: mengxinzxz <2223529500@qq.com> Date: Mon, 29 Apr 2024 09:34:27 +0800 Subject: [PATCH] =?UTF-8?q?tempname=E8=8E=B7=E5=8F=96bugfix=EF=BC=8C?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ①修复无get.character的name获取tempname引发的报错问题(eg:国战) ②格式化noname\game\index.js为新Prettier准则 --- noname/game/index.js | 1055 +++++++++++------------------------------- 1 file changed, 279 insertions(+), 776 deletions(-) diff --git a/noname/game/index.js b/noname/game/index.js index a42e73e4b..61b6062b1 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -16,14 +16,7 @@ import { lib } from "../library/index.js"; import { _status } from "../status/index.js"; import { ui } from "../ui/index.js"; import { gnc } from "../gnc/index.js"; -import { - userAgent, - Uninstantable, - GeneratorFunction, - AsyncFunction, - delay, - nonameInitialized, -} from "../util/index.js"; +import { userAgent, Uninstantable, GeneratorFunction, AsyncFunction, delay, nonameInitialized } from "../util/index.js"; import { DynamicStyle } from "./dynamic-style/index.js"; import { GamePromises } from "./promises.js"; @@ -111,10 +104,10 @@ export class Game { if (typeof event.name != "string") return; const handlerMap = this._handlers[event.name]; if (!handlerMap) return; - Object.keys(handlerMap).forEach((key) => { + Object.keys(handlerMap).forEach(key => { const list = handlerMap[key]; if (!list) return; - list.forEach((handler) => { + list.forEach(handler => { event.pushHandler(key, handler); }); }); @@ -123,25 +116,13 @@ export class Game { //Stratagem //谋攻 setStratagemBuffCost(cardName, cost) { - return game.broadcastAll( - (clientCardName, clientCost) => lib.stratagemBuff.cost.set(clientCardName, clientCost), - cardName, - cost - ); + return game.broadcastAll((clientCardName, clientCost) => lib.stratagemBuff.cost.set(clientCardName, clientCost), cardName, cost); } setStratagemBuffEffect(cardName, effect) { - return game.broadcastAll( - (clientCardName, clientEffect) => lib.stratagemBuff.cost.set(clientCardName, clientEffect), - cardName, - effect - ); + return game.broadcastAll((clientCardName, clientEffect) => lib.stratagemBuff.cost.set(clientCardName, clientEffect), cardName, effect); } setStratagemBuffPrompt(cardName, prompt) { - return game.broadcastAll( - (clientCardName, clientPrompt) => lib.stratagemBuff.cost.set(clientCardName, clientPrompt), - cardName, - prompt - ); + return game.broadcastAll((clientCardName, clientPrompt) => lib.stratagemBuff.cost.set(clientCardName, clientPrompt), cardName, prompt); } /** * 添加新的属性杀 @@ -158,7 +139,7 @@ export class Game { hasNature(item, nature, player) { var natures = get.natureList(item, player); if (!nature) return natures.length > 0; - if (nature == "linked") return natures.some((n) => lib.linked.includes(n)); + if (nature == "linked") return natures.some(n => lib.linked.includes(n)); return get.is.sameNature(natures, nature); } /** @@ -267,40 +248,19 @@ export class Game { return yingbianEffect; } setYingbianConditionColor(yingbianCondition, color) { - return game.broadcastAll( - (yingbianCondition, color) => lib.yingbian.condition.color.set(yingbianCondition, color), - yingbianCondition, - color - ); + return game.broadcastAll((yingbianCondition, color) => lib.yingbian.condition.color.set(yingbianCondition, color), yingbianCondition, color); } setComplexYingbianCondition(yingbianCondition, condition) { - return game.broadcastAll( - (yingbianCondition, condition) => - lib.yingbian.condition.complex.set(yingbianCondition, condition), - yingbianCondition, - condition - ); + return game.broadcastAll((yingbianCondition, condition) => lib.yingbian.condition.complex.set(yingbianCondition, condition), yingbianCondition, condition); } setSimpleYingbianCondition(yingbianCondition, condition) { - return game.broadcastAll( - (yingbianCondition, condition) => lib.yingbian.condition.simple.set(yingbianCondition, condition), - yingbianCondition, - condition - ); + return game.broadcastAll((yingbianCondition, condition) => lib.yingbian.condition.simple.set(yingbianCondition, condition), yingbianCondition, condition); } setYingbianEffect(yingbianEffect, effect) { - return game.broadcastAll( - (yingbianEffect, effect) => lib.yingbian.effect.set(yingbianEffect, effect), - yingbianEffect, - effect - ); + return game.broadcastAll((yingbianEffect, effect) => lib.yingbian.effect.set(yingbianEffect, effect), yingbianEffect, effect); } setYingbianPrompt(yingbian, prompt) { - return game.broadcastAll( - (yingbian, prompt) => lib.yingbian.prompt.set(yingbian, prompt), - yingbian, - prompt - ); + return game.broadcastAll((yingbian, prompt) => lib.yingbian.prompt.set(yingbian, prompt), yingbian, prompt); } /** * Dynamic Style Manager @@ -370,8 +330,7 @@ export class Game { node._link.current = this.link; const tmpName = node.lastChild.innerHTML; node.lastChild.innerHTML = config.item[this._link]; - if (config.onclick && config.onclick.call(node, this._link, this) === false) - node.lastChild.innerHTML = tmpName; + if (config.onclick && config.onclick.call(node, this._link, this) === false) node.lastChild.innerHTML = tmpName; if (config.update) config.update(); }, menu.childElementCount - 2 @@ -412,18 +371,16 @@ export class Game { if (background.startsWith("blob:") || background.startsWith("data:")) { uiBackground.setBackgroundImage(background); } else if (background.startsWith("db:")) uiBackground.setBackgroundDB(background.slice(3)); - else if (background.startsWith("ext:")) - uiBackground.setBackgroundImage(`extension/${background.slice(4)}`); + else if (background.startsWith("ext:")) uiBackground.setBackgroundImage(`extension/${background.slice(4)}`); else if (background == "default") { uiBackground.addTempClass("start"); style.backgroundImage = "none"; } else if (background.startsWith("custom_")) { style.backgroundImage = "none"; - game.getDB("image", background).then((fileToLoad) => { + game.getDB("image", background).then(fileToLoad => { if (!fileToLoad) return; const fileReader = new FileReader(); - fileReader.onload = (fileLoadedEvent) => - (style.backgroundImage = `url(${fileLoadedEvent.target.result})`); + fileReader.onload = fileLoadedEvent => (style.backgroundImage = `url(${fileLoadedEvent.target.result})`); fileReader.readAsDataURL(fileToLoad, "UTF-8"); }); } else uiBackground.setBackgroundImage(`image/background/${background}.jpg`); @@ -436,7 +393,7 @@ export class Game { * 用给定的BPM、节拍和偏移生成谱面 */ generateBeatmapTimeleap(bpm, beats, offset) { - return beats.map((value) => Math.round((value * 60000) / bpm + (offset || 0))); + return beats.map(value => Math.round((value * 60000) / bpm + (offset || 0))); } updateRenku() { game.broadcast(function (renku) { @@ -457,7 +414,7 @@ export class Game { cards = [cards]; } // @ts-ignore - cards.forEach((card) => card.addKnower(players)); + cards.forEach(card => card.addKnower(players)); } /** * 移除牌的所有知情者。 @@ -470,7 +427,7 @@ export class Game { cards = [cards]; } // @ts-ignore - cards.forEach((card) => card.clearKnowers()); + cards.forEach(card => card.clearKnowers()); } /** * @param { { [key: string]: any } } [arg] @@ -639,7 +596,7 @@ export class Game { */ hasAllGlobalHistory(key, filter, last) { if (!key || !filter) return false; - return _status.globalHistory.some((value) => { + return _status.globalHistory.some(value => { if (value[key]) { if (last && value[key].includes(last)) { const lastIndex = value[key].indexOf(last); @@ -666,7 +623,7 @@ export class Game { checkAllGlobalHistory(key, filter, last) { if (!key || !filter) return; let stopped = false; - _status.globalHistory.forEach((value) => { + _status.globalHistory.forEach(value => { if (value[key]) { if (last && value[key].includes(last) && !stopped) { stopped = true; @@ -695,7 +652,7 @@ export class Game { */ getAllGlobalHistory(key, filter, last) { const history = []; - _status.globalHistory.forEach((value) => { + _status.globalHistory.forEach(value => { if (!key || !value[key]) { history.push(value); } else { @@ -935,11 +892,8 @@ export class Game { (node.system = ui.create.system(lib.translate[skill], null, true, true)), () => { const uiIntro = ui.create.dialog("hidden"); - uiIntro.addText(player ? `来源:${get.translation(player)}` : "地图").style.margin = - "0"; - uiIntro._place_text = uiIntro.add( - ui.create.div(".text", lib.translate[`${skill}_info`]) - ); + uiIntro.addText(player ? `来源:${get.translation(player)}` : "地图").style.margin = "0"; + uiIntro._place_text = uiIntro.add(ui.create.div(".text", lib.translate[`${skill}_info`])); uiIntro.add(ui.create.div(".placeholder.slim")); return uiIntro; }, @@ -962,7 +916,7 @@ export class Game { let n = updates.length; for (let i = 0; i < updates.length; i++) { if (lib.node && lib.node.fs) { - lib.node.fs.access(__dirname + "/" + updates[i], (err) => { + lib.node.fs.access(__dirname + "/" + updates[i], err => { if (!err) { let stat = lib.node.fs.statSync(__dirname + "/" + updates[i]); // @ts-ignore @@ -1244,14 +1198,7 @@ export class Game { ui.timer.show(); let num; //这么一大行都是为了祢衡 - if ( - _status.event && - _status.event.name == "chooseToUse" && - _status.event.type == "phase" && - _status.event.player && - _status.event.player.forceCountChoose && - typeof _status.event.player.forceCountChoose.phaseUse == "number" - ) { + if (_status.event && _status.event.name == "chooseToUse" && _status.event.type == "phase" && _status.event.player && _status.event.player.forceCountChoose && typeof _status.event.player.forceCountChoose.phaseUse == "number") { num = _status.event.player.forceCountChoose.phaseUse; } else if (_status.connectMode) { num = lib.configOL.choose_timeout; @@ -1275,11 +1222,7 @@ export class Game { } else if (_status.event.player.forceCountChoose && _status.event.isMine() && !_status.countDown) { let info = _status.event.player.forceCountChoose; let num; - if ( - _status.event.name == "chooseToUse" && - _status.event.type == "phase" && - typeof info.phaseUse == "number" - ) { + if (_status.event.name == "chooseToUse" && _status.event.type == "phase" && typeof info.phaseUse == "number") { num = info.phaseUse; } else if (typeof info[_status.event.name] == "number") { num = info[_status.event.name]; @@ -1299,10 +1242,7 @@ export class Game { } else if (ui.confirm.str.includes("o")) { ui.click.ok(); } - } else if ( - ["chooseControl", "chooseBool"].includes(_status.event.name) && - _status.paused - ) { + } else if (["chooseControl", "chooseBool"].includes(_status.event.name) && _status.paused) { _status.event.result = "ai"; game.resume(); } else { @@ -1364,8 +1304,7 @@ export class Game { delete game.ws; } let str = ""; - if (!ip.startsWith("wss://") && !ip.startsWith("ws://")) - str = get.config("wss_mode", "connect") ? "wss://" : "ws://"; + if (!ip.startsWith("wss://") && !ip.startsWith("ws://")) str = get.config("wss_mode", "connect") ? "wss://" : "ws://"; game.ws = new WebSocket(str + ip + ""); } catch { // 今天狂神龙尊来了这里也没有参数 @@ -1443,8 +1382,7 @@ export class Game { if (_status.video) break; } if (path.startsWith("ext:")) path = path.replace(/^ext:/, "extension/"); - else if (!["db:", "blob:", "data:"].some((prefix) => path.startsWith(prefix))) - path = `audio/${path}`; + else if (!["db:", "blob:", "data:"].some(prefix => path.startsWith(prefix))) path = `audio/${path}`; if (!lib.config.repeat_audio && _status.skillaudio.includes(path)) return; } const audio = document.createElement("audio"); @@ -1457,21 +1395,17 @@ export class Game { setTimeout(() => _status.skillaudio.remove(path), 1000); game.addVideo("playAudio", null, path); }; - audio.onended = (event) => audio.remove(); - audio.onerror = (event) => { + audio.onended = event => audio.remove(); + audio.onerror = event => { audio.remove(); if (onError) onError(event); }; new Promise((resolve, reject) => { - if (path.startsWith("db:")) - game.getDB("image", path.slice(3)).then( - (octetStream) => resolve(get.objectURL(octetStream)), - reject - ); + if (path.startsWith("db:")) game.getDB("image", path.slice(3)).then(octetStream => resolve(get.objectURL(octetStream)), reject); else if (lib.path.extname(path)) resolve(`${lib.assetURL}${path}`); else if (URL.canParse(path)) resolve(path); else resolve(`${lib.assetURL}${path}.mp3`); - }).then((resolvedPath) => { + }).then(resolvedPath => { audio.src = resolvedPath; ui.window.appendChild(audio); }); @@ -1520,31 +1454,30 @@ export class Game { if (typeof player === "string") player = { name: player }; else if (typeof player !== "object" || player === null) player = {}; - if (skillInfo && (typeof skillInfo !== "object" || Array.isArray(skillInfo))) - skillInfo = { audio: skillInfo }; + if (skillInfo && (typeof skillInfo !== "object" || Array.isArray(skillInfo))) skillInfo = { audio: skillInfo }; const checkSkill = (skill, history) => { if (!lib.skill[skill]) return false; if (!history.includes(skill)) return true; if (history[0] === skill) return false; //deadlock - throw new RangeError(`parseSkillAudio: ${skill} in ${ history }forms a deadlock`); + throw new RangeError(`parseSkillAudio: ${skill} in ${history}forms a deadlock`); }; - const getName = (filter) => { - const name = (player.tempname || []).find((i) => filter(i)); + const getName = filter => { + const name = (player.tempname || []).find(i => filter(i)); return ( name || [player.name, player.name1, player.name2].reduce((result, name) => { if (result) return result; if (!name) return result; if (filter(name)) return name; - let tempname = get.character(name).trashBin.find((tag) => tag.startsWith("tempname:")); + let tempname = (get.character(name).trashBin || []).find(tag => tag.startsWith("tempname:")); if (!tempname) return result; tempname = tempname .split(":") .slice(1) - .find((i) => filter(i)); + .find(i => filter(i)); return tempname || result; }, void 0) ); @@ -1567,7 +1500,7 @@ export class Game { history.unshift(skill); let audioInfo = info.audio; if (Array.isArray(info.audioname)) audioname.addArray(info.audioname); - if (info.audioname2) audioInfo = info.audioname2[getName((i) => info.audioname2[i])] || audioInfo; + if (info.audioname2) audioInfo = info.audioname2[getName(i => info.audioname2[i])] || audioInfo; if (typeof audioInfo === "function") audioInfo = audioInfo(player); return parseAudio(skill, options, audioInfo); @@ -1586,18 +1519,15 @@ export class Game { if (Array.isArray(audioInfo)) { if (typeof audioInfo[0] === "string" && typeof audioInfo[1] === "number") { // [audioname, number] - if (checkSkill(audioInfo[0], history)) - return getAudioList(audioInfo[0], options).slice(0, audioInfo[1]); + if (checkSkill(audioInfo[0], history)) return getAudioList(audioInfo[0], options).slice(0, audioInfo[1]); return parseAudio(audioInfo[0], options, audioInfo[1]); } return audioInfo.reduce((total, i) => total.addArray(parseAudio(skill, options, i)), []); } - if (!["string", "number", "boolean"].includes(typeof audioInfo)) - return parseAudio(skill, options, [true, 2]); + if (!["string", "number", "boolean"].includes(typeof audioInfo)) return parseAudio(skill, options, [true, 2]); if (audioInfo === false) return []; - if (typeof audioInfo === "string" && checkSkill(audioInfo, history)) - return getAudioList(audioInfo, options); + if (typeof audioInfo === "string" && checkSkill(audioInfo, history)) return getAudioList(audioInfo, options); audioInfo = String(audioInfo); let list = audioInfo.match(/(?:(.*):|^)(true|\d+)(?::(.*)|$)/); // [path, number|true, format] @@ -1605,25 +1535,20 @@ export class Game { let path = "", format = ""; if (!/^db:|^ext:|\//.test(audioInfo)) path = "skill/"; - if ( - !/\.\w+$/.test(audioInfo) && - !["data:", "blob:"].some((name) => audioInfo.startsWith(name)) - ) - format = ".mp3"; + if (!/\.\w+$/.test(audioInfo) && !["data:", "blob:"].some(name => audioInfo.startsWith(name))) format = ".mp3"; if (path && format) return parseAudio(audioInfo, options, [true, 2]); return [useRawAudio ? audioInfo : `${path}${audioInfo}${format}`]; } - let _audioname = getName((i) => audioname.includes(i)); + let _audioname = getName(i => audioname.includes(i)); _audioname = _audioname ? `_${_audioname}` : ""; - if (list[2] === "true") - return [`${list[1] || "skill"}/${skill}${_audioname}.${list[3] || "mp3"}`]; + if (list[2] === "true") return [`${list[1] || "skill"}/${skill}${_audioname}.${list[3] || "mp3"}`]; const audioList = []; list[2] = parseInt(list[2]); for (let i = 1; i <= list[2]; i++) { - if(useRawAudio) audioList.push(`${skill}${_audioname}${i}`); + if (useRawAudio) audioList.push(`${skill}${_audioname}${i}`); else audioList.push(`${list[1] || "skill"}/${skill}${_audioname}${i}.${list[3] || "mp3"}`); } return audioList; @@ -1640,12 +1565,12 @@ export class Game { * @param { skillInfo | audioInfo } [skillInfo] 预设的skillInfo/audioInfo(转为skillInfo),覆盖lib.skill[skill] * @returns { string[] } 语音地址列表 */ - parseSkillText(skill, player, skillInfo){ + parseSkillText(skill, player, skillInfo) { const audios = game.parseSkillAudio(skill, player, skillInfo, true); const voiceMap = []; audios.forEach(audioname => { const voiceText = lib.translate[`#${audioname}`]; - if(voiceText) voiceMap.push(voiceText); + if (voiceText) voiceMap.push(voiceText); }); return voiceMap; } @@ -1659,8 +1584,7 @@ export class Game { * @returns */ trySkillAudio(skill, player, directaudio, nobroadcast, skillInfo) { - if (!nobroadcast) - game.broadcast(game.trySkillAudio, skill, player, directaudio, nobroadcast, skillInfo); + if (!nobroadcast) game.broadcast(game.trySkillAudio, skill, player, directaudio, nobroadcast, skillInfo); const info = skillInfo || lib.skill[skill]; if (!info) return; if (!lib.config.background_speak) return; @@ -1762,19 +1686,10 @@ export class Game { const audio = get.dynamicVariable(lib.card[card.name].audio, card, sex); if (typeof audio == "string") { const audioInfo = audio.split(":"); - if (["blob:", "data:"].some((prefix) => audio.startsWith(prefix))) { + if (["blob:", "data:"].some(prefix => audio.startsWith(prefix))) { game.playAudio(audio); - } else if (audio.startsWith("db:")) - game.playAudio( - `${audioInfo[0]}:${audioInfo[1]}`, - audioInfo[2], - `${card.name}_${sex}.${audioInfo[3] || "mp3"}` - ); - else if (audio.startsWith("ext:")) - game.playAudio( - `${audioInfo[0]}:${audioInfo[1]}`, - `${card.name}_${sex}.${audioInfo[2] || "mp3"}` - ); + } else if (audio.startsWith("db:")) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`, audioInfo[2], `${card.name}_${sex}.${audioInfo[3] || "mp3"}`); + else if (audio.startsWith("ext:")) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`, `${card.name}_${sex}.${audioInfo[2] || "mp3"}`); else game.playAudio("card", sex, `${audioInfo[0]}.${audioInfo[1] || "mp3"}`); } else game.playAudio("card", sex, card.name); } @@ -1787,46 +1702,29 @@ export class Game { const aozhanBGMConfiguration = lib.config.mode_config.guozhan.aozhan_bgm; if (aozhanBGMConfiguration == "disabled") return; let aozhan = _status.tempAozhan || aozhanBGMConfiguration; - if (Array.isArray(aozhan)) - aozhan = aozhan.randomGet("disabled", _status.currentAozhan) || aozhanBGMConfiguration; - if (aozhan == "random") - aozhan = Object.keys(lib.mode.guozhan.config.aozhan_bgm.item).randomGet( - "disabled", - "random", - _status.currentAozhan - ); + if (Array.isArray(aozhan)) aozhan = aozhan.randomGet("disabled", _status.currentAozhan) || aozhanBGMConfiguration; + if (aozhan == "random") aozhan = Object.keys(lib.mode.guozhan.config.aozhan_bgm.item).randomGet("disabled", "random", _status.currentAozhan); _status.currentAozhan = aozhan; - if (["blob:", "data:"].some((prefix) => aozhan.startsWith(prefix))) { + if (["blob:", "data:"].some(prefix => aozhan.startsWith(prefix))) { ui.backgroundMusic.src = aozhan; - } else if (aozhan.startsWith("db:")) - game.getDB("image", aozhan.slice(3)).then((result) => (ui.backgroundMusic.src = result)); - else if (aozhan.startsWith("ext:")) - ui.backgroundMusic.src = `${lib.assetURL}extension/${aozhan.slice(4)}`; + } else if (aozhan.startsWith("db:")) game.getDB("image", aozhan.slice(3)).then(result => (ui.backgroundMusic.src = result)); + else if (aozhan.startsWith("ext:")) ui.backgroundMusic.src = `${lib.assetURL}extension/${aozhan.slice(4)}`; else ui.backgroundMusic.src = `${lib.assetURL}audio/background/aozhan_${aozhan}.mp3`; return; } let music = _status.tempMusic || lib.config.background_music; - if (Array.isArray(music)) - music = music.randomGet("music_off", _status.currentMusic) || lib.config.background_music; - if (music == "music_random") - music = lib.config.all.background_music.randomGet( - "music_off", - "music_random", - _status.currentMusic - ); + if (Array.isArray(music)) music = music.randomGet("music_off", _status.currentMusic) || lib.config.background_music; + if (music == "music_random") music = lib.config.all.background_music.randomGet("music_off", "music_random", _status.currentMusic); _status.currentMusic = music; if (music == "music_custom") { const backgroundMusicSourceConfiguration = lib.config.background_music_src; - if (backgroundMusicSourceConfiguration) - ui.backgroundMusic.src = backgroundMusicSourceConfiguration; + if (backgroundMusicSourceConfiguration) ui.backgroundMusic.src = backgroundMusicSourceConfiguration; return; } - if (["blob:", "data:"].some((prefix) => music.startsWith(prefix))) { + if (["blob:", "data:"].some(prefix => music.startsWith(prefix))) { ui.backgroundMusic.src = music; - } else if (music.startsWith("db:")) - game.getDB("image", music.slice(3)).then((result) => (ui.backgroundMusic.src = result)); - else if (music.startsWith("ext:")) - ui.backgroundMusic.src = `${lib.assetURL}extension/${music.slice(4)}`; + } else if (music.startsWith("db:")) game.getDB("image", music.slice(3)).then(result => (ui.backgroundMusic.src = result)); + else if (music.startsWith("ext:")) ui.backgroundMusic.src = `${lib.assetURL}extension/${music.slice(4)}`; else ui.backgroundMusic.src = `${lib.assetURL}audio/background/${music}.mp3`; } // 某种意义上,改不了,得重写 @@ -1911,7 +1809,7 @@ export class Game { */ import(type, content, url) { if (type == "extension") { - const promise = game.loadExtension(content).then((name) => { + const promise = game.loadExtension(content).then(name => { if (typeof _status.extensionLoaded == "undefined") _status.extensionLoaded = []; _status.extensionLoaded.add(name); return name; @@ -1921,9 +1819,7 @@ export class Game { return promise; } else { if (!lib.imported[type]) lib.imported[type] = {}; - const promise = Promise.resolve( - (gnc.is.generator(content) ? gnc.of(content) : content)(lib, game, ui, get, ai, _status) - ).then((content2) => { + const promise = Promise.resolve((gnc.is.generator(content) ? gnc.of(content) : content)(lib, game, ui, get, ai, _status)).then(content2 => { if (content2.name) { lib.imported[type][content2.name] = content2; delete content2.name; @@ -1938,14 +1834,7 @@ export class Game { async loadExtension(object) { let noEval = false; if (typeof object == "function") { - object = await (gnc.is.generatorFunc(object) ? gnc.of(object) : object)( - lib, - game, - ui, - get, - ai, - _status - ); + object = await (gnc.is.generatorFunc(object) ? gnc.of(object) : object)(lib, game, ui, get, ai, _status); noEval = true; } if (object.closeSyntaxCheck) { @@ -2008,8 +1897,7 @@ export class Game { name: "编辑此扩展", clear: true, onclick: () => { - if (game.editExtension && lib.extensionPack && lib.extensionPack[name]) - game.editExtension(name); + if (game.editExtension && lib.extensionPack && lib.extensionPack[name]) game.editExtension(name); else alert("无法编辑未启用的扩展,请启用此扩展并重启后重试"); }, }; @@ -2019,18 +1907,14 @@ export class Game { onclick: function () { if (this.innerHTML != "确认删除") { this.innerHTML = "确认删除"; - new Promise((resolve) => setTimeout(resolve, 1000)).then( - () => (this.innerHTML = "删除此扩展") - ); + new Promise(resolve => setTimeout(resolve, 1000)).then(() => (this.innerHTML = "删除此扩展")); return; } const page = this.parentNode, start = page.parentNode.previousSibling; page.remove(); if (start) { - const pageInStart = Array.from(start.childNodes).find( - (childNode) => childNode.link == page - ); + const pageInStart = Array.from(start.childNodes).find(childNode => childNode.link == page); if (pageInStart) { let active = false; if (pageInStart.classList.contains("active")) active = true; @@ -2054,8 +1938,7 @@ export class Game { if (!object || !libConfig[`${extensionName}_enable`]) return; if (!noEval) lib.init.eval(object); const config = Object.keys(libConfig).reduce((constructingConfig, key) => { - if (key != extensionName && key.startsWith(extensionName)) - constructingConfig[key.slice(11 + name.length)] = libConfig[key]; + if (key != extensionName && key.startsWith(extensionName)) constructingConfig[key.slice(11 + name.length)] = libConfig[key]; return constructingConfig; }, {}); try { @@ -2080,30 +1963,15 @@ export class Game { if (precontent) { _status.extension = name; - await (gnc.is.generatorFunc(precontent) ? gnc.of(precontent) : precontent).call( - object, - config - ); + await (gnc.is.generatorFunc(precontent) ? gnc.of(precontent) : precontent).call(object, config); delete _status.extension; } } catch (e1) { console.log(`加载《${name}》扩展的precontent时出现错误。`, e1); - if (!lib.config.extension_alert) - alert( - `加载《${name}》扩展的precontent时出现错误。\n该错误本身可能并不影响扩展运行。您可以在“设置→通用→无视扩展报错”中关闭此弹窗。\n${decodeURI( - e1.stack - )}` - ); + if (!lib.config.extension_alert) alert(`加载《${name}》扩展的precontent时出现错误。\n该错误本身可能并不影响扩展运行。您可以在“设置→通用→无视扩展报错”中关闭此弹窗。\n${decodeURI(e1.stack)}`); } - if (content) - lib.extensions.push([ - name, - content, - config, - _status.evaluatingExtension, - objectPackage || {}, - ]); + if (content) lib.extensions.push([name, content, config, _status.evaluatingExtension, objectPackage || {}]); } catch (e) { console.log(e); } @@ -2172,7 +2040,7 @@ export class Game { filelist2 = _filelist || []; if (_filelist) delete data._filelist; const filelist = Object.keys(data); - filelist.forEach((value) => zip.file(value, data[value])); + filelist.forEach(value => zip.file(value, data[value])); game.print(filelist); game.print(filelist2); const generate = zip.generate({ @@ -2183,22 +2051,14 @@ export class Game { return; } if (extensionPackage) { - extensionPackage.files = filelist - .concat(filelist2) - .filter((value) => value != "extension.js"); + extensionPackage.files = filelist.concat(filelist2).filter(value => value != "extension.js"); const size = generate.byteLength; if (size < 1000) extensionPackage.size = `${size}B`; else if (size < 1000000) extensionPackage.size = `${Math.round(size / 1000)}KB`; else extensionPackage.size = `${Math.round(size / 100000) / 10}MB`; zip.file( "package.js", - Object.keys(extensionPackage).reduce( - (constructingData, key, currentIndex, keys) => - `${constructingData}\t${key}:${JSON.stringify(extensionPackage[key])}${ - currentIndex < keys.length - 1 ? ",\n" : "\n};" - }`, - `extension["${exportExtension}"]={\n` - ) + Object.keys(extensionPackage).reduce((constructingData, key, currentIndex, keys) => `${constructingData}\t${key}:${JSON.stringify(extensionPackage[key])}${currentIndex < keys.length - 1 ? ",\n" : "\n};"}`, `extension["${exportExtension}"]={\n`) ); } const blob = zip.generate({ @@ -2207,13 +2067,10 @@ export class Game { fileNameToSaveAs = `${exportExtension.replace(/\\|\/|:|\?|"|\*|<|>|\|/g, "-")}.zip`; if (lib.device) { - const directory = - lib.device == "android" - ? cordova.file.externalDataDirectory - : cordova.file.documentsDirectory; + const directory = lib.device == "android" ? cordova.file.externalDataDirectory : cordova.file.documentsDirectory; new Promise((resolve, reject) => window.resolveLocalFileSystemURL(directory, resolve, reject)) .then( - (directoryEntry) => + directoryEntry => new Promise((resolve, reject) => directoryEntry.getFile( fileNameToSaveAs, @@ -2225,12 +2082,9 @@ export class Game { ) ) ) + .then(fileEntry => new Promise((resolve, reject) => fileEntry.createWriter(resolve, reject))) .then( - (fileEntry) => - new Promise((resolve, reject) => fileEntry.createWriter(resolve, reject)) - ) - .then( - (fileWriter) => + fileWriter => new Promise((resolve, reject) => { fileWriter.onerror = reject; fileWriter.onwriteend = resolve; @@ -2250,7 +2104,7 @@ export class Game { return; } //导入 - const UHP = (error) => { + const UHP = error => { if (!(error instanceof Error)) error = new Error(error); for (const [key, value] of Object.entries(Object.getOwnPropertyDescriptors(error))) { if (value.configurable === true) { @@ -2282,21 +2136,25 @@ export class Game { if (str === "" || str === undefined) throw "你导入的不是扩展!请选择正确的文件"; // 编译ts扩展 if (isTsFile) { - if (typeof globalThis.ts === 'undefined') { - await lib.init.promises.js('game', 'typescript'); + if (typeof globalThis.ts === "undefined") { + await lib.init.promises.js("game", "typescript"); } /** * @type {typeof import('typescript')} */ const ts = globalThis.ts; - str = ts.transpile(str, { - module: ts.ModuleKind.ES2015, - //@todo: ES2019 -> ES2020 - target: ts.ScriptTarget.ES2019, - inlineSourceMap: true, - resolveJsonModule: true, - esModuleInterop: true, - }, 'extension.ts'); + str = ts.transpile( + str, + { + module: ts.ModuleKind.ES2015, + //@todo: ES2019 -> ES2020 + target: ts.ScriptTarget.ES2019, + inlineSourceMap: true, + resolveJsonModule: true, + esModuleInterop: true, + }, + "extension.ts" + ); } _status.importingExtension = true; try { @@ -2311,16 +2169,16 @@ export class Game { // 是模块扩展 if ( // @ts-ignore - error.message === 'Cannot use import statement outside a module' || + error.message === "Cannot use import statement outside a module" || // @ts-ignore - error.message === 'await is only valid in async functions and the top level bodies of modules' + error.message === "await is only valid in async functions and the top level bodies of modules" ) { // 改为用info.json判断扩展名 const infoFile = zip.file("info.json"); if (!infoFile) throw new Error("未找到info.json,导入模块化扩展必须加入info.json!"); const info = JSON.parse(infoFile.asText()); - if (typeof info.name == 'string') { - await game.import('extension', () => { + if (typeof info.name == "string") { + await game.import("extension", () => { return Object.assign(info, { config: {}, }); @@ -2338,21 +2196,20 @@ export class Game { game.saveConfigValue("extensions"); game.saveConfig(`extension_${extensionName}_enable`, true); const config = game.importedPack.config; - Object.keys(config).forEach((value) => { + Object.keys(config).forEach(value => { const configObject = config[value]; - if (configObject && "init" in configObject) - game.saveConfig(`extension_${extensionName}_${value}`, configObject.init); + if (configObject && "init" in configObject) game.saveConfig(`extension_${extensionName}_${value}`, configObject.init); }); if (game.download) { const files = zip.files, hiddenFileFlags = [".", "_"], fileList = Object.keys(files) - .filter((key) => !files[key].dir && !hiddenFileFlags.includes(key[0])) + .filter(key => !files[key].dir && !hiddenFileFlags.includes(key[0])) .reverse(); //电脑端 //具备nodeJS环境 if (lib.node && lib.node.fs) { - const writeFile = (errnoException) => { + const writeFile = errnoException => { if (errnoException) { finishLoad(); UHP(errnoException); @@ -2364,30 +2221,16 @@ export class Game { const zipDir = fileList.pop(), fileName = zipDir.split("/"), name = fileName.pop(), - letGo = (name) => - new Promise((resolve) => - lib.node.fs.writeFile( - `${__dirname}/extension/${extensionName}/${name}`, - zip.file(zipDir).asNodeBuffer(), - null, - resolve - ) - ).then(writeFile); - return fileName.length - ? game.promises - .createDir(`extension/${extensionName}/${fileName.join("/")}`) - .then(() => letGo(`${fileName.join("/")}/${name}`)) - : letGo(name); + letGo = name => new Promise(resolve => lib.node.fs.writeFile(`${__dirname}/extension/${extensionName}/${name}`, zip.file(zipDir).asNodeBuffer(), null, resolve)).then(writeFile); + return fileName.length ? game.promises.createDir(`extension/${extensionName}/${fileName.join("/")}`).then(() => letGo(`${fileName.join("/")}/${name}`)) : letGo(name); } finishLoad(); }; game.promises.ensureDirectory(`extension/${extensionName}`).then(writeFile).catch(UHP); } else - new Promise((resolve, reject) => - window.resolveLocalFileSystemURL(nonameInitialized, resolve, reject) - ) + new Promise((resolve, reject) => window.resolveLocalFileSystemURL(nonameInitialized, resolve, reject)) .then( - (directoryEntry) => + directoryEntry => new Promise((resolve, reject) => directoryEntry.getDirectory( `extension/${extensionName}`, @@ -2399,7 +2242,7 @@ export class Game { ) ) ) - .then((directoryEntry) => { + .then(directoryEntry => { //扩展文件夹 const writeFile = () => { if (!fileList.length) { @@ -2410,7 +2253,7 @@ export class Game { const zipDirectory = fileList.shift(), fileName = zipDirectory.split("/"), name = fileName.pop(), - letGo = (name) => + letGo = name => new Promise((resolve, reject) => directoryEntry.getFile( name, @@ -2421,28 +2264,17 @@ export class Game { reject ) ) + .then(fileEntry => new Promise((resolve, reject) => fileEntry.createWriter(resolve, reject))) .then( - (fileEntry) => - new Promise((resolve, reject) => - fileEntry.createWriter(resolve, reject) - ) - ) - .then( - (fileWriter) => + fileWriter => new Promise((resolve, reject) => { fileWriter.onerror = reject; fileWriter.onwriteend = resolve; - fileWriter.write( - zip.file(zipDirectory).asArrayBuffer() - ); + fileWriter.write(zip.file(zipDirectory).asArrayBuffer()); }) ) .then(writeFile); - return fileName.length - ? game.promises - .createDir(`extension/${extensionName}/${fileName.join("/")}`) - .then(() => letGo(`${fileName.join("/")}/${name}`)) - : letGo(name); + return fileName.length ? game.promises.createDir(`extension/${extensionName}/${fileName.join("/")}`).then(() => letGo(`${fileName.join("/")}/${name}`)) : letGo(name); }; return writeFile(); }) @@ -2450,16 +2282,13 @@ export class Game { } else { localStorage.setItem(`${lib.configprefix}extension_${extensionName}`, str); const hiddenFileFlags = [".", "_"], - fileList = Object.keys(zip.files).filter( - (filePath) => - !hiddenFileFlags.includes(filePath[0]) && filePath[filePath.length - 1] != "/" - ); + fileList = Object.keys(zip.files).filter(filePath => !hiddenFileFlags.includes(filePath[0]) && filePath[filePath.length - 1] != "/"); if (fileList.length && lib.db) { lib.config.extensionInfo[extensionName] = { file: fileList, }; game.saveConfigValue("extensionInfo"); - fileList.forEach((filePath) => { + fileList.forEach(filePath => { const arrayBuffer = zip.file(filePath).asArrayBuffer(); if (!arrayBuffer) return; const blob = new Blob([arrayBuffer]); @@ -2468,13 +2297,7 @@ export class Game { fileReader.onerror = reject; fileReader.onload = resolve; fileReader.readAsDataURL(blob, "UTF-8"); - }).then((fileLoadedEvent) => - game.putDB( - "image", - `extension-${extensionName}:${filePath}`, - fileLoadedEvent.target.result - ) - ); + }).then(fileLoadedEvent => game.putDB("image", `extension-${extensionName}:${filePath}`, fileLoadedEvent.target.result)); }); } finishLoad(); @@ -2747,12 +2570,7 @@ export class Game { if (_status.mode == "stratagem") { game.players[i].init(players[i].name, players[i].name2); game.players[i].identity = players[i].identity; - if ( - (game.players[i].identity == "fan" && - game.players[i].isCamouflaged && - game.me.identity == "nei") || - game.players[i] == game.me - ) { + if ((game.players[i].identity == "fan" && game.players[i].isCamouflaged && game.me.identity == "nei") || game.players[i] == game.me) { game.players[i].setIdentity(players[i].identity); } } else { @@ -3115,14 +2933,7 @@ export class Game { player.tempname.add(map.to); player.skin[name] = map.to; const goon = !lib.character[map.to]; - if (goon) - lib.character[map.to] = [ - "", - "", - 0, - [], - (map.list.find((i) => i[0] == map.to) || [map.to, []])[1], - ]; + if (goon) lib.character[map.to] = ["", "", 0, [], (map.list.find(i => i[0] == map.to) || [map.to, []])[1]]; player.smoothAvatar(map.avatar2); player.node["avatar" + map.name.slice(4)].setBackground(map.to, "character"); player.node["avatar" + map.name.slice(4)].show(); @@ -3199,11 +3010,7 @@ export class Game { player.classList.remove("unseen2_v"); break; } - if ( - !player.classList.contains("unseen_v") && - (!player.name2 || !player.classList.contains("unseen2_v")) && - player.storage.nohp - ) { + if (!player.classList.contains("unseen_v") && (!player.name2 || !player.classList.contains("unseen2_v")) && player.storage.nohp) { delete player.storage.nohp; player.node.hp.show(); player.update(); @@ -3281,11 +3088,7 @@ export class Game { }, compareMultiple: function (player, info) { if (player && info) { - player.$compareMultiple( - get.infoCard(info[0]), - get.infoTargets(info[1]), - get.infoCards(info[2]) - ); + player.$compareMultiple(get.infoCard(info[0]), get.infoTargets(info[1]), get.infoCards(info[2])); } else { console.log(player); } @@ -3327,11 +3130,7 @@ export class Game { } for (var i = 0; i < cards.length; i++) { for (var j = 0; j < nodes.length; j++) { - if ( - cards[i][2] == nodes[j].name && - cards[i][0] == nodes[j].suit && - cards[i][1] == nodes[j].number - ) { + if (cards[i][2] == nodes[j].name && cards[i][0] == nodes[j].suit && cards[i][1] == nodes[j].number) { nodes[j].moveDelete(player); cards.splice(i--, 1); nodes.splice(j--, 1); @@ -3355,11 +3154,7 @@ export class Game { } for (var i = 0; i < cards.length; i++) { for (var j = 0; j < nodes.length; j++) { - if ( - cards[i][2] == nodes[j].name && - cards[i][0] == nodes[j].suit && - cards[i][1] == nodes[j].number - ) { + if (cards[i][2] == nodes[j].name && cards[i][0] == nodes[j].suit && cards[i][1] == nodes[j].number) { nodes[j].delete(); if (method == "zoom") { nodes[j].style.transform = "scale(0)"; @@ -3454,11 +3249,7 @@ export class Game { var checkMatch = function (l1, l2) { for (var i = 0; i < l1.length; i++) { for (var j = 0; j < l2.length; j++) { - if ( - l2[j].suit == l1[i][0] && - l2[j].number == l1[i][1] && - l2[j].name == l1[i][2] - ) { + if (l2[j].suit == l1[i][0] && l2[j].number == l1[i][1] && l2[j].name == l1[i][2]) { l2[j].addGaintag(content[1]); l2.splice(j--, 1); break; @@ -3667,14 +3458,9 @@ export class Game { if (player && content) { var card = get.infoCard(content[0]); card.viewAs = content[1]; - if ( - card.viewAs && - card.viewAs != card.name && - (card.classList.contains("fullskin") || card.classList.contains("fullborder")) - ) { + if (card.viewAs && card.viewAs != card.name && (card.classList.contains("fullskin") || card.classList.contains("fullborder"))) { card.classList.add("fakejudge"); - card.node.background.innerHTML = - lib.translate[card.viewAs + "_bg"] || get.translation(card.viewAs)[0]; + card.node.background.innerHTML = lib.translate[card.viewAs + "_bg"] || get.translation(card.viewAs)[0]; } card.classList.add("drawinghidden"); player.node.judges.insertBefore(card, player.node.judges.firstChild); @@ -3774,11 +3560,7 @@ export class Game { var checkMatch = function (l1, l2) { for (var i = 0; i < l1.length; i++) { for (var j = 0; j < l2.length; j++) { - if ( - l2[j].suit == l1[i][0] && - l2[j].number == l1[i][1] && - l2[j].name == l1[i][2] - ) { + if (l2[j].suit == l1[i][0] && l2[j].number == l1[i][1] && l2[j].name == l1[i][2]) { l2[j].remove(); l2.splice(j--, 1); break; @@ -4467,35 +4249,15 @@ export class Game { surface.beginPath(); var middle = 0.5; var radius = p.radius; - if ( - type == "recover" || - type == "legend" || - type == "rare" || - type == "epic" || - type == "coin" || - type == "dust" - ) { + if (type == "recover" || type == "legend" || type == "rare" || type == "epic" || type == "coin" || type == "dust") { middle = 0.7; radius /= 3; } p.opacity = Math.round((p.death / p.life) * 100) / 100; - var gradient = surface.createRadialGradient( - p.location.x, - p.location.y, - 0, - p.location.x, - p.location.y, - p.radius - ); - gradient.addColorStop( - 0, - "rgba(" + p.r + ", " + p.g + ", " + p.b + ", " + p.opacity + ")" - ); - gradient.addColorStop( - middle, - "rgba(" + p.r + ", " + p.g + ", " + p.b + ", " + p.opacity + ")" - ); + var gradient = surface.createRadialGradient(p.location.x, p.location.y, 0, p.location.x, p.location.y, p.radius); + gradient.addColorStop(0, "rgba(" + p.r + ", " + p.g + ", " + p.b + ", " + p.opacity + ")"); + gradient.addColorStop(middle, "rgba(" + p.r + ", " + p.g + ", " + p.b + ", " + p.opacity + ")"); gradient.addColorStop(1, "rgba(" + p.r + ", " + p.g + ", " + p.b + ", 0)"); surface.fillStyle = gradient; surface.arc(p.location.x, p.location.y, radius, Math.PI * 2, false); @@ -4539,7 +4301,7 @@ export class Game { dashed = false, drag = false; if (arguments[1] && typeof arguments[1] == "object") - Object.keys(arguments[1]).forEach((value) => { + Object.keys(arguments[1]).forEach(value => { switch (value) { case "opacity": opacity = arguments[1][value]; @@ -4646,19 +4408,11 @@ export class Game { let current; if (time < total / 3) { ctx.strokeStyle = "rgba(" + color.toString() + "," + opacity * (time / (total / 3)) + ")"; - current = [ - from[0] + ((to[0] - from[0]) * time) / (total / 3), - from[1] + ((to[1] - from[1]) * time) / (total / 3), - ]; + current = [from[0] + ((to[0] - from[0]) * time) / (total / 3), from[1] + ((to[1] - from[1]) * time) / (total / 3)]; } else if (time <= total) { current = to; if (time > total / 1.5) { - ctx.strokeStyle = - "rgba(" + - color.toString() + - "," + - opacity * (1 - (time - total / 1.5) / (total - total / 1.5)) + - ")"; + ctx.strokeStyle = "rgba(" + color.toString() + "," + opacity * (1 - (time - total / 1.5) / (total - total / 1.5)) + ")"; } else { ctx.strokeStyle = "rgba(" + color.toString() + "," + opacity + ")"; } @@ -4724,18 +4478,7 @@ export class Game { addCharacter(name, information) { //TODO: 这一坨也要改 const extensionName = _status.extension || information.extension, - character = [ - information.sex, - information.group, - information.hp, - information.skills || [], - [ - _status.evaluatingExtension - ? `db:extension-${extensionName}:${name}.jpg` - : `ext:${extensionName}/${name}.jpg`, - `die:ext:${extensionName}/${name}.mp3`, - ], - ]; + character = [information.sex, information.group, information.hp, information.skills || [], [_status.evaluatingExtension ? `db:extension-${extensionName}:${name}.jpg` : `ext:${extensionName}/${name}.jpg`, `die:ext:${extensionName}/${name}.mp3`]]; if (information.tags) character[4] = character[4].concat(information.tags); lib.character[name] = character; const packName = `mode_extension_${extensionName}`; @@ -4771,15 +4514,8 @@ export class Game { imgsrc = "ext:" + extname + "/" + j + ".jpg"; } const audiosrc = "die:ext:" + extname + "/" + j + ".mp3"; - if ( - !pack[i][j][4].some( - (str) => - typeof str == "string" && /^(?:db:extension-.+?|ext|img):(?:.+)/.test(str) - ) - ) - pack[i][j][4].add(imgsrc); - if (!pack[i][j][4].some((str) => typeof str == "string" && /^die:(?:.+)/.test(str))) - pack[i][j][4].add(audiosrc); + if (!pack[i][j][4].some(str => typeof str == "string" && /^(?:db:extension-.+?|ext|img):(?:.+)/.test(str))) pack[i][j][4].add(imgsrc); + if (!pack[i][j][4].some(str => typeof str == "string" && /^die:(?:.+)/.test(str))) pack[i][j][4].add(audiosrc); if (pack[i][j][4].includes("boss") || pack[i][j][4].includes("hiddenboss")) { lib.config.forbidai.add(j); } @@ -4849,11 +4585,7 @@ export class Game { suits = ["club", "spade"]; } for (let i = 0; i < info2.number; i++) { - lib.card.list.push([ - suits[Math.floor(Math.random() * suits.length)], - Math.ceil(Math.random() * 13), - name, - ]); + lib.card.list.push([suits[Math.floor(Math.random() * suits.length)], Math.ceil(Math.random() * 13), name]); } } let packname = "mode_extension_" + extname; @@ -5099,7 +4831,7 @@ export class Game { */ removeExtension(extensionName, keepFile) { const prefix = `extension_${extensionName}`; - Object.keys(lib.config).forEach((key) => { + Object.keys(lib.config).forEach(key => { if (key.startsWith(prefix)) game.saveConfig(key); }); localStorage.removeItem(`${lib.configprefix}${prefix}`); @@ -5108,10 +4840,7 @@ export class Game { game.saveConfig("extensions", lib.config.extensions); const modeList = lib.config.extensionInfo[extensionName]; if (modeList) { - if (modeList.file) - Object.values(modeList.file).forEach((filePath) => - game.deleteDB("image", `extension-${extensionName}:${filePath}`) - ); + if (modeList.file) Object.values(modeList.file).forEach(filePath => game.deleteDB("image", `extension-${extensionName}:${filePath}`)); if (modeList.mode) Object.values(modeList.mode).forEach(game.clearModeConfig); delete lib.config.extensionInfo[extensionName]; game.saveConfigValue("extensionInfo"); @@ -5470,9 +5199,7 @@ export class Game { for (i = 0; i < game.players.length; i++) { tr = document.createElement("tr"); td = document.createElement("td"); - td.innerHTML = - get.translation(game.players[i]) + - (game.players[i].ai.stratagem_camouflage ? "(被伪装)" : ""); + td.innerHTML = get.translation(game.players[i]) + (game.players[i].ai.stratagem_camouflage ? "(被伪装)" : ""); tr.appendChild(td); td = document.createElement("td"); num = 0; @@ -5542,8 +5269,7 @@ export class Game { for (i = 0; i < game.dead.length; i++) { tr = document.createElement("tr"); td = document.createElement("td"); - td.innerHTML = - get.translation(game.dead[i]) + (game.dead[i].ai.stratagem_camouflage ? "(被伪装)" : ""); + td.innerHTML = get.translation(game.dead[i]) + (game.dead[i].ai.stratagem_camouflage ? "(被伪装)" : ""); tr.appendChild(td); td = document.createElement("td"); num = 0; @@ -5598,24 +5324,21 @@ export class Game { td = document.createElement("td"); num = 0; for (j = 0; j < game.additionaldead[i].stat.length; j++) { - if (game.additionaldead[i].stat[j].damage != undefined) - num += game.additionaldead[i].stat[j].damage; + if (game.additionaldead[i].stat[j].damage != undefined) num += game.additionaldead[i].stat[j].damage; } td.innerHTML = num; tr.appendChild(td); td = document.createElement("td"); num = 0; for (j = 0; j < game.additionaldead[i].stat.length; j++) { - if (game.additionaldead[i].stat[j].damaged != undefined) - num += game.additionaldead[i].stat[j].damaged; + if (game.additionaldead[i].stat[j].damaged != undefined) num += game.additionaldead[i].stat[j].damaged; } td.innerHTML = num; tr.appendChild(td); td = document.createElement("td"); num = 0; for (j = 0; j < game.additionaldead[i].stat.length; j++) { - if (game.additionaldead[i].stat[j].gain != undefined) - num += game.additionaldead[i].stat[j].gain; + if (game.additionaldead[i].stat[j].gain != undefined) num += game.additionaldead[i].stat[j].gain; } td.innerHTML = num; tr.appendChild(td); @@ -5631,8 +5354,7 @@ export class Game { td = document.createElement("td"); num = 0; for (j = 0; j < game.additionaldead[i].stat.length; j++) { - if (game.additionaldead[i].stat[j].kill != undefined) - num += game.additionaldead[i].stat[j].kill; + if (game.additionaldead[i].stat[j].kill != undefined) num += game.additionaldead[i].stat[j].kill; } td.innerHTML = num; tr.appendChild(td); @@ -5654,8 +5376,7 @@ export class Game { dialog.add(ui.create.div(".placeholder")); for (let i = 0; i < game.players.length; i++) { - if (!_status.connectMode && game.players[i].isUnderControl(true) && game.layout != "long2") - continue; + if (!_status.connectMode && game.players[i].isUnderControl(true) && game.layout != "long2") continue; let hs = game.players[i].getCards("h"); if (hs.length) { dialog.add('