-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.go
151 lines (128 loc) · 2.44 KB
/
data.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
package main
import (
"strconv"
"log"
"encoding/json"
)
// TODO these probably don't have to be exportabl
type Encounter struct {
Player []Character
Npc []Character
Enemy []Monster
Env Environment
NumMonsters int
Difficulty Difficulty
Condition []Condition
}
func (encounter *Encounter) getString() string {
b, err := json.Marshal(encounter)
if err != nil {
log.Fatal("Couldn't serialize encounter!")
}
return string(b[:])
}
type Condition struct {
}
// TODO abstract implementing function pointers? too annoying?
func greaterThanEqualChallengeRating(cr string, otherCr string) bool {
crInt, err := strconv.Atoi(cr);
otherCrInt, err := strconv.Atoi(otherCr)
if err != nil {
log.Fatal("challenge ratings are non-numeric")
}
return crInt >= otherCrInt
}
type Monster struct {
Name string
Alignment string
Challenge_Rating string // challenge rating
env []Environment // places usually found
exp int // experience points award for defeat
Hit_Dice DamageRoll
Base_Stats BaseStats
Skills Skills
//Saves Saves
Damage_Vulnerabilities string
Damage_Immunities string
Special_Abilities []Action
Legendary_Actions []Action
Actions[] Action
}
type Action struct {
Name string
Desc string
Attack_Bonus int
Damage_Dice DamageRoll
Damage_Bonus int
}
type Skills struct {
// there has to be a better way to do this?
// at least with a java class, enum constructors...
Athletics int
Acrobatics int
Sleight_of_Hand int
Stealth int
Arcana int
History int
Investigation int
Nature int
Religion int
Animal_Handling int
Insight int
Medicine int
Perception int
Survival int
Deception int
Intimidation int
Performance int
Persuasion int
}
type DamageRoll struct {
rolls int
die int
}
type Environment int
const (
arctic Environment = iota
coastal
desert
forest
grassland
hill
mountain
swamp
underdark
underwater
urban
)
var Environments = []Environment {
arctic, coastal, desert, forest, grassland,
hill, mountain, swamp, underdark, underwater, urban}
type Difficulty int // encounter difficulty
const (
easy Difficulty = iota
medium
hard
deadly
)
type BaseStats struct {
Strength int
Charisma int
Constitution int
Wisdom int
Intelligence int
Dexterity int
}
type Saves struct { // statistics related to saving throws
Strength_Save int
Charisma_Save int
Constitution_Save int
Wisdom_Save int
Intelligence_Save int
Dexterity_Save int
}
type Character struct {
name string
level int
stats BaseStats
}