Compare commits
9 Commits
c5c733d14c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0fc68e9bd8 | |||
| 50b98be6d3 | |||
| 30d4eeea40 | |||
| f0c5e19870 | |||
| c0abf72041 | |||
| 780002b35f | |||
| 1dae50a918 | |||
| f4f563c530 | |||
| ff20bbef2c |
@@ -20,13 +20,9 @@ type Set[V any] struct {
|
||||
// The behavior is undefined if the key already has a value.
|
||||
func (s *Set[V]) Add(key string, val V) {
|
||||
k := util.ToChars([]byte(key))
|
||||
i, ok := slices.BinarySearchFunc(s.keys, k, func(a, b util.Chars) int {
|
||||
i, _ := slices.BinarySearchFunc(s.keys, k, func(a, b util.Chars) int {
|
||||
return bytes.Compare(a.Bytes(), b.Bytes())
|
||||
})
|
||||
if ok {
|
||||
s.vals[i] = val
|
||||
return
|
||||
}
|
||||
s.keys = slices.Insert(s.keys, i, k)
|
||||
s.vals = slices.Insert(s.vals, i, val)
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@@ -3,7 +3,7 @@ module git.sunturtle.xyz/zephyr/horsebot
|
||||
go 1.25.5
|
||||
|
||||
require (
|
||||
git.sunturtle.xyz/zephyr/horse v0.0.0-20260123040553-4bfb06b6826f
|
||||
git.sunturtle.xyz/zephyr/horse v0.0.0-20260210125822-b55e1bc200a1
|
||||
github.com/disgoorg/disgo v0.19.0-rc.15
|
||||
github.com/junegunn/fzf v0.67.0
|
||||
)
|
||||
|
||||
4
go.sum
4
go.sum
@@ -1,5 +1,5 @@
|
||||
git.sunturtle.xyz/zephyr/horse v0.0.0-20260123040553-4bfb06b6826f h1:S287bkj7whgs5NY0u3ih4Ggy+2LTrnfHY3K/smfv9dU=
|
||||
git.sunturtle.xyz/zephyr/horse v0.0.0-20260123040553-4bfb06b6826f/go.mod h1:qGXO/93EfCOI1oGSLqrRkPDF/EAdsgLNZJjRKx+i4Lk=
|
||||
git.sunturtle.xyz/zephyr/horse v0.0.0-20260210125822-b55e1bc200a1 h1:nIk5Mis384wx/ndMa/3zSr1omkWK8rg4I/Z46BCAIe8=
|
||||
git.sunturtle.xyz/zephyr/horse v0.0.0-20260210125822-b55e1bc200a1/go.mod h1:qGXO/93EfCOI1oGSLqrRkPDF/EAdsgLNZJjRKx+i4Lk=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/disgoorg/disgo v0.19.0-rc.15 h1:x0NsV2gcbdjwuztsg2wYXw76p1Cpc8f6ByDrkPcfQtU=
|
||||
|
||||
6
main.go
6
main.go
@@ -163,11 +163,7 @@ func skillHandler(data discord.SlashCommandInteractionData, e *handler.CommandEv
|
||||
func skillAutocomplete(e *handler.AutocompleteEvent) error {
|
||||
q := e.Data.String("query")
|
||||
opts := skillGlobalAuto().Find(nil, q)
|
||||
r := make([]discord.AutocompleteChoice, min(len(opts), 25))
|
||||
for i, k := range opts[:min(len(opts), len(r))] {
|
||||
r[i] = discord.AutocompleteChoiceString{Name: k, Value: k}
|
||||
}
|
||||
return e.AutocompleteResult(r)
|
||||
return e.AutocompleteResult(opts[:min(len(opts), 25)])
|
||||
}
|
||||
|
||||
func skillButton(data discord.ButtonInteractionData, e *handler.ComponentEvent) error {
|
||||
|
||||
27
skill.go
27
skill.go
@@ -18,13 +18,25 @@ func RenderSkill(id horse.SkillID, all map[horse.SkillID]horse.Skill, groups map
|
||||
}
|
||||
|
||||
thumburl := fmt.Sprintf("https://gametora.com/images/umamusume/skill_icons/utx_ico_skill_%d.png", s.IconID)
|
||||
r := discord.NewContainer(discord.NewSection(discord.NewTextDisplayf("## %s\n%s", s.Name, s.Description)).WithAccessory(discord.NewThumbnail(thumburl)))
|
||||
top := "## " + s.Name
|
||||
if s.UniqueOwner != "" {
|
||||
top += "\n-# " + s.UniqueOwner
|
||||
}
|
||||
r := discord.NewContainer(
|
||||
discord.NewSection(
|
||||
discord.NewTextDisplay(top),
|
||||
discord.NewTextDisplay(s.Description),
|
||||
).WithAccessory(discord.NewThumbnail(thumburl)),
|
||||
)
|
||||
var skilltype string
|
||||
switch {
|
||||
case s.Rarity == 3, s.Rarity == 4, s.Rarity == 5:
|
||||
// unique of various star levels
|
||||
r.AccentColor = 0xaca4d4
|
||||
skilltype = "Unique Skill"
|
||||
case s.UniqueOwner != "":
|
||||
r.AccentColor = 0xcccccc
|
||||
skilltype = "Inherited Unique"
|
||||
case s.Rarity == 2:
|
||||
// rare (gold)
|
||||
r.AccentColor = 0xd7c25b
|
||||
@@ -118,11 +130,18 @@ func isDebuff(s horse.Skill) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var skillGlobalAuto = sync.OnceValue(func() *autocomplete.Set[string] {
|
||||
var set autocomplete.Set[string]
|
||||
var skillGlobalAuto = sync.OnceValue(func() *autocomplete.Set[discord.AutocompleteChoice] {
|
||||
var set autocomplete.Set[discord.AutocompleteChoice]
|
||||
for _, id := range global.OrderedSkills {
|
||||
s := global.AllSkills[id]
|
||||
set.Add(s.Name, s.Name)
|
||||
set.Add(s.Name, discord.AutocompleteChoiceString{Name: s.Name, Value: s.Name})
|
||||
if s.UniqueOwner != "" {
|
||||
if s.Rarity >= 3 {
|
||||
set.Add(s.UniqueOwner, discord.AutocompleteChoiceString{Name: "Unique: " + s.UniqueOwner, Value: s.Name})
|
||||
} else {
|
||||
set.Add(s.UniqueOwner, discord.AutocompleteChoiceString{Name: "Inherited unique: " + s.UniqueOwner, Value: s.Name})
|
||||
}
|
||||
}
|
||||
}
|
||||
return &set
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user