Skip to content

Commit

Permalink
feat: Faction status checker (#225)
Browse files Browse the repository at this point in the history
Co-authored-by: Brandon Roberts <[email protected]>
  • Loading branch information
manlikeHB and b-j-roberts authored Jun 10, 2024
1 parent d6833e4 commit 3add424
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/quests/quests.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const (
TemplateQuestType
UnruggableQuestType
VoteQuestType
FactionQuestType
UsernameQuestType
)

Expand All @@ -24,6 +25,7 @@ var OnchainQuestTypes = map[string]int{
"TemplateQuest": TemplateQuestType,
"UnruggableQuest": UnruggableQuestType,
"VoteQuest": VoteQuestType,
"FactionQuest": FactionQuestType,
"UsernameQuest": UsernameQuestType,
}

Expand Down
10 changes: 10 additions & 0 deletions backend/quests/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var QuestChecks = map[int]func(*Quest, string) (int, int){
TemplateQuestType: CheckTemplateStatus,
UnruggableQuestType: CheckUnruggableStatus,
VoteQuestType: CheckVoteStatus,
FactionQuestType: CheckFactionStatus,
UsernameQuestType: CheckUsernameStatus,
}

Expand Down Expand Up @@ -83,6 +84,15 @@ func CheckVoteStatus(q *Quest, user string) (progress int, needed int) {
return *count, 1
}

func CheckFactionStatus(q *Quest, user string) (progress int, needed int) {
count, err := core.PostgresQueryOne[int]("SELECT COUNT(*) FROM FactionMembersInfo WHERE user_address = $1", user)
if err != nil {
return 0, 1
}

return *count, 1
}

func CheckRainbowStatus(q *Quest, user string) (progress int, needed int) {
// TODO: Implement this
return 0, 1
Expand Down

0 comments on commit 3add424

Please sign in to comment.