This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathaptitude.go
85 lines (79 loc) · 1.76 KB
/
aptitude.go
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
type aptitude int
const (
AptObstruction aptitude = iota
AptAgile
AptFast
AptHealthy
AptStealthyMovement
AptScales
AptStealthyLOS
AptMagic
AptConfusingGas
AptSmoke
AptHear
AptTeleport
AptLignification
AptStrong
)
const NumApts = int(AptStrong) + 1
func (ap aptitude) String() string {
var text string
switch ap {
case AptObstruction:
text = "The earth occasionally blows monsters away when hurt."
case AptAgile:
text = "You are agile."
case AptFast:
text = "You move fast."
case AptHealthy:
text = "You are healthy."
case AptStealthyMovement:
text = "You move stealthily."
case AptScales:
text = "You are covered by scales."
case AptHear:
text = "You have good ears."
case AptStrong:
text = "You are strong."
case AptMagic:
text = "You have big magic reserves."
case AptStealthyLOS:
text = "The shadows follow you. (reduced LOS)"
case AptConfusingGas:
text = "You occasionally release some confusing gas when hurt."
case AptSmoke:
text = "You occasionally get energetic and emit smoke clouds when hurt."
case AptLignification:
text = "Nature occasionally lignifies your foes when hurt."
case AptTeleport:
text = "You occasionally teleport your foes when hurt."
}
return text
}
func (g *game) RandomApt() (aptitude, bool) {
count := 0
var apt aptitude
for {
count++
if count > 1000 {
break
}
r := RandInt(NumApts)
apt = aptitude(r)
if g.Player.Aptitudes[apt] {
continue
}
return apt, true
}
return apt, false
}
func (g *game) ApplyAptitude(ap aptitude) {
if g.Player.Aptitudes[ap] {
// should not happen
g.PrintStyled("Hm… You already have that aptitude. "+ap.String(), logError)
return
}
g.Player.Aptitudes[ap] = true
g.PrintStyled("You feel different. "+ap.String(), logSpecial)
}