landscape/desk/lib/treaty.hoon
fang 6fa000a6ee
various: remove trailing whitespace and empty lines
Touching these up to avoid cleanup noise in future commits touching this
code.
2023-02-10 13:38:30 +01:00

94 lines
1.6 KiB
Plaintext

/- *treaty
/+ dock=docket
|%
++ enjs
=, enjs:format
|%
++ merge
|= [a=json b=json]
^- json
?> &(?=(%o -.a) ?=(%o -.b))
[%o (~(uni by p.a) p.b)]
::
++ treaty
|= t=^treaty
%+ merge (docket:enjs:dock docket.t)
%- pairs
:~ ship+s+(scot %p ship.t)
desk+s+desk.t
cass+(case case.t)
hash+s+(scot %uv hash.t)
==
::
++ case
|= c=^case
%+ frond -.c
?- -.c
%da s+(scot %da p.c)
%tas s+(scot %tas p.c)
%ud (numb p.c)
==
::
++ foreign-desk
|= [s=^ship =desk]
^- cord
(crip "{(scow %p s)}/{(trip desk)}")
::
++ alliance
|= a=^alliance
^- json
:- %a
%+ turn ~(tap in a)
|= [=^ship =desk]
^- json
s+(foreign-desk ship desk)
::
++ treaty-update
|= u=update:^treaty
^- json
%+ frond -.u
?- -.u
%add (treaty treaty.u)
%del s+(foreign-desk +.u)
::
%ini
%- pairs
%+ turn ~(tap by init.u)
|= [[s=^ship =desk] t=^treaty]
[(foreign-desk s desk) (treaty t)]
==
::
++ ally-update
|= u=update:ally
^- json
%+ frond -.u
?- -.u
?(%add %del) s+(scot %p ship.u)
::
%ini
%- pairs
%+ turn ~(tap by init.u)
|= [s=^ship a=^alliance]
[(scot %p s) (alliance a)]
::
%new
%- pairs
:~ ship+s+(scot %p ship.u)
alliance+(alliance alliance.u)
==
==
--
++ dejs
=, dejs:format
|%
++ ship (su ;~(pfix sig fed:ag))
++ ally-update
^- $-(json update:ally)
%- of
:~ add+ship
del+ship
==
--
--