/
cult.hoon
394 lines (394 loc) · 10.7 KB
/
cult.hoon
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
:: cult - make a murder cult, the easy way.
:: by quartus
::
:: v.0.1.0
::
:: cult's state is called cargo.
::
:: rituals are for those with elaborate rites
:: for a cut and dry cult use %cult-easy mark
::
:: using cult:
:: 1. copy /cult/lib, ../sur to your desk's /lib, /sur
:: 2. import cult in agent with `/= cult /cult/cult`
:: 3. expect a subscription on `/~/cult` in your agent
:: 4. call cult `%- (agent:cult ~ ~)` as default case
:: - alternatively, call agent:cult with a club babe
:: 5. emit a cage `[%cult-easy !>(easy)]` on `/~/cult`
:: - alternatively, use native facts that babe knows
:: 6. user adds to `clique` with `cult-dead` mark poke
:: - alternatively, see our /cult/mar/cult/dead.hoon
:: 7. cult handles the rest, making or modifying group
::
:: need help? join ~mister-hilper-dozzod-dalten/quartus
::
/- gup=groups
/+ verb
::
|%
::
:: cargo objects
:: $clique - maps key to cult
:: $ritual - elaborage change
:: $relics - for failed cages
::
+$ clique (map * term)
+$ ritual (map mark $-(vase (unit easy)))
+$ retire (map mark *)
+$ relics (map @da cage)
+$ augury (unit $-(* json))
::
:: $cow - cult-dead mark
:: [%del *] :: removes a key from clique
:: [%add * term] :: correlates noun with term
::
:: $skull - $cows subset
:: [%kik @da] :: reprocess relic, maybe new ritual
:: [%kil @da] :: remove one relic from the chamber
::
+$ cow
$% [%del *]
[%add * term]
skull
==
::
+$ skull
$% [%kik @da]
[%kil @da]
==
::
:: $easy - use cult-easy
:: $diff - how to treat em
::
+$ easy [* diff] :: the key! induct them
::
+$ diff
$% [%put (set ship)] :: induct new initiates
[%pak (set ship)] :: only these initiates
[%pop (set ship)] :: excommunication now!
==
::
:: +agent:cult - what's he up to? he looks weird
::
++ agent
|= $: club=clique :: just a social club
babe=ritual :: a babe-lon working
crow=augury :: divine divinations
==
^- $-(agent:gall agent:gall)
|^ agent
::
+$ card card:agent:gall
+$ versioned-cargo $%(cargo-0 cargo-1)
+$ cargo-0 [%0 =clique ritual=retire =relics]
+$ cargo-1 [%1 =clique =relics]
::
++ agent
|= inner=agent:gall
=| cargo-1
=* cargo -
%+ verb |
^- agent:gall
|_ dish=bowl:gall
+* this .
ho ~(. helps dish cargo)
og ~(. inner dish)
now (scot %da now.dish)
our (scot %p our.dish)
::
++ on-peek
|= =path
^- (unit (unit cage))
:: ~> %bout.[0 '%cult +on-peek']
?: =(/x/~/cult/state path)
``noun+!>(cargo)
(on-peek:og path)
++ on-arvo
|= [wire sign-arvo]
^- (quip card _this)
:: ~> %bout.[0 '%cult +on-arvo']
=^ cards inner (on-arvo:og +<)
[cards this]
++ on-fail
|= [term tang]
^- (quip card _this)
=^ cards inner (on-fail:og +<)
[cards this]
++ on-leave
|= path
^- (quip card _this)
=^ cards inner (on-leave:og +<)
[cards this]
::
++ on-watch
|= path
^- (quip card _this)
?: ?=([%~.~ %augury ~] +<)
?~ crow `this
[~(all omen:ho u.crow) this]
=^ cards inner (on-watch:og +<)
[cards this]
::
++ on-init
:: ~> %bout.[0 '%cult +on-init']
^- (quip card _this)
=. clique (~(uni by clique) club)
=^ cards inner on-init:og
[[hear:ho cards] this]
++ on-save !>([[%cult cargo] on-save:og])
++ on-load
|= ole=vase
:: ~> %bout.[0 '%cult +on-load']
^- (quip card _this)
?. ?=([[%cult *] *] q.ole)
=. clique club
=^ cards inner (on-load:og ole)
[[hear:ho cards] this]
=+ !<([[%cult old=versioned-cargo] oil=vase] ole)
?- -.old
%0
=. cargo [clique relics]:old
=^ cards inner (on-load:og oil)
[[hear:ho cards] this]
%1
=. cargo old
=^ cards inner (on-load:og oil)
[[hear:ho cards] this]
==
++ on-agent
|= [wir=wire sig=sign:agent:gall]
?. ?=([%~.~ %cthulhu ~] wir)
=^ cards inner (on-agent:og wir sig)
[cards this]
?- -.sig
%watch-ack
[?~(p.sig ~ [hear:ho]~) this]
::
%poke-ack
~& >> [cult+dap.dish %unexpected-poke-ack wir]
`this
::
%kick
[[hear:ho]~ this]
::
%fact
=^ cards cargo
(go-easy:go:ho cage.sig)
[cards this]
==
::
++ on-poke
|= [=mark =vase]
:: ~> %bout.[0 '%cult +on-poke']
?. ?=(%cult-dead mark)
=^ cards inner
(on-poke:og mark vase)
[cards this]
=/ calf=cow !<(cow vase)
?- -.calf
%del
~& [%cult-remove +.calf]
:_ this(clique (~(del by clique) +.calf))
?~(crow ~ (~(del omen:ho u.crow) +.calf))
::
%add
~& [%cult-form +>.calf %for +<.calf]
:_ this(clique (~(put by clique) +.calf))
?~(crow ~ (~(add omen:ho u.crow) +.calf))
::
%kik `this :: TODO: make functional
%kil `this :: TODO: make functional
==
--
::
++ helps
|_ [dish=bowl:gall cargo=cargo-1]
+* dis .
++ hear
^- card
=- [%pass /~/cthulhu %agent -]
[[our.dish dap.dish] [%watch /~/cult]]
++ omen
=, enjs:format
|_ lock=$-(* json)
++ del
|= key=*
=- [%give %fact [/~/augury]~ json+!>(-)]~
(frond del+(frond key+(lock key)))
++ add
|= [key=* vault=@tas]
=- [%give %fact [/~/augury]~ json+!>(-)]~
%+ frond %add
%- pairs
~[key+(lock key) vault+s/(scot %tas vault)]
++ all
=- [%give %fact [/~/augury]~ json+!>(-)]~
%+ frond %set
:- %a
%+ turn ~(tap by clique.cargo)
|= [kex=* vault=term]
%- pairs
~[key+(lock kex) vault+s/(scot %tas vault)]
--
:: +go - roll ur own cults
::
:: +go-emit - add card to cards
:: +go-emil - add list of cards
:: +go-abet - and state changes
:: +go-dick - inspect the group
:: +go-form - maybe form a cult
:: +go-diff - handle easy diffs
:: +go-easy - start cult engine
::
++ go
|_ $: =flag:gup
real=?
door=(unit cordon:gup)
team=(set ship)
cord=[pend=(set ship) act=(set ship)]
cards=(list card)
==
+* now (scot %da now.dish)
our (scot %p our.dish)
go .
::
++ go-emit |=(=card go(cards [card cards]))
++ go-emil
|=(lac=(list card) go(cards (welp lac cards)))
++ go-abet
^- (quip card _cargo)
[(flop cards) cargo]
::
++ go-easy
|= egg=cage
^- (quip card _cargo)
|^
?: ?=(%cult-easy p.egg)
=+ ease=!<(easy q.egg)
(over ease)
?~ fix=(~(get by babe) p.egg)
=. relics.cargo
(~(put by relics.cargo) now.dish egg)
go-abet
=+ hard=`(unit easy)`(u.fix q.egg)
?~ hard go-abet
(over u.hard)
::
++ over
|= ease=easy
?~ turn=(~(get by clique.cargo) -.ease)
go-abet
=~
:- ease=`_ease`ease
=~ go(flag [our.dish u.turn])
go-dick
go-form
==
(go-diff +.ease)
go-abet
==
--
::
++ go-dick
^+ go
=/ gups=groups:gup
.^(groups:gup %gx /[our]/groups/[now]/groups/noun)
?~ gup=(~(get by gups) flag)
go(real %.n, door ~)
~| [%bad-group-state flag cordon.u.gup]
?> ?=(%shut -.cordon.u.gup)
%= go
real %.y
door `cordon.u.gup
::
team
(~(del in ~(key by fleet.u.gup)) our.dish)
::
cord
[pend.cordon.u.gup ask.cordon.u.gup]
==
::
++ go-form
^+ go
?: real go
=; cag=cage
%- go-emit
[%pass /gnosis/[now] %agent [our.dish %groups] %poke cag]
:- %group-create
!> ^- create:gup
:* q.flag
'a cult'
'keep it secret, sorta'
'https://freedom-club.sfo2.digitaloceanspaces.com/props/quartus/long-logo/ab_Quartus-05_only.png'
['#bb2649' [%shut ~ ~] ~ %|]
==
::
++ go-diff
|= d=diff
^+ go
?- -.d
%pak
=; punch=$-(action:gup card)
=/ pip=(set ship) (~(dif in team) +.d) :: ships to kick
=/ pil=(set ship) :: pends to cancel
(~(dif in pend.cord) +.d)
=/ pit=(set ship) :: invites to send
%. (sy ~[our.dish])
~(dif in (~(dif in +.d) team))
=| caz=(list card)
%- go-emil
=? caz
?=(^ pit)
:_ caz
%- punch
^- action:gup
:+ flag now.dish
[%cordon [%shut [%add-ships %pending pit]]]
=? caz
?=(^ pil)
:_ caz
%- punch
^- action:gup
:+ flag now.dish
[%cordon [%shut [%del-ships %pending pil]]]
=? caz
?=(^ pip)
:_ caz
%- punch
^- action:gup
[flag [now.dish [%fleet pip [%del ~]]]]
caz
|= a=action:gup
:^ %pass /gnosis/[now] %agent
[[our.dish %groups] %poke %group-action !>(a)]
::
%put
=; cag=cage
%- go-emit
[%pass /gnosis/[now] %agent [our.dish %groups] %poke cag]
=. +.d (~(del in +.d) our.dish)
:- %group-action
!> ^- action:gup
:+ flag now.dish
[%cordon [%shut [%add-ships %pending +.d]]]
::
%pop
=; [cag=cage caz=cage]
%- go-emil
:~ [%pass /gnosis/[now] %agent [our.dish %groups] %poke cag]
[%pass /gnosis/[now] %agent [our.dish %groups] %poke caz]
==
=. +.d (~(del in +.d) our.dish)
:-
:- %group-action
!> ^- action:gup
[flag [now.dish [%fleet +.d [%del ~]]]]
:- %group-action
!> ^- action:gup
:+ flag now.dish
[%cordon [%shut [%del-ships %pending +.d]]]
==
--
--
--
--