Skip to content

Commit

Permalink
bug fix for picking cards
Browse files Browse the repository at this point in the history
  • Loading branch information
walkingeyerobot committed Jul 12, 2020
1 parent b47ae40 commit 4e1a4d3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ func doPick(tx *sql.Tx, userID int64, cardID int64, pass bool) (int64, int64, []

row = tx.QueryRow(query, draftID, newPosition)
var newPositionID int64
var newPositionDiscordID string
var newPositionDiscordID sql.NullString
err = row.Scan(&newPositionID, &newPositionDiscordID)
if err != nil {
return draftID, myPackID, announcements, round, err
Expand All @@ -756,7 +756,7 @@ func doPick(tx *sql.Tx, userID int64, cardID int64, pass bool) (int64, int64, []
return draftID, myPackID, announcements, round, err
}

log.Printf("player %d in draft %d took %d", userID, draftID, cardID)
log.Printf("player %d in draft %d took card %d", userID, draftID, cardID)

// Get the number of remaining packs in the seat.
query = `select
Expand Down Expand Up @@ -790,9 +790,9 @@ func doPick(tx *sql.Tx, userID int64, cardID int64, pass bool) (int64, int64, []
err = row.Scan(&roundsMatch)
if err != nil {
log.Printf("cannot determine if rounds match for notify")
} else if roundsMatch == 1 {
} else if roundsMatch == 1 && newPositionDiscordID.Valid {
log.Printf("attempting to notify position %d draft %d", newPosition, draftID)
err = NotifyByDraftAndDiscordID(draftID, newPositionDiscordID)
err = NotifyByDraftAndDiscordID(draftID, newPositionDiscordID.String)
if err != nil {
log.Printf("error with notify")
}
Expand Down Expand Up @@ -863,7 +863,7 @@ func doPick(tx *sql.Tx, userID int64, cardID int64, pass bool) (int64, int64, []

rowCount := 0
var blockingPosition int64
var blockingDiscordID string
var blockingDiscordID sql.NullString
for rows.Next() {
rowCount++
err = rows.Scan(&blockingPosition, &blockingDiscordID)
Expand All @@ -873,8 +873,8 @@ func doPick(tx *sql.Tx, userID int64, cardID int64, pass bool) (int64, int64, []
break
}
}
if rowCount == 1 {
err = NotifyByDraftAndDiscordID(draftID, blockingDiscordID)
if rowCount == 1 && blockingDiscordID.Valid {
err = NotifyByDraftAndDiscordID(draftID, blockingDiscordID.String)
if err != nil {
log.Printf("error with blocking notify")
}
Expand Down

0 comments on commit 4e1a4d3

Please sign in to comment.