Skip to content

Commit fceb170

Browse files
authored
feat(blackjack): get rid of logs (#319)
1 parent 1ffafba commit fceb170

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

src/components/games/blackjack.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { container } from '@sapphire/framework';
21
import { Action, actions, Card, Game, presets } from 'engine-blackjack-ts';
32
import _ from 'lodash';
43

@@ -86,29 +85,13 @@ const getGameState = (game: Game): GameState => {
8685
Starts a blackjack game for a given player and returns the new game's state
8786
*/
8887
export const startGame = (amount: number, playerId: string, channelId: string): GameState | null => {
89-
const { logger } = container;
90-
logger.info({
91-
event: 'blackjack_start',
92-
amount,
93-
channelId,
94-
playerId
95-
});
96-
9788
// if player started a game more than a minute ago, allow them to start another one in case the game got stuck
9889
if (gamesByPlayerId.has(playerId)) {
9990
// player already has a game in progress, get the start time of the existing game
10091
const startedAt = gamesByPlayerId.get(playerId)?.startedAt.getTime();
10192
const now = new Date().getTime();
10293
if (startedAt && now - startedAt < 60000) {
10394
// game was started in the past minute, don't start a new one
104-
logger.info({
105-
event: 'blackjack_start_exists',
106-
startedAt,
107-
now,
108-
amount,
109-
channelId,
110-
playerId
111-
});
11295
return null;
11396
}
11497
}
@@ -124,34 +107,19 @@ export const startGame = (amount: number, playerId: string, channelId: string):
124107
End blackjack game for a given player
125108
*/
126109
export const endGame = (playerId: string): void => {
127-
const { logger } = container;
128-
logger.info({ event: 'blackjack_end', playerId });
129110
gamesByPlayerId.delete(playerId);
130111
};
131112

132113
/*
133114
Perform a player action and returns the game state after that action
134115
*/
135116
export const performGameAction = (playerId: string, actionName: BlackjackAction): GameState | null => {
136-
const { logger } = container;
137-
logger.info({
138-
event: 'blackjack_action',
139-
actionName,
140-
playerId
141-
});
142-
143117
// get game and action
144118
const game = gamesByPlayerId.get(playerId)?.game;
145119
const gameAction = gameActionsMap.get(actionName);
146120

147121
if (!game || !gameAction) {
148122
// no game state if game does not exist or if action is in valid
149-
logger.info({
150-
event: 'blackjack_action_error',
151-
error: !game ? 'game does not exist for player' : 'invalid action',
152-
actionName,
153-
playerId
154-
});
155123
return null;
156124
}
157125

0 commit comments

Comments
 (0)