diff --git a/noname/library/element/content.js b/noname/library/element/content.js index e9a6f1e4d..8cec78a27 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -6,6 +6,7 @@ import { status as _status } from '../../status/index.js'; import { UI as ui } from '../../ui/index.js'; import { GNC as gnc } from '../../gnc/index.js'; +// 未来再改 export default { emptyEvent: async (event) => { event.trigger(event.name); @@ -2405,223 +2406,6 @@ export default { game.pause(); } }, - phase: [ - async (event, _trigger, player) => { - // 初始化阶段列表 - if (!event.phaseList) { - event.phaseList = ['phaseZhunbei', 'phaseJudge', 'phaseDraw', 'phaseUse', 'phaseDiscard', 'phaseJieshu']; - } - - if (typeof event.num != 'number') { - event.num = 0; - } - - // 规则集中的“回合开始后①”,更新游戏轮数,触发“一轮游戏开始时” - let isRound = false; - if (!event.skill) { - isRound = _status.roundSkipped; - if (_status.isRoundFilter) { - isRound = _status.isRoundFilter(event, player); - } - else if (_status.seatNumSettled) { - var seatNum = player.getSeatNum(); - if (seatNum != 0) { - if (get.itemtype(_status.lastPhasedPlayer) != 'player' || seatNum < _status.lastPhasedPlayer.getSeatNum()) isRound = true; - _status.lastPhasedPlayer = player; - } - } - else if (player == _status.roundStart) isRound = true; - if (isRound) { - delete _status.roundSkipped; - game.roundNumber++; - event._roundStart = true; - game.updateRoundNumber(); - for (var i = 0; i < game.players.length; i++) { - if (game.players[i].isOut() && game.players[i].outCount > 0) { - game.players[i].outCount--; - if (game.players[i].outCount == 0 && !game.players[i].outSkills) { - game.players[i].in(); - } - } - } - event.trigger('roundStart'); - } - } - - _status.globalHistory.push({ - cardMove: [], - custom: [], - useCard: [], - changeHp: [], - everything: [], - }); - - const players = game.players.slice(0).concat(game.dead); - for (const current of players) { - current.actionHistory.push({ useCard: [], respond: [], skipped: [], lose: [], gain: [], sourceDamage: [], damage: [], custom: [], useSkill: [] }); - current.stat.push({ card: {}, skill: {} }); - if (isRound) { - current.getHistory().isRound = true; - current.getStat().isRound = true; - } - } - - if (isRound) { - game.getGlobalHistory().isRound = true; - } - }, - async (event) => { - //规则集中的“回合开始后②(1v1武将登场专用)” - event.trigger('phaseBeforeStart'); - }, - async (event) => { - //规则集中的“回合开始后③(处理“游戏开始时”的时机)” - event.trigger('phaseBefore'); - }, - async (event) => { - //规则集中的“回合开始后④(卑弥呼〖纵傀〗的时机)” - event.trigger('phaseBeforeEnd'); - }, - async (event, _trigger, player) => { - //规则集中的“回合开始后⑤”,进行翻面检测 - if (player.isTurnedOver() && !event._noTurnOver) { - event.cancel(); - player.turnOver(); - player.phaseSkipped = true; - } - else { - player.phaseSkipped = false; - player.getHistory().isMe = true; - player.getStat().isMe = true; - } - }, - async (event, _trigger, player) => { - // 规则集中的“回合开始后⑥”,更新“当前回合角色” - while (ui.dialogs.length) { - ui.dialogs[0].close(); - } - - ++game.phaseNumber; - ++player.phaseNumber; - - game.broadcastAll((player, num, popup) => { - if (lib.config.glow_phase) { - player.classList.add('glow_phase'); - } - player.phaseNumber = num; - _status.currentPhase = player; - if (popup && lib.config.show_phase_prompt) player.popup('回合开始', null, false); - }, player, player.phaseNumber, !player.noPhaseDelay); - - _status.currentPhase = player; - _status.discarded = []; - - game.syncState(); - game.addVideo('phaseChange', player); - - if (game.phaseNumber == 1) { - delete player._start_cards; - if (lib.configOL.observe) { - lib.configOL.observeReady = true; - game.send('server', 'config', lib.configOL); - } - } - - game.log(); - game.log(player, '的回合开始'); - player._noVibrate = true; - - if (get.config('identity_mode') != 'zhong' && get.config('identity_mode') != 'purple' && !_status.connectMode) { - let num; - switch (get.config('auto_identity')) { - case 'one': num = 1; break; - case 'two': num = 2; break; - case 'three': num = 3; break; - case 'always': num = -1; break; - default: num = 0; break; - } - if (num && !_status.identityShown && game.phaseNumber > game.players.length * num && game.showIdentity) { - if (!_status.video) player.popup('显示身份'); - _status.identityShown = true; - game.showIdentity(false); - } - } - player.ai.tempIgnore = []; - if (ui.land && ui.land.player == player) { - game.addVideo('destroyLand'); - ui.land.destroy(); - } - }, - async (event) => { - //规则集中的“回合开始后⑦”,国战武将明置武将牌 - event.trigger('phaseBeginStart'); - }, - async (event) => { - //规则集中的“回合开始后⑨”,进行当先,化身等操作 - //没有⑧ 因为⑧用不到 - event.trigger('phaseBegin'); - }, - async (event, _trigger, player) => { - if (event.num < event.phaseList.length) { - //规则集中没有的新时机 可以用来插入额外阶段啥的 - if (player.isIn()) event.trigger('phaseChange'); - } - else event.goto(11); - }, - async (event, _trigger, player) => { - if (player.isIn() && event.num < event.phaseList.length) { - const phase = event.phaseList[event.num].split('|'); - event.currentPhase = phase[0]; - const next = player[event.currentPhase](); - next.phaseIndex = event.num; - if (phase.length > 1) { - next._extraPhaseReason = phase[1]; - } - if (event.currentPhase == 'phaseDraw' || event.currentPhase == 'phaseDiscard') { - if (!player.noPhaseDelay) { - if (player == game.me) { - game.delay(); - } - else { - game.delayx(); - } - } - } - } - }, - async (event, _trigger, player) => { - if (event.currentPhase == 'phaseUse') { - game.broadcastAll(() => { - if (ui.tempnowuxie) { - ui.tempnowuxie.close(); - delete ui.tempnowuxie; - } - }); - delete player._noSkill; - } - ++event.num; - }, - async (event) => { - if (event.num < event.phaseList.length) { - event.goto(8); - } - else if (!event._phaseEndTriggered) { - event._phaseEndTriggered = true; - event.trigger('phaseEnd'); - event.redo(); - } - }, - async (event) => { - event.trigger('phaseAfter'); - }, - async ({ player }) => { - //删除当前回合角色 此时处于“不属于任何角色的回合”的阶段 - game.broadcastAll((player) => { - player.classList.remove('glow_phase'); - delete _status.currentPhase; - }, player); - } - ], /** * @deprecated */ diff --git a/noname/library/element/contents.js b/noname/library/element/contents.js new file mode 100644 index 000000000..e89431ad2 --- /dev/null +++ b/noname/library/element/contents.js @@ -0,0 +1,248 @@ +import { AI as ai } from '../../ai/index.js'; +import { Get as get } from '../../get/index.js'; +import { Game as game } from '../../game/index.js'; +import { Library as lib } from "../index.js"; +import { status as _status } from '../../status/index.js'; +import { UI as ui } from '../../ui/index.js'; +import { GNC as gnc } from '../../gnc/index.js'; + +export default { + phase: [ + async (event, _trigger, player) => { + // 初始化阶段列表 + if (!event.phaseList) { + event.phaseList = ['phaseZhunbei', 'phaseJudge', 'phaseDraw', 'phaseUse', 'phaseDiscard', 'phaseJieshu']; + } + + if (typeof event.num != 'number') { + event.num = 0; + } + + // 规则集中的“回合开始后①”,更新游戏轮数,触发“一轮游戏开始时” + let isRound = false; + if (!event.skill) { + isRound = _status.roundSkipped; + if (_status.isRoundFilter) { + isRound = _status.isRoundFilter(event, player); + } + else if (_status.seatNumSettled) { + var seatNum = player.getSeatNum(); + if (seatNum != 0) { + // @ts-ignore + if (get.itemtype(_status.lastPhasedPlayer) != 'player' || seatNum < _status.lastPhasedPlayer.getSeatNum()) isRound = true; + _status.lastPhasedPlayer = player; + } + } + else if (player == _status.roundStart) isRound = true; + if (isRound) { + delete _status.roundSkipped; + game.roundNumber++; + event._roundStart = true; + game.updateRoundNumber(); + for (var i = 0; i < game.players.length; i++) { + // @ts-ignore + if (game.players[i].isOut() && game.players[i].outCount > 0) { + // @ts-ignore + game.players[i].outCount--; + if (game.players[i].outCount == 0 && !game.players[i].outSkills) { + game.players[i].in(); + } + } + } + event.trigger('roundStart'); + } + } + + _status.globalHistory.push({ + cardMove: [], + custom: [], + useCard: [], + changeHp: [], + everything: [], + }); + + const players = game.players.slice(0).concat(game.dead); + for (const current of players) { + // @ts-ignore + current.actionHistory.push({ useCard: [], respond: [], skipped: [], lose: [], gain: [], sourceDamage: [], damage: [], custom: [], useSkill: [] }); + // @ts-ignore + current.stat.push({ card: {}, skill: {} }); + if (isRound) { + current.getHistory().isRound = true; + current.getStat().isRound = true; + } + } + + if (isRound) { + // @ts-ignore + game.getGlobalHistory().isRound = true; + } + }, + async (event) => { + //规则集中的“回合开始后②(1v1武将登场专用)” + event.trigger('phaseBeforeStart'); + }, + async (event) => { + //规则集中的“回合开始后③(处理“游戏开始时”的时机)” + event.trigger('phaseBefore'); + }, + async (event) => { + //规则集中的“回合开始后④(卑弥呼〖纵傀〗的时机)” + event.trigger('phaseBeforeEnd'); + }, + async (event, _trigger, player) => { + //规则集中的“回合开始后⑤”,进行翻面检测 + if (player.isTurnedOver() && !event._noTurnOver) { + event.cancel(); + player.turnOver(); + player.phaseSkipped = true; + } + else { + player.phaseSkipped = false; + player.getHistory().isMe = true; + player.getStat().isMe = true; + } + }, + async (event, _trigger, player) => { + // 规则集中的“回合开始后⑥”,更新“当前回合角色” + // @ts-ignore + while (ui.dialogs.length) { + // @ts-ignore + ui.dialogs[0].close(); + } + + ++game.phaseNumber; + ++player.phaseNumber; + + // @ts-ignore + game.broadcastAll((player, num, popup) => { + if (lib.config.glow_phase) { + player.classList.add('glow_phase'); + } + player.phaseNumber = num; + _status.currentPhase = player; + if (popup && lib.config.show_phase_prompt) player.popup('回合开始', null, false); + }, player, player.phaseNumber, !player.noPhaseDelay); + + _status.currentPhase = player; + _status.discarded = []; + + game.syncState(); + // @ts-ignore + game.addVideo('phaseChange', player); + + if (game.phaseNumber == 1) { + delete player._start_cards; + if (lib.configOL.observe) { + lib.configOL.observeReady = true; + game.send('server', 'config', lib.configOL); + } + } + + game.log(); + game.log(player, '的回合开始'); + player._noVibrate = true; + + if (get.config('identity_mode') != 'zhong' && get.config('identity_mode') != 'purple' && !_status.connectMode) { + let num; + switch (get.config('auto_identity')) { + case 'one': num = 1; break; + case 'two': num = 2; break; + case 'three': num = 3; break; + case 'always': num = -1; break; + default: num = 0; break; + } + // @ts-ignore + if (num && !_status.identityShown && game.phaseNumber > game.players.length * num && game.showIdentity) { + if (!_status.video) player.popup('显示身份'); + _status.identityShown = true; + // @ts-ignore + game.showIdentity(false); + } + } + player.ai.tempIgnore = []; + // @ts-ignore + if (ui.land && ui.land.player == player) { + // @ts-ignore + game.addVideo('destroyLand'); + // @ts-ignore + ui.land.destroy(); + } + }, + async (event) => { + //规则集中的“回合开始后⑦”,国战武将明置武将牌 + event.trigger('phaseBeginStart'); + }, + async (event) => { + //规则集中的“回合开始后⑨”,进行当先,化身等操作 + //没有⑧ 因为⑧用不到 + event.trigger('phaseBegin'); + }, + async (event, _trigger, player) => { + if (event.num < event.phaseList.length) { + //规则集中没有的新时机 可以用来插入额外阶段啥的 + if (player.isIn()) event.trigger('phaseChange'); + } + else event.goto(11); + }, + async (event, _trigger, player) => { + if (player.isIn() && event.num < event.phaseList.length) { + const phase = event.phaseList[event.num].split('|'); + event.currentPhase = phase[0]; + const next = player[event.currentPhase](); + next.phaseIndex = event.num; + if (phase.length > 1) { + next._extraPhaseReason = phase[1]; + } + if (event.currentPhase == 'phaseDraw' || event.currentPhase == 'phaseDiscard') { + if (!player.noPhaseDelay) { + // @ts-ignore + if (player == game.me) { + game.delay(); + } + else { + game.delayx(); + } + } + } + } + }, + async (event, _trigger, player) => { + if (event.currentPhase == 'phaseUse') { + // @ts-ignore + game.broadcastAll(() => { + // @ts-ignore + if (ui.tempnowuxie) { + // @ts-ignore + ui.tempnowuxie.close(); + // @ts-ignore + delete ui.tempnowuxie; + } + }); + delete player._noSkill; + } + ++event.num; + }, + async (event) => { + if (event.num < event.phaseList.length) { + event.goto(8); + } + else if (!event._phaseEndTriggered) { + event._phaseEndTriggered = true; + event.trigger('phaseEnd'); + event.redo(); + } + }, + async (event) => { + event.trigger('phaseAfter'); + }, + async ({ player }) => { + //删除当前回合角色 此时处于“不属于任何角色的回合”的阶段 + // @ts-ignore + game.broadcastAll((player) => { + player.classList.remove('glow_phase'); + delete _status.currentPhase; + }, player); + } + ], +}; diff --git a/noname/library/index.js b/noname/library/index.js index 840f04b51..e90493602 100644 --- a/noname/library/index.js +++ b/noname/library/index.js @@ -21,6 +21,7 @@ import { GNC as gnc } from '../gnc/index.js'; import { LibInit } from "./init/index.js"; import { Announce } from "./announce/index.js"; import Content from "./element/content.js"; +import Contents from "./element/contents.js"; export class Library extends Uninstantable { static configprefix = 'noname_0.9_'; @@ -9212,6 +9213,7 @@ export class Library extends Uninstantable { }; static element = { content: Content, + contents: Contents, Player: class extends HTMLDivElement { /** * @param {HTMLDivElement} [position] @@ -19914,12 +19916,12 @@ export class Library extends Uninstantable { /** * - * @param {import("../util/index.js").AsyncFunction[] | keyof typeof lib.element.content} contents + * @param {import("../util/index.js").AsyncFunction[] | keyof typeof lib.element.contents} contents * @returns {GameEvent} */ setContents(contents) { if (Array.isArray(contents)) this.contents = contents; - else if (contents in lib.element.content) return this.setContents(lib.element.content[contents]); + else if (contents in lib.element.contents) return this.setContents(lib.element.contents[contents]); else throw new Error('not supported value.'); return this; } @@ -24603,7 +24605,11 @@ export class Library extends Uninstantable { static other = { ignore: () => void 0 }; -}; +} +Library.config = undefined; + +Library.configOL = undefined; +; export const lib = Library;