From af674390cbc93fdcbf9188f5be2fac58cd2f8d0e Mon Sep 17 00:00:00 2001 From: Vivianne Langdon Date: Sun, 5 Feb 2023 06:20:04 -0800 Subject: [PATCH] More tweaks and tidies and fixes to unnecessary things --- gib-gab-gob/actors.scm | 10 +++++----- gib-gab-gob/rps.scm | 25 +++++++++++-------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/gib-gab-gob/actors.scm b/gib-gab-gob/actors.scm index 8da3344..623f7f1 100644 --- a/gib-gab-gob/actors.scm +++ b/gib-gab-gob/actors.scm @@ -9,18 +9,18 @@ (define (^game-lobby bcom) (define pick (pick-rps)) (methods - ((register-opponent name client sealed-pick) + [(register-opponent name client sealed-pick) (format #t "Hey there, ~a! You sent me your pick of rock-paper-scissors; now I will send mine.\n" name) (on (<- (<- client 'exchange-pick-for-unsealer pick) sealed-pick) (lambda (peer-pick) - (format #t "The peer has picked ~a (do I win? ~s)\n" peer-pick (rps-winner pick peer-pick))))))) + (format #t "The peer has picked ~a (do I win? ~s)\n" peer-pick (rps-winner pick peer-pick))))])) (define (^client-picker bcom) (define-values (seal-pick unseal-pick my-pick?) (spawn-sealer-triplet)) (define pick (pick-rps)) (methods - ((get-sealed-pick) ($ seal-pick pick)) - ((exchange-pick-for-unsealer peer-pick) + [(get-sealed-pick) ($ seal-pick pick)] + [(exchange-pick-for-unsealer peer-pick) (format #t "Peer picked ~a... a bold choice (do I win? ~s), i will send my unsealer\n" peer-pick (rps-winner pick peer-pick)) - unseal-pick))) + unseal-pick])) diff --git a/gib-gab-gob/rps.scm b/gib-gab-gob/rps.scm index d2d3fb1..4fc9db4 100644 --- a/gib-gab-gob/rps.scm +++ b/gib-gab-gob/rps.scm @@ -29,17 +29,14 @@ (unless (access? tmp X_OK) (mkdir tmp)) (spawn ^testuds-netlayer tmp)) -(define (do-rps user-name) - (make #:user-name user-name)) - ;; ;; Client logic ;; (define-class () - (vat #:accessor vat #:init-keyword #:vat #:init-thunk spawn-vat) - (lobby #:accessor lobby) + (vat #:accessor vat #:init-thunk spawn-vat) + (user-name #:accessor user-name #:init-keyword #:user-name) (addr #:accessor addr #:init-keyword #:addr) - (user-name #:accessor user-name #:init-keyword #:user-name)) + (lobby #:accessor lobby)) (define-method (initialize (client ) initargs) (next-method) @@ -47,7 +44,7 @@ (define lobby-sref (string->ocapn-id (addr client))) (define mycapn (spawn-mycapn (new-testuds-netlayer))) (set! (lobby client) - (<- mycapn 'enliven lobby-sref)))) + ($ mycapn 'enliven lobby-sref)))) (define (join-rps user-name addr) (define client (make #:user-name user-name #:addr addr)) @@ -67,10 +64,10 @@ (define (rps-winner a b) (if (and (memq a rock-paper-scissors) (memq b rock-paper-scissors)) - (match (list a b) - ((x x) 'tie) - (('rock 'scissors) #t) - (('rock 'paper) #f) - (('scissors 'paper) #t) - ((x y) (not (rps-winner y x)))) - (error "Unexpected item in the shooting area" a b))) + (match (list a b) + [(x x) 'tie] + [('rock 'scissors) #t] + [('rock 'paper) #f] + [('scissors 'paper) #t] + [(x y) (not (rps-winner y x))]) + (error "Unexpected item in the shooting area" a b)))