1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-10 10:36:42 -05:00

d2core: fix part of remaining lint errors

This commit is contained in:
gucio321 2021-06-13 17:22:13 +02:00
parent baf573f53d
commit bbea424b22
10 changed files with 136 additions and 134 deletions

View File

@ -18,8 +18,8 @@ const (
// Button is a user actionable drawable toggle switch // Button is a user actionable drawable toggle switch
type Button struct { type Button struct {
widgetBase
surfaces []d2interface.Surface surfaces []d2interface.Surface
widgetBase
width int width int
height int height int
state buttonState state buttonState

View File

@ -21,12 +21,12 @@ const (
// Label is renderable text // Label is renderable text
type Label struct { type Label struct {
widgetBase
blinkTimer time.Time blinkTimer time.Time
renderer d2interface.Renderer renderer d2interface.Renderer
surface d2interface.Surface surface d2interface.Surface
font *d2font.Font font *d2font.Font
text string text string
widgetBase
color color.RGBA color color.RGBA
hoverColor color.RGBA hoverColor color.RGBA
isHovered bool isHovered bool

View File

@ -57,10 +57,10 @@ var _ widget = &Layout{}
// Layout is a gui element container which will automatically position/align gui elements. // Layout is a gui element container which will automatically position/align gui elements.
// Layouts are gui elements as well, so they can be nested in other layouts. // Layouts are gui elements as well, so they can be nested in other layouts.
type Layout struct { type Layout struct {
widgetBase
renderer d2interface.Renderer renderer d2interface.Renderer
assetManager *d2asset.AssetManager assetManager *d2asset.AssetManager
entries []*layoutEntry entries []*layoutEntry
widgetBase
width int width int
height int height int
verticalAlign VerticalAlign verticalAlign VerticalAlign

View File

@ -22,8 +22,8 @@ var _ widget = &Sprite{}
// Sprite is an image // Sprite is an image
type Sprite struct { type Sprite struct {
widgetBase
animation d2interface.Animation animation d2interface.Animation
widgetBase
segmentsX int segmentsX int
segmentsY int segmentsY int
frameOffset int frameOffset int

View File

@ -55,63 +55,53 @@ var _ d2item.Item = &Item{}
// Item is a representation of a diablo2 item // Item is a representation of a diablo2 item
// nolint:structcheck,unused // WIP // nolint:structcheck,unused // WIP
type Item struct { type Item struct {
setItemStatList d2stats.StatList
statContext d2item.StatContext
uniqueStatList d2stats.StatList
statList d2stats.StatList
rand *rand.Rand
properties map[PropertyPool][]*Property
attributes *itemAttributes
factory *ItemFactory factory *ItemFactory
name string
Seed int64
rand *rand.Rand // non-global rand instance for re-generating the item
slotType d2enum.EquippedSlot
TypeCode string TypeCode string
CommonCode string
UniqueCode string
SetCode string SetCode string
SetItemCode string SetItemCode string
PrefixCodes []string CommonCode string
name string
UniqueCode string
SuffixCodes []string SuffixCodes []string
PrefixCodes []string
properties map[PropertyPool][]*Property sockets []*d2item.Item
statContext d2item.StatContext slotType d2enum.EquippedSlot
statList d2stats.StatList Seed int64
uniqueStatList d2stats.StatList
setItemStatList d2stats.StatList
attributes *itemAttributes
GridX int GridX int
GridY int GridY int
sockets []*d2item.Item // there will be checks for handling the craziness this might entail
} }
// nolint:structcheck,unused // WIP // nolint:structcheck,unused // WIP
type itemAttributes struct { type itemAttributes struct {
worldSprite *d2ui.Sprite worldSprite *d2ui.Sprite
inventorySprite *d2ui.Sprite inventorySprite *d2ui.Sprite
personalization string
damageOneHand minMaxEnhanceable damageOneHand minMaxEnhanceable
damageTwoHand minMaxEnhanceable damageTwoHand minMaxEnhanceable
damageMissile minMaxEnhanceable damageMissile minMaxEnhanceable
stackSize minMaxEnhanceable stackSize minMaxEnhanceable
durability minMaxEnhanceable durability minMaxEnhanceable
classSpecific d2enum.Hero
personalization string
quality int
defense int defense int
currentStackSize int currentStackSize int
currentDurability int currentDurability int
baseItemLevel int quality int
requiredLevel int requiredLevel int
numSockets int numSockets int
requirementsEnhancement int requirementsEnhancement int
requiredStrength int requiredStrength int
requiredDexterity int requiredDexterity int
classSpecific d2enum.Hero baseItemLevel int
identitified bool identitified bool
crafted bool crafted bool
durable bool // some items specify that they have no durability durable bool
indestructable bool indestructable bool
ethereal bool ethereal bool
throwable bool throwable bool

View File

@ -75,12 +75,8 @@ type Property struct {
factory *ItemFactory factory *ItemFactory
record *d2records.PropertyRecord record *d2records.PropertyRecord
stats []d2stats.Stat stats []d2stats.Stat
PropertyType PropertyType
// the inputValues that were passed initially when calling `NewProperty`
inputParams []int inputParams []int
PropertyType PropertyType
// some properties are statless and used only for computing a value
computedInt int computedInt int
computedBool bool computedBool bool
} }

View File

@ -443,122 +443,122 @@ func TestNewProperty(t *testing.T) { //nolint:funlen // it's mostly test-case de
tests := []struct { tests := []struct {
propKey string propKey string
inputValues []int inputValues []int
expectNumStats int
expectStr []string expectStr []string
expectNumStats int
}{ }{
{ // fnId 1 + 3 { // fnId 1 + 3
"allstats", "allstats",
[]int{1, 10}, []int{1, 10},
4,
[]string{ []string{
"+# to Strength", "+# to Strength",
"+# to Dexterity", "+# to Dexterity",
"+# to Vitality", "+# to Vitality",
"+# to Energy", "+# to Energy",
}, },
4,
}, },
{ // fnId 2 { // fnId 2
"ac%", "ac%",
[]int{1, 10}, []int{1, 10},
1,
[]string{"+#% Enhanced Defense"}, []string{"+#% Enhanced Defense"},
1,
}, },
{ // fnId 5 { // fnId 5
// dmg-min, dmg-max, dmg%, indestructable, and ethereal dont have stats! // dmg-min, dmg-max, dmg%, indestructable, and ethereal dont have stats!
"dmg-min", "dmg-min",
[]int{1, 10}, []int{1, 10},
0,
[]string{""}, []string{""},
0,
}, },
{ // fnId 6 { // fnId 6
// dmg-min, dmg-max, dmg%, indestructable, and ethereal dont have stats! // dmg-min, dmg-max, dmg%, indestructable, and ethereal dont have stats!
"dmg-max", "dmg-max",
[]int{1, 10}, []int{1, 10},
0,
[]string{""}, []string{""},
0,
}, },
{ // fnId 7 { // fnId 7
// dmg-min, dmg-max, dmg%, indestructable, and ethereal dont have stats! // dmg-min, dmg-max, dmg%, indestructable, and ethereal dont have stats!
"dmg%", "dmg%",
[]int{1, 10}, []int{1, 10},
0,
[]string{""}, []string{""},
0,
}, },
{ // fnId 8 { // fnId 8
"cast1", "cast1",
[]int{1, 10}, []int{1, 10},
1,
[]string{"+#% Faster Cast Rate"}, []string{"+#% Faster Cast Rate"},
1,
}, },
{ {
"indestruct", "indestruct",
[]int{0, 1}, []int{0, 1},
0,
[]string{""}, []string{""},
0,
}, },
{ {
"ethereal", "ethereal",
[]int{0, 1}, []int{0, 1},
0,
[]string{""}, []string{""},
0,
}, },
{ // fnId 10 { // fnId 10
"skilltab", "skilltab",
[]int{10, 1, 3}, []int{10, 1, 3},
1,
[]string{"+# to Offensive Auras (Paladin Only)"}, []string{"+# to Offensive Auras (Paladin Only)"},
1,
}, },
{ // fnId 11 { // fnId 11
"levelup-skill", "levelup-skill",
[]int{64, 100, 3}, []int{64, 100, 3},
1,
[]string{"#% Chance to cast level # Frozen Orb when you Level-Up"}, []string{"#% Chance to cast level # Frozen Orb when you Level-Up"},
1,
}, },
{ // fnId 12 { // fnId 12
"skill-rand", "skill-rand",
[]int{10, 64, 64}, []int{10, 64, 64},
1,
[]string{"+# to Frozen Orb"}, []string{"+# to Frozen Orb"},
1,
}, },
{ // fnId 13 { // fnId 13
"dur%", "dur%",
[]int{1, 10}, []int{1, 10},
1,
[]string{"Increase Maximum Durability +#%"}, []string{"Increase Maximum Durability +#%"},
1,
}, },
{ // fnId 14 { // fnId 14
"sock", "sock",
[]int{0, 6}, []int{0, 6},
1,
[]string{""}, []string{""},
1,
}, },
{ // fnId 15, 16, 17 { // fnId 15, 16, 17
"dmg-pois", "dmg-pois",
[]int{100, 5, 10}, []int{100, 5, 10},
3,
[]string{ []string{
"+# to Minimum Poison Damage", "+# to Minimum Poison Damage",
"+# to Maximum Poison Damage", "+# to Maximum Poison Damage",
"", // length, non-printing "", // length, non-printing
}, },
3,
}, },
{ // fnId 19 { // fnId 19
"charged", "charged",
[]int{64, 20, 10}, []int{64, 20, 10},
1,
[]string{"Level # Frozen Orb (#/# Charges)"}, []string{"Level # Frozen Orb (#/# Charges)"},
1,
}, },
{ // fnId 21 { // fnId 21
"pal", "pal",
[]int{1, 5}, []int{1, 5},
1,
[]string{"+# to Paladin Skill Levels"}, []string{"+# to Paladin Skill Levels"},
1,
}, },
{ // fnId 22 { // fnId 22
"oskill", "oskill",
[]int{64, 1, 5}, []int{64, 1, 5},
1,
[]string{"+# to Frozen Orb"}, []string{"+# to Frozen Orb"},
1,
}, },
} }

View File

@ -18,9 +18,9 @@ type NPC struct {
monstatRecord *d2records.MonStatRecord monstatRecord *d2records.MonStatRecord
monstatEx *d2records.MonStat2Record monstatEx *d2records.MonStat2Record
composite *d2asset.Composite composite *d2asset.Composite
mapEntity
name string name string
Paths []d2path.Path Paths []d2path.Path
mapEntity
action int action int
path int path int
repetitions int repetitions int

View File

@ -13,16 +13,16 @@ import (
// Player is the player character entity. // Player is the player character entity.
type Player struct { type Player struct {
onFinishedCasting func() Skills map[int]*d2hero.HeroSkill
LeftSkill *d2hero.HeroSkill LeftSkill *d2hero.HeroSkill
RightSkill *d2hero.HeroSkill RightSkill *d2hero.HeroSkill
composite *d2asset.Composite composite *d2asset.Composite
Equipment *d2inventory.CharacterEquipment Equipment *d2inventory.CharacterEquipment
Stats *d2hero.HeroStatsState Stats *d2hero.HeroStatsState
Skills map[int]*d2hero.HeroSkill onFinishedCasting func()
mapEntity
name string name string
animationMode string animationMode string
mapEntity
Gold int Gold int
lastPathSize int lastPathSize int
Class d2enum.Hero Class d2enum.Hero

View File

@ -301,86 +301,102 @@ func TestStat_Clone(t *testing.T) {
func TestStat_Descriptions(t *testing.T) { func TestStat_Descriptions(t *testing.T) {
tests := []struct { tests := []struct {
recordKey string recordKey string
vals []float64
expect string expect string
vals []float64
}{ }{
// DescFn1 // DescFn1
{"strength", []float64{31}, "+31 to Strength"}, {"strength", "+31 to Strength", []float64{31}},
{"hpregen", []float64{20}, "Replenish Life +20"}, {"hpregen", "Replenish Life +20", []float64{20}},
{"hpregen", []float64{-8}, "Drain Life -8"}, {"hpregen", "Drain Life -8", []float64{-8}},
// DescFn2 // DescFn2
{"toblock", []float64{16}, "+16% Increased Chance of Blocking"}, {"toblock", "+16% Increased Chance of Blocking", []float64{16}},
{"item_absorblight_percent", []float64{10}, "Lightning Absorb +10%"}, {"item_absorblight_percent", "Lightning Absorb +10%", []float64{10}},
// DescFn3 // DescFn3
{"normal_damage_reduction", []float64{25}, "Damage Reduced by 25"}, {"normal_damage_reduction", "Damage Reduced by 25", []float64{25}},
{"item_restinpeace", []float64{25}, "Slain Monsters Rest in Peace"}, {"item_restinpeace", "Slain Monsters Rest in Peace", []float64{25}},
// DescFn4 // DescFn4
{"poisonresist", []float64{25}, "Poison Resist +25%"}, {"poisonresist", "Poison Resist +25%", []float64{25}},
{"item_fastermovevelocity", []float64{25}, "+25% Faster Run/Walk"}, {"item_fastermovevelocity", "+25% Faster Run/Walk", []float64{25}},
// DescFn5 // DescFn5
{"item_howl", []float64{25}, "Hit Causes Monster to Flee 25%"}, {"item_howl", "Hit Causes Monster to Flee 25%", []float64{25}},
// DescFn6 // DescFn6
{"item_hp_perlevel", []float64{25}, "+25 to Life (Based on Character Level)"}, {"item_hp_perlevel", "+25 to Life (Based on Character Level)", []float64{25}},
// DescFn7 // DescFn7
{"item_resist_ltng_perlevel", []float64{25}, {
"Lightning Resist +25% (Based on Character Level)"}, "item_resist_ltng_perlevel",
{"item_find_magic_perlevel", []float64{25}, "+25% Better Chance of Getting Magic Items (" + "Lightning Resist +25% (Based on Character Level)",
"Based on Character Level)"}, []float64{25},
},
{
"item_find_magic_perlevel", "+25% Better Chance of Getting Magic Items (Based on Character Level)",
[]float64{25},
},
// DescFn8 // DescFn8
{"item_armorpercent_perlevel", []float64{25}, {
"+25% Enhanced Defense (Based on Character Level)"}, "item_armorpercent_perlevel",
{"item_regenstamina_perlevel", []float64{25}, "+25% Enhanced Defense (Based on Character Level)",
"Heal Stamina Plus +25% (Based on Character Level)"}, []float64{25},
},
{
"item_regenstamina_perlevel",
"Heal Stamina Plus +25% (Based on Character Level)",
[]float64{25},
},
// DescFn9 // DescFn9
{"item_thorns_perlevel", []float64{25}, "Attacker Takes Damage of 25 (" + {
"Based on Character Level)"}, "item_thorns_perlevel", "Attacker Takes Damage of 25 (Based on Character Level)",
[]float64{25},
},
// DescFn11 // DescFn11
{"item_replenish_durability", []float64{2}, "Repairs 2 durability per second"}, {"item_replenish_durability", "Repairs 2 durability per second", []float64{2}},
// DescFn12 // DescFn12
{"item_stupidity", []float64{5}, "Hit Blinds Target +5"}, {"item_stupidity", "Hit Blinds Target +5", []float64{5}},
// DescFn13 // DescFn13
{"item_addclassskills", []float64{5, 3}, "+5 to Paladin Skill Levels"}, {"item_addclassskills", "+5 to Paladin Skill Levels", []float64{5, 3}},
// DescFn14 // DescFn14
{"item_addskill_tab", []float64{5, 3, 0}, "+5 to Combat Skills (Paladin Only)"}, {"item_addskill_tab", "+5 to Combat Skills (Paladin Only)", []float64{5, 3, 0}},
{"item_addskill_tab", []float64{5, 3, 1}, "+5 to Offensive Auras (Paladin Only)"}, {"item_addskill_tab", "+5 to Offensive Auras (Paladin Only)", []float64{5, 3, 1}},
{"item_addskill_tab", []float64{5, 3, 2}, "+5 to Defensive Auras (Paladin Only)"}, {"item_addskill_tab", "+5 to Defensive Auras (Paladin Only)", []float64{5, 3, 2}},
// DescFn15 // DescFn15
{"item_skillonattack", []float64{5, 7, 64}, {
"5% Chance to cast level 7 Frozen Orb on attack"}, "item_skillonattack",
"5% Chance to cast level 7 Frozen Orb on attack",
[]float64{5, 7, 64},
},
// DescFn16 // DescFn16
{"item_aura", []float64{3, 37}, "Level 3 Warmth Aura When Equipped"}, {"item_aura", "Level 3 Warmth Aura When Equipped", []float64{3, 37}},
// DescFn20 // DescFn20
{"item_fractionaltargetac", []float64{-25}, "-25% Target Defense"}, {"item_fractionaltargetac", "-25% Target Defense", []float64{-25}},
// DescFn22 // DescFn22
{"attack_vs_montype", []float64{25, 40}, "25% to Attack Rating versus Specter"}, {"attack_vs_montype", "25% to Attack Rating versus Specter", []float64{25, 40}},
// DescFn23 // DescFn23
{"item_reanimate", []float64{25, 40}, "25% Reanimate as: Specter"}, {"item_reanimate", "25% Reanimate as: Specter", []float64{25, 40}},
// DescFn24 // DescFn24
{"item_charged_skill", []float64{25, 64, 20, 19}, "Level 25 Frozen Orb (19/20 Charges)"}, {"item_charged_skill", "Level 25 Frozen Orb (19/20 Charges)", []float64{25, 64, 20, 19}},
// DescFn27 // DescFn27
{"item_singleskill", []float64{25, 64, 3}, "+25 to Frozen Orb (Paladin Only)"}, {"item_singleskill", "+25 to Frozen Orb (Paladin Only)", []float64{25, 64, 3}},
// DescFn28 // DescFn28
{"item_nonclassskill", []float64{25, 64}, "+25 to Frozen Orb"}, {"item_nonclassskill", "+25 to Frozen Orb", []float64{25, 64}},
} }
for idx := range tests { for idx := range tests {