spacetea/simulator/item_table.go

53 lines
1.1 KiB
Go
Raw Normal View History

2022-05-19 17:09:46 -04:00
package simulator
import "strconv"
//ItemEntry is a human/ui friendly item description
type ItemEntry interface {
Name() string
Render() string
ID() string
}
type itemType int
func (i itemType) String() string {
return strconv.Itoa(int(i))
}
const (
itemPlantTea itemType = iota + 1
itemPlantWood
convertPulper
)
//GlobalItemList of all items
var GlobalItemList = []itemType{itemPlantTea, itemPlantWood, convertPulper}
2022-05-24 18:26:34 -04:00
//GlobalTechList list of all techs
var GlobalTechList = []Tech{techPulper}
2022-05-19 17:09:46 -04:00
//Lookup returns a human friendly item entry
func Lookup(id itemType) ItemEntry {
switch id {
case itemPlantTea:
2022-05-24 18:26:34 -04:00
return plantEntry{itemPlantTea, 1, "tea"}
2022-05-19 17:09:46 -04:00
case itemPlantWood:
return plantEntry{itemPlantWood, 10, "wood"}
case convertPulper:
return converterEntry{convertPulper, 5, "teaConverter", itemPlantTea, itemPlantWood}
}
return nil
}
2022-05-24 18:26:34 -04:00
//LookupTech converts a tech ID to an item ID
func LookupTech(id Tech) ItemEntry {
switch id {
case techPulper:
return converterEntry{convertPulper, 5, "teaConverter", itemPlantTea, itemPlantWood}
}
return nil
}