urbit/base/ape/oct1/core.hook

140 lines
9.3 KiB
Plaintext
Raw Normal View History

2015-05-19 07:27:39 +03:00
:: :: ::
2015-05-30 01:24:34 +03:00
:::: /hook/core/oct1/ape :::::: dependencies
2015-05-19 07:27:39 +03:00
:: :: ::
2015-05-21 02:54:49 +03:00
/? 310 :: arvo version
2015-05-30 01:24:34 +03:00
/- *sole, *oct1 :: structures
/+ sole, oct1 :: libraries
2015-05-19 07:27:39 +03:00
:: :: ::
2015-05-29 11:36:23 +03:00
:::: :::::: interfaces
2015-05-19 07:27:39 +03:00
!: :: ::
2015-05-29 11:36:23 +03:00
=> |% ::
2015-05-23 20:03:02 +03:00
++ axle ,[eye=face rem=(unit ship) gam=game] :: agent state
2015-05-08 20:56:30 +03:00
++ card $% [%diff lime] :: update
[%quit ~] :: cancel
[%peer wire dock path] :: subscribe
2015-05-21 02:54:49 +03:00
[%poke wire dock pear] :: send move
[%pull wire dock ~] :: unsubscribe
2015-05-08 20:56:30 +03:00
== ::
2015-05-26 05:15:08 +03:00
++ face (map bone sole-share) :: console state
2015-05-08 20:56:30 +03:00
++ lime $% [%sole-effect sole-effect] :: :sole update
2015-05-30 01:24:34 +03:00
[%oct1-update play] :: :oct1 update
2015-05-08 20:56:30 +03:00
== ::
++ move (pair bone card) :: cause and action
2015-05-30 01:24:34 +03:00
++ pear ,[%oct1-move point] :: outgoing move
2015-05-21 02:54:49 +03:00
-- ::
2015-05-29 11:36:23 +03:00
:: :: ::
:::: :::::: past state
:: :: ::
=> |% ::
++ agon (unit ,[(list move) axon]) :: boot argument
++ axon $%([%1 axle] [%0 axle-0]) :: all states
++ axle-0 ,[eye=face gam=game-0] :: old axle
++ game-0 ,[who=? box=board boo=board] :: old game
++ wake |= axon :- %1 ?- +<- %1 +<+ :: coarse upgrade
%0 [eye ~ [who ~^~ ~ box boo]:gam]:+<+ ::
== -- ::
:: :: ::
:::: :::::: parsers
:: :: ::
=> |% ::
2015-05-08 20:56:30 +03:00
++ colm (cook |=(a=@ (sub a '1')) (shim '1' '3')) :: row or column
++ come ;~(plug colm ;~(pfix fas colm)) :: coordinate
2015-05-21 02:54:49 +03:00
++ comb (pick come ;~(pfix sig (punt fed:ag))) :: all command input
2015-05-08 20:56:30 +03:00
++ cope |=(? ?:(+< (stag %| (cold ~ sig)) comb)) :: with wait mode
-- ::
2015-05-29 11:36:23 +03:00
:: :: ::
:::: :::::: process core
2015-05-26 05:15:08 +03:00
:: :: ::
2015-05-29 11:36:23 +03:00
|_ $: bowl
moz=(list move) :: pending actions
[%1 axle] :: process state, v1
== ::
:: :: ::
:::: :::::: process tools
2015-05-26 05:15:08 +03:00
:: :: ::
2015-05-29 11:36:23 +03:00
++ abet [(flop moz) .(moz ~)] :: resolve
++ bike $+(_. _+>) :: self-transformer
++ dish |=(cad=card %_(+> moz [[ost cad] moz])) :: request
2015-05-30 01:09:25 +03:00
++ done (echo eels |=(_. (dish:+< %quit ~))) :: cancel everyone
2015-05-29 22:45:05 +03:00
++ echo |= [all=(list sink) fun=bike] =+ old=+>+<- :: publish to all
|- ^+ +>.^$ ?~ all +>.^$(+<- old) ::
=> .(ost p.i.all, src q.i.all) ::
$(all t.all, +>.^$ (fun +>.^$)) ::
2015-05-29 11:36:23 +03:00
++ eels (~(tap by sup)) :: all clients
2015-05-30 01:24:34 +03:00
++ elfs (prey /oct1 +<-) :: network clients
2015-05-29 11:36:23 +03:00
++ elks (prey /sole +<-) :: console clients
++ emit |=(lime (dish %diff +<)) :: publish
++ flap |= [net=bike con=bike] :: update all clients
(echo:(echo elks con) elfs net) ::
++ here ~(. go src gam) :: game core
:: :: ::
:::: :::::: server logic
2015-05-26 05:15:08 +03:00
:: :: ::
2015-05-29 11:36:23 +03:00
++ fail ?:(soul (fect %bel ~) ~|(%invalid-move !!)) :: user error
++ fect |=(sole-effect (emit %sole-effect +<)) :: update console
2015-05-30 01:24:34 +03:00
++ fact |=(play (emit %oct1-update +<)) :: update partner
2015-05-29 11:36:23 +03:00
++ harp |=(game ?:(=(gam +<) +> wild(gam +<))) :: update game
++ heal |= old=axon =. +>+<+> (wake old) :: complete update
=- +>.$(gam -) ?. !=(1 +<-) gam ::
(muy:here (turn eels |=(sink q))) ::
++ hear |=(play ?-(+<- | (word +<+), & (harp +<+))) :: network update
++ kick |= point =^ dud gam ~(m at:here +<) ::
?.(dud fail wild:?~(rem kind (send +>-))) ::
++ kind =+(res:here ?~(- + (word(gam new:here) ->))) :: move result
2015-05-30 01:09:25 +03:00
++ plan |= (unit ship) ?~ +< stop(gam new:here) :: link/unlink
2015-05-29 11:36:23 +03:00
?^(rem fail link(rem +<)) ::
++ plot |= (each point (unit ship)) :: apply command
?-(+<- & (kick +<+), | (plan +<+)) ::
2015-05-30 01:24:34 +03:00
++ like |*(* [/oct1 [+.rem dap] +<]) :: friend message
++ link (dish peer/(like /oct1)) :: subscribe to friend
2015-05-29 11:36:23 +03:00
++ lose ?^(rem . tame(gam out:here)) :: lost subscriber
++ meet ?^(rem . tame(gam inn:here)) :: gained subscriber
2015-05-30 01:24:34 +03:00
++ prom (fect %pro %& %oct1 stat) :: update prompt
2015-05-29 11:36:23 +03:00
++ rend (turn `wall`tab:here |=(tape txt/+<)) :: table print
++ sawn lose(eye (~(del by eye) ost)) :: console unsubscribe
++ seen meet(eye (~(put by eye) ost *sole-share)) :: console subscribe
2015-05-30 01:24:34 +03:00
++ send |=(point (dish poke/(like %oct1-move +<))) :: send move
2015-05-29 11:36:23 +03:00
++ show prom:(fect %mor rend) :: update console
++ soul =(%sole -:q:(~(got by sup) ost)) :: is console
++ stat (weld ?~(rem ~ "@{(scow p/u.rem)}") voy:here) :: prompt line
2015-05-30 01:09:25 +03:00
++ stop ?~(rem done wild:(dish pull/(like ~))) :: unsubscribe
2015-05-29 11:36:23 +03:00
++ tame (flap |=(_. (fact:+< &/gam)) |=(_. prom:+<)) :: light update
++ wild (flap |=(_. (fact:+< &/gam)) |=(_. show:+<)) :: full update
++ with |=(? (word(rem ?:(+< rem ~)) "{<[+< src]>}")) ::
++ word |= txt=tape %+ flap :: game message
|=(_+> (fact:+< |/txt)) ::
|=(_+> (fect:+< txt/txt)) ::
:: :: ::
:::: :::::: console UI
2015-05-26 05:15:08 +03:00
:: :: ::
2015-05-29 11:36:23 +03:00
++ work :: console action
|= act=sole-action ::
=+ say=(~(got by eye) ost) ::
|^ ?:(?=(%det -.act) (delt +.act) dive) ::
++ abet ..work(eye (~(put by eye) ost say)) :: resolve
++ cusp (cope !ept:here) :: parsing rule
++ delt |= cal=sole-change :: edit command line
=^ cul say (~(remit cs say) cal good) ::
?~(cul abet fail:(fect:abet det/u.cul)) ::
++ dive =+ (rust (tufa buf.say) (punt comb)) :: apply command line
?~(- fail ?~(-> show (plot:wipe ->+))) ::
++ good |=((list ,@c) -:(rose (tufa +<) cusp)) :: validate input
++ wipe =^ cal say (~(transmit cs say) set/~) :: clear line
(fect:abet %det cal) ::
2015-05-08 20:56:30 +03:00
-- ::
2015-05-21 02:54:49 +03:00
:: :: ::
2015-05-29 11:36:23 +03:00
:::: :::::: arvo handlers
2015-05-21 02:54:49 +03:00
:: :: ::
2015-05-30 01:24:34 +03:00
++ reap-oct1 |=([* (unit)] abet:(with =(~ +<+))) :: linked to friend
++ coup-oct1 |=([* (unit)] abet:?~(+<+ +> fail)) :: move acknowledge
++ diff-oct1-update |=([* play] abet:(hear +<+)) :: network update
++ peer-oct1 |=(* abet:tame:meet) :: urbit subscribe
2015-05-29 11:36:23 +03:00
++ peer-sole |=(* abet:show:seen) :: console subscribe
++ poke-sole-action |=(sole-action abet:(work +<)) :: console input
2015-05-30 01:24:34 +03:00
++ poke-oct1-move |=(point abet:wild:(kick +<)) :: urbit move
2015-05-29 11:36:23 +03:00
++ prep |=(agon abet:?~(+< +> (heal +<+>))) :: load state
2015-05-30 01:24:34 +03:00
++ pull-oct1 |=(* abet:lose) :: urbit unsubscribe
2015-05-29 11:36:23 +03:00
++ pull-sole |=(* abet:sawn) :: console unsubscribe
2015-05-30 01:24:34 +03:00
++ quit-oct1 |=(* abet:?~(rem +> wild(rem ~))) :: unlinked by friend
2015-05-08 20:56:30 +03:00
--