summaryrefslogtreecommitdiff
path: root/stats/ancients.go
blob: 16ea207f8f53e4cc521330b3f27491c4c34ca178 (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
42
43
44
45
46
47
48
49
50
package stats

import (
	"sts2stats/model"
)

const (
	AncientKey = "ancient"
)

type AncientChoice struct {
	RunStat
	AncientOption
	ActIndex int
	ActName  string
	Chosen   bool
}

type AncientOption struct {
	Key  string
	Type string
}

func EnrichAncients(run model.Run, st RunStat) (opts []any, err error) {
	for actIndex, act := range run.MapPointHistory {
		for _, floor := range act {
			if floor.MapPointType != AncientKey {
				continue
			}

			for _, stat := range floor.PlayerStats {
				for _, choice := range stat.AncientChoice {

					opts = append(opts, &AncientChoice{
						AncientOption: AncientOption{
							Key:  choice.TextKey,
							Type: choice.Title.Table,
						},
						RunStat:  st,
						ActIndex: actIndex,
						ActName:  run.Acts[actIndex],
						Chosen:   choice.WasChosen,
					})
				}
			}

		}
	}
	return opts, nil
}