1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-05 15:30:42 +00:00
OpenDiablo2/d2common/d2data/d2datadict/elemtype.go

40 lines
876 B
Go
Raw Normal View History

2020-07-30 06:41:19 +00:00
package d2datadict
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
2020-07-30 06:41:19 +00:00
)
// ElemTypeRecord represents a single line in ElemType.txt
2020-07-30 06:41:19 +00:00
type ElemTypeRecord struct {
// ElemType Elemental damage type name
2020-07-30 06:41:19 +00:00
ElemType string
// Code Elemental damage type code
2020-07-30 06:41:19 +00:00
Code string
}
// ElemTypes stores the ElemTypeRecords
2020-07-30 06:41:19 +00:00
var ElemTypes map[string]*ElemTypeRecord //nolint:gochecknoglobals // Currently global by design
// LoadElemTypes loads ElemTypeRecords into ElemTypes
2020-07-30 06:41:19 +00:00
func LoadElemTypes(file []byte) {
ElemTypes = make(map[string]*ElemTypeRecord)
d := d2txt.LoadDataDictionary(file)
2020-07-30 06:41:19 +00:00
for d.Next() {
record := &ElemTypeRecord{
ElemType: d.String("Elemental Type"),
Code: d.String("Code"),
}
ElemTypes[record.ElemType] = record
}
if d.Err != nil {
panic(d.Err)
}
log.Printf("Loaded %d ElemType records", len(ElemTypes))
}