diff options
Diffstat (limited to 'internal/game/sys_technology.go')
| -rw-r--r-- | internal/game/sys_technology.go | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/internal/game/sys_technology.go b/internal/game/sys_technology.go index 9e6a635..c7214af 100644 --- a/internal/game/sys_technology.go +++ b/internal/game/sys_technology.go @@ -8,9 +8,9 @@ import ( "gopkg.in/yaml.v3" "thehouseoficarus/internal/behavior" + "thehouseoficarus/internal/combat" "thehouseoficarus/internal/net" "thehouseoficarus/internal/player" - "thehouseoficarus/internal/world" ) type TechEffects struct { @@ -44,8 +44,7 @@ var techByID map[string]*TechDef func (g *Game) LoadTechs() error { dir := filepath.Join(g.DataDir, "techs") AllTechs = nil - techByID = make(map[string]*TechDef) - behavior.WalkYAMLDir(dir, func(path, id string, data []byte) error { + if err := behavior.WalkYAMLDir(dir, func(path, id string, data []byte) error { var t TechDef if err := yaml.Unmarshal(data, &t); err != nil { return nil @@ -53,7 +52,9 @@ func (g *Game) LoadTechs() error { t.ID = id AllTechs = append(AllTechs, &t) return nil - }) + }); err != nil { + return err + } techByID = make(map[string]*TechDef, len(AllTechs)) for _, t := range AllTechs { techByID[t.ID] = t @@ -199,8 +200,8 @@ func (g *Game) tryRecharge(sess *net.Session, p *player.Player, input string) bo return false } -func (g *Game) applyTechProtection(p *player.Player, mob *world.MobInstance, dmg int) int { - return g.damageAfterTechProtection(p, mob.AttackType, dmg) +func (g *Game) applyTechProtection(p *player.Player, attackType string, dmg int) int { + return g.damageAfterTechProtection(p, attackType, dmg) } // damageAfterTechProtection reduces incoming damage if the player has the @@ -220,16 +221,16 @@ func (g *Game) damageAfterTechProtection(p *player.Player, attackType string, dm } if attackType == "" { - attackType = "crush" + attackType = combat.DefaultAttackType } var protectTechID string - switch attackType { - case "stab", "slash", "crush": + switch { + case combat.IsMeleeType(attackType): protectTechID = "protect_melee" - case "ranged": + case attackType == combat.AttackRanged: protectTechID = "protect_ranged" - case "science": + case attackType == combat.AttackScience: protectTechID = "protect_science" } |
