50 lines
814 B
Go
50 lines
814 B
Go
package simulator
|
|
|
|
import "github.com/BurntSushi/toml"
|
|
|
|
//TechID is a tech level
|
|
type TechID int
|
|
|
|
type relation struct {
|
|
Name string
|
|
Value int
|
|
}
|
|
|
|
//Tech is a tech level
|
|
type Tech struct {
|
|
ID TechID `toml:"techid"`
|
|
DisplayName string `toml:"displayName"`
|
|
Name string `toml:"name"`
|
|
Requires []relation `toml:"requires"`
|
|
Unlocks []string `toml:"unlocks"`
|
|
}
|
|
|
|
const (
|
|
techPulper TechID = iota
|
|
)
|
|
|
|
//GlobalTechs list of all techs
|
|
var GlobalTechs []Tech
|
|
|
|
type techs struct {
|
|
Tech []Tech
|
|
}
|
|
|
|
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
|
|
}
|