Skip to content

Commit

Permalink
feat:CheckRainbowStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
lfgtwo authored Jun 12, 2024
1 parent f457eca commit 383382f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion backend/quests/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,23 @@ func CheckFactionStatus(q *Quest, user string) (progress int, needed int) {
}

func CheckRainbowStatus(q *Quest, user string) (progress int, needed int) {
// TODO: Implement this
// Get the count of distinct colors the user has
userColorCount, err := core.PostgresQueryOne[int]("SELECT COUNT(DISTINCT p.color) FROM Pixels p WHERE p.address = $1", user)
if err != nil {
return 0, 1
}

// Get the total count of colors
totalColorCount, err := core.PostgresQueryOne[int]("SELECT COUNT(*) FROM Colors")
if err != nil {
return 0, 1
}

// Check if the user has all colors
if *userColorCount == *totalColorCount {
return 1, 1
}

return 0, 1
}

Expand Down

0 comments on commit 383382f

Please sign in to comment.