aboutsummaryrefslogtreecommitdiff
path: root/internal/combat/types.go
blob: bb2a89719bb5b1e0af845944fefbbcc65dc37fe3 (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
package combat

// Attack type identifiers shared across combat, mobs, weapons, hazards and
// validation. These are the canonical string values stored in YAML.
const (
	AttackStab    = "stab"
	AttackSlash   = "slash"
	AttackCrush   = "crush"
	AttackRanged  = "ranged"
	AttackScience = "science"

	// DefaultAttackType is the fallback when no attack type is specified.
	DefaultAttackType = AttackCrush
)

// MeleeAttackTypes lists the melee attack types (exactly one of which a mob
// must have).
var MeleeAttackTypes = []string{AttackStab, AttackSlash, AttackCrush}

// AllAttackTypes lists every valid attack type.
var AllAttackTypes = []string{AttackStab, AttackSlash, AttackCrush, AttackRanged, AttackScience}

// IsMeleeType reports whether t is a melee attack type.
func IsMeleeType(t string) bool {
	return t == AttackStab || t == AttackSlash || t == AttackCrush
}

// IsValidAttackType reports whether t is any recognized attack type.
func IsValidAttackType(t string) bool {
	switch t {
	case AttackStab, AttackSlash, AttackCrush, AttackRanged, AttackScience:
		return true
	default:
		return false
	}
}