standardize display, add flavour text

This commit is contained in:
stryan 2022-05-25 18:07:07 -04:00
parent c4ba6b83e6
commit ffbf8afca3
8 changed files with 26 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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?"

View File

@ -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

View File

@ -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
}

View File

@ -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 {

View File

@ -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)
}

View File

@ -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"`
}