Commit db791535 authored by nanahira's avatar nanahira

just a bit sort

parent 029e8bb2
Pipeline #43192 failed with stages
in 1 minute and 9 seconds
...@@ -2,6 +2,7 @@ import YGOProDeck from 'ygopro-deck-encode'; ...@@ -2,6 +2,7 @@ import YGOProDeck from 'ygopro-deck-encode';
import { YGOProYrp, ReplayHeader } from 'ygopro-yrp-encode'; import { YGOProYrp, ReplayHeader } from 'ygopro-yrp-encode';
import { Room } from './room'; import { Room } from './room';
import { YGOProMsgBase } from 'ygopro-msg-encode'; import { YGOProMsgBase } from 'ygopro-msg-encode';
import { calculateDuelOptions } from '../utility/calculate-duel-options';
// Constants from ygopro // Constants from ygopro
const REPLAY_COMPRESSED = 0x1; const REPLAY_COMPRESSED = 0x1;
...@@ -68,7 +69,7 @@ export class DuelRecord { ...@@ -68,7 +69,7 @@ export class DuelRecord {
startLp: room.hostinfo.start_lp, startLp: room.hostinfo.start_lp,
startHand: room.hostinfo.start_hand, startHand: room.hostinfo.start_hand,
drawCount: room.hostinfo.draw_count, drawCount: room.hostinfo.draw_count,
opt: room.opt, opt: calculateDuelOptions(room.hostinfo),
hostDeck: this.toReplayDeck(this.players[0]?.deck), hostDeck: this.toReplayDeck(this.players[0]?.deck),
clientDeck: isTag clientDeck: isTag
? this.toReplayDeck(this.players[2]?.deck) ? this.toReplayDeck(this.players[2]?.deck)
......
...@@ -119,10 +119,6 @@ export class Room { ...@@ -119,10 +119,6 @@ export class Room {
return this.hostinfo.mode === 2; return this.hostinfo.mode === 2;
} }
get opt() {
return calculateDuelOptions(this.hostinfo, this.isTag);
}
players = new Array<Client | undefined>(this.hostinfo.mode === 2 ? 4 : 2); players = new Array<Client | undefined>(this.hostinfo.mode === 2 ? 4 : 2);
watchers = new Set<Client>(); watchers = new Set<Client>();
get playingPlayers() { get playingPlayers() {
...@@ -215,7 +211,7 @@ export class Room { ...@@ -215,7 +211,7 @@ export class Room {
} }
} }
get joinGameMessage() { private get joinGameMessage() {
return new YGOProStocJoinGame().fromPartial({ return new YGOProStocJoinGame().fromPartial({
info: { info: {
...this.hostinfo, ...this.hostinfo,
...@@ -224,7 +220,7 @@ export class Room { ...@@ -224,7 +220,7 @@ export class Room {
}); });
} }
get watcherSizeMessage() { private get watcherSizeMessage() {
return new YGOProStocHsWatchChange().fromPartial({ return new YGOProStocHsWatchChange().fromPartial({
watch_count: this.watchers.size, watch_count: this.watchers.size,
}); });
...@@ -354,7 +350,7 @@ export class Room { ...@@ -354,7 +350,7 @@ export class Room {
); );
} }
async sendReplays(client: Client) { private async sendReplays(client: Client) {
for (let i = 0; i < this.duelRecords.length; i++) { for (let i = 0; i < this.duelRecords.length; i++) {
const duelRecord = this.duelRecords[i]; const duelRecord = this.duelRecords[i];
await client.sendChat( await client.sendChat(
...@@ -927,7 +923,7 @@ export class Room { ...@@ -927,7 +923,7 @@ export class Room {
return true; return true;
} }
private ocgcore?: OcgcoreWorker; ocgcore?: OcgcoreWorker;
private registry: Record<string, string> = {}; private registry: Record<string, string> = {};
turnCount = 0; turnCount = 0;
turnIngamePos = 0; turnIngamePos = 0;
...@@ -1592,4 +1588,12 @@ export class Room { ...@@ -1592,4 +1588,12 @@ export class Room {
// TODO: teammate surrender in tag duel // TODO: teammate surrender in tag duel
return this.win({ player: 1 - this.getIngameDuelPos(client), type: 0x0 }); return this.win({ player: 1 - this.getIngameDuelPos(client), type: 0x0 });
} }
async getLP(player: number): Promise<number | undefined> {
if (!this.ocgcore) {
return undefined;
}
const info = await this.ocgcore.queryFieldInfo();
return info.field.players[this.getIngameDuelPosByDuelPos(player)].lp;
}
} }
...@@ -7,10 +7,7 @@ import { OcgcoreDuelOptionFlag } from 'koishipro-core.js'; ...@@ -7,10 +7,7 @@ import { OcgcoreDuelOptionFlag } from 'koishipro-core.js';
* @param isTag Whether this is a tag duel * @param isTag Whether this is a tag duel
* @returns Duel options number * @returns Duel options number
*/ */
export function calculateDuelOptions( export function calculateDuelOptions(hostinfo: HostInfo): number {
hostinfo: HostInfo,
isTag: boolean = false,
): number {
// duel_rule is stored in high 16 bits // duel_rule is stored in high 16 bits
let opt = hostinfo.duel_rule << 16; let opt = hostinfo.duel_rule << 16;
...@@ -18,7 +15,7 @@ export function calculateDuelOptions( ...@@ -18,7 +15,7 @@ export function calculateDuelOptions(
opt |= OcgcoreDuelOptionFlag.PseudoShuffle; opt |= OcgcoreDuelOptionFlag.PseudoShuffle;
} }
if (isTag) { if (hostinfo.mode & 0x2) {
opt |= OcgcoreDuelOptionFlag.TagMode; opt |= OcgcoreDuelOptionFlag.TagMode;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment