2020-07-13 09:02:09 -04:00
|
|
|
package d2datadict
|
|
|
|
|
|
|
|
import (
|
2020-07-30 10:14:15 -04:00
|
|
|
"log"
|
2020-07-13 09:02:09 -04:00
|
|
|
|
2020-07-30 10:14:15 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
2020-07-13 09:02:09 -04:00
|
|
|
)
|
|
|
|
|
2020-07-30 10:14:15 -04:00
|
|
|
type PropertyStatRecord struct {
|
|
|
|
SetID int
|
|
|
|
Value int
|
2020-07-13 09:02:09 -04:00
|
|
|
FunctionID int
|
2020-07-30 10:14:15 -04:00
|
|
|
StatCode string
|
2020-07-13 09:02:09 -04:00
|
|
|
}
|
|
|
|
|
2020-07-30 10:14:15 -04:00
|
|
|
// PropertyRecord is a representation of a single row of properties.txt
|
2020-07-13 09:02:09 -04:00
|
|
|
type PropertyRecord struct {
|
2020-07-30 10:14:15 -04:00
|
|
|
Code string
|
2020-07-13 09:02:09 -04:00
|
|
|
Active string
|
2020-07-30 10:14:15 -04:00
|
|
|
Stats [7]*PropertyStatRecord
|
2020-07-13 09:02:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Properties stores all of the PropertyRecords
|
|
|
|
var Properties map[string]*PropertyRecord //nolint:gochecknoglobals // Currently global by design,
|
|
|
|
// only written once
|
|
|
|
|
|
|
|
// LoadProperties loads gem records into a map[string]*PropertiesRecord
|
|
|
|
func LoadProperties(file []byte) {
|
|
|
|
Properties = make(map[string]*PropertyRecord)
|
|
|
|
|
|
|
|
d := d2common.LoadDataDictionary(file)
|
|
|
|
for d.Next() {
|
|
|
|
prop := &PropertyRecord{
|
2020-07-30 10:14:15 -04:00
|
|
|
Code: d.String("code"),
|
2020-07-13 09:02:09 -04:00
|
|
|
Active: d.String("*done"),
|
2020-07-30 10:14:15 -04:00
|
|
|
Stats: [7]*PropertyStatRecord{
|
2020-07-13 09:02:09 -04:00
|
|
|
{
|
2020-07-30 10:14:15 -04:00
|
|
|
SetID: d.Number("set1"),
|
|
|
|
Value: d.Number("val1"),
|
2020-07-13 09:02:09 -04:00
|
|
|
FunctionID: d.Number("func1"),
|
2020-07-30 10:14:15 -04:00
|
|
|
StatCode: d.String("stat1"),
|
2020-07-13 09:02:09 -04:00
|
|
|
},
|
|
|
|
{
|
2020-07-30 10:14:15 -04:00
|
|
|
SetID: d.Number("set2"),
|
|
|
|
Value: d.Number("val2"),
|
2020-07-13 09:02:09 -04:00
|
|
|
FunctionID: d.Number("func2"),
|
2020-07-30 10:14:15 -04:00
|
|
|
StatCode: d.String("stat2"),
|
2020-07-13 09:02:09 -04:00
|
|
|
},
|
|
|
|
{
|
2020-07-30 10:14:15 -04:00
|
|
|
SetID: d.Number("set3"),
|
|
|
|
Value: d.Number("val3"),
|
2020-07-13 09:02:09 -04:00
|
|
|
FunctionID: d.Number("func3"),
|
2020-07-30 10:14:15 -04:00
|
|
|
StatCode: d.String("stat3"),
|
2020-07-13 09:02:09 -04:00
|
|
|
},
|
|
|
|
{
|
2020-07-30 10:14:15 -04:00
|
|
|
SetID: d.Number("set4"),
|
|
|
|
Value: d.Number("val4"),
|
2020-07-13 09:02:09 -04:00
|
|
|
FunctionID: d.Number("func4"),
|
2020-07-30 10:14:15 -04:00
|
|
|
StatCode: d.String("stat4"),
|
2020-07-13 09:02:09 -04:00
|
|
|
},
|
|
|
|
{
|
2020-07-30 10:14:15 -04:00
|
|
|
SetID: d.Number("set5"),
|
|
|
|
Value: d.Number("val5"),
|
2020-07-13 09:02:09 -04:00
|
|
|
FunctionID: d.Number("func5"),
|
2020-07-30 10:14:15 -04:00
|
|
|
StatCode: d.String("stat5"),
|
2020-07-13 09:02:09 -04:00
|
|
|
},
|
|
|
|
{
|
2020-07-30 10:14:15 -04:00
|
|
|
SetID: d.Number("set6"),
|
|
|
|
Value: d.Number("val6"),
|
2020-07-13 09:02:09 -04:00
|
|
|
FunctionID: d.Number("func6"),
|
2020-07-30 10:14:15 -04:00
|
|
|
StatCode: d.String("stat6"),
|
2020-07-13 09:02:09 -04:00
|
|
|
},
|
|
|
|
{
|
2020-07-30 10:14:15 -04:00
|
|
|
SetID: d.Number("set7"),
|
|
|
|
Value: d.Number("val7"),
|
2020-07-13 09:02:09 -04:00
|
|
|
FunctionID: d.Number("func7"),
|
2020-07-30 10:14:15 -04:00
|
|
|
StatCode: d.String("stat7"),
|
2020-07-13 09:02:09 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
Properties[prop.Code] = prop
|
|
|
|
}
|
|
|
|
|
|
|
|
if d.Err != nil {
|
|
|
|
panic(d.Err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("Loaded %d Property records", len(Properties))
|
|
|
|
}
|