import { loadStdlib } from '@reach-sh/stdlib'; import * as backend from './build/index.main.mjs'; (async () => { const stdlib = await loadStdlib(); const startingBalance = stdlib.parseCurrency(10); const accAlice = await stdlib.newTestAccount(startingBalance); const accBob = await stdlib.newTestAccount(startingBalance); const ctcAlice = accAlice.deploy(backend); const ctcBob = accBob.attach(backend, ctcAlice.getInfo()); const HAND = ['Rock', 'Paper', 'Scissors']; const OUTCOME = ['Bob wins', 'Draw', 'Alice wins']; const Player = (Who) => ({ getHand: () => { const hand = Math.floor(Math.random() * 3); console.log(`${Who} played ${HAND[hand]}`); return hand; }, seeOutcome: (outcome) => { console.log(`${Who} saw outcome ${OUTCOME[outcome]}`); }, }); await Promise.all([ backend.Alice( ctcAlice, Player('Alice'), ), backend.Bob( ctcBob, Player('Bob'), ), ]); })();