Checking in what exists so far
This commit is contained in:
commit
d7e1046c2c
|
@ -0,0 +1 @@
|
|||
reference/
|
|
@ -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
|
||||
```
|
||||
|
|
@ -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).
|
||||
|
|
@ -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
|
||||
*
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
type Building struct {
|
||||
Name string
|
||||
Description string
|
||||
Quantity int
|
||||
Cps float64
|
||||
Price float64
|
||||
}
|
||||
|
||||
func (b Building) PurchaseCost() {
|
||||
|
||||
}
|
|
@ -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))
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<!DOCTYPE html>
|
||||
<title>CC</title>
|
||||
<code>curl https://cc.woozle.org/ --data-binary '{"action": "click"}'</code>
|
Loading…
Reference in New Issue