commit d7e1046c2c6d6bd1ee310328b88dc9ed19318d75 Author: Neale Pickett Date: Sun Dec 31 10:10:03 2023 -0700 Checking in what exists so far diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..feead5b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +reference/ diff --git a/DESIGN.md b/DESIGN.md new file mode 100644 index 0000000..c5bfd90 --- /dev/null +++ b/DESIGN.md @@ -0,0 +1,29 @@ +# The Beginning + +`$ curl https://cc.woozle.org/` +```json +{ + "cookies": 1, + "message": "You have made your first cookie!", + "api": { + "url": "api/click", + "example": "curl https://cc.woozle.org/ | curl --data-binary @- https://cc.woozle.org/api/click" + }, + "state": ":f1d2d2f924e986ac86fdf7b36c94bcdf32beec15" +} +``` + +`$ curl https://cc.woozle.org/api/click` +```json +{ + "cookies": 2, + "message": "You have made two cookies. Maybe you're onto something!", + "api": { + "url": "api/click", + "method": "POST" + }, + "state": "2:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15" +} +$ curl https://cc.woozle.org/click +``` + diff --git a/README.md b/README.md new file mode 100644 index 0000000..75e56f5 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +Cookie Clicker: Stateless API +============================= + +I like playing cookie clicker. +At some point, I realized I was writing a program to play cookie clicker for me. +That's fun, for me. +So I started thinking about how to make a game just for people like me. + +The idea here is that you write a program to submit a "turn". +The way I was going to do this was by sending the entire state to the client, +with some sort of cryptographic signature. +As part of the turn submission, +the client sends its state blob back. + +I started on a [design document](DESIGN.md). + diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..7ae02f0 --- /dev/null +++ b/TODO.md @@ -0,0 +1,6 @@ +Stuff I'd like to implement +=================== + +* `/export` which adds an `export` field and recomputes the MAC. + You can only submit this for verification, it won't compute a new state +* \ No newline at end of file diff --git a/buildings.go b/buildings.go new file mode 100644 index 0000000..8e88f25 --- /dev/null +++ b/buildings.go @@ -0,0 +1,13 @@ +package main + +type Building struct { + Name string + Description string + Quantity int + Cps float64 + Price float64 +} + +func (b Building) PurchaseCost() { + +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..8763c20 --- /dev/null +++ b/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "log" + "net/http" + "time" +) + +type State struct { + Cookies float64 +} + +func clickHandler + +func main() { + http.HandleFunc("/click", clickHandler) + http.Handle("/", http.FileServer(http.Dir("static/"))) + + foraByName = map[string]*Forum{} + f := newForum("") + f.Log = []Message{ + { + When: time.Now().Unix(), + Who: "(system)", + Text: "Welcome to μChat", + }, + } + + bind := ":8080" + log.Printf("Listening on %s", bind) + log.Fatal(http.ListenAndServe(bind, nil)) +} diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..9013078 --- /dev/null +++ b/static/index.html @@ -0,0 +1,3 @@ + +CC +curl https://cc.woozle.org/ --data-binary '{"action": "click"}'