stuff is wired up, but not quite communicating yet
This commit is contained in:
parent
3eee55910f
commit
ddea33ef6b
|
@ -19,37 +19,23 @@ open Game.Game
|
||||||
// Web app
|
// Web app
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
|
|
||||||
let indexHandler (name: string) =
|
|
||||||
let view = Views.index()
|
|
||||||
htmlView view
|
|
||||||
|
|
||||||
let mapHandler() =
|
|
||||||
let floor = [
|
|
||||||
[ Wall Corner; Wall EW; Wall EW; Wall EW; Wall Corner ];
|
|
||||||
[ Wall NS; Floor; Floor; Floor; Wall NS ];
|
|
||||||
[ Wall NS; Floor; Floor; Floor; Wall NS ];
|
|
||||||
[ Wall NS; Floor; Floor; Floor; Wall NS ];
|
|
||||||
[ Wall Corner; Wall EW; Wall EW; Wall EW; Wall Corner ]
|
|
||||||
]
|
|
||||||
json Current.JSON
|
|
||||||
|
|
||||||
let moveHandler (next: HttpFunc) (ctx: HttpContext) =
|
let moveHandler (next: HttpFunc) (ctx: HttpContext) =
|
||||||
task {
|
task {
|
||||||
let! cmd = ctx.BindJsonAsync<Command>()
|
let! cmd = ctx.BindJsonAsync<Command>()
|
||||||
return! (mapHandler()) next ctx
|
Current.cmd cmd |> ignore
|
||||||
|
return! (json Current.JSON) next ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
let webApp =
|
let webApp =
|
||||||
choose [
|
choose [
|
||||||
GET >=>
|
GET >=>
|
||||||
choose [
|
choose [
|
||||||
route "/" >=> indexHandler "world"
|
route "/" >=> htmlFile "WebRoot/index.html"
|
||||||
routef "/hello/%s" indexHandler
|
route "/map" >=> json Current.JSON
|
||||||
route "/map" >=> mapHandler()
|
|
||||||
]
|
]
|
||||||
POST >=>
|
POST >=>
|
||||||
choose [
|
choose [
|
||||||
route "/move" >=> moveHandler
|
route "/cmd" >=> moveHandler
|
||||||
]
|
]
|
||||||
setStatusCode 404 >=> text "Not Found" ]
|
setStatusCode 404 >=> text "Not Found" ]
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/rot.js/0.6.0/rot.js"></script>
|
||||||
|
<script src="//unpkg.com/vue"></script>
|
||||||
|
<script src="//unpkg.com/axios/dist/axios.min.js"></script>
|
||||||
|
<script src="/main.js" async></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Dis my dumb game</h1>
|
||||||
|
<div id="app">
|
||||||
|
<div id="game"></div>
|
||||||
|
<button id="south" v-on:click="sendCommand('south')">South</button>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -32,8 +32,11 @@ let app = new Vue({
|
||||||
},
|
},
|
||||||
// sendCommand will be wired to the various keybinds
|
// sendCommand will be wired to the various keybinds
|
||||||
// each binding should send the game command expected
|
// each binding should send the game command expected
|
||||||
sendCommand: function (cmd) {
|
sendCommand: function (direction) {
|
||||||
axios.post("/cmd")
|
if (direction == 'south') {
|
||||||
|
direction = {Case: 'South'}
|
||||||
|
}
|
||||||
|
axios.post("/cmd", direction)
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
console.log("Got data from cmd:\n", resp)
|
console.log("Got data from cmd:\n", resp)
|
||||||
this.board = resp.data;
|
this.board = resp.data;
|
||||||
|
|
Loading…
Reference in New Issue