aboutsummaryrefslogtreecommitdiff
path: root/internal/game/core_equip.go
blob: 02b834845e1767191895fdde6ed499d031ace48f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package game

import (
	"thehouseoficarus/internal/object"
	"thehouseoficarus/internal/player"
)

func (g *Game) playerEquipBonuses(p *player.Player) object.ItemStats {
	var totals object.ItemStats
	for _, itemID := range p.Equipment {
		def, err := g.ItemStore.Load(itemID)
		if err != nil {
			continue
		}
		totals.StabAttack += def.Stats.StabAttack
		totals.SlashAttack += def.Stats.SlashAttack
		totals.CrushAttack += def.Stats.CrushAttack
		totals.ScienceAttack += def.Stats.ScienceAttack
		totals.RangedAttack += def.Stats.RangedAttack
		totals.StabDefense += def.Stats.StabDefense
		totals.SlashDefense += def.Stats.SlashDefense
		totals.CrushDefense += def.Stats.CrushDefense
		totals.ScienceDefense += def.Stats.ScienceDefense
		totals.RangedDefense += def.Stats.RangedDefense
		totals.StrengthBonus += def.Stats.StrengthBonus
		totals.RangedStrength += def.Stats.RangedStrength
		totals.ScienceDamage += def.Stats.ScienceDamage
		totals.TechnologyBonus += def.Stats.TechnologyBonus
	}
	return totals
}

func (g *Game) playerWeaponSpeed(p *player.Player) float64 {
	if itemID, ok := p.Equipment[object.SlotMainHand]; ok {
		def, err := g.ItemStore.Load(itemID)
		if err == nil && def.Speed > 0 {
			return def.Speed
		}
	}
	return 5.0
}