aboutsummaryrefslogtreecommitdiff
path: root/internal/game/core_equip.go
blob: 7a1c1bc8438afe3a529c8f651200a2a6b0f26f85 (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/item"
	"thehouseoficarus/internal/player"
)

func (g *Game) playerEquipBonuses(p *player.Player) item.ItemStats {
	var totals item.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[item.SlotMainHand]; ok {
		def, err := g.ItemStore.Load(itemID)
		if err == nil && def.Speed() > 0 {
			return def.Speed()
		}
	}
	return 5.0
}