Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBackstabi authored Mar 28, 2024
2 parents e07fe68 + 6591927 commit d168dc5
Show file tree
Hide file tree
Showing 8 changed files with 486 additions and 203 deletions.
31 changes: 18 additions & 13 deletions sim/core/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type Item struct {
Stats stats.Stats // Stats applied to wearer
Quality proto.ItemQuality
SetName string // Empty string if not part of a set.
RandomPropPoints int32 // Used to rescale random suffix stats
RandomPropPoints int32 // Used to rescale random suffix stats

GemSockets []proto.GemColor
SocketBonus stats.Stats
Expand Down Expand Up @@ -322,6 +322,7 @@ func NewItem(itemSpec ItemSpec) Item {

if itemSpec.Reforging > 112 { // There is no id below 113
reforge := ReforgeStatsByID[itemSpec.Reforging]

if validateReforging(&item, reforge) {
item.Reforging = &reforge
} else {
Expand Down Expand Up @@ -352,10 +353,15 @@ func NewItem(itemSpec ItemSpec) Item {

func validateReforging(item *Item, reforging ReforgeStat) bool {
// Validate that the item can reforge these to stats
stats := stats.Stats{}
if item.RandomSuffix.ID != 0 {
stats = stats.Add(item.RandomSuffix.Stats.Multiply(float64(item.RandomPropPoints) / 10000.))
} else {
stats = stats.Add(item.Stats)
}
fromStatValid := false
for _, fromStat := range reforging.FromStat {
if item.Stats[fromStat] > 0 {
println("hello")
if stats[fromStat] > 0 {
fromStatValid = true
break
}
Expand All @@ -366,8 +372,7 @@ func validateReforging(item *Item, reforging ReforgeStat) bool {

toStatValid := false
for _, toStat := range reforging.ToStat {
if item.Stats[toStat] == 0 {
println("hello2")
if stats[toStat] == 0 {
toStatValid = true
break
}
Expand Down Expand Up @@ -419,19 +424,19 @@ func (equipment *Equipment) Stats() stats.Stats {

// Apply reforging
if item.Reforging != nil {
itemStats := item.Stats.Add(rawSuffixStats.Multiply(float64(item.RandomPropPoints) / 10000.))

reforgingChanges := stats.Stats{}
for _, fromStat := range item.Reforging.FromStat {
if equipStats[fromStat] > 0 {
reduction := math.Floor(equipStats[fromStat] * item.Reforging.Multiplier)
if itemStats[fromStat] > 0 {
reduction := math.Floor(itemStats[fromStat] * item.Reforging.Multiplier)
reforgingChanges[fromStat] = -reduction
for _, toStat := range item.Reforging.ToStat {
reforgingChanges[toStat] = reduction
}
}
}
for _, toStat := range item.Reforging.FromStat {
if equipStats[toStat] > 0 {
increase := math.Floor(equipStats[toStat] * item.Reforging.Multiplier)
reforgingChanges[toStat] = +increase
}
}

equipStats = equipStats.Add(reforgingChanges)
}

Expand Down
Loading

0 comments on commit d168dc5

Please sign in to comment.