movement\!
This commit is contained in:
parent
1f58cd2c03
commit
673edf6efb
|
@ -5,7 +5,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Library.fs"/>
|
<Compile Include="Library.fs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -22,6 +22,7 @@ open Game.Game
|
||||||
let moveHandler (next: HttpFunc) (ctx: HttpContext) =
|
let moveHandler (next: HttpFunc) (ctx: HttpContext) =
|
||||||
task {
|
task {
|
||||||
let! cmd = ctx.BindJsonAsync<Command>()
|
let! cmd = ctx.BindJsonAsync<Command>()
|
||||||
|
printfn "%O" cmd |> ignore
|
||||||
Current.cmd cmd |> ignore
|
Current.cmd cmd |> ignore
|
||||||
return! (json Current.JSON) next ctx
|
return! (json Current.JSON) next ctx
|
||||||
}
|
}
|
||||||
|
@ -32,6 +33,7 @@ let webApp =
|
||||||
choose [
|
choose [
|
||||||
route "/" >=> htmlFile "WebRoot/index.html"
|
route "/" >=> htmlFile "WebRoot/index.html"
|
||||||
route "/map" >=> json Current.JSON
|
route "/map" >=> json Current.JSON
|
||||||
|
route "/test" >=> json (Move South)
|
||||||
]
|
]
|
||||||
POST >=>
|
POST >=>
|
||||||
choose [
|
choose [
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />
|
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />
|
||||||
<PackageReference Include="Giraffe" Version="3.4.*" />
|
<PackageReference Include="Giraffe" Version="4.0.0" />
|
||||||
<PackageReference Include="TaskBuilder.fs" Version="2.1.*" />
|
<PackageReference Include="TaskBuilder.fs" Version="2.1.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,12 @@
|
||||||
<h1>Dis my dumb game</h1>
|
<h1>Dis my dumb game</h1>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<div id="game"></div>
|
<div id="game"></div>
|
||||||
<button id="south" v-on:click="sendCommand('south')">South</button>
|
<div>
|
||||||
|
<button id="north" v-on:click="sendCommand('North')">North</button>
|
||||||
|
<button id="south" v-on:click="sendCommand('South')">South</button>
|
||||||
|
<button id="east" v-on:click="sendCommand('East')">East</button>
|
||||||
|
<button id="west" v-on:click="sendCommand('West')">West</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -33,13 +33,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 (direction) {
|
sendCommand: function (direction) {
|
||||||
if (direction == 'south') {
|
let move = {"case": "Move", "fields": [{"case": direction}]}
|
||||||
direction = {Case: 'South'}
|
axios.post("/cmd", move)
|
||||||
}
|
|
||||||
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.state = resp.data;
|
||||||
this.draw()
|
this.draw()
|
||||||
})
|
})
|
||||||
.catch(err => this.err = err);
|
.catch(err => this.err = err);
|
||||||
|
|
Loading…
Reference in New Issue