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
// ArmorClass is a 3-character token for the armor. It's used for speed calculations.
type ArmorClass string
// Armor classes
const (
ArmorClassLite = "lit"
ArmorClassMedium = "med"

View File

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

View File

@ -29,7 +29,7 @@ const (
mapWidth = 150
mapHeight = mapWidth
mapMargin = 9
autoFileIndex = d2mapstamp.AutoFileIndex
autoFileIndex = -1
)
// 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"
)
const (
AutoFileIndex = -1
)
// NewStampFactory creates a MapStamp factory instance
func NewStampFactory(asset *d2asset.AssetManager, entity *d2mapentity.MapEntityFactory) *StampFactory {
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()))
if fileIndex >= 0 && fileIndex < len(levelFilesToPick) {
levelIndex = fileIndex

View File

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

View File

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

View File

@ -40,15 +40,15 @@ type Inventory struct {
grid *ItemGrid
hoverLabel *d2ui.Label
closeButton *d2ui.Button
hoverX int
hoverY int
originX int
originY int
lastMouseX int
lastMouseY int
hovering bool
isOpen bool
onCloseCb func()
hoverX int
hoverY int
originX int
originY int
lastMouseX int
lastMouseY int
hovering bool
isOpen bool
onCloseCb func()
}
// NewInventory creates an inventory instance and returns a pointer to it
@ -99,9 +99,9 @@ func (g *Inventory) Close() {
g.onCloseCb()
}
// Set the callback run on closing the inventory
// SetOnCloseCb the callback run on closing the inventory
func (g *Inventory) SetOnCloseCb(cb func()) {
g.onCloseCb = cb
g.onCloseCb = cb
}
// Load the resources required by the inventory