Skip to content

Commit

Permalink
Restart button (#72)
Browse files Browse the repository at this point in the history
* Remove the NoOp message type from Game.elm

* viewRestartButton

* restart Button during the game
  • Loading branch information
Leoactionz authored Oct 10, 2021
1 parent e573af3 commit 5d8891f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Pages/About.elm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ view model =
[ column (style model)
[ el [ Region.heading 1, centerX, Font.bold ] (text "What is this project?")
, paragraph [ width fill, height fill, spacing 5, Font.color Styles.blue ]
[ text "This is example project of the game Quarto, built using the Elm programming language." ]
[ text "This is an example project of the game Quarto, built using the Elm programming language." ]
, el [ Region.heading 1, centerX, Font.bold ] (text "What is Quarto")
, paragraph [ width fill, height fill, spacing 5, Font.color Styles.blue ]
[ text "Quarto is a board game for two players invented by Swiss mathematician Blaise Müller. It is published and copyrighted by Gigamic. "
Expand Down
29 changes: 22 additions & 7 deletions src/Pages/Top.elm
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import Game
, GameStatus(..)
, Msg(..)
, Player(..)
, Turn(..)
, StatusMessage(..)
, Turn(..)
)
import Game.Core
exposing
Expand Down Expand Up @@ -156,6 +156,7 @@ view model =
]
, viewGamestatus (Game.currentStatus model.game) model.dimensions
, viewStatusMessage (Game.currentStatusMessage model.game)
, viewRestartButton model.game
]
]
}
Expand Down Expand Up @@ -190,10 +191,10 @@ viewGamestatus gamestatus dimensions =
in
case gamestatus of
Won winner ->
containerize [ text <| "The Winner is : " ++ Game.playerToString winner, viewRestartButton ]
containerize [ text <| "The Winner is : " ++ Game.playerToString winner ]

Draw ->
containerize [ text "It's a Draw!", viewRestartButton ]
containerize [ text "It's a Draw!" ]

InPlay player (ChoosingCellToPlay gamepiece) ->
let
Expand Down Expand Up @@ -229,9 +230,11 @@ viewStatusMessage statusMessage =
case statusMessage of
NoMessage ->
Element.el [] (Element.text "")

SomePiecePlayedWhenNotPlayersTurn ->
Element.el [ centerX, Font.center, Region.announce ] (Element.text "It's not your turn to choose a piece!")


viewCell : Cell -> Element Msg
viewCell { name, status } =
case status of
Expand All @@ -251,10 +254,22 @@ viewCellButton cell =
}


viewRestartButton : Element Msg
viewRestartButton =
Input.button [ Background.color Styles.white, Border.width 5, Border.color Styles.blue, padding 5, centerX, Font.color Styles.blue ]
{ onPress = Just (GameMessage RestartWanted), label = text "Restart" }
viewRestartButton : Game.Model -> Element Msg
viewRestartButton gamemodel =
let
button =
Input.button [ Background.color Styles.white, Border.width 5, Border.color Styles.blue, padding 5, centerX, Font.color Styles.blue ]
{ onPress = Just (GameMessage RestartWanted), label = text "Restart" }
in
if gamemodel /= Game.init then
button
else
Element.none



-- and then stick in the view below the viewStatusMessage
-- viewRestartButton model.game


viewRemainingPiecesButton : Gamepiece -> Element Msg
Expand Down

0 comments on commit 5d8891f

Please sign in to comment.