Skip to content

Commit

Permalink
Merge pull request #16 from nokka/feature/linting_gomod
Browse files Browse the repository at this point in the history
Made structs available publically and ran linter, also added go.mod.
  • Loading branch information
nokka authored Nov 8, 2020
2 parents bbed34a + 9b59b46 commit 3903524
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 86 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lint:
golangci-lint run --disable-all -E golint -E staticcheck -E structcheck -E unused -E gocritic -E gofmt -E interfacer -E misspell -E stylecheck -E unconvert -E unparam -E scopelint -E prealloc
3 changes: 2 additions & 1 deletion attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const (
stashedGold = 15
)

type attributes struct {
// Attributes are the different type of attributes a character can have.
type Attributes struct {
Strength uint64 `json:"strength"`
Energy uint64 `json:"energy"`
Dexterity uint64 `json:"dexterity"`
Expand Down
21 changes: 11 additions & 10 deletions character.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import (

// Character represents all the d2s character data.
type Character struct {
Header header `json:"header"`
Attributes attributes `json:"attributes"`
Skills []skill `json:"skills"`
Items []item `json:"items"`
CorpseItems []item `json:"corpse_items"`
MercItems []item `json:"merc_items"`
GolemItem *item `json:"golem_item"`
Header Header `json:"header"`
Attributes Attributes `json:"attributes"`
Skills []Skill `json:"skills"`
Items []Item `json:"items"`
CorpseItems []Item `json:"corpse_items"`
MercItems []Item `json:"merc_items"`
GolemItem *Item `json:"golem_item"`
IsDead uint16 `json:"is_dead"`
}

func (h *header) MarshalJSON() ([]byte, error) {
type Alias header
// MarshalJSON ...
func (h *Header) MarshalJSON() ([]byte, error) {
type Alias Header

leftSkill, ok := skillMap[int(h.LeftSkill)]
if !ok {
Expand Down Expand Up @@ -86,7 +87,7 @@ func (h *header) MarshalJSON() ([]byte, error) {
}

// Header determines the header data of a d2s file.
type header struct {
type Header struct {
Identifier uint32 `json:"identifier"`
Version uint32 `json:"version"`
FileSize uint32 `json:"filesize"`
Expand Down
Loading

0 comments on commit 3903524

Please sign in to comment.