forked from ironarachne/world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsize.go
107 lines (96 loc) · 1.91 KB
/
size.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
package size
// Category is a general size category for creatures
type Category struct {
Name string
Level int
BaseHeight int // Base height in inches
BaseWeight int // Base weight in pounds
}
// Larger returns a category larger than the current one, or the current one if it's the biggest
func (category Category) Larger() Category {
categories := getAllSizeCategories()
for _, c := range categories {
if c.Level == category.Level+1 {
return c
}
}
return category
}
// Smaller returns a category smaller than the current one, or the current one if it's the smallest
func (category Category) Smaller() Category {
categories := getAllSizeCategories()
for _, c := range categories {
if c.Level == category.Level-1 {
return c
}
}
return category
}
func getAllSizeCategories() []Category {
return []Category{
{
Name: "fine",
Level: 1,
BaseHeight: 3,
BaseWeight: 1,
},
{
Name: "diminutive",
Level: 2,
BaseHeight: 9,
BaseWeight: 1,
},
{
Name: "tiny",
Level: 3,
BaseHeight: 20,
BaseWeight: 6,
},
{
Name: "small",
Level: 4,
BaseHeight: 36,
BaseWeight: 30,
},
{
Name: "medium",
Level: 5,
BaseHeight: 72,
BaseWeight: 200,
},
{
Name: "large",
Level: 6,
BaseHeight: 144,
BaseWeight: 1000,
},
{
Name: "huge",
Level: 7,
BaseHeight: 288,
BaseWeight: 14000,
},
{
Name: "gargantuan",
Level: 8,
BaseHeight: 576,
BaseWeight: 142000,
},
{
Name: "colossal",
Level: 9,
BaseHeight: 768,
BaseWeight: 250000,
},
}
}
// GetCategoryByName returns a size category based on name
func GetCategoryByName(name string) Category {
categories := getAllSizeCategories()
for _, c := range categories {
if c.Name == name {
return c
}
}
panic("Couldn't find size category for name " + name)
}