add related skill buttons
This commit is contained in:
20
skill.go
20
skill.go
@@ -8,7 +8,11 @@ import (
|
||||
"github.com/disgoorg/disgo/discord"
|
||||
)
|
||||
|
||||
func RenderSkill(s horse.Skill) discord.ContainerComponent {
|
||||
func RenderSkill(id horse.SkillID, all map[horse.SkillID]horse.Skill, groups map[int32][4]horse.SkillID) discord.ContainerComponent {
|
||||
s, ok := all[id]
|
||||
if !ok {
|
||||
return discord.NewContainer(discord.NewTextDisplayf("invalid skill ID %v made it to RenderSkill", id))
|
||||
}
|
||||
skilltype := discord.TextDisplayComponent{
|
||||
ID: 4,
|
||||
Content: "Skill Issue",
|
||||
@@ -90,7 +94,19 @@ func RenderSkill(s horse.Skill) discord.ContainerComponent {
|
||||
ID: 51,
|
||||
Content: fmt.Sprintf("SP cost %d. Grade value %d.", s.SPCost, s.GradeValue),
|
||||
})
|
||||
// TODO(zeph): related skills, use a row of buttons with skill numbers for the ids and edit the message when clicked?
|
||||
rel := make([]horse.Skill, 0, 4)
|
||||
for _, id := range groups[s.Group] {
|
||||
if id != 0 {
|
||||
rel = append(rel, all[id])
|
||||
}
|
||||
}
|
||||
if len(rel) > 1 {
|
||||
buttons := make([]discord.InteractiveComponent, 0, 4)
|
||||
for _, rs := range rel {
|
||||
buttons = append(buttons, discord.NewButton(discord.ButtonStyleSecondary, rs.Name, fmt.Sprintf("/skill/%d", rs.ID), "", 0))
|
||||
}
|
||||
r.Components = append(r.Components, discord.NewActionRow(buttons...))
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user