1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-19 21:55:24 +00:00

removed all golint lint errors (#833)

* removed all 'golint' type lint errors
This commit is contained in:
gravestench 2020-10-25 23:23:55 +00:00 committed by GitHub
parent 025ee94e50
commit a1380bc264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 29 deletions

View File

@ -1,7 +1,9 @@
package d2enum package d2enum
// ArmorClass is a 3-character token for the armor. It's used for speed calculations.
type ArmorClass string type ArmorClass string
// Armor classes
const ( const (
ArmorClassLite = "lit" ArmorClassLite = "lit"
ArmorClassMedium = "med" ArmorClassMedium = "med"

View File

@ -2,10 +2,11 @@ package d2enum
import "log" import "log"
// SkillClass represents the skills for a character class
type SkillClass int type SkillClass int
// Skill classes
const ( const (
// SkillClassGeneric is ""
SkillClassGeneric SkillClass = iota SkillClassGeneric SkillClass = iota
SkillClassBarbarian SkillClassBarbarian
SkillClassNecromancer SkillClassNecromancer

View File

@ -29,7 +29,7 @@ const (
mapWidth = 150 mapWidth = 150
mapHeight = mapWidth mapHeight = mapWidth
mapMargin = 9 mapMargin = 9
autoFileIndex = d2mapstamp.AutoFileIndex autoFileIndex = -1
) )
// GenerateAct1Overworld generates the map and entities for the first town and surrounding area. // GenerateAct1Overworld generates the map and entities for the first town and surrounding area.

View File

@ -13,10 +13,6 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
) )
const (
AutoFileIndex = -1
)
// NewStampFactory creates a MapStamp factory instance // NewStampFactory creates a MapStamp factory instance
func NewStampFactory(asset *d2asset.AssetManager, entity *d2mapentity.MapEntityFactory) *StampFactory { func NewStampFactory(asset *d2asset.AssetManager, entity *d2mapentity.MapEntityFactory) *StampFactory {
return &StampFactory{asset, entity} return &StampFactory{asset, entity}
@ -67,6 +63,7 @@ func (f *StampFactory) LoadStamp(levelType d2enum.RegionIdType, levelPreset, fil
} }
} }
// nolint:gosec // not a big deal for now
levelIndex := int(math.Round(float64(len(levelFilesToPick)-1) * rand.Float64())) levelIndex := int(math.Round(float64(len(levelFilesToPick)-1) * rand.Float64()))
if fileIndex >= 0 && fileIndex < len(levelFilesToPick) { if fileIndex >= 0 && fileIndex < len(levelFilesToPick) {
levelIndex = fileIndex levelIndex = fileIndex

View File

@ -8,22 +8,25 @@ import (
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset" "github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
) )
type frameOrientation = int
// Frame orientations
const (
FrameLeft frameOrientation = iota
FrameRight
)
// UIFrame is a representation of a ui panel that occupies the left or right half of the screen
// when it is visible.
type UIFrame struct { type UIFrame struct {
asset *d2asset.AssetManager asset *d2asset.AssetManager
uiManager *UIManager uiManager *UIManager
frame *Sprite frame *Sprite
originX int originX int
originY int originY int
frameOrientation FrameOrientation frameOrientation frameOrientation
} }
type FrameOrientation = int
const (
FrameLeft FrameOrientation = iota
FrameRight
)
// frame indices into dc6 images for panels // frame indices into dc6 images for panels
const ( const (
leftFrameTopLeft = iota leftFrameTopLeft = iota
@ -38,12 +41,11 @@ const (
rightFrameBottomLeft rightFrameBottomLeft
) )
type offsetCalcFn = func(u *UIFrame) (x, y int) // NewUIFrame creates a new Frame instance
func NewUIFrame( func NewUIFrame(
asset *d2asset.AssetManager, asset *d2asset.AssetManager,
uiManager *UIManager, uiManager *UIManager,
frameOrientation FrameOrientation, frameOrientation frameOrientation,
) *UIFrame { ) *UIFrame {
var originX, originY = 0, 0 var originX, originY = 0, 0
@ -55,6 +57,7 @@ func NewUIFrame(
originX = 400 originX = 400
originY = 0 originY = 0
} }
frame := &UIFrame{ frame := &UIFrame{
asset: asset, asset: asset,
uiManager: uiManager, uiManager: uiManager,
@ -63,17 +66,21 @@ func NewUIFrame(
originY: originY, originY: originY,
} }
frame.Load() frame.Load()
return frame return frame
} }
// Load the necessary frame resources
func (u *UIFrame) Load() { func (u *UIFrame) Load() {
sprite, err := u.uiManager.NewSprite(d2resource.Frame, d2resource.PaletteSky) sprite, err := u.uiManager.NewSprite(d2resource.Frame, d2resource.PaletteSky)
if err != nil { if err != nil {
log.Print(err) log.Print(err)
} }
u.frame = sprite u.frame = sprite
} }
// Render the frame to the target surface
func (u *UIFrame) Render(target d2interface.Surface) error { func (u *UIFrame) Render(target d2interface.Surface) error {
switch u.frameOrientation { switch u.frameOrientation {
case FrameLeft: case FrameLeft:
@ -81,6 +88,7 @@ func (u *UIFrame) Render(target d2interface.Surface) error {
case FrameRight: case FrameRight:
return u.renderRight(target) return u.renderRight(target)
} }
return nil return nil
} }
@ -200,10 +208,12 @@ func (u *UIFrame) renderRight(target d2interface.Surface) error {
return nil return nil
} }
// GetFrameBounds returns the maximum width and height of all frames in sprite.
func (u *UIFrame) GetFrameBounds() (width, height int) { func (u *UIFrame) GetFrameBounds() (width, height int) {
return u.frame.GetFrameBounds() return u.frame.GetFrameBounds()
} }
// GetFrameCount returns the number of frames in the sprite
func (u *UIFrame) GetFrameCount() int { func (u *UIFrame) GetFrameCount() int {
return u.frame.GetFrameCount() return u.frame.GetFrameCount()
} }

View File

@ -168,7 +168,7 @@ func (s *HeroStatsPanel) Close() {
s.onCloseCb() s.onCloseCb()
} }
// Set the callback run on closing the HeroStatsPanel // SetOnCloseCb the callback run on closing the HeroStatsPanel
func (s *HeroStatsPanel) SetOnCloseCb(cb func()) { func (s *HeroStatsPanel) SetOnCloseCb(cb func()) {
s.onCloseCb = cb s.onCloseCb = cb
} }

View File

@ -99,7 +99,7 @@ func (g *Inventory) Close() {
g.onCloseCb() g.onCloseCb()
} }
// Set the callback run on closing the inventory // SetOnCloseCb the callback run on closing the inventory
func (g *Inventory) SetOnCloseCb(cb func()) { func (g *Inventory) SetOnCloseCb(cb func()) {
g.onCloseCb = cb g.onCloseCb = cb
} }