mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-13 12:06:31 -05:00
bfd3f1046d
* 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
84 lines
1.9 KiB
Go
84 lines
1.9 KiB
Go
package diablo2stats
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2data/d2datadict"
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2stats"
|
|
)
|
|
|
|
const (
|
|
monsterNotFound = "{Monster not found!}"
|
|
)
|
|
|
|
func getHeroMap() []d2enum.Hero {
|
|
return []d2enum.Hero{
|
|
d2enum.HeroAmazon,
|
|
d2enum.HeroSorceress,
|
|
d2enum.HeroNecromancer,
|
|
d2enum.HeroPaladin,
|
|
d2enum.HeroBarbarian,
|
|
d2enum.HeroDruid,
|
|
d2enum.HeroAssassin,
|
|
}
|
|
}
|
|
|
|
func stringerUnsignedInt(sv d2stats.StatValue) string {
|
|
return fmt.Sprintf("%d", sv.Int())
|
|
}
|
|
|
|
func stringerUnsignedFloat(sv d2stats.StatValue) string {
|
|
return fmt.Sprintf("%.2f", sv.Float())
|
|
}
|
|
|
|
func stringerEmpty(_ d2stats.StatValue) string {
|
|
return ""
|
|
}
|
|
|
|
func stringerIntSigned(sv d2stats.StatValue) string {
|
|
return fmt.Sprintf("%+d", sv.Int())
|
|
}
|
|
|
|
func stringerIntPercentageSigned(sv d2stats.StatValue) string {
|
|
return fmt.Sprintf("%+d%%", sv.Int())
|
|
}
|
|
|
|
func stringerIntPercentageUnsigned(sv d2stats.StatValue) string {
|
|
return fmt.Sprintf("%d%%", sv.Int())
|
|
}
|
|
|
|
func stringerClassAllSkills(sv d2stats.StatValue) string {
|
|
heroIndex := sv.Int()
|
|
|
|
heroMap := getHeroMap()
|
|
classRecord := d2datadict.CharStats[heroMap[heroIndex]]
|
|
|
|
return d2common.TranslateString(classRecord.SkillStrAll)
|
|
}
|
|
|
|
func stringerClassOnly(sv d2stats.StatValue) string {
|
|
heroMap := getHeroMap()
|
|
heroIndex := sv.Int()
|
|
classRecord := d2datadict.CharStats[heroMap[heroIndex]]
|
|
classOnlyKey := classRecord.SkillStrClassOnly
|
|
|
|
return d2common.TranslateString(classOnlyKey)
|
|
}
|
|
|
|
func stringerSkillName(sv d2stats.StatValue) string {
|
|
skillRecord := d2datadict.SkillDetails[sv.Int()]
|
|
return skillRecord.Skill
|
|
}
|
|
|
|
func stringerMonsterName(sv d2stats.StatValue) string {
|
|
for key := range d2datadict.MonStats {
|
|
if d2datadict.MonStats[key].ID == sv.Int() {
|
|
return d2datadict.MonStats[key].NameString
|
|
}
|
|
}
|
|
|
|
return monsterNotFound
|
|
}
|