mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-19 10:56:07 -05:00
78ecc3557e
* wip d2items system and item properties * added loader for TreasureClassEx.txt * wip item spawn from treasure class records * wip items * add call to init item equivalencies, remove treasure class test from d2app * made item affix records global var a map of affix codes to the records * changed how item to item common record equivalency is determined * changed set items records export to a map of their codes to the records, grouped property params into a struct * changed property parameter field from calcstring to string * fixed bug in stat value clone * adding equipper interface as part of stat context, eventually to be used to resolve set bonus (among other things) * made the item interface simpler, only needs name and description methods * adding equipper interface, for anything that will equip or have active items * handle case where min and max are swapped, removed commented code * added property/stat resolution for magic, rare, set, and unique items * adding item generator which can roll for items using treasure class records * fixed item equivalency func being called in the wrong spot * added item spawning - added packet type for spawning items - added client/server handlers for SpawnItem packets - added map entity for items - added simpler item provider function in diablo2item package - added debug terminal command for spawning items
95 lines
1.7 KiB
Go
95 lines
1.7 KiB
Go
package diablo2item
|
|
|
|
import "github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
|
|
|
|
func NewItem(codes ...string) *Item {
|
|
var item *Item
|
|
|
|
var common, set, unique string
|
|
|
|
var prefixes, suffixes []string
|
|
|
|
for _, code := range codes {
|
|
if found := d2datadict.CommonItems[code]; found != nil {
|
|
common = code
|
|
continue
|
|
}
|
|
|
|
if found := d2datadict.SetItems[code]; found != nil {
|
|
set = code
|
|
continue
|
|
}
|
|
|
|
if found := d2datadict.UniqueItems[code]; found != nil {
|
|
unique = code
|
|
continue
|
|
}
|
|
|
|
if found := d2datadict.MagicPrefix[code]; found != nil {
|
|
if prefixes == nil {
|
|
prefixes = make([]string, 0)
|
|
}
|
|
|
|
prefixes = append(prefixes, code)
|
|
|
|
continue
|
|
}
|
|
|
|
if found := d2datadict.MagicSuffix[code]; found != nil {
|
|
if suffixes == nil {
|
|
suffixes = make([]string, 0)
|
|
}
|
|
|
|
suffixes = append(suffixes, code)
|
|
|
|
continue
|
|
}
|
|
}
|
|
|
|
if common != "" { // we will at least have a regular item
|
|
item = &Item{CommonCode: common}
|
|
|
|
if set != "" { // it's a set item
|
|
item.SetItemCode = set
|
|
return item.init()
|
|
}
|
|
|
|
if unique != "" { // it's a unique item
|
|
item.UniqueCode = unique
|
|
return item.init()
|
|
}
|
|
|
|
if prefixes != nil {
|
|
if len(prefixes) > 0 { // it's a magic or rare item
|
|
item.PrefixCodes = prefixes
|
|
}
|
|
}
|
|
|
|
if suffixes != nil {
|
|
if len(suffixes) > 0 { // it's a magic or rare item
|
|
item.SuffixCodes = suffixes
|
|
}
|
|
}
|
|
|
|
return item.init()
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// NewProperty creates a property
|
|
func NewProperty(code string, values ...int) *Property {
|
|
record := d2datadict.Properties[code]
|
|
|
|
if record == nil {
|
|
return nil
|
|
}
|
|
|
|
result := &Property{
|
|
record: record,
|
|
inputParams: values,
|
|
}
|
|
|
|
return result.init()
|
|
}
|