Skip to content

Commit

Permalink
Add rulesettype
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPresso committed Jul 26, 2024
1 parent 2696991 commit 9b29be3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"cdnBaseUrl": "https://zunivers-cdn.zerator.com/zunivers-prod",
"api": {
"baseUrl": "https://zunivers-api.zerator.com",
"rulesettype": "NORMAL",
"timeout": 10
},
"webhooks": [],
Expand Down
2 changes: 1 addition & 1 deletion structures/Shop.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ShopEntry struct {

type ShopInventory struct {
Balance int `json:"balance"`
Golden bool `json:"isGolden"`
ShinyLevel int `json:"shinyLevel"`
UpgradeLevel int `json:"upgradeLevel"`
Item *Item `json:"item"`
}
17 changes: 13 additions & 4 deletions tasks/checkShopEntries.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,21 @@ func makeShopEmbed(entries []structures.ShopEntry) *discord.Embed {
}

for _, entry := range entries {
golden := ""
if entry.ShopInventory.Golden {
golden = " (dorée)"
shiny := ""

switch entry.ShopInventory.ShinyLevel {
case 0:
shiny = ""
break
case 1:
shiny = " (dorée)"
break
case 2:
shiny = " (chroma)"
break
}

namesField.Value += fmt.Sprintf("`%s%s`\n", entry.ShopInventory.Item.Name, golden)
namesField.Value += fmt.Sprintf("`%s%s`\n", entry.ShopInventory.Item.Name, shiny)
raritiesField.Value += fmt.Sprintf("`%s`\n", strings.Repeat("★", entry.ShopInventory.Item.Rarity))
pricesField.Value += fmt.Sprintf("`%d`\n", entry.ShopInventory.Balance)
}
Expand Down
1 change: 1 addition & 0 deletions utils/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func Request(uri, method string, body []byte, structure interface{}) (err error)
req.Header.Set("sec-fetch-mode", "cors")
req.Header.Set("sec-fetch-site", "same-site")
req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36")
req.Header.Set("x-zunivers-rulesettype", viper.GetString("api.rulesettype"))

r, err := client.Do(req)
if err != nil {
Expand Down

0 comments on commit 9b29be3

Please sign in to comment.