2022-05-24 18:26:34 -04:00
|
|
|
package simulator
|
|
|
|
|
2022-05-24 21:12:35 -04:00
|
|
|
import "github.com/BurntSushi/toml"
|
|
|
|
|
|
|
|
//TechID is a tech level
|
|
|
|
type TechID int
|
|
|
|
|
|
|
|
type relation struct {
|
|
|
|
name string
|
|
|
|
value int
|
|
|
|
}
|
|
|
|
|
2022-05-24 18:26:34 -04:00
|
|
|
//Tech is a tech level
|
2022-05-24 21:12:35 -04:00
|
|
|
type Tech struct {
|
|
|
|
ID int `toml:"techid"`
|
|
|
|
DisplayName string `toml:"display_name"`
|
|
|
|
Name string `toml:"name"`
|
|
|
|
Requires []relation `toml:"requires"`
|
|
|
|
Unlocks []string `toml:"unlocks"`
|
|
|
|
}
|
2022-05-24 18:26:34 -04:00
|
|
|
|
|
|
|
const (
|
2022-05-24 21:12:35 -04:00
|
|
|
techPulper TechID = iota
|
2022-05-24 18:26:34 -04:00
|
|
|
)
|
2022-05-24 21:12:35 -04:00
|
|
|
|
|
|
|
//GlobalTechList list of all techs
|
|
|
|
var GlobalTechList = []TechID{techPulper}
|
|
|
|
|
|
|
|
//GlobalTechs list of all techs
|
|
|
|
var GlobalTechs []Tech
|
|
|
|
|
|
|
|
type techs struct {
|
|
|
|
tech []Tech
|
|
|
|
}
|
|
|
|
|
|
|
|
//LookupTech converts a tech ID to an item ID
|
|
|
|
func LookupTech(id TechID) ItemEntry {
|
|
|
|
switch id {
|
|
|
|
case techPulper:
|
|
|
|
return converterEntry{convertPulper, 5, "teaConverter", itemPlantTea, itemPlantWood}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func lookupTechByName(name string) Tech {
|
|
|
|
for _, v := range GlobalTechs {
|
|
|
|
if v.Name == name {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Tech{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func loadTechs(filename string) {
|
|
|
|
var res techs
|
|
|
|
_, err := toml.DecodeFile(filename, &res)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
GlobalTechs = res.tech
|
|
|
|
}
|