benknoble / frosthaven-manager

GUI Frosthaven Scenario Manager
https://benknoble.github.io/frosthaven-manager
Other
5 stars 0 forks source link

Local HTTP server for other players #25

Closed benknoble closed 1 year ago

benknoble commented 1 year ago

We can add an option to start a local HTTP server that players can use to enter their names, HP, and even adjust initiative. The implementation would likely consist of a servlet with forms which trigger updates to game-state observables (completing #12 might help organize this). The manager would need updates to the GUI to show the current actual state, in case of conflict (say, typing a name after someone has entered it through the server—how do we know which name is actually used?).

Starting the server should always be optional; that is, playing with a single "controller" as things stand currently should always be possible. If the server is started, there should be an informational display at the bottom of the manager (possibly with a more detailed display of logs on request). The info should at least consist of some indicator that the server is running and how it can be accessed (e.g., http://IP/frosthaven-manager.rkt).

It might be possible to display more game state (such as the main screen, or loot, etc.) in the served pages, but handling updates will be tricky.


The following is a "hello world" servlet:

(require web-server/servlet web-server/servlet-env)
(define (start req)
  (response/xexpr
   `(html (head (title "Hello world"))
          (body (p "Hey out there")))))
(serve/servlet start #:listen-ip #f #:port 80)

If you curl http://$(getip)/servlets/standalone.rkt after running this code, you'll see the response. (Note that getip is defined as ipconfig getifaddr en0 on my machine.)

cf. https://defn.io/2020/02/12/racket-web-server-guide/ because of weirdness with serve/servlet and servlet paths: by default, all the demo servlets are available, too.

benknoble commented 1 year ago

@winny- points out on Discord that the nat-traversal library implements a best-interface-ip-address function, among others.

benknoble commented 1 year ago

Relevant docs:

benknoble commented 1 year ago

Next up: player summons. The design for these will probably inform how monsters work, too, since they have some similar concerns around being able to change how many there are.

Also: Change initiative slider to some other kind of input for ease of use (or make it width: 80% or something).

benknoble commented 1 year ago

My design notes for summons:

benknoble commented 1 year ago

Since that worked, let's try monsters?