From 028c1f5922ae420aa4cb8ef1081e9b9dda818d42 Mon Sep 17 00:00:00 2001 From: Eccentric Date: Sun, 18 Feb 2024 03:19:36 +0000 Subject: [PATCH] Maps are unordered duh --- fortnite/external.go | 1 - fortnite/shop.go | 48 ++++++++++++++++++++++++++------------------ handlers/discord.go | 6 +----- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/fortnite/external.go b/fortnite/external.go index 87b48fd..bb13795 100644 --- a/fortnite/external.go +++ b/fortnite/external.go @@ -241,7 +241,6 @@ func GetRandomItemWithDisplayAssetOfNotType(notType string) *FortniteItem { return &flat[aid.RandomInt(0, len(flat))] } - func GetRandomSet() *FortniteSet { sets := []FortniteSet{} for _, set := range External.FortniteSets { diff --git a/fortnite/shop.go b/fortnite/shop.go index ee745a1..a536b79 100644 --- a/fortnite/shop.go +++ b/fortnite/shop.go @@ -52,17 +52,23 @@ var ( }, } - dailyItemLookup = map[int]int{ - 2: 4, - 4: 6, - 13: 10, + dailyItemLookup = []struct { + Season int + Items int + }{ + {2, 4}, + {4, 6}, + {13, 10}, } - weeklySetLookup = map[int]int{ - 2: 2, - 4: 3, - 11: 4, - 13: 3, + weeklySetLookup = []struct { + Season int + Sets int + }{ + {2, 2}, + {4, 3}, + {11, 4}, + {13, 3}, } ) @@ -71,27 +77,31 @@ func price(rarity, type_ string) int { } func dailyItems(season int) int { - var items int + currentValue := 4 - for s, i := range dailyItemLookup { - if season >= s { - items = i + for _, item := range dailyItemLookup { + if item.Season > season { + continue } + + currentValue = item.Items } - return items + return currentValue } func weeklySets(season int) int { - var sets int + currentValue := 2 - for s, i := range weeklySetLookup { - if season >= s { - sets = i + for _, set := range weeklySetLookup { + if set.Season > season { + continue } + + currentValue = set.Sets } - return sets + return currentValue } type FortniteCatalogSectionOffer struct { diff --git a/handlers/discord.go b/handlers/discord.go index 57e0f9c..503225d 100644 --- a/handlers/discord.go +++ b/handlers/discord.go @@ -84,9 +84,5 @@ func GetDiscordOAuthURL(c *fiber.Ctx) error { return c.Status(fiber.StatusInternalServerError).JSON(aid.ErrorInternalServer) } - c.Cookie(&fiber.Cookie{ - Name: "access_token", - Value: access, - }) - return c.Redirect("http://" + aid.Config.API.Host + aid.Config.API.FrontendPort + "/attempt") + return c.Redirect("snow://auth:" + access) } \ No newline at end of file