<commit_before>import Html exposing (Html)
import Html.Events exposing (onClick)
import Html.Attributes exposing (style)
import StartApp.Simple exposing (start)
import Signal exposing (Address)
import Graphics.Element as G
import Text as T
import Color
import Array
import EmailTexts exposing (emailTexts)

type ScreenState = TitleScreen | ChooseLevelScreen | LevelScreen Int | MessageScreen Int

type alias Model = { numCars: Int, screen: ScreenState }

initialModel : Model
initialModel =  { numCars = 0, screen = TitleScreen }

type Action = GoToScreen ScreenState
            | Tick

update : Action -> Model -> Model
update action oldModel =  case action of
    GoToScreen newScreen -> { oldModel | screen <- newScreen }
    _ -> oldModel

view : Address Action -> Model -> Html
view address model = case model.screen of
    TitleScreen ->  renderTitleScreen address
    ChooseLevelScreen -> renderChooseLevel address model
    MessageScreen n -> renderMessageScreen n address
    LevelScreen n -> renderLevel n address model

gameButton : Address Action -> Action -> String -> Html
gameButton address action text =
    Html.button 
        [
            onClick address action,
            style [ ("background-color", "rgb(94, 5, 135)"),
                    ("color", "white"),
                    ("width", "100px"),
                    ("height", "100px")
                  ]
        ] 
        [Html.text text]

renderTitleScreen : Address Action -> Html
renderTitleScreen address = 
        let
            titleBackgroundColor = Color.rgb 94 5 135
            titleImage = G.image 800 600 "../game_logo.png"
        in
            Html.div 
                []
                [   Html.fromElement <| titleImage,
                    gameButton address (GoToScreen <| MessageScreen 0)  "New Game",
                    gameButton address (GoToScreen <| ChooseLevelScreen)  "Continue"
                ]

renderChooseLevel : Address Action -> Model -> Html
renderChooseLevel address model = Html.div []
        [ Html.text "Choose a level" ,
          Html.button [onClick address (GoToScreen TitleScreen)] [Html.text "Return to title"]
        ]

renderLevel : Int -> Address Action -> Model -> Html<commit_msg>Nicer html for level list<commit_after>import Html exposing (Html)
import Html.Events exposing (onClick)
import Html.Attributes exposing (style)
import StartApp.Simple exposing (start)
import Signal exposing (Address)
import Graphics.Element as G
import Text as T
import List as L
import Color
import Array
import EmailTexts exposing (emailTexts)


type GameScreenType = Message Int | Level Int

gameScreens = [
        (Message 0, "Email"),
        (Level 0, "Monday Morning MTA Madness")
    ]
type ScreenState = TitleScreen | ChooseLevelScreen | LevelScreen Int | MessageScreen Int

type alias Model = { numCars: Int, screen: ScreenState }

initialModel : Model
initialModel =  { numCars = 0, screen = TitleScreen }

type Action = GoToScreen ScreenState
            | Tick

update : Action -> Model -> Model
update action oldModel =  case action of
    GoToScreen newScreen -> { oldModel | screen <- newScreen }
    _ -> oldModel

view : Address Action -> Model -> Html
view address model = case model.screen of
    TitleScreen ->  renderTitleScreen address
    ChooseLevelScreen -> renderChooseLevel address model
    MessageScreen n -> renderMessageScreen n address
    LevelScreen n -> renderLevel n address model

gameButton : Address Action -> Action -> String -> Html
gameButton address action text =
    Html.button 
        [
            onClick address action,
            style [ ("background-color", "rgb(94, 5, 135)"),
                    ("color", "white"),
                    ("width", "100px"),
                    ("height", "100px")
                  ]
        ] 
        [Html.text text]

renderTitleScreen : Address Action -> Html
renderTitleScreen address = 
        let
            titleBackgroundColor = Color.rgb 94 5 135
            titleImage = G.image 800 600 "../game_logo.png"
        in
            Html.div 
                []
                [   Html.fromElement <| titleImage,
                    gameButton address (GoToScreen <| MessageScreen 0)  "New Game",
                    gameButton address (GoToScreen <| ChooseLevelScreen)  "Continue"
                ]



renderChooseLevel : Address Action -> Model -> Html
renderChooseLevel address model =
    let
        screenLinkIfUnlocked address (screenType, name) =
            case screenType of
                Message n -> Html.li [onClick address (GoToScreen <| MessageScreen n)] [Html.text name]
                Level n -> Html.li [onClick address (GoToScreen <| LevelScreen n)] [Html.text name]
   
    in Html.div []
        [
            Html.div [style [("color", "white"),
                             ("background-color", "rgb(94, 5, 135"),
                             ("width", "800px"),
                             ("height", "600px")]
                     ] 
            [
                Html.text "Choose a level" ,
                Html.ul [] <| L.map (screenLinkIfUnlocked address) gameScreens
            ],
           gameButton address (GoToScreen TitleScreen) "Return to title"
        ]

renderLevel : Int -> Address Action -> Model -> Html
{'fraction_non_alphanumeric': 0.08858118361153262, 'fraction_numerical': 0.01251896813353566, 'mean_word_length': 2.1650660264105643, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5143165', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1324, 'n_words': 459}