mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-24 19:18:12 -05:00
clean up error handling in d2game/d2player/inventory.go and d2core/d2item/diablo2item/
This commit is contained in:
parent
d302263ac1
commit
509dfda5e5
@ -419,9 +419,17 @@ var testAssetManager *d2asset.AssetManager
|
||||
var testItemFactory *ItemFactory
|
||||
|
||||
func TestSetup(t *testing.T) {
|
||||
var err error
|
||||
|
||||
testAssetManager = &d2asset.AssetManager{}
|
||||
testAssetManager.Records = &d2records.RecordManager{}
|
||||
testItemFactory, _ = NewItemFactory(testAssetManager)
|
||||
|
||||
testItemFactory, err = NewItemFactory(testAssetManager)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
testAssetManager.Records.Item.Stats = itemStatCosts
|
||||
testAssetManager.Records.Character.Stats = charStats
|
||||
testAssetManager.Records.Skill.Details = skillDetails
|
||||
|
@ -208,7 +208,12 @@ func NewGameControls(
|
||||
|
||||
heroStatsPanel := NewHeroStatsPanel(asset, ui, hero.Name(), hero.Class, l, hero.Stats)
|
||||
questLog := NewQuestLog(asset, ui, l, hero.Act)
|
||||
inventory := NewInventory(asset, ui, l, hero.Gold, inventoryRecord)
|
||||
|
||||
inventory, err := NewInventory(asset, ui, l, hero.Gold, inventoryRecord)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
skilltree := newSkillTree(hero.Skills, hero.Class, asset, l, ui)
|
||||
|
||||
miniPanel := newMiniPanel(asset, ui, l, isSinglePlayer)
|
||||
|
@ -32,11 +32,13 @@ func NewInventory(asset *d2asset.AssetManager,
|
||||
ui *d2ui.UIManager,
|
||||
l d2util.LogLevel,
|
||||
gold int,
|
||||
record *d2records.InventoryRecord) *Inventory {
|
||||
record *d2records.InventoryRecord) (*Inventory, error) {
|
||||
itemTooltip := ui.NewTooltip(d2resource.FontFormal11, d2resource.PaletteStatic, d2ui.TooltipXCenter, d2ui.TooltipYBottom)
|
||||
|
||||
// https://github.com/OpenDiablo2/OpenDiablo2/issues/797
|
||||
itemFactory, _ := diablo2item.NewItemFactory(asset)
|
||||
itemFactory, err := diablo2item.NewItemFactory(asset)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("during creating new item factory: %s", err)
|
||||
}
|
||||
|
||||
inventory := &Inventory{
|
||||
asset: asset,
|
||||
@ -54,7 +56,7 @@ func NewInventory(asset *d2asset.AssetManager,
|
||||
inventory.Logger.SetLevel(l)
|
||||
inventory.Logger.SetPrefix(logPrefix)
|
||||
|
||||
return inventory
|
||||
return inventory, nil
|
||||
}
|
||||
|
||||
// Inventory represents the inventory
|
||||
|
Loading…
Reference in New Issue
Block a user