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';
import { YGOProYrp, ReplayHeader } from 'ygopro-yrp-encode';
import { Room } from './room';
import { YGOProMsgBase } from 'ygopro-msg-encode';
import { calculateDuelOptions } from '../utility/calculate-duel-options';
// Constants from ygopro
const REPLAY_COMPRESSED = 0x1;
......@@ -68,7 +69,7 @@ export class DuelRecord {
startLp: room.hostinfo.start_lp,
startHand: room.hostinfo.start_hand,
drawCount: room.hostinfo.draw_count,
opt: room.opt,
opt: calculateDuelOptions(room.hostinfo),
hostDeck: this.toReplayDeck(this.players[0]?.deck),
clientDeck: isTag
? this.toReplayDeck(this.players[2]?.deck)
......
......@@ -119,10 +119,6 @@ export class Room {
return this.hostinfo.mode === 2;
}
get opt() {
return calculateDuelOptions(this.hostinfo, this.isTag);
}
players = new Array<Client | undefined>(this.hostinfo.mode === 2 ? 4 : 2);
watchers = new Set<Client>();
get playingPlayers() {
......@@ -215,7 +211,7 @@ export class Room {
}
}
get joinGameMessage() {
private get joinGameMessage() {
return new YGOProStocJoinGame().fromPartial({
info: {
...this.hostinfo,
......@@ -224,7 +220,7 @@ export class Room {
});
}
get watcherSizeMessage() {
private get watcherSizeMessage() {
return new YGOProStocHsWatchChange().fromPartial({
watch_count: this.watchers.size,
});
......@@ -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++) {
const duelRecord = this.duelRecords[i];
await client.sendChat(
......@@ -927,7 +923,7 @@ export class Room {
return true;
}
private ocgcore?: OcgcoreWorker;
ocgcore?: OcgcoreWorker;
private registry: Record<string, string> = {};
turnCount = 0;
turnIngamePos = 0;
......@@ -1592,4 +1588,12 @@ export class Room {
// TODO: teammate surrender in tag duel
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';
* @param isTag Whether this is a tag duel
* @returns Duel options number
*/
export function calculateDuelOptions(
hostinfo: HostInfo,
isTag: boolean = false,
): number {
export function calculateDuelOptions(hostinfo: HostInfo): number {
// duel_rule is stored in high 16 bits
let opt = hostinfo.duel_rule << 16;
......@@ -18,7 +15,7 @@ export function calculateDuelOptions(
opt |= OcgcoreDuelOptionFlag.PseudoShuffle;
}
if (isTag) {
if (hostinfo.mode & 0x2) {
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