-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
258 lines (249 loc) · 16 KB
/
root.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
package main
// DO NOT EDIT: This file was generated by vugu. Please regenerate instead of editing or add additional code in a separate file.
import "fmt"
import "reflect"
import "github.com/vugu/vugu"
type RootData struct {
NumSides int `default:"20"`
NumRows int `default:"5"`
TotalRollCount *int `default:"0"`
MinNumberOfRolls int
IsMinNumRollsMet bool `default:"false"`
BalanceThreshold float64 `default:"0.0"` // Threshold for the SumSquaredError.
ExpectedRollsPerSide float64 `default:"0.0"` // `TotalRollCount/NumberOfSides`
SumSquaredError float64 `default:"0.0"` // Total of all options SquaredError different from expected roll count. aka 'SSE'
IsBalanced bool `default:"false"` // SSE <= BalanceThreshold
}
func (comp *Root) NewData(props vugu.Props) (interface{}, error) {
ret := &RootData{
TotalRollCount: &state.TotalRollCount,
}
return ret, nil
}
var _ vugu.ComponentType = (*Root)(nil)
func (comp *Root) BuildVDOM(dataI interface{}) (vdom *vugu.VGNode, css *vugu.VGNode, reterr error) {
data := dataI.(*RootData)
_ = data
_ = fmt.Sprint
_ = reflect.Value{}
event := vugu.DOMEventStub
_ = event
css = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "style", DataAtom: vugu.VGAtom(458501), Namespace: "", Attr: []vugu.VGAttribute(nil)}
css.AppendChild(&vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\tdiv.root {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\toverflow: hidden;\n\t\tbackground-size: cover;\n\t\tposition: absolute;\n\t\tdisplay: grid;\n\t\tgrid-template-rows: 80% 1fr;\n\t\tplace-items: center;\n\t}\n\n\tdiv.root:before {\n\t\tcontent: close-quote;\n\t\tbackground: inherit;\n\t\tposition: absolute;\n\t\tleft: -10px;\n\t\tright: -10px;\n\t\ttop: -10px;\n\t\tbottom: -10px;\n\t\tbox-shadow: inset 0 0 0 2000px rgba(255,255,255,0.1);\n\t\tfilter: blur(1px);\n\t}\n\n\t.stat-score-block {\n\t\tposition: relative;\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\t\tjustify-content: center;\n\t\tbackground: 50% transparent url(https://www.dndbeyond.com/Content/Skins/Waterdeep/images/character-sheet/content-frames/ac.svg) no-repeat;\n\t\tbackground-size: contain;\n\t\ttext-align: center;\n\t\tcolor: #838383;\n\t\tfont-size: large;\n\t\tline-height: 1;\n\t\tfilter: drop-shadow(1px 2px 2px black);\n\t}\n\n\t.stat-score-block-data {\n\t\tfont-weight: 700;\n\t\tfont-size: 130%;\n\t\tletter-spacing: -1px;\n\t\tcolor: black;\n\t}\n\n\t.stat-score-block-row {\n\t\twidth: 100%;\n\t\theight: 100%;\n\t\tdisplay: grid;\n\t\tjustify-content: space-around;\n\t\tgrid-row-start: 2;\n\t\tgrid-row-end: 3;\n\t\tgrid-template-rows: 1fr;\n\t\tgrid-template-columns: repeat(6, 1fr);\n\t}\n\n\n\n", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)})
var n *vugu.VGNode
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "root"}}}
vdom = n
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "dice-sides-grid", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
n.Props = vugu.Props{
"rows": state.NumRows,
"sides": state.NumSides,
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-row"}}}
parent.AppendChild(n)
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Total Rolls:")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprint(*data.TotalRollCount))
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Min # Rolls: ")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprint(state.DieBalanceComputationValues.DieConstants.MinNumberOfRolls))
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if !state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Balance Threshold: ")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if !state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprint("Min # Rolls Not Met"))
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Balance Threshold: ")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprintf("%.2f", state.DieBalanceComputationValues.BalanceThreshold))
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if !state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Expected Rolls/Side: ")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if !state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprint("Min # Rolls Not Met"))
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Expected Rolls/Side: ")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprintf("%.2f", state.DieBalanceComputationValues.ExpectedRollsPerSide))
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if !state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Sum Squared Error: ")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if !state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprint("Min # Rolls Not Met"))
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Sum Squared Error: ")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprintf("%.2f", state.DieBalanceComputationValues.SumSquaredError))
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if !state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Balanced: ")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if !state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprint("Min # Rolls Not Met"))
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint("Balanced: ")
{
parent := n
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
if state.IsMinNumRollsMet {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "stat-score-block-data"}}}
parent.AppendChild(n)
n.InnerHTML = fmt.Sprint(fmt.Sprint(state.DieBalanceComputationValues.IsBalanced))
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n\t", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
for i := 0; i < 15; i++ {
n = &vugu.VGNode{Type: vugu.VGNodeType(3), Data: "div", DataAtom: vugu.VGAtom(92931), Namespace: "", Attr: []vugu.VGAttribute{vugu.VGAttribute{Namespace: "", Key: "class", Val: "firefly"}}}
parent.AppendChild(n)
}
n = &vugu.VGNode{Type: vugu.VGNodeType(1), Data: "\n", DataAtom: vugu.VGAtom(0), Namespace: "", Attr: []vugu.VGAttribute(nil)}
parent.AppendChild(n)
}
return
}
type Root struct {}
func init() { vugu.RegisterComponentType("root", &Root{}) }