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 10
/
Copy pathstats.go
216 lines (207 loc) · 6.27 KB
/
stats.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
package main
import (
"github.com/anaseto/gruid"
)
type stats struct {
Story []string
Killed int
KilledMons map[monsterKind]int
Moves int
Waits int
Jumps int
WallJumps int
ReceivedHits int
Dodges int
MagarasUsed int
DMagaraUses [MaxDepth + 1]int
UsedStones int
UsedMagaras map[magaraKind]int
Damage int
DDamage [MaxDepth + 1]int
DExplPerc [MaxDepth + 1]int
DSleepingPerc [MaxDepth + 1]int
DKilledPerc [MaxDepth + 1]int
Burns int
Digs int
Rest int
DRests [MaxDepth + 1]int
Turns int
TWounded int
TMWounded int
TMonsLOS int
NSpotted int
NUSpotted int
DSpotted [MaxDepth + 1]int
DUSpotted [MaxDepth + 1]int
DUSpottedPerc [MaxDepth + 1]int
Achievements map[achievement]int
AtNotablePos map[gruid.Point]bool
HarmonicMagUse int
OricMagUse int
FireUse int
DestructionUse int
OricTelUse int
ClimbedTree int
TableHides int
HoledWallsCrawled int
DoorsOpened int
BarrelHides int
Extinguishments int
Lore map[int]bool
Statuses map[status]int
StolenBananas int
TimesPushed int
TimesBlinked int
TimesBlocked int
}
func (g *game) TurnStats() {
g.Stats.Turns++
g.DepthPlayerTurn++
if g.Player.HP < g.Player.HPMax() {
g.Stats.TWounded++
}
if g.MonsterInLOS() != nil {
g.Stats.TMonsLOS++
if g.Player.HP < g.Player.HPMax() {
g.Stats.TMWounded++
}
}
}
func (g *game) LevelStats() {
free := 0
exp := 0
it := g.Dungeon.Grid.Iterator()
for it.Next() {
c := cell(it.Cell())
if c.IsWall() || terrain(c) == ChasmCell {
continue
}
free++
if explored(c) {
exp++
}
}
g.Stats.DExplPerc[g.Depth] = exp * 100 / free
if g.Stats.DExplPerc[g.Depth] > 93 {
AchNoviceExplorer.Get(g)
}
if g.Depth >= 5 && g.Stats.DExplPerc[g.Depth] > 93 && g.Stats.DExplPerc[g.Depth-1] > 93 && g.Stats.DExplPerc[g.Depth-2] > 93 {
AchInitiateExplorer.Get(g)
}
if g.Depth >= 8 && g.Stats.DExplPerc[g.Depth] > 93 && g.Stats.DExplPerc[g.Depth-1] > 93 && g.Stats.DExplPerc[g.Depth-2] > 93 &&
g.Stats.DExplPerc[g.Depth-3] > 93 && g.Stats.DExplPerc[g.Depth-4] > 93 {
AchMasterExplorer.Get(g)
}
//g.Stats.DBurns[g.Depth] = g.Stats.CurBurns // XXX to avoid little dump info leak
nmons := len(g.Monsters)
kmons := 0
smons := 0
for _, mons := range g.Monsters {
if !mons.Exists() {
kmons++
continue
}
if mons.State == Resting {
smons++
}
}
g.Stats.DSleepingPerc[g.Depth] = smons * 100 / nmons
g.Stats.DKilledPerc[g.Depth] = kmons * 100 / nmons
g.Stats.DUSpottedPerc[g.Depth] = g.Stats.DUSpotted[g.Depth] * 100 / nmons
}
type achievement string
// Achievements.
const (
NoAchievement achievement = "Pitiful Death"
AchBananaCollector achievement = "Banana Collector"
AchHarmonistNovice achievement = "Harmonist Novice"
AchHarmonistInitiate achievement = "Harmonist Initiate"
AchHarmonistMaster achievement = "Harmonist Master"
AchNoviceOricCelmist achievement = "Oric Celmist Novice"
AchInitiateOricCelmist achievement = "Oric Celmist Initiate"
AchMasterOricCelmist achievement = "Oric Celmist Master"
AchUnstealthy achievement = "Unstealthy Gawalt"
AchStealthNovice achievement = "Stealth Novice"
AchStealthInitiate achievement = "Stealth Initiate"
AchStealthMaster achievement = "Stealth Master"
AchPyromancerNovice achievement = "Pyromancer Novice"
AchPyromancerInitiate achievement = "Pyromancer Initiate"
AchPyromancerMaster achievement = "Pyromancer Master"
AchDestructorNovice achievement = "Destructor Novice"
AchDestructorInitiate achievement = "Destructor Initiate"
AchDestructorMaster achievement = "Destructor Master"
AchTeleport achievement = "Oric Teleport Maniac"
AchCloak achievement = "Dressed Gawalt"
AchAmulet achievement = "Protective Charm"
AchRescuedShaedra achievement = "Rescued Shaedra"
AchRetrievedArtifact achievement = "Recovered Gem Portal Artifact"
AchAcrobat achievement = "Acrobat"
AchTree achievement = "Tree Climber"
AchTable achievement = "Under Table Gawalt"
AchHole achievement = "Hole Crawler"
AchDoors achievement = "Door Opener"
AchBarrels achievement = "Barrel Enthousiast"
AchExtinguisher achievement = "Light Extinguisher"
AchLoreStudent achievement = "Lore student"
AchLoremaster achievement = "Loremaster"
AchNoviceExplorer achievement = "Novice Explorer"
AchInitiateExplorer achievement = "Initiate Explorer"
AchMasterExplorer achievement = "Master Explorer"
AchAssassin achievement = "Assassin"
AchInsomniaNovice achievement = "Insomnia Novice"
AchInsomniaInitiate achievement = "Insomnia Initiate"
AchInsomniaMaster achievement = "Insomnia Master"
AchSleepy achievement = "Sleepy Gawalt"
AchAntimagicNovice achievement = "Antimagic Novice"
AchAntimagicInitiate achievement = "Antimagic Initiate"
AchAntimagicMaster achievement = "Antimagic Master"
)
func (ach achievement) Get(g *game) {
if g.Stats.Achievements[ach] == 0 {
g.Stats.Achievements[ach] = g.Turn
g.PrintfStyled("Achievement: %s.", logSpecial, ach)
g.StoryPrintf("Achievement: %s", ach)
}
}
func (c cell) ReachNotable() bool {
switch terrain(c) {
case TreeCell, TableCell, HoledWallCell, DoorCell, BarrelCell:
return true
default:
return false
}
}
func (g *game) Reach(p gruid.Point) {
if g.Stats.AtNotablePos[p] {
return
}
g.Stats.AtNotablePos[p] = true
c := g.Dungeon.Cell(p)
switch terrain(c) {
case TreeCell:
g.Stats.ClimbedTree++
if g.Stats.ClimbedTree == 12 {
AchTree.Get(g)
}
case TableCell:
g.Stats.TableHides++
if g.Stats.TableHides == 12 {
AchTable.Get(g)
}
case HoledWallCell:
g.Stats.HoledWallsCrawled++
if g.Stats.HoledWallsCrawled == 12 {
AchHole.Get(g)
}
case DoorCell:
g.Stats.DoorsOpened++
if g.Stats.DoorsOpened == 100 {
AchDoors.Get(g)
}
case BarrelCell:
g.Stats.BarrelHides++
if g.Stats.BarrelHides == 20 {
AchBarrels.Get(g)
}
}
}