Commits

Yaron Minsky committed 8d7258a

added second game

Comments (0)

Files changed (6)

-open Core.Std
 include Vec.Export
 include Direction.Export
 
-let maybe_parse_direction line embed_direction parse_other =
-  let line = String.strip line |> String.lowercase in
-  match Direction.of_letter line with
-  | Some d -> Ok (embed_direction d)
-  | None ->
-    match parse_other line with
-    | Some x -> Ok x
-    | None -> error "Unknown action" line <:sexp_of<string>>
-

common.mli

-open Core.Std
-
-val maybe_parse_direction
-  :  string
-  -> (Direction.t -> 'a)
-  -> (string -> 'a option)
-  -> 'a Or_error.t
 open Core.Std
-open Vec.Export
-open Direction.Export
+open Common
 
 let name = "findme"
 
 
 let states : (module State_intf.S) list =
   [ (module Findme)
+  ; (module Zev)
   ]
 
 let send_update w u =
        let state = ref (State.create ())
      end : Game))
   in
+  let gnames =
+    List.map states ~f:(fun (module State : State_intf.S) ->
+      State.name)
+  in
   let host_and_port =
     Tcp.Server.create
       ~on_handler_error:`Raise
       (Tcp.on_port port)
       (fun addr r w ->
+         send_update w
+           (Update.ok ("Games: " ^ String.concat ~sep:", " gnames))
+         >>= fun () ->
          Reader.read_line r
          >>= function
            | `Eof -> Deferred.unit
+open Core.Std
+open Common
+
+let name = "zev"
+
+type action = unit
+let line_to_action _ = Some ()
+
+type t = unit
+
+let create () = ()
+
+let act t _pname () = (t,Update.ok "nothing happened")
+
+let register_player t _pname = t
+
+include State_intf.S