Skip to content
This repository was archived by the owner on Sep 1, 2023. It is now read-only.

Commit 071dbcc

Browse files
committed
more debug info
1 parent 9a48a0e commit 071dbcc

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

src/commands/eval.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import database from "../database.js";
99
import { games } from "../gameLogic/index.js";
1010
import * as gameLogic from "../gameLogic/index.js";
1111
import { config } from "../index.js";
12-
import { Command, UnoGame } from "../types";
12+
import { Command } from "../types";
1313
import * as utils from "../utils.js";
1414
client; components; gameLogic; database; constants; utils;
1515

@@ -19,14 +19,6 @@ const bash = (cmd: string) => execSync(cmd, { encoding: "utf8" });
1919
const update = () => bash("git pull && npm run build");
2020
update;
2121

22-
function sendDrawProxyStatus(game: UnoGame<true>) {
23-
return clientUtils.sendMessage(game.message.channelID, Object.entries(game.cards).map(([k, v]) =>
24-
// @ts-ignore
25-
`\`${k}:\` ${v.owner ? `yes (${v.owner})` : "no"}`
26-
).join("\n"));
27-
}
28-
sendDrawProxyStatus;
29-
3022
export const cmd = {
3123
name: "eval",
3224
aliases: ["adminabuse"],

src/commands/fixgame.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { games, sendGameMessage } from "../gameLogic/index.js";
66
import { config } from "../index.js";
77
import timeouts from "../timeouts.js";
88
import { Command, UnoGame } from "../types";
9-
import { cardArrayToCount, getUsername, hasStarted, next, updateStats, without } from "../utils.js";
9+
import { cardArrayToCount, drawProxyStatus, getUsername, hasStarted, next, updateStats, without } from "../utils.js";
1010

1111
function sendDebugLog(game: UnoGame<true>, reason: "player left" | "card was played") {
1212
const debugChannel = client.getChannel(config.logChannel);
@@ -19,11 +19,14 @@ ${config.developerIds.map(id => `<@${id}>`).join(" ")}`,
1919
allowedMentions: { users: true },
2020
attachments: [{
2121
id: "0",
22-
filename: "game.json"
22+
filename: "game.ts"
2323
}],
2424
files: [{
25-
name: "game.json",
26-
contents: Buffer.from(inspect(without(game, "message"), { depth: Infinity }))
25+
name: "game.ts",
26+
contents: Buffer.from(`Card proxy status:
27+
${drawProxyStatus(game)}
28+
29+
${inspect(without(game, "message"), { depth: Infinity })}`)
2730
}]
2831
});
2932
}

src/gameLogic/notStarted.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ const drawUntilNotSpecial = (game: UnoGame<true>) => {
5858
function dupe<T>(a: T[]): T[] { return a.concat(a); }
5959

6060
function pushStateFactory(game: UnoGame<true>): (state: DebugState & { type: DebugStateType }) => void {
61-
const MAX_STATE_LENGTH = 8;
61+
const MAX_STATE_LENGTH = 10;
6262
return state => {
6363
const stateArray = game._debug._state[state.type];
6464
stateArray.push({
65-
...without(game, "_debug", "message", "deck"),
65+
...without(game, "_debug", "message", "deck", "settings"),
6666
action: state,
6767
_index: (stateArray.at(-1)?._index ?? 0) + 1
6868
});

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export type UnoGame<T extends boolean> = T extends true ? {
7979
_modified: boolean,
8080
_debug: {
8181
_state: {
82-
[k in DebugStateType]: (Omit<UnoGame<true>, "_debug" | "message" | "deck"> & {
82+
[k in DebugStateType]: (Omit<UnoGame<true>, "_debug" | "message" | "deck" | "settings"> & {
8383
action: DebugState,
8484
_index: number
8585
})[]

src/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ export class Queue {
4848
}
4949
}
5050

51+
export function drawProxyStatus(game: UnoGame<true>) {
52+
return Object.entries(game.cards).map(([k, v]) =>
53+
// @ts-ignore
54+
`\`${k}:\` ${v.owner ? `yes (${v.owner})` : "no"}`
55+
).join("\n");
56+
}
57+
5158
export const toTitleCase = (n: string) =>
5259
n.split("-").map(w => `${w[0].toUpperCase()}${w.slice(1).toLowerCase()}`).join(" ");
5360

0 commit comments

Comments
 (0)