Game basics
- Players can pass device to choose armies.
- Game state is loaded from the URL.
- URL is kept up-to-date with the state of the game.
- When the game is over, the winner is displayed and the board is disabled.
Challenges
| import { Methods, Context } from "./.hathora/methods"; | |
| import { Response } from "../api/base"; | |
| import { | |
| UserId, | |
| PlayerState, | |
| IJoinGameRequest, | |
| IChooseGestureRequest, | |
| INextRoundRequest, | |
| Gesture, | |
| } from "../api/types"; |
| import { z, UserId, Response, Engine } from "./util"; | |
| const Gesture = z.enum(["ROCK", "PAPER", "SCISSORS"]); | |
| type Gesture = z.infer<typeof Gesture>; | |
| const PlayerInfo = z.object({ | |
| id: UserId, | |
| score: z.number(), | |
| gesture: Gesture.nullable(), | |
| }); | |
| const PlayerState = z.object({ |
| package main | |
| import ( | |
| "fmt" | |
| "io" | |
| "net/http" | |
| "github.com/gin-gonic/gin" | |
| "github.com/gorilla/websocket" | |
| "github.com/spf13/afero" |
| import { Conn, Transport, Message, RPCMessage, Client } from "capnp-ts"; | |
| class AsyncQueue<T> { | |
| waitingData: T[] = []; | |
| waitingReaders: ((m: T) => void)[] = []; | |
| push(val: T) { | |
| if (this.waitingReaders.length > 0) { | |
| this.waitingReaders.shift()!(val); | |
| } else { |
| package search | |
| import ( | |
| "math" | |
| "time" | |
| "github.com/blevesearch/bleve/index" | |
| "github.com/blevesearch/bleve/mapping" | |
| "github.com/blevesearch/bleve/numeric" | |
| "github.com/blevesearch/bleve/search" |
| import React, { Component } from "react"; | |
| import nouislider from "nouislider"; | |
| import "nouislider/distribute/nouislider.min.css"; | |
| import "./Slider.css"; | |
| class Slider extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.root = React.createRef(); |
| $PATH: | |
| /usr/local/bin | |
| ./node_modules/.bin | |
| /usr/local/bin | |
| /usr/bin | |
| /bin | |
| /usr/sbin | |
| /sbin | |
| /opt/X11/bin |
| import { createSelector } from 'reselect'; | |
| import _ from 'underscore'; | |
| const createSelectorSelector = (...funcs) => { | |
| const base = createSelector(...funcs); | |
| const selector = (...args) => base(...args)(...args); | |
| _.extendOwn(selector, base); | |
| return selector; | |
| }; |