Skip to content

Commit

Permalink
package structure (#8):
Browse files Browse the repository at this point in the history
- move iron_golem.go into d2sirongolem package
  • Loading branch information
gucio321 committed May 17, 2021
1 parent b8eda00 commit c75a066
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 4 additions & 3 deletions d2s.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/gucio321/d2d2s/d2scorpse"
"github.com/gucio321/d2d2s/d2sdifficulty"
"github.com/gucio321/d2d2s/d2senums"
"github.com/gucio321/d2d2s/d2sirongolem"
"github.com/gucio321/d2d2s/d2sitems"
"github.com/gucio321/d2d2s/datautils"
)
Expand Down Expand Up @@ -63,7 +64,7 @@ type D2S struct {
Items *d2sitems.Items
Corpse *d2scorpse.Corpse
// necromancer only
IronGolem *IronGolem
IronGolem *d2sirongolem.IronGolem
}

// New creates a new D2S structure
Expand All @@ -78,7 +79,7 @@ func New() *D2S {
Stats: &Stats{},
Items: &d2sitems.Items{},
Corpse: d2scorpse.New(),
IronGolem: &IronGolem{},
IronGolem: d2sirongolem.New(),
}

return result
Expand Down Expand Up @@ -254,7 +255,7 @@ func Unmarshal(data []byte) (*D2S, error) {
// iron golem for necromancer
if result.Class == d2senums.CharacterClassNecromancer && result.Status.Expansion {
if err := result.IronGolem.Load(sr); err != nil {
return nil, err
return nil, fmt.Errorf("error loading iron golem: %w", err)
}
}

Expand Down
2 changes: 2 additions & 0 deletions d2sirongolem/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package d2sirongolem stores iron golem's data if necromancer
package d2sirongolem
11 changes: 10 additions & 1 deletion iron_golem.go → d2sirongolem/iron_golem.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package d2d2s
package d2sirongolem

import (
"errors"
Expand All @@ -12,6 +12,15 @@ import (

const golemHeaderID = "kf"

// New creates a new IronGolem
func New() *IronGolem {
result := &IronGolem{
Item: &d2sitems.Item{},
}

return result
}

// IronGolem represents an iron golem
type IronGolem struct {
Item *d2sitems.Item
Expand Down

0 comments on commit c75a066

Please sign in to comment.