2020-05-10 18:44:20 +00:00
|
|
|
package tins2020
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Herbarium struct {
|
|
|
|
flowers map[string]FlowerDescriptor
|
|
|
|
order []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHerbarium() Herbarium {
|
|
|
|
return Herbarium{map[string]FlowerDescriptor{}, nil}
|
|
|
|
}
|
|
|
|
|
|
|
|
type FlowerDescriptor struct {
|
2020-05-10 21:00:19 +00:00
|
|
|
Name string
|
|
|
|
Description string
|
|
|
|
BuyPrice int
|
|
|
|
SellPrice int
|
|
|
|
|
2020-05-10 18:44:20 +00:00
|
|
|
Unlocked bool
|
|
|
|
IconTemplate IconTemplate
|
|
|
|
Traits FlowerTraits
|
|
|
|
}
|
|
|
|
|
|
|
|
type IconTemplate string
|
|
|
|
|
|
|
|
func (t IconTemplate) Disabled() string { return t.Fmt("disabled") }
|
|
|
|
|
|
|
|
func (t IconTemplate) Fmt(s string) string { return fmt.Sprintf(string(t), s) }
|
|
|
|
|
|
|
|
func (t IconTemplate) Variant(i int) string { return t.Fmt(strconv.Itoa(i)) }
|
|
|
|
|
|
|
|
func (h *Herbarium) Add(id string, desc FlowerDescriptor) {
|
|
|
|
h.flowers[id] = desc
|
|
|
|
h.order = append(h.order, id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Herbarium) Find(id string) (FlowerDescriptor, bool) {
|
|
|
|
flower, ok := h.flowers[id]
|
|
|
|
return flower, ok
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Herbarium) Flowers() []string { return h.order }
|