1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-30 07:06:18 -04:00

Add gamble.txt loader (#764)

This commit is contained in:
kottz 2020-10-11 00:45:28 +02:00 committed by GitHub
parent d1d8a52810
commit b5e052fc81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 1 deletions

View File

@ -228,7 +228,7 @@ const (
ObjectGroup = "/data/global/excel/objgroup.txt"
CompCode = "/data/global/excel/compcode.txt"
Belts = "/data/global/excel/belts.txt"
Gamble = "/data/global/excel/gamble.txt"
// --- Animations ---

View File

@ -0,0 +1,29 @@
package d2records
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
func gambleLoader(r *RecordManager, d *d2txt.DataDictionary) error {
records := make(Gamble)
for d.Next() {
record := &GambleRecord{
Name: d.String("name"),
Code: d.String("code"),
}
records[record.Name] = record
}
if d.Err != nil {
return d.Err
}
log.Printf("Loaded %d gamble records", len(records))
r.Gamble = records
return nil
}

View File

@ -0,0 +1,8 @@
package d2records
type Gamble map[string]*GambleRecord
type GambleRecord struct {
Name string
Code string
}

View File

@ -45,6 +45,7 @@ type RecordManager struct {
ComponentCodes
DifficultyLevels
ElemTypes
Gamble
Hirelings
Item struct {
All CommonItems // NOTE: populated when armor, weapons, and misc items are ALL loaded
@ -167,6 +168,7 @@ func (r *RecordManager) init() error {
{d2resource.ItemRatio, itemRatioLoader},
{d2resource.Overlays, overlaysLoader},
{d2resource.CharStats, charStatsLoader},
{d2resource.Gamble, gambleLoader},
{d2resource.Hireling, hirelingLoader},
{d2resource.Experience, experienceLoader},
{d2resource.Gems, gemsLoader},