Skip to content

Commit

Permalink
remove logs
Browse files Browse the repository at this point in the history
  • Loading branch information
rileythomp committed Jul 15, 2024
1 parent 716fabc commit 72c234c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
21 changes: 0 additions & 21 deletions be-jeopardy/internal/jeopardy/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,8 @@ func (g *Game) processMessages() {
log.Errorf("Error processing message: %s", err.Error())
}
case player := <-g.disconnectChan:
log.Infof("Stopping game %s", g.Name)
g.disconnectPlayer(player)
case <-g.restartChan:
log.Infof("Restarting game %s", g.Name)
g.restartGame(context.Background())
}
}
Expand Down Expand Up @@ -239,21 +237,17 @@ func (g *Game) disconnectPlayer(player GamePlayer) {
func (g *Game) processMsg(ctx context.Context, msg Message) error {
player := msg.Player
if g.State != msg.State {
log.Infof("Ignoring message from player %s because it is not for the current game state", player.name())
return nil
}
if g.Paused {
if msg.Pause == -1 {
log.Infof("Player %s resumed the game", player.name())
g.startGame()
g.messageAllPlayers("Player %s resumed the game", player.name())
return nil
}
log.Infof("Ignoring message from player %s because game is paused", player.name())
return nil
}
if msg.Pause == 1 {
log.Infof("Player %s paused the game", player.name())
g.pauseGame()
g.messageAllPlayers("Player %s paused the game", player.name())
return nil
Expand All @@ -262,34 +256,19 @@ func (g *Game) processMsg(ctx context.Context, msg Message) error {
switch g.State {
case RecvPick:
if msg.InitDispute {
log.Infof("Player %s disputed the previous question", player.name())
err = g.initDispute(player)
} else {
log.Debugf("Player %s picked", player.name())
err = g.processPick(player, msg.CatIdx, msg.ValIdx)
}
case RecvBuzz:
action := "buzzed"
if msg.IsPass {
action = "passed"
}
log.Debugf("Player %s %s", player.name(), action)
err = g.processBuzz(ctx, player, msg.IsPass)
case RecvAns:
log.Debugf("Player %s answered", player.name())
err = g.processAnswer(ctx, player, msg.Answer)
case RecvWager:
log.Debugf("Player %s wagered", player.name())
err = g.processWager(player, msg.Wager)
case RecvDispute:
action := "confirmed"
if !msg.Dispute {
action = "disputed"
}
log.Debugf("Player %s %s the question", player.name(), action)
err = g.processDispute(ctx, player, msg.Dispute)
case PostGame:
log.Debugf("Player %s protested", player.name())
err = g.processProtest(player, msg.ProtestFor)
case PreGame:
err = fmt.Errorf("received unexpected message")
Expand Down
4 changes: 1 addition & 3 deletions be-jeopardy/internal/jeopardy/reaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ func (p *Player) processReactions(reactChan chan Reaction) {
if err != nil {
log.Errorf("Error reading reaction message from player %s: %s", p.Name, err.Error())
if websocket.IsCloseError(err, 1001) {
log.Infof("Player %s closed chat connection", p.Name)
log.Infof("Player %s closed reaction connection", p.Name)
}
return
}
var msg Reaction
if err := json.Unmarshal(message, &msg); err != nil {
log.Errorf("Error parsing reaction message: %s", err.Error())
}
log.Infof("Received reaction from player %s: %+v", p.Name, msg)
msg.PlayerName = p.Name
msg.TimeStamp = time.Now().Unix()
msg.RandPos = getRandPos(10, 150)
Expand Down Expand Up @@ -89,7 +88,6 @@ func (p *Player) readReaction() ([]byte, error) {
}

func (p *Player) sendReaction(msg Reaction) error {
log.Infof("Sending reaction to player %s: %+v", p.Name, msg)
if p.ReactionConn == nil {
log.Errorf("Error sending reaction to player %s because connection is nil", p.Name)
return fmt.Errorf("player has no reaction connection")
Expand Down

0 comments on commit 72c234c

Please sign in to comment.