@@ -12,7 +12,6 @@ import Miso.Lens
1212import Miso.Html.Element as H
1313import Miso.Html.Event as E
1414import Miso.Html.Property as P
15- -- import Miso.CSS qualified as CSS
1615
1716import Model
1817import Game
@@ -29,8 +28,7 @@ assetsUrl = "assets/"
2928-------------------------------------------------------------------------------
3029
3130data Action
32- = ActionSayHelloWorld
33- | ActionSetLevel Int
31+ = ActionSetLevel Int
3432 | ActionKey IS. IntSet
3533
3634-------------------------------------------------------------------------------
@@ -39,11 +37,6 @@ data Action
3937
4038updateModel :: Action -> Transition Model Action
4139
42- updateModel ActionSayHelloWorld =
43- io_ $ do
44- consoleLog " Hello World"
45- alert " Hello World"
46-
4740updateModel (ActionSetLevel n) = do
4841 put $ mkModel n
4942 io_ $ consoleLog $ " level " <> ms (show n)
@@ -61,13 +54,6 @@ updateModel (ActionKey keys)
6154 modelGame .= g
6255 modelNbMoves += 1
6356
64- {-
65- g <- use modelGame
66- if computeTerminated g
67- then issue $ ActionSetLevel (getLevel g + 1)
68- else doKey
69- -}
70-
7157-------------------------------------------------------------------------------
7258-- resources
7359-------------------------------------------------------------------------------
@@ -104,7 +90,10 @@ instance FromJSVal Resources where
10490viewModel :: Model -> View Model Action
10591viewModel m@ Model {.. } =
10692 div_ []
107- [ p_ [] [ button_ [ onClick ActionSayHelloWorld ] [ " Alert Hello World!" ] ]
93+ [ p_ []
94+ [ button_ [ onClick (ActionSetLevel $ getLevel _modelGame) ] [ " reset" ]
95+ , button_ [ onClick (ActionSetLevel $ 1 + getLevel _modelGame) ] [ " next" ]
96+ ]
10897 , p_ [] [ text (" nb moves: " <> ms (show _modelNbMoves) <> status) ]
10998 , Canvas. canvas
11099 [ width_ $ ms $ show w
@@ -115,7 +104,7 @@ viewModel m@Model{..} =
115104 ]
116105 where
117106 (w, h) = ij2xy $ getNiNj _modelGame
118- status = if computeRunning _modelGame then " ... " else " , done !!!"
107+ status = if computeRunning _modelGame then " " else " , done !!!"
119108
120109initCanvas :: DOMRef -> Canvas Resources
121110initCanvas _ = liftJSM $
@@ -164,7 +153,6 @@ mkComponent =
164153 let initialMode = mkModel 1
165154 in (component initialMode updateModel viewModel)
166155 { subs = [ keyboardSub ActionKey ]
167- -- , initialAction = Just (ActionSetLevel 1)
168- , logLevel = DebugAll
156+ -- , logLevel = DebugAll
169157 }
170158
0 commit comments