From ffbf8afca38126966a1e9a4313abff679c5e0c25 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 25 May 2022 18:07:07 -0400 Subject: [PATCH] standardize display, add flavour text --- data/converters.toml | 4 +++- data/resources.toml | 2 ++ menu.go | 4 ++-- simulator/converter.go | 7 +++++++ simulator/item.go | 2 ++ simulator/player.go | 2 +- simulator/resource.go | 12 ++++++++---- simulator/tech.go | 1 + 8 files changed, 26 insertions(+), 8 deletions(-) diff --git a/data/converters.toml b/data/converters.toml index 1a5bec0..64770ca 100644 --- a/data/converters.toml +++ b/data/converters.toml @@ -1,7 +1,8 @@ [[converter]] itemid = 3 name = "teaConverter" -displayName = "Tea Pulper" +displayName = "Tea Presser" +flavour = "Compresses tea leaves into useful bricks" source = "tea" output = "brick" rate = 4 @@ -14,6 +15,7 @@ value = 10 itemid = 4 name = "teaPlanter" displayName = "Tea Planter" +flavour = "Grows tea leaves automagically" source = "" output = "tea" rate = 0 diff --git a/data/resources.toml b/data/resources.toml index cd82a02..15ac822 100644 --- a/data/resources.toml +++ b/data/resources.toml @@ -2,6 +2,7 @@ itemid = 1 name = "tea" displayName = "Tea" +flavour = "Simple tea leaves. If only I could boil water.." buildable = true icon = "p" rate = 3 @@ -10,6 +11,7 @@ rate = 3 itemid = 2 name = "brick" displayName = "Tea Bricks" +flavour = "Tea compressed into a brick shape" icon = "b" buildable = false diff --git a/menu.go b/menu.go index ac7994e..fcef07e 100644 --- a/menu.go +++ b/menu.go @@ -39,10 +39,10 @@ func newMenuModel(entries []sim.ItemEntry, i menutype) menuModel { p.kind = i items := []list.Item{} for _, v := range entries { - items = append(items, item{v.String(), "no description", v.ID().String(), v}) + items = append(items, item{v.Describe(), v.Description(), v.ID().String(), v}) } //w,h - p.list = list.New(items, list.NewDefaultDelegate(), 32, 32) + p.list = list.New(items, list.NewDefaultDelegate(), 80, 32) switch i { case placeMenu: p.list.Title = "What do you want to place?" diff --git a/simulator/converter.go b/simulator/converter.go index a763a03..efae2ea 100644 --- a/simulator/converter.go +++ b/simulator/converter.go @@ -10,6 +10,7 @@ type Converter struct { Name string `toml:"name"` DisplayName string `toml:"displayName"` Icon string `toml:"icon"` + Flavour string `toml:"flavour"` Rate int `toml:"rate"` source itemType SourceName string `toml:"source"` @@ -35,6 +36,7 @@ func newConverter(k itemType, o *Player) *Converter { res.DisplayName = temp.DisplayName res.Name = temp.Name res.Icon = temp.Icon + res.Flavour = temp.Flavour res.source = lookupByName(temp.SourceName).ID() res.output = lookupByName(temp.OutputName).ID() res.Rate = temp.Rate @@ -68,6 +70,11 @@ func (c Converter) Describe() string { return c.DisplayName } +//Description returns flavour description +func (c Converter) Description() string { + return c.Flavour +} + //Type returns consumer func (c Converter) Type() ObjectType { return consumerObject diff --git a/simulator/item.go b/simulator/item.go index 5569b61..7a22e39 100644 --- a/simulator/item.go +++ b/simulator/item.go @@ -17,7 +17,9 @@ type item interface { //ItemEntry is a human/ui friendly item description type ItemEntry interface { String() string + Describe() string Render() string + Description() string ID() itemType } diff --git a/simulator/player.go b/simulator/player.go index c3814c3..9217959 100644 --- a/simulator/player.go +++ b/simulator/player.go @@ -65,7 +65,7 @@ func (p *Player) String() string { sort.Ints(ress) for _, k := range ress { id := itemType(k) - res += fmt.Sprintf("%v: %v\n", GlobalItems[id], p.Resources[id]) + res += fmt.Sprintf("%v: %v\n", GlobalItems[id].Describe(), p.Resources[id]) } res += "\nLocation: \n" if p.CurrentTile != nil { diff --git a/simulator/resource.go b/simulator/resource.go index 147ad38..b4a053a 100644 --- a/simulator/resource.go +++ b/simulator/resource.go @@ -1,8 +1,6 @@ package simulator import ( - "log" - "github.com/BurntSushi/toml" ) @@ -11,6 +9,7 @@ type Resource struct { Id itemType `toml:"itemid"` Name string `toml:"name"` DisplayName string `toml:"displayName"` + Flavour string `toml:"flavour"` Buildable bool `toml:"buildable"` Rate int `toml:"rate"` Icon string `toml:"icon"` @@ -27,10 +26,12 @@ func newResource(k itemType) *Resource { if template, ok := GlobalItems[k]; ok { temp := template.(Resource) res.DisplayName = temp.DisplayName + res.Flavour = temp.Flavour res.Id = k res.Name = temp.Name res.Buildable = temp.Buildable res.Rate = temp.Rate + res.Flavour = temp.Flavour res.Icon = temp.Icon res.value = 0 res.growth = 0 @@ -69,10 +70,13 @@ func (r Resource) Render() string { func (r Resource) Describe() string { return r.DisplayName } + +func (r Resource) Description() string { + return r.Flavour +} func loadResources(filename string) { var res resources - foo, err := toml.DecodeFile(filename, &res) - log.Println(foo.Undecoded()) + _, err := toml.DecodeFile(filename, &res) if err != nil { panic(err) } diff --git a/simulator/tech.go b/simulator/tech.go index a33f82d..0c841aa 100644 --- a/simulator/tech.go +++ b/simulator/tech.go @@ -15,6 +15,7 @@ type Tech struct { ID TechID `toml:"techid"` DisplayName string `toml:"displayName"` Name string `toml:"name"` + Flavour string `toml:"flavour"` Requires []relation `toml:"requires"` Unlocks []string `toml:"unlocks"` }