Checking in what exists so far

This commit is contained in:
Neale Pickett 2023-12-31 10:10:03 -07:00
commit d7e1046c2c
7 changed files with 100 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
reference/

29
DESIGN.md Normal file
View File

@ -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
```

16
README.md Normal file
View File

@ -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).

6
TODO.md Normal file
View File

@ -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
*

13
buildings.go Normal file
View File

@ -0,0 +1,13 @@
package main
type Building struct {
Name string
Description string
Quantity int
Cps float64
Price float64
}
func (b Building) PurchaseCost() {
}

32
main.go Normal file
View File

@ -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))
}

3
static/index.html Normal file
View File

@ -0,0 +1,3 @@
<!DOCTYPE html>
<title>CC</title>
<code>curl https://cc.woozle.org/ --data-binary '{"action": "click"}'</code>