Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rock-paper-scissors #14

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

feat: rock-paper-scissors #14

wants to merge 13 commits into from

Conversation

dckc
Copy link
Contributor

@dckc dckc commented Apr 25, 2024

goal:

playground/packages/fun-games$ endo purge --force

playground/packages/fun-games$ endo make src/rock-paper-scissors.js -n rps
Starting Endo daemon...
Object [Alleged: RockPaperScissors] {}

playground/packages/fun-games$ endo mkhost bob bob-agent
Object [Alleged: EndoHost] {}

playground/packages/fun-games$ endo eval 'E(rps).playAgainst(bob)' bob rps

but I get:

CapTP cli exception: (RemoteTypeError(error:captp:Endo#20001)#1)
RemoteTypeError(error:captp:Endo#20001)#1: target has no method "accept", has ["__getInterfaceGuard__","__getMethodNames__","open","receive"]

  at decodeErrorCommon (packages/marshal/src/marshal.js:303:24)
  at decodeErrorFromCapData (packages/marshal/src/marshal.js:331:14)
  at decodeFromCapData (packages/marshal/src/encodeToCapData.js:384:27)
  at fromCapData (packages/marshal/src/marshal.js:393:23)
  at CTP_RETURN (packages/captp/src/captp.js:693:24)
  at dispatch (packages/captp/src/captp.js:772:7)
  at packages/daemon/src/connection.js:36:7

(RemoteTypeError(error:captp:Endo#20001)#1)

@dckc
Copy link
Contributor Author

dckc commented Apr 26, 2024

simplified design: gameServer.attack(move) => { defend(move) => result }

based on discussion with @kriskowal

playground/packages/fun-games$ endo make src/rock-paper-scissors.js -n p1
Object [Alleged: RockPaperScissors] {}

playground/packages/fun-games$ endo eval "E(p1).attack('rock')" p1 -n p2
Object [Alleged: Defender] {}

playground/packages/fun-games$ endo eval "E(p2).defend('paper')" p2
{ why: 'paper covers rock', winner: 2 }
  • interface names are kinda goofy

added some unit tests too:

$ yarn test
yarn run v1.22.21
$ ava

  ✔ Rock Paper Scissors: 1 game
    ℹ {
        why: 'paper covers rock',
        winner: 2,
      }
  ✔ only 3 choices allowed
  ✔ attacker cannot attack again
  ─

  3 tests passed

@dckc dckc requested a review from kriskowal April 26, 2024 20:19
@dckc dckc changed the title WIP: rock-scissors-paper feat: rock-paper-scissors Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant