Still working on spell conversion scripting to take items with spell effects into raw stats

This commit is contained in:
2024-07-04 01:03:24 -04:00
parent f32f073c26
commit 45638563ff
3 changed files with 103 additions and 3 deletions

2
go.mod
View File

@@ -4,11 +4,11 @@ go 1.22.4
replace github.com/araxiaonline/endgame-item-generator/models => ../models
require github.com/go-sql-driver/mysql v1.8.1
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/jmoiron/sqlx v1.4.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/thoas/go-funk v0.9.3 // indirect
)

8
go.sum
View File

@@ -1,5 +1,6 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
@@ -8,3 +9,10 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View File

@@ -5,6 +5,7 @@ import (
"strconv"
"github.com/araxiaonline/endgame-item-generator/utils"
"github.com/thoas/go-funk"
)
var SpellEffects = [...]int{
@@ -41,6 +42,22 @@ var SpellAuraEffects = [...]int{
189, // Modifies Armor Rating
}
var SpellEffectStatMap = map[int][]int{
10: {41},
17: {38, 39},
22: {14},
23: {15},
58: {38, 39},
67: {1},
}
// result of a stat conversion from spell to raw stats on item
type SpellStat struct {
StatType int
StatValue int
Budget int
}
type Spell struct {
ID int `db:"ID"`
Name string `db:"Name_Lang_enUS"`
@@ -82,7 +99,82 @@ func (db Database) GetSpell(id int) (Spell, error) {
return Spell{}, fmt.Errorf("failed to get spell: %v", err)
}
// log.Printf("%s was found for id %d", spell.Name, spell.ID)
return spell, nil
}
func (s Spell) effectNeedsScaled() bool {
if s.Effect1 == 0 {
return false
}
for _, effect := range SpellEffects {
if s.Effect1 == effect || s.Effect2 == effect || s.Effect3 == effect {
return true
}
}
return false
}
func (s Spell) auraEffectNeedsScaled() bool {
if s.EffectAura1 == 0 {
return false
}
for _, effect := range SpellAuraEffects {
if s.EffectAura1 == effect || s.EffectAura2 == effect || s.EffectAura3 == effect {
return true
}
}
return false
}
func (s Spell) HasAuraEffect() bool {
return s.EffectAura1 != 0 || s.EffectAura2 != 0 || s.EffectAura3 != 0
}
// If a spell effect can be converted over to a primary stat addition
func EffectCanBeConv(effect int) bool {
statMods := [...]int{17, 10, 22, 23, 58}
return funk.Contains(statMods, effect)
}
func AuraEffectCanBeConv(effect int) bool {
statMods := [...]int{13, 22, 34, 85, 99, 107, 115, 124, 135, 189}
return funk.Contains(statMods, effect)
}
func (s Spell) ConvertToStats() ([]SpellStat, error) {
stats := []SpellStat{}
if s.Effect1 == 0 && s.EffectAura1 == 0 {
fmt.Print("Spell does not have an effect1 or autaEffect1")
return stats, nil
}
if EffectCanBeConv(s.Effect1) {
stats = append(stats, SpellStat{
StatType: SpellEffectStatMap[s.Effect1][0],
StatValue: s.EffectBasePoints1,
Budget: s.EffectBonusMultiplier1,
})
}
if s.Effect2 != 0 && EffectCanBeConv(s.Effect2) {
stats = append(stats, SpellStat{
StatType: SpellEffectStatMap[s.Effect2][0],
StatValue: s.EffectBasePoints2,
Budget: s.EffectBonusMultiplier2,
})
}
if s.Effect3 != 0 && EffectCanBeConv(s.Effect3) {
stats = append(stats, SpellStat{
StatType: SpellEffectStatMap[s.Effect3][0],
StatValue: s.EffectBasePoints3,
Budget: s.EffectBonusMultiplier3,
})
}
return stats, nil
}