From 9540b7f9206b220cbfe2afda6deb61f8f68f97b9 Mon Sep 17 00:00:00 2001 From: lfg2 Date: Fri, 21 Jun 2024 23:01:07 +0800 Subject: [PATCH] feat:CheckRainbowStatus (#239) * feat:CheckRainbowStatus * Patch rainbow quest status impl --------- Co-authored-by: Brandon Roberts --- backend/quests/status.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/quests/status.go b/backend/quests/status.go index 096b58e1..34d80499 100644 --- a/backend/quests/status.go +++ b/backend/quests/status.go @@ -1,6 +1,8 @@ package quests -import "github.com/keep-starknet-strange/art-peace/backend/core" +import ( + "github.com/keep-starknet-strange/art-peace/backend/core" +) var QuestChecks = map[int]func(*Quest, string) (int, int){ AuthorityQuestType: CheckAuthorityStatus, @@ -97,9 +99,18 @@ func CheckFactionStatus(q *Quest, user string) (progress int, needed int) { return *count, 1 } +type RainbowStatus struct { + Used int `json:"used"` + Colors int `json:"colors"` +} + func CheckRainbowStatus(q *Quest, user string) (progress int, needed int) { - // TODO: Implement this - return 0, 1 + status, err := core.PostgresQueryOne[RainbowStatus]("SELECT COUNT(DISTINCT p.color) as used, (SELECT COUNT(*) FROM Colors) as colors FROM Pixels p WHERE p.address = $1", user) + if err != nil { + return 0, 1 + } + + return status.Used, status.Colors } func CheckTemplateStatus(q *Quest, user string) (progress int, needed int) {