-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.d.ts
110 lines (86 loc) · 2.4 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { Message, TextChannel, User } from 'discord.js';
import Hangman from './hangman';
type GameStatus = 'in progress' | 'won' | 'lost';
interface GameResult {
game?: Hangman;
selector?: User;
}
interface GameInfo {
status: GameStatus;
progress: string;
misses: string[];
lifes: number;
}
interface HangmanMessages {
createNoPlayers: string;
customNotEnoughPlayers: string;
customInitMessage: string;
customNoMoreWords: string;
gatherPlayersMsg: string;
getWordFromPlayersDm: string;
timesUpDm: string;
timesUpMsg: string;
wordSuccess: string;
invalidWord: string;
tooManyInvalidsWords: string;
misses: string;
won: string;
noplayersleft: string;
gameOver: string;
gameOverMsg: string;
}
interface HangmanOptions {
word?: string;
messages?: HangmanMessages;
displayWordOnGameOver?: boolean;
players?: User[];
filter?: function;
}
class Hangman {
public word: string;
public lives: number;
public progress: string;
public remaining: number;
public misses: string[];
public status: GameStatus;
public gameOver: boolean;
public message: Message | null;
public constructor(
word?: string,
public channel: TextChannel,
public players: User[],
public messages: HangmanMessages,
public displayWordOnGameOver: boolean
);
public static hyphenString(n: number): string;
public replaceChar(char: string): void;
public async showProgress(): Promise<void>;
public playerlist(): string;
public getFigure(): string;
public guess(c: string): GameInfo;
public guessAll(word: string): boolean;
public async start(): Promise<void>;
}
export default class HangmansManager {
public async create(
channel: TextChannel,
gameType: 'random' | 'custom',
options?: HangmanOptions
): Promise<GameResult>
private #getPlayersFromMessage(
channel: TextChannel
): Promise<User[]>
private async #gatherPlayersFromReaction(
message: Message,
emoji: string
): Promise<User[]>
private async #gatherPlayers(
channel: TextChannel,
messages: HangmanMessages
): Promise<User[]>
private async #getWordFromPlayers(
players: User[],
channel: TextChannel,
messages: HangmanMessages
): void | GameResult;
}