1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-18 02:16:23 -05:00
OpenDiablo2/d2core/d2records/unique_items_loader.go

135 lines
3.1 KiB
Go
Raw Normal View History

package d2records
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// nolint:funlen // cant reduce
func uniqueItemsLoader(r *RecordManager, d *d2txt.DataDictionary) error {
records := make(UniqueItems)
for d.Next() {
record := &UniqueItemRecord{
Name: d.String("index"),
Version: d.Number("version"),
Enabled: d.Number("enabled") == 1,
Ladder: d.Number("ladder") == 1,
Rarity: d.Number("rarity"),
NoLimit: d.Number("nolimit") == 1,
Level: d.Number("lvl"),
RequiredLevel: d.Number("lvl req"),
Code: d.String("code"),
TypeDescription: d.String("*type"),
UberDescription: d.String("*uber"),
SingleCopy: d.Number("carry1") == 1,
CostMultiplier: d.Number("cost mult"),
CostAdd: d.Number("cost add"),
CharacterGfxTransform: d.String("chrtransform"),
InventoryGfxTransform: d.String("invtransform"),
FlippyFile: d.String("flippyfile"),
InventoryFile: d.String("invfile"),
DropSound: d.String("dropsound"),
DropSfxFrame: d.Number("dropsfxframe"),
UseSound: d.String("usesound"),
Properties: [12]*UniqueItemProperty{
{
Code: d.String("prop1"),
Parameter: d.String("par1"),
Min: d.Number("min1"),
Max: d.Number("max1"),
},
{
Code: d.String("prop2"),
Parameter: d.String("par2"),
Min: d.Number("min2"),
Max: d.Number("max2"),
},
{
Code: d.String("prop3"),
Parameter: d.String("par3"),
Min: d.Number("min3"),
Max: d.Number("max3"),
},
{
Code: d.String("prop4"),
Parameter: d.String("par4"),
Min: d.Number("min4"),
Max: d.Number("max4"),
},
{
Code: d.String("prop5"),
Parameter: d.String("par5"),
Min: d.Number("min5"),
Max: d.Number("max5"),
},
{
Code: d.String("prop6"),
Parameter: d.String("par6"),
Min: d.Number("min6"),
Max: d.Number("max6"),
},
{
Code: d.String("prop7"),
Parameter: d.String("par7"),
Min: d.Number("min7"),
Max: d.Number("max7"),
},
{
Code: d.String("prop8"),
Parameter: d.String("par8"),
Min: d.Number("min8"),
Max: d.Number("max8"),
},
{
Code: d.String("prop9"),
Parameter: d.String("par9"),
Min: d.Number("min9"),
Max: d.Number("max9"),
},
{
Code: d.String("prop10"),
Parameter: d.String("par10"),
Min: d.Number("min10"),
Max: d.Number("max10"),
},
{
Code: d.String("prop11"),
Parameter: d.String("par11"),
Min: d.Number("min11"),
Max: d.Number("max11"),
},
{
Code: d.String("prop12"),
Parameter: d.String("par12"),
Min: d.Number("min12"),
Max: d.Number("max12"),
},
},
}
Removing d2datadict singletons (#738) * Remove weapons, armor, misc, itemCommon, itemTyps datadict singletons - removed loader calls from d2app - removed the HeroObjects singleton from `d2core/d2inventory` - added an InventoryItemFactory in d2inventory - package-level functions that use data records are now methods of the InventoryItemFactory - renamed ItemGenerator in d2item to ItemFactory - package-level functions that use records are now methods of ItemFactory - d2map.MapEntityFactory now has an item factory instance for creating items - fixed a bug in unique item record loader where it loaded an empty record - added a PlayerStateFactory for creating a player state (uses the asset manager) - updated the test inventory/equipment code in d2player to handle errors from the ItemFactory - character select and character creation screens have a player state and inventory item factory - updated item tests to use the item factory * minor edit * Removed d2datadict.Experience singleton added a HeroStatsFactory, much like the other factories. The factory gets an asset manager reference in order to use data records. * removed d2datadict.AutoMagic singleton * removed d2datadict.AutoMap singleton * removed d2datadict.BodyLocations singleton * removed d2datadict.Books singleton * Removed singletons for level records - removed loader calls in d2app - changed type references from d2datadict to d2records - added a `MapGenerator` in d2mapgen which uses thew asset manager and map engine - package-level map generation functions are now MapGenerator methods - `d2datadict.GetLevelDetails(id int)` is now a method of the RecordManager * remove SkillCalc and MissileCalc singletons * Removed CharStats and ItemStatCost singletons - added an ItemStatFactory which uses the asset manager to create stats - package-level functions for stats in d2item are now StatFactory methods - changed type references from d2datadict to d2records - `d2player.GetAllPlayerStates` is now a method of the `PlayerStateFactory` * Removed DkillDesc and Skills singletons from d2datadict - removed loader calls from d2app - diablo2stats.Stat instances are given a reference to the factory for doing record lookups * update the stats test to use mock a asset manager and stat factory * fixed diablo2stats tests and diablo2item tests * removed CompCodes singleton from d2datadict * remove cubemain singleton from d2datadict * removed DifficultyLevels singleton from d2datadict * removed ElemTypes singleton from d2datadict * removed events.go loader from d2datadict (was unused) * removed Gems singleton from d2datadict * removed Hireling and Inventory singletons from d2datadict * removed MagicPrefix and MagicSuffix singletons from d2datadict * removed ItemRatios singleton from d2datadict * removed Missiles singleton from d2datadict * removed MonModes singleton * Removed all monster and npc singletons from d2datadict - MapStamp instances now get a reference to their factory for doing record lookups * removed SoundEntry and SoundEnviron singletons from d2datadict
2020-09-20 17:52:01 -04:00
if record.Name == "" {
continue
}
records[record.Name] = record
}
if d.Err != nil {
return d.Err
}
r.Item.Unique = records
2020-12-18 01:40:54 -05:00
r.Debugf("Loaded %d UniqueItem records", len(records))
return nil
}